Skip to main content
Solved

Select execution not working for financial period

  • February 23, 2023
  • 4 replies
  • 151 views

Forum|alt.badge.img

I want to find the financial period based on the date. Below is the code I have written but it feels something is wrong here. When I debug it says Model.cs not found when I execute view.SelectMulti.

Can anyone help me here. Below is the code snippet.

Filter is my own custom DAC for the filter.

var query = new SelectFrom<FinPeriod>.
            Where<Filter.fromDate.FromCurrent.IsNull.Or<
                Filter.fromDate.IsBetween<FinPeriod.startDate.FromCurrent, FinPeriod.endDate.FromCurrent>>>();
            var view = new PXView(this, true, query);
            var finPeriods = view.SelectMulti(null);

Thanks

Best answer by Yuriy Zaletskyy

Regarding error message Model.cs not found, additional context is needed. As Acumatica has more then one model class.

Overall, without context, which I asked you before,  I can suggest something like this:

 

    public class YourGraph : PXGraph<YourGraph>
    {
        public PXFilter<FinPeriodFilter> Filter;

        public PXSelect<FinPeriod,
            Where<FinPeriod.startDate, LessEqual<Current<FinPeriodFilter.fromDate>>,
                And<FinPeriod.endDate, GreaterEqual<Current<FinPeriodFilter.fromDate>>>>> FinPeriods;

        public virtual IEnumerable finPeriods()
        {
            FinPeriodFilter filter = Filter.Current;
            if (filter != null && filter.FromDate != null)
            {
                foreach (FinPeriod period in PXSelect<FinPeriod,
                                 Where<FinPeriod.startDate, LessEqual<Required<FinPeriodFilter.fromDate>>,
                                     And<FinPeriod.endDate, GreaterEqual<Required<FinPeriodFilter.fromDate>>>>>
                             .Select(this, filter.FromDate, filter.FromDate))
                {
                    yield return period;
                }
            }
        }
    }

    public class FinPeriodFilter : IBqlTable
    {
        #region FromDate
        public abstract class fromDate : PX.Data.BQL.BqlDateTime.Field<fromDate> { }

        [PXDate]
        [PXUIField(DisplayName = "From Date")]
        public virtual DateTime? FromDate { get; set; }
        #endregion
    }

also question seems to be abandoned.

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img
  • Author
  • Freshman I
  • 21 replies
  • February 24, 2023

Anyone knows solution to this ??


Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+3

In which graph, and which event you execute that? Which Acumatica build?


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • March 20, 2023

Hi @tanuj81  were you able to find a solution? Thank you!


Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+3

Regarding error message Model.cs not found, additional context is needed. As Acumatica has more then one model class.

Overall, without context, which I asked you before,  I can suggest something like this:

 

    public class YourGraph : PXGraph<YourGraph>
    {
        public PXFilter<FinPeriodFilter> Filter;

        public PXSelect<FinPeriod,
            Where<FinPeriod.startDate, LessEqual<Current<FinPeriodFilter.fromDate>>,
                And<FinPeriod.endDate, GreaterEqual<Current<FinPeriodFilter.fromDate>>>>> FinPeriods;

        public virtual IEnumerable finPeriods()
        {
            FinPeriodFilter filter = Filter.Current;
            if (filter != null && filter.FromDate != null)
            {
                foreach (FinPeriod period in PXSelect<FinPeriod,
                                 Where<FinPeriod.startDate, LessEqual<Required<FinPeriodFilter.fromDate>>,
                                     And<FinPeriod.endDate, GreaterEqual<Required<FinPeriodFilter.fromDate>>>>>
                             .Select(this, filter.FromDate, filter.FromDate))
                {
                    yield return period;
                }
            }
        }
    }

    public class FinPeriodFilter : IBqlTable
    {
        #region FromDate
        public abstract class fromDate : PX.Data.BQL.BqlDateTime.Field<fromDate> { }

        [PXDate]
        [PXUIField(DisplayName = "From Date")]
        public virtual DateTime? FromDate { get; set; }
        #endregion
    }

also question seems to be abandoned.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings