示例#1
0
        public virtual void CheckRelatedGLHistoryDoesNotExist(int?[] branchIDs)
        {
            if (branchIDs == null || branchIDs.IsEmpty())
            {
                return;
            }

            GLHistory history = GLUtility.GetRelatedToBranchGLHistory(Graph, branchIDs);

            if (history != null)
            {
                Branch branch = BranchMaint.FindBranchByID(Graph, history.BranchID);

                if (branch != null)
                {
                    throw new PXException(Messages.BranchCanNotBeDeletedBecausePostedGLTransExist,
                                          branch.BranchCD.Trim());
                }
            }
        }
示例#2
0
        protected virtual void BranchBAccount_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            BranchBAccount item = e.Row as BranchBAccount;

            if (item != null)
            {
                Ledger ledger = PXSelectJoin <Ledger,
                                              InnerJoin <Branch, On <Branch.branchID, Equal <Ledger.defBranchID> > >,
                                              Where <Branch.branchCD, Equal <Required <Branch.branchCD> > > > .Select(this, item.BranchBranchCD);

                if (ledger != null)
                {
                    GLHistory hist = PXSelect <GLHistory, Where <GLHistory.ledgerID, Equal <Required <GLHistory.ledgerID> > > > .Select(this, ledger.LedgerID);

                    if (hist != null)
                    {
                        throw new PXSetPropertyException(ErrorMessages.CantDeleteRecord);
                    }
                }
            }
        }
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            GLSetup gLSetup = PXSelect <GLSetup> .Select(sender.Graph);

            decimal?result        = 0m;
            object  cashAccountID = sender.GetValue(e.Row, _CashAccount);

            object finPeriodID = null;

            if (string.IsNullOrEmpty(_FinPeriodID))
            {
                object    finDate   = sender.GetValue(e.Row, _FinDate);
                FinPeriod finPeriod = PXSelect <FinPeriod, Where <FinPeriod.startDate, LessEqual <Required <FinPeriod.startDate> >,
                                                                  And <FinPeriod.endDate, Greater <Required <FinPeriod.endDate> > > > > .Select(sender.Graph, finDate, finDate);

                if (finPeriod != null)
                {
                    finPeriodID = finPeriod.FinPeriodID;
                }
            }
            else
            {
                finPeriodID = sender.GetValue(e.Row, _FinPeriodID);
            }

            if (cashAccountID != null && finPeriodID != null)
            {
                // clear glhistory cache for ReleasePayments longrun
                sender.Graph.Caches <GLHistory>().ClearQueryCache();
                sender.Graph.Caches <GLHistory>().Clear();

                GLHistory gLHistory = PXSelectJoin <GLHistory,
                                                    InnerJoin <GLHistoryByPeriod,
                                                               On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                   And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                        And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                             And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                  And <GLHistoryByPeriod.lastActivityPeriod, Equal <GLHistory.finPeriodID> > > > > >,
                                                               InnerJoin <Branch,
                                                                          On <Branch.branchID, Equal <GLHistory.branchID>,
                                                                              And <Branch.ledgerID, Equal <GLHistory.ledgerID> > >,
                                                                          InnerJoin <CashAccount,
                                                                                     On <GLHistoryByPeriod.branchID, Equal <CashAccount.branchID>,
                                                                                         And <GLHistoryByPeriod.accountID, Equal <CashAccount.accountID>,
                                                                                              And <GLHistoryByPeriod.subID, Equal <CashAccount.subID> > > >,
                                                                                     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> > > > > > > > >,
                                                    Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> >,
                                                           And <GLHistoryByPeriod.finPeriodID, Equal <Required <GLHistoryByPeriod.finPeriodID> > >
                                                           > > .Select(sender.Graph, cashAccountID, finPeriodID);

                if (gLHistory != null)
                {
                    result = gLHistory.CuryFinYtdBalance;
                }
            }
            e.ReturnValue = result;
            e.Cancel      = true;
        }
示例#4
0
        public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            GLSetup gLSetup = PXSelect <GLSetup> .Select(sender.Graph);

            decimal?result        = 0m;
            object  cashAccountID = sender.GetValue(e.Row, _CashAccount);

            object finPeriodID = null;

            if (string.IsNullOrEmpty(_FinPeriodID))
            {
                object finDate   = sender.GetValue(e.Row, _FinDate);
                var    finPeriod = "";

                if (finPeriod != null)
                {
                    CashAccount cashaccount = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(sender.Graph, cashAccountID);

                    if (cashaccount != null)
                    {
                        finPeriodID = sender.Graph.GetService <IFinPeriodRepository>().FindFinPeriodByDate((DateTime?)sender.GetValue(e.Row, _FinDate), PXAccess.GetParentOrganizationID(cashaccount.BranchID))?.FinPeriodID;
                    }
                }
            }
            else
            {
                finPeriodID = sender.GetValue(e.Row, _FinPeriodID);
            }

            if (cashAccountID != null && finPeriodID != null)
            {
                // clear glhistory cache for ReleasePayments longrun
                sender.Graph.Caches <GLHistory>().ClearQueryCacheObsolete();
                sender.Graph.Caches <GLHistory>().Clear();

                GLHistory gLHistory = PXSelectJoin <GLHistory,
                                                    InnerJoin <GLHistoryByPeriod,
                                                               On <GLHistoryByPeriod.accountID, Equal <GLHistory.accountID>,
                                                                   And <GLHistoryByPeriod.branchID, Equal <GLHistory.branchID>,
                                                                        And <GLHistoryByPeriod.ledgerID, Equal <GLHistory.ledgerID>,
                                                                             And <GLHistoryByPeriod.subID, Equal <GLHistory.subID>,
                                                                                  And <GLHistoryByPeriod.lastActivityPeriod, Equal <GLHistory.finPeriodID> > > > > >,
                                                               InnerJoin <Branch,
                                                                          On <Branch.branchID, Equal <GLHistory.branchID>,
                                                                              And <Branch.ledgerID, Equal <GLHistory.ledgerID> > >,
                                                                          InnerJoin <CashAccount,
                                                                                     On <GLHistoryByPeriod.branchID, Equal <CashAccount.branchID>,
                                                                                         And <GLHistoryByPeriod.accountID, Equal <CashAccount.accountID>,
                                                                                              And <GLHistoryByPeriod.subID, Equal <CashAccount.subID> > > >,
                                                                                     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> > > > > > > > >,
                                                    Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> >,
                                                           And <GLHistoryByPeriod.finPeriodID, Equal <Required <GLHistoryByPeriod.finPeriodID> > >
                                                           > > .Select(sender.Graph, cashAccountID, finPeriodID);

                if (gLHistory != null)
                {
                    result = gLHistory.CuryFinYtdBalance;
                }
            }
            e.ReturnValue = result;
            e.Cancel      = true;
        }