public virtual IEnumerable ViewDetails(PXAdapter adapter)
        {
            if (this.EnqResult.Current != null && this.Filter.Current != null)
            {
                GLHistoryEnquiryResult res           = this.EnqResult.Current;
                GLHistoryEnqFilter     currentFilter = this.Filter.Current;

                AccountByPeriodEnq    graph  = PXGraph.CreateInstance <AccountByPeriodEnq>();
                AccountByPeriodFilter filter = graph.Filter.Current;
                Copy(filter, currentFilter);

                filter.AccountID = res.AccountID;
                graph.Filter.Update(filter);
                filter = graph.Filter.Select();
                throw new PXRedirectRequiredException(graph, "Account Details");
            }
            return(Filter.Select());
        }
        protected virtual IEnumerable enqResult()
        {
            AccountByYearFilter filter = this.CurrentFilter;
            bool showCurrency          = filter.ShowCuryDetail.HasValue && filter.ShowCuryDetail.Value;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);

            if (filter.AccountID == null || filter.LedgerID == null || filter.FinYear == null)
            {
                yield break;                 //Prevent code from accessing database;
            }

            PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                            InnerJoin <Account,
                                                                                       On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                       InnerJoin <FinPeriod,
                                                                                                  On <GLHistoryByPeriod.finPeriodID, Equal <FinPeriod.finPeriodID> >,
                                                                                                  InnerJoin <Sub,
                                                                                                             On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                             LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                                      And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                           And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                                And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                                     And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                                       LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                                         And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                              And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                                   And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                                        And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > > >,
                                                                            Where <GLHistoryByPeriod.ledgerID, Equal <Current <AccountByYearFilter.ledgerID> >,
                                                                                   And <FinPeriod.finYear, Equal <Current <AccountByYearFilter.finYear> >,
                                                                                        And <GLHistoryByPeriod.accountID, Equal <Current <AccountByYearFilter.accountID> >,
                                                                                             And <
                                                                                                 Where2 <
                                                                                                     Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                             Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                     Or <
                                                                                                         Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                                And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                            Or <Account.type, Equal <AccountType.income>,
                                                                                                                                Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > > >,
                                                                            Aggregate <
                                                                                Sum <AH.finYtdBalance,
                                                                                     Sum <AH.curyFinYtdBalance,
                                                                                          Sum <GLHistory.finPtdDebit,
                                                                                               Sum <GLHistory.finPtdCredit,
                                                                                                    Sum <GLHistory.finBegBalance,
                                                                                                         Sum <GLHistory.finYtdBalance,
                                                                                                              Sum <GLHistory.curyFinBegBalance,
                                                                                                                   Sum <GLHistory.curyFinYtdBalance,
                                                                                                                        Sum <GLHistory.curyFinPtdCredit,
                                                                                                                             Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                  GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                           GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                    GroupBy <GLHistoryByPeriod.finPeriodID
                                                                                                                                                             > > > > > > > > > > > > > > >(this);

            if (filter.SubID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.subID, Equal <Current <AccountByYearFilter.subID> > > >();
            }

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <AccountByYearFilter.branchID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <AccountByYearFilter.subCDWildcard> > > >();
            }

            string  yearBegPeriod = filter.BegFinPeriod;
            GLSetup glSetup       = glsetup.Current;
            bool    reverseSign   = (glSetup != null) && (glSetup.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);

            foreach (PXResult <GLHistoryByPeriod, Account, FinPeriod, Sub, GLHistory, AH> it in cmd.Select(yearBegPeriod))
            {
                GLHistoryByPeriod baseview = (GLHistoryByPeriod)it;
                Account           acct     = (Account)it;
                GLHistory         ah       = (GLHistory)it;
                AH ah1 = (AH)it;

                if (reverseSign && acct.AccountID == glSetup.YtdNetIncAccountID)
                {
                    continue;
                }

                GLHistoryEnquiryResult item = new GLHistoryEnquiryResult();
                item.AccountID          = baseview.AccountID;
                item.LedgerID           = baseview.LedgerID;
                item.LastActivityPeriod = baseview.FinPeriodID;
                item.PtdCreditTotal     = ah.FinPtdCredit;
                item.PtdDebitTotal      = ah.FinPtdDebit;
                item.CuryID             = ah1.CuryID;
                item.Type       = acct.Type;
                item.EndBalance = ah1.FinYtdBalance;
                if (!string.IsNullOrEmpty(ah1.CuryID))
                {
                    item.CuryEndBalance     = ah1.CuryFinYtdBalance;                         //
                    item.CuryPtdCreditTotal = ah.CuryFinPtdCredit;
                    item.CuryPtdDebitTotal  = ah.CuryFinPtdDebit;
                }
                else
                {
                    item.CuryEndBalance     = null;
                    item.CuryPtdCreditTotal = null;
                    item.CuryPtdDebitTotal  = null;
                }
                item.recalculate(true);                         // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                item.recalculateSignAmount(reverseSign);
                yield return(item);
            }
        }
