Пример #1
0
        public virtual IEnumerable previousperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = Filter.Current as GLHistoryEnqFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID,
                                                             Less <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Desc <FinPeriod.finPeriodID> >
                                                      > .SelectWindowed(this, 0, 1);

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

                if (nextperiod == null)
                {
                    yield return(filter);
                }
            }

            filter.FinPeriodID = nextperiod != null ? nextperiod.FinPeriodID : null;

            yield return(filter);
        }
 public static void Copy(AccountByPeriodFilter filter, GLHistoryEnqFilter histFilter)
 {
     filter.BranchID       = histFilter.BranchID;
     filter.FinPeriodID    = histFilter.FinPeriodID;
     filter.LedgerID       = histFilter.LedgerID;
     filter.AccountID      = histFilter.AccountID;
     filter.SubID          = histFilter.SubCD;
     filter.StartPeriodID  = histFilter.BegFinPeriod;
     filter.ShowCuryDetail = histFilter.ShowCuryDetail;
 }
Пример #3
0
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter = Filter.Current as GLHistoryEnqFilter;

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

            FinPeriod nextPeriod = FinPeriodRepository.FindNextPeriod(calendarOrganizationID, filter.FinPeriodID, looped: true);

            filter.FinPeriodID = nextPeriod != null ? nextPeriod.FinPeriodID : null;
            return(adapter.Get());
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = CurrentFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID, Greater <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1)
                                            ?? PXSelectOrderBy <FinPeriod,
                                                                OrderBy <Asc <FinPeriod.finPeriodID> > > .SelectWindowed(this, 0, 1);

            filter.FinPeriodID = nextperiod?.FinPeriodID;
            return(adapter.Get());
        }
Пример #5
0
 public static void Copy(AccountByPeriodFilter filter, GLHistoryEnqFilter histFilter)
 {
     filter.OrganizationID    = histFilter.OrganizationID;
     filter.BranchID          = histFilter.BranchID;
     filter.StartPeriodID     = histFilter.FinPeriodID;
     filter.EndPeriodID       = histFilter.FinPeriodID;
     filter.LedgerID          = histFilter.LedgerID;
     filter.AccountID         = histFilter.AccountID;
     filter.SubID             = histFilter.SubCD;
     filter.StartPeriodID     = histFilter.BegFinPeriod;
     filter.ShowCuryDetail    = histFilter.ShowCuryDetail;
     filter.UseMasterCalendar = histFilter.UseMasterCalendar;
 }
        protected virtual void GLHistoryEnqFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            GLHistoryEnqFilter row = (GLHistoryEnqFilter)e.Row;

            if (row?.AccountID != null)
            {
                Account acctDef       = AccountInfo.Current == null || row.AccountID != AccountInfo.Current.AccountID ? AccountInfo.Select() : AccountInfo.Current;
                bool    isDenominated = !string.IsNullOrEmpty(acctDef.CuryID);
                PXUIFieldAttribute.SetEnabled <GLHistoryEnqFilter.showCuryDetail>(cache, e.Row, isDenominated);
                if (!isDenominated)
                {
                    row.ShowCuryDetail = false;
                }
            }
        }
        protected virtual IEnumerable AccountBySub(PXAdapter adapter)
        {
            if (this.EnqResult.Current != null)
            {
                AccountHistoryBySubEnq graph  = PXGraph.CreateInstance <AccountHistoryBySubEnq>();
                GLHistoryEnqFilter     filter = PXCache <GLHistoryEnqFilter> .CreateCopy(graph.Filter.Current);

                filter.AccountID      = this.Filter.Current.AccountID;
                filter.LedgerID       = this.Filter.Current.LedgerID;
                filter.BranchID       = this.Filter.Current.BranchID;
                filter.SubCD          = this.Filter.Current.SubCD;
                filter.FinPeriodID    = this.EnqResult.Current.LastActivityPeriod;
                filter.ShowCuryDetail = this.Filter.Current.ShowCuryDetail;
                graph.Filter.Update(filter);
                throw new PXRedirectRequiredException(graph, "Account by Subaccount");
            }
            return(adapter.Get());
        }
        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());
        }
        public virtual IEnumerable nextperiod(PXAdapter adapter)
        {
            GLHistoryEnqFilter filter     = Filter.Current as GLHistoryEnqFilter;
            FinPeriod          nextperiod = PXSelect <FinPeriod,
                                                      Where <FinPeriod.finPeriodID,
                                                             Greater <Current <GLHistoryEnqFilter.finPeriodID> > >,
                                                      OrderBy <Asc <FinPeriod.finPeriodID> >
                                                      > .SelectWindowed(this, 0, 1);

            if (nextperiod == null)
            {
                nextperiod = PXSelectOrderBy <FinPeriod,
                                              OrderBy <Asc <FinPeriod.finPeriodID> >
                                              > .SelectWindowed(this, 0, 1);
            }

            filter.FinPeriodID = nextperiod != null ? nextperiod.FinPeriodID : null;
            return(adapter.Get());
        }
        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);

            if (filter.BranchID != null)
            {
                cmd.WhereAnd <Where <GLHistoryByPeriod.branchID, Equal <Current <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))
            {
                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);
            }
        }
Пример #11
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);
            }
        }