private bool IsFirstOrLastOrganizationFinYear(OrganizationFinYear organizationFinYear)
        {
            FinYear firstFinYear = FinPeriodRepository.FindFirstYear(organizationFinYear.OrganizationID, clearQueryCache: true);

            FinYear lastFinYear = FinPeriodRepository.FindLastYear(organizationFinYear.OrganizationID, clearQueryCache: true);

            return(organizationFinYear.Year == firstFinYear.Year ||
                   organizationFinYear.Year == lastFinYear.Year);
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            AccountByYearFilter filter     = CurrentFilter;
            FinYear             nextperiod = PXSelect <FinYear,
                                                       Where <FinYear.year, Greater <Current <AccountByYearFilter.finYear> > >,
                                                       OrderBy <Asc <FinYear.year> > > .SelectWindowed(this, 0, 1)
                                             ?? PXSelectOrderBy <FinYear,
                                                                 OrderBy <Asc <FinYear.year> > > .SelectWindowed(this, 0, 1);

            filter.FinYear = nextperiod?.Year;
            return(adapter.Get());
        }
        public virtual IEnumerable previousperiod(PXAdapter adapter)
        {
            AccountByYearFilter filter     = this.CurrentFilter;
            FinYear             nextperiod = PXSelect <FinYear,
                                                       Where <FinYear.year,
                                                              Less <Current <AccountByYearFilter.finYear> > >,
                                                       OrderBy <Desc <FinYear.year> >
                                                       > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinYear,
                                              OrderBy <Desc <FinYear.year> >
                                              > .SelectWindowed(this, 0, 1);

                if (nextperiod == null)
                {
                    yield return(filter);
                }
            }
            filter.FinYear = nextperiod != null ? nextperiod.Year : null;
            yield return(filter);
        }
        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());
        }