Example #3
0
        protected virtual IEnumerable enqResult()
        {
            GLHistoryEnqFilter filter = CurrentFilter;
            bool showCurrency         = filter.ShowCuryDetail == true;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);

            if (filter.AccountID == null || filter.LedgerID == null || filter.FinPeriodID == null)
            {
                yield break;                                                                                    //Prevent code from accessing database;
            }
            PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                            InnerJoin <Account,
                                                                                       On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                       InnerJoin <Sub,
                                                                                                  On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                  LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                           And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                     And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                          And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                            LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                              And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                   And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                        And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                             And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > >,
                                                                            Where <GLHistoryByPeriod.ledgerID, Equal <Current <GLHistoryEnqFilter.ledgerID> >,
                                                                                   And <GLHistoryByPeriod.accountID, Equal <Current <GLHistoryEnqFilter.accountID> >,
                                                                                        And <GLHistoryByPeriod.finPeriodID, Equal <Current <GLHistoryEnqFilter.finPeriodID> >,
                                                                                             And <
                                                                                                 Where2 <
                                                                                                     Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                             Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                     Or <Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                                And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                            Or <Account.type, Equal <AccountType.income>,
                                                                                                                                Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > > >,
                                                                            Aggregate <
                                                                                Sum <AH.finYtdBalance,
                                                                                     Sum <AH.curyFinYtdBalance,
                                                                                          Sum <GLHistory.finPtdDebit,
                                                                                               Sum <GLHistory.finPtdCredit,
                                                                                                    Sum <GLHistory.finBegBalance,
                                                                                                         Sum <GLHistory.finYtdBalance,
                                                                                                              Sum <GLHistory.curyFinBegBalance,
                                                                                                                   Sum <GLHistory.curyFinYtdBalance,
                                                                                                                        Sum <GLHistory.curyFinPtdCredit,
                                                                                                                             Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                  GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                           GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                    GroupBy <GLHistoryByPeriod.subID> > > > > > > > > > > > > > >(this);

            int[] branchIDs = null;

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <GLHistoryEnqFilter.branchID> > > >();
            }
            else if (filter.OrganizationID != null)
            {
                branchIDs = PXAccess.GetChildBranchIDs(filter.OrganizationID);

                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, In <Required <GLHistoryEnqFilter.branchID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <GLHistoryEnqFilter.subCDWildcard> > > >();
            }

            foreach (PXResult <GLHistoryByPeriod, Account, Sub, GLHistory, AH> it in cmd.Select(filter.BegFinPeriod, branchIDs))
            {
                GLHistoryByPeriod baseview = it;
                Account           acct     = it;
                GLHistory         ah       = it;
                AH ah1 = it;

                GLHistoryEnquiryResult item = new GLHistoryEnquiryResult
                {
                    AccountID          = baseview.AccountID,
                    AccountCD          = acct.AccountCD,
                    LedgerID           = baseview.LedgerID,
                    Type               = acct.Type,
                    Description        = acct.Description,
                    LastActivityPeriod = baseview.LastActivityPeriod,
                    PtdCreditTotal     = ah.FinPtdCredit,
                    PtdDebitTotal      = ah.FinPtdDebit,
                    CuryID             = ah1.CuryID,
                    SubCD              = ((Sub)it).SubCD,
                    EndBalance         = ah1.FinYtdBalance
                };
                if (!string.IsNullOrEmpty(ah1.CuryID))
                {
                    item.CuryEndBalance     = ah1.CuryFinYtdBalance;
                    item.CuryPtdCreditTotal = ah.CuryFinPtdCredit;
                    item.CuryPtdDebitTotal  = ah.CuryFinPtdDebit;
                }
                else
                {
                    item.CuryEndBalance     = null;
                    item.CuryPtdCreditTotal = null;
                    item.CuryPtdDebitTotal  = null;
                }
                item.recalculate(true);                 // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                item.recalculateSignAmount(glsetup.Current?.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);
                yield return(item);
            }
        }
