public virtual IEnumerable NextPeriod(PXAdapter adapter)
        {
            DiscrepancyEnqFilter filter = Filter.Current as DiscrepancyEnqFilter;

            filter.UseMasterCalendar = filter.OrganizationID == null && filter.BranchID == null;
            int?calendarOrganizationID = FinPeriodRepository.GetCalendarOrganizationID(filter.OrganizationID, filter.BranchID, filter.UseMasterCalendar);

            FinPeriod nextPeriodFrom = FinPeriodRepository.FindNextPeriod(calendarOrganizationID, filter.PeriodFrom, looped: true);

            filter.PeriodFrom = nextPeriodFrom != null ? nextPeriodFrom.FinPeriodID : null;

            FinPeriod nextPeriodTo = FinPeriodRepository.FindNextPeriod(calendarOrganizationID, filter.PeriodTo, looped: true);

            filter.PeriodTo      = nextPeriodTo != null ? nextPeriodTo.FinPeriodID : null;
            filter.FilterDetails = null;
            return(adapter.Get());
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            AccountByYearFilter filter = CurrentFilter;
            int?calendarOrganizationID =
                FinPeriodRepository.GetCalendarOrganizationID(filter.OrganizationID,
                                                              filter.BranchID,
                                                              filter.UseMasterCalendar);
            FinYear nextperiod = PXSelect <
                FinYear,
                Where <FinYear.year, Greater <Required <AccountByYearFilter.finYear> >,
                       And <FinYear.organizationID, Equal <Required <AccountByYearFilter.organizationID> > > >,
                OrderBy <
                    Asc <FinYear.year> > >
                                 .Select(this, filter.FinYear, calendarOrganizationID)
                                 ?? PXSelect <
                FinYear,
                Where <FinYear.organizationID, Equal <Required <AccountByYearFilter.organizationID> > >,
                OrderBy <
                    Asc <FinYear.year> > >
                                 .Select(this, calendarOrganizationID);

            filter.FinYear = nextperiod?.Year;
            return(adapter.Get());
        }