Example #4
0
        protected virtual IEnumerable enqResult()
        {
            GLHistoryEnqFilter filter = (GLHistoryEnqFilter)this.Filter.Current;
            bool showCurrency         = filter.ShowCuryDetail.HasValue && filter.ShowCuryDetail.Value;

            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyID>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdCreditTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyPtdDebitTotal>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.curyEndBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryBegBalance>(EnqResult.Cache, null, showCurrency);
            PXUIFieldAttribute.SetVisible <GLHistoryEnquiryResult.signCuryEndBalance>(EnqResult.Cache, null, showCurrency);
            if (filter.LedgerID == null || filter.FinPeriodID == null)
            {
                yield break;                 //Prevent code from accessing database;
            }
            #region cmd
            PXSelectBase <GLHistoryByPeriod> cmd = new PXSelectJoinGroupBy <GLHistoryByPeriod,
                                                                            InnerJoin <Account,
                                                                                       On <GLHistoryByPeriod.accountID, Equal <Account.accountID>, And <Match <Account, Current <AccessInfo.userName> > > >,
                                                                                       InnerJoin <Sub,
                                                                                                  On <GLHistoryByPeriod.subID, Equal <Sub.subID>, And <Match <Sub, Current <AccessInfo.userName> > > >,
                                                                                                  LeftJoin <GLHistory, On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                                                                           And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                                                                                And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                                                                                     And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                                                                          And <GLHistoryByPeriod.finPeriodID, Equal <GLHistory.finPeriodID> > > > > >,
                                                                                                            LeftJoin <AH, On <GLHistoryByPeriod.ledgerID, Equal <AH.ledgerID>,
                                                                                                                              And <GLHistoryByPeriod.branchID, Equal <AH.branchID>,
                                                                                                                                   And <GLHistoryByPeriod.accountID, Equal <AH.accountID>,
                                                                                                                                        And <GLHistoryByPeriod.subID, Equal <AH.subID>,
                                                                                                                                             And <GLHistoryByPeriod.lastActivityPeriod, Equal <AH.finPeriodID> > > > > > > > > >,
                                                                            Where <GLHistoryByPeriod.ledgerID, Equal <Current <GLHistoryEnqFilter.ledgerID> >,
                                                                                   And <GLHistoryByPeriod.finPeriodID, Equal <Current <GLHistoryEnqFilter.finPeriodID> >,
                                                                                        And <
                                                                                            Where2 <
                                                                                                Where <Account.accountID, NotEqual <Current <GLSetup.ytdNetIncAccountID> >, And <Where <Account.type, Equal <AccountType.asset>,
                                                                                                                                                                                        Or <Account.type, Equal <AccountType.liability> > > > >,
                                                                                                Or <Where <GLHistoryByPeriod.lastActivityPeriod, GreaterEqual <Required <GLHistoryByPeriod.lastActivityPeriod> >,
                                                                                                           And <Where <Account.type, Equal <AccountType.expense>,
                                                                                                                       Or <Account.type, Equal <AccountType.income>,
                                                                                                                           Or <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > > > > > > > > >,
                                                                            Aggregate <
                                                                                Sum <AH.finYtdBalance,
                                                                                     Sum <AH.tranYtdBalance,
                                                                                          Sum <AH.curyFinYtdBalance,
                                                                                               Sum <AH.curyTranYtdBalance,
                                                                                                    Sum <GLHistory.finPtdDebit,
                                                                                                         Sum <GLHistory.tranPtdDebit,
                                                                                                              Sum <GLHistory.finPtdCredit,
                                                                                                                   Sum <GLHistory.tranPtdCredit,
                                                                                                                        Sum <GLHistory.finBegBalance,
                                                                                                                             Sum <GLHistory.tranBegBalance,
                                                                                                                                  Sum <GLHistory.finYtdBalance,
                                                                                                                                       Sum <GLHistory.tranYtdBalance,
                                                                                                                                            Sum <GLHistory.curyFinBegBalance,
                                                                                                                                                 Sum <GLHistory.curyTranBegBalance,
                                                                                                                                                      Sum <GLHistory.curyFinYtdBalance,
                                                                                                                                                           Sum <GLHistory.curyTranYtdBalance,
                                                                                                                                                                Sum <GLHistory.curyFinPtdCredit,
                                                                                                                                                                     Sum <GLHistory.curyTranPtdCredit,
                                                                                                                                                                          Sum <GLHistory.curyFinPtdDebit,
                                                                                                                                                                               Sum <GLHistory.curyTranPtdDebit,
                                                                                                                                                                                    GroupBy <GLHistoryByPeriod.branchID,
                                                                                                                                                                                             GroupBy <GLHistoryByPeriod.ledgerID,
                                                                                                                                                                                                      GroupBy <GLHistoryByPeriod.accountID,
                                                                                                                                                                                                               GroupBy <GLHistoryByPeriod.finPeriodID
                                                                                                                                                                                                                        > > > > > > > > > > > > > > > > > > > > > > > > > >(this);

            if (filter.LedgerID != null)
            {
                Ledger ledger = (Ledger)PXSelectorAttribute.Select <GLHistoryEnqFilter.ledgerID>(Filter.Cache, filter);
                if (ledger?.BalanceType == LedgerBalanceType.Budget)
                {
                    // we shouldn't select history from the previous years for the budget ledgers
                    cmd.WhereAnd <Where <Substring <GLHistoryByPeriod.finPeriodID, int1, int4>, Equal <Substring <GLHistoryByPeriod.lastActivityPeriod, int1, int4> > > >();
                }
            }
            if (filter.AccountID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.accountID, Equal <Current <GLHistoryEnqFilter.accountID> > > >();
            }
            if (filter.AccountClassID != null)
            {
                cmd.WhereAnd <Where <Account.accountClassID, Equal <Current <GLHistoryEnqFilter.accountClassID> > > >();
            }

            if (filter.SubID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.subID, Equal <Current <GLHistoryEnqFilter.subID> > > >();
            }

            int[] branchIDs = null;

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <GLHistoryEnqFilter.branchID> > > >();
            }
            else if (filter.OrganizationID != null)
            {
                branchIDs = PXAccess.GetChildBranchIDs(filter.OrganizationID, false);

                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, In <Required <GLHistoryEnqFilter.branchID> >,
                                     And <MatchWithBranch <GLHistoryByPeriod.branchID> > > >();
            }

            if (!SubCDUtils.IsSubCDEmpty(filter.SubCD))
            {
                cmd.WhereAnd <Where <Sub.subCD, Like <Current <GLHistoryEnqFilter.subCDWildcard> > > >();
            }
            //cmd.WhereAnd<Where<Match<Current<AccessInfo.userName>>>>();
            #endregion
            string  yearBegPeriod = filter.BegFinPeriod;
            GLSetup glSetup       = glsetup.Current;
            bool    reverseSign   = (glSetup != null) && (glSetup.TrialBalanceSign == GLSetup.trialBalanceSign.Reversed);
            foreach (PXResult <GLHistoryByPeriod, Account, Sub, GLHistory, AH> it in cmd.Select(yearBegPeriod, branchIDs))
            {
                GLHistoryByPeriod baseview = (GLHistoryByPeriod)it;
                Account           acct     = (Account)it;
                GLHistory         ah       = (GLHistory)it;
                AH ah1 = (AH)it;
                ah.FinFlag  = filter.UseMasterCalendar != true;
                ah1.FinFlag = filter.UseMasterCalendar != true;

                if (reverseSign && acct.AccountID == glSetup.YtdNetIncAccountID)
                {
                    continue;
                }

                GLHistoryEnquiryResult item = new GLHistoryEnquiryResult();
                item.BranchID           = baseview.BranchID;
                item.LedgerID           = baseview.LedgerID;
                item.AccountID          = baseview.AccountID;
                item.AccountCD          = acct.AccountCD;
                item.Type               = acct.Type;
                item.Description        = acct.Description;
                item.LastActivityPeriod = baseview.LastActivityPeriod;
                item.PtdCreditTotal     = ah.PtdCredit ?? 0m;
                item.PtdDebitTotal      = ah.PtdDebit ?? 0m;
                item.EndBalance         = ah1.YtdBalance ?? 0m;
                item.ConsolAccountCD    = acct.GLConsolAccountCD;
                item.AccountClassID     = acct.AccountClassID;
                if (!(string.IsNullOrEmpty(ah.CuryID) && string.IsNullOrEmpty(ah1.CuryID)))
                {
                    item.CuryEndBalance     = ah1.CuryYtdBalance ?? 0m;
                    item.CuryPtdCreditTotal = ah.CuryPtdCredit ?? 0m;
                    item.CuryPtdDebitTotal  = ah.CuryPtdDebit ?? 0m;
                    item.CuryID             = string.IsNullOrEmpty(ah.CuryID) ? ah1.CuryID : ah.CuryID;
                }
                else
                {
                    item.CuryEndBalance     = null;
                    item.CuryPtdCreditTotal = null;
                    item.CuryPtdDebitTotal  = null;
                    item.CuryID             = null;
                }

                item.recalculate(true);                 // End balance is considered as correct digit - so we need to calculate begBalance base on ending one
                item.recalculateSignAmount(reverseSign);
                yield return(item);
            }
        }