コード例 #1
0
        private static void CAExpense_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var expense = (CAExpense)e.Row;

            if (string.IsNullOrEmpty(expense.AdjRefNbr))
            {
                return;
            }

            CAAdj adj = PXSelect <CAAdj, Where <CAAdj.adjTranType, Equal <CATranType.cATransferExp>, And <CAAdj.adjRefNbr, Equal <Required <CAExpense.adjRefNbr> > > > > .Select(sender.Graph, expense.AdjRefNbr);

            CASplit split = PXSelect <CASplit, Where <CASplit.adjTranType, Equal <CATranType.cATransferExp>, And <CASplit.adjRefNbr, Equal <Required <CAExpense.adjRefNbr> >,
                                                                                                                  And <CASplit.lineNbr, Equal <one> > > > > .Select(sender.Graph, expense.AdjRefNbr);

            adj.EntryTypeID     = expense.EntryTypeID;
            split.AccountID     = expense.AccountID;
            split.SubID         = expense.SubID;
            split.CuryUnitPrice = expense.CuryTranAmt;
            split.CuryTranAmt   = expense.CuryTranAmt;
            split.TranAmt       = expense.TranAmt;
            adj.DrCr            = expense.DrCr;
            adj.CuryTranAmt     = expense.CuryTranAmt;
            adj.TranAmt         = expense.TranAmt;
            adj.CuryControlAmt  = expense.CuryTranAmt;
            adj.ControlAmt      = expense.TranAmt;
            adj.TranDate        = expense.TranDate;
            adj.TranPeriodID    = expense.TranPeriodID;
            adj.TranDesc        = expense.TranDesc;
            adj.ExtRefNbr       = expense.ExtRefNbr;

            sender.Graph.Caches[typeof(CASplit)].Update(split);
            sender.Graph.Caches[typeof(CAAdj)].Update(adj);
        }
        protected virtual void CAAdj_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            CAAdj row = e.Row as CAAdj;

            if (row == null)
            {
                return;
            }
            bool           isWithinContext = Base.IsWithinContext;
            GLVoucher      voucher         = this.Voucher.Select();
            GLVoucherBatch voucherBatch    = this.VoucherBatch.Select();
            PXCache        voucherCache    = this.Voucher.Cache;
            bool           isDetached      = (voucher == null);

            PXUIFieldAttribute.SetEnabled <GLVoucher.refNbr>(voucherCache, voucher, false);
            PXUIFieldAttribute.SetVisible <GLVoucher.refNbr>(voucherCache, voucher, !isDetached);
            PXUIFieldAttribute.SetEnabled <CAAdj.adjRefNbr>(sender, e.Row, !isWithinContext);
            this.SaveAndAdd.SetVisible(!isDetached && isWithinContext);
            this.SaveAndAdd.SetEnabled(!isDetached && isWithinContext);
            if (isWithinContext)
            {
                Base.Release.SetVisible(false);
                Base.Release.SetEnabled(false);
            }
            PXUIFieldAttribute.SetVisible <GLVoucher.voucherBatchNbr>(Voucher.Cache, null, !isDetached && !isWithinContext);
            PXUIFieldAttribute.SetVisible <GLVoucher.workBookID>(Voucher.Cache, null, !isDetached && !isWithinContext);
            if (isWithinContext && !isDetached)
            {
                sender.AllowInsert = !(voucherBatch != null && voucherBatch.Released == true);
            }
        }
コード例 #3
0
        protected virtual void CAEntryType_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CAEntryType row = e.Row as CAEntryType;

            PXDefaultAttribute.SetPersistingCheck <CAEntryType.referenceID>(sender, e.Row, PXPersistingCheck.Nothing);

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                CAAdj foundCAAdj = PXSelectReadonly <CAAdj,
                                                     Where <CAAdj.entryTypeID, Equal <Required <CAAdj.entryTypeID> > > > .
                                   Select(this, row.EntryTypeId);

                if (foundCAAdj != null)
                {
                    CAEntryType foundCAEntryType = PXSelectReadonly <CAEntryType,
                                                                     Where <CAEntryType.entryTypeId, Equal <Required <CAEntryType.entryTypeId> > > > .
                                                   Select(this, row.EntryTypeId);

                    if (foundCAEntryType != null)
                    {
                        if (row.DrCr != foundCAEntryType.DrCr)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.drCr>(e.Row, row.DrCr, new PXSetPropertyException(Messages.CantEditDisbReceipt, PXErrorLevel.RowError, typeof(CAEntryType.drCr).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.drCr).Name, row.DrCr, Messages.CantEditDisbReceipt, typeof(CAEntryType.drCr).Name);
                            }
                        }
                        if (row.Module != foundCAEntryType.Module)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.module>(e.Row, row.Module, new PXSetPropertyException(Messages.CantEditModule, PXErrorLevel.RowError, typeof(CAEntryType.module).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.module).Name, row.Module, Messages.CantEditModule, typeof(CAEntryType.module).Name);
                            }
                        }
                    }
                }
            }
            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
            {
                if (row.UseToReclassifyPayments == true && row.AccountID.HasValue)
                {
                    CashAccount cashAcct = PXSelectReadonly <CashAccount,
                                                             Where <CashAccount.accountID, Equal <Required <CashAccount.accountID> >,
                                                                    And <CashAccount.subID, Equal <Required <CashAccount.subID> > > > > .Select(this, row.AccountID, row.SubID);

                    GL.Account acct = PXSelectReadonly <Account,
                                                        Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.AccountID);

                    if (cashAcct == null || !cashAcct.AccountID.HasValue)
                    {
                        if (sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, acct.AccountCD, new PXSetPropertyException(Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount, PXErrorLevel.Error)))
                        {
                            throw new PXRowPersistingException(typeof(CAEntryType.accountID).Name, acct.AccountCD, Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: CAReleaseProcess.cs プロジェクト: JeffJave/Ipevo
        public void OnReleaseComplete(ICADocument doc, OnReleaseCompleteDelegate baseMethod)
        {
            CAAdj cAAdj = doc as CAAdj;

            if (TWNGUIValidation.ActivateTWGUI(Base) == true &&
                cAAdj != null &&
                cAAdj.Released == true &&
                cAAdj.AdjTranType == CATranType.CAAdjustment)
            {
                TWNReleaseProcess rp = PXGraph.CreateInstance <TWNReleaseProcess>();

                PXSelectBase <TWNManualGUIBank> ViewManGUIBank = new SelectFrom <TWNManualGUIBank> .Where <TWNManualGUIBank.adjRefNbr.IsEqual <@P.AsString> > .View(Base);

                foreach (TWNManualGUIBank manualGUIBank in ViewManGUIBank.Cache.Cached)
                {
                    if (PXCache <Tax> .GetExtension <TaxExt>(Tax.PK.Find(Base, manualGUIBank.TaxID)).UsrTWNGUI.Equals(false))
                    {
                        continue;
                    }

                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        rp.CreateGUITrans(new STWNGUITran()
                        {
                            VATCode      = manualGUIBank.VATInCode,
                            GUINbr       = manualGUIBank.GUINbr,
                            GUIStatus    = TWNGUIStatus.Used,
                            BranchID     = Base.CATranCashTrans_Ordered.Current.BranchID,
                            GUIDirection = TWNGUIDirection.Receipt,
                            GUIDate      = manualGUIBank.GUIDate,
                            GUITitle     = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                                typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                                typeof(Vendor.acctName).Name),
                            TaxZoneID     = manualGUIBank.TaxZoneID,
                            TaxCategoryID = manualGUIBank.TaxCategoryID,
                            TaxID         = manualGUIBank.TaxID,
                            TaxNbr        = manualGUIBank.TaxNbr,
                            OurTaxNbr     = manualGUIBank.OurTaxNbr,
                            NetAmount     = manualGUIBank.NetAmt,
                            TaxAmount     = manualGUIBank.TaxAmt,
                            AcctCD        = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                                 typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                                 typeof(Vendor.acctCD).Name),
                            AcctName = (string)PXSelectorAttribute.GetField(ViewManGUIBank.Cache, manualGUIBank,
                                                                            typeof(APRegister.vendorID).Name, manualGUIBank.VendorID,
                                                                            typeof(Vendor.acctName).Name),
                            DeductionCode = manualGUIBank.Deduction,
                            Remark        = manualGUIBank.Remark,
                            OrderNbr      = manualGUIBank.AdjRefNbr
                        });

                        ts.Complete(Base);
                    }
                }
            }

            baseMethod(doc);
        }
        protected virtual void CAAdj_RowPersisting(PXCache sender, PXRowPersistingEventArgs e, PXRowPersisting bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }
            CAAdj row = e.Row as CAAdj;

            SetNumbering(sender, row);
        }
        protected virtual void CAAdj_AdjRefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e, PXFieldDefaulting bs)
        {
            CAAdj row = e.Row as CAAdj;

            SetNumbering(sender, row);
            if (bs != null)
            {
                bs(sender, e);
            }
        }
        public static CAAdj Process(CAAdj doc)
        {
            List <CAAdj> list = new List <CAAdj>();

            list.Add(doc);

            List <CAAdj> listWithTax = Process(list, false);

            return(listWithTax[0]);
        }
コード例 #8
0
 public static void UpdateStatus(PXCache cache, CAAdj row)
 {
     foreach (var attr in cache.GetAttributes <CAAdj.status>(row))
     {
         if (attr is SetStatusAttribute)
         {
             (attr as SetStatusAttribute).UpdateStatus(cache, row, row.Hold);
         }
     }
 }
コード例 #9
0
        public virtual IEnumerable release(PXAdapter adapter)
        {
            PXCache    cache    = Caches[typeof(CATransfer)];
            CATransfer transfer = Transfer.Current;

            if (PXLongOperation.Exists(UID))
            {
                throw new ApplicationException(GL.Messages.PrevOperationNotCompleteYet);
            }
            bool holdExpenses = false;

            foreach (PXResult <CATran, CAAdj> expense in TransferTran.Select())
            {
                CAAdj  expenseAdj  = (CAAdj)expense;
                CATran expenseTran = (CATran)expense;
                if (expenseAdj != null && (expenseAdj.Hold == true || expenseAdj.Approved == false))
                {
                    holdExpenses = true;
                    TransferTran.Cache.RaiseExceptionHandling <CATran.extRefNbr>(expenseTran, expenseTran.ExtRefNbr, new PXSetPropertyException(Messages.HoldExpense, PXErrorLevel.RowError));
                }
            }
            if (holdExpenses)
            {
                throw new PXException(Messages.HoldExpenses, transfer.RefNbr);
            }
            Save.Press();
            List <CARegister> list = new List <CARegister>();
            CATran            tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDIn> > > > .Select(this, transfer.TranIDIn);

            if (tran != null)
            {
                list.Add(CATrxRelease.CARegister(transfer, tran));
            }
            else
            {
                throw new PXException(Messages.TransactionNotFound);
            }

            tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDOut> > > > .Select(this, transfer.TranIDOut);

            if (tran == null)
            {
                throw new PXException(Messages.TransactionNotFound);
            }

            PXLongOperation.StartOperation(this, delegate() { CATrxRelease.GroupRelease(list, false); });

            List <CATransfer> ret = new List <CATransfer>();

            ret.Add(transfer);
            return(ret);
        }
コード例 #10
0
        public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row)
        {
            CAAdj parentDoc = (CAAdj)orig_Row;

            if ((parentDoc.Released == true) && (catran_Row.TranID != null))
            {
                return(null);
            }
            if (catran_Row.TranID == null || catran_Row.TranID < 0)
            {
                catran_Row.OrigModule   = BatchModule.CA;
                catran_Row.OrigTranType = parentDoc.AdjTranType;

                if (parentDoc.TransferNbr == null)
                {
                    catran_Row.OrigRefNbr = parentDoc.AdjRefNbr;
                }
                else
                {
                    catran_Row.OrigRefNbr = parentDoc.TransferNbr;
                }
            }

            catran_Row.CashAccountID = parentDoc.CashAccountID;
            catran_Row.ExtRefNbr     = parentDoc.ExtRefNbr;
            catran_Row.CuryID        = parentDoc.CuryID;
            catran_Row.CuryInfoID    = parentDoc.CuryInfoID;
            catran_Row.CuryTranAmt   = parentDoc.CuryTranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.TranAmt       = parentDoc.TranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.DrCr          = parentDoc.DrCr;
            catran_Row.TranDate      = parentDoc.TranDate;
            catran_Row.TranDesc      = parentDoc.TranDesc;
            catran_Row.ReferenceID   = null;
            catran_Row.Released      = parentDoc.Released;
            catran_Row.Hold          = parentDoc.Hold;
            catran_Row.FinPeriodID   = parentDoc.FinPeriodID;
            catran_Row.TranPeriodID  = parentDoc.TranPeriodID;
            catran_Row.Cleared       = parentDoc.Cleared;
            catran_Row.ClearDate     = parentDoc.ClearDate;

            PXSelectBase <CashAccount> selectStatement = new PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > >(sender.Graph);
            CashAccount cashacc = (CashAccount)selectStatement.View.SelectSingle(catran_Row.CashAccountID);

            if (cashacc != null && cashacc.Reconcile == false && (catran_Row.Cleared != true || catran_Row.TranDate == null))
            {
                catran_Row.Cleared   = true;
                catran_Row.ClearDate = catran_Row.TranDate;
            }

            return(catran_Row);
        }
コード例 #11
0
        public override void Persist()
        {
            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    List <CATran> deleted = new List <CATran>();
                    RowPersisting.AddHandler <CATran>((sender, e) =>
                    {
                        if (deleted.Contains((CATran)e.Row))
                        {
                            e.Cancel = true;
                        }
                    });
                    CATranEntry graph = null;
                    foreach (CATran catran in TransferTran.Cache.Deleted)
                    {
                        if (graph == null)
                        {
                            graph = PXGraph.CreateInstance <CATranEntry>();
                        }
                        CAAdj adj = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID);

                        if (adj != null)
                        {
                            graph.TimeStamp = TimeStamp;
                            graph.CAAdjRecords.Delete(adj);
                            graph.Save.Press();
                            graph.Clear();
                            deleted.Add(catran);
                        }
                    }
                    base.Persist();
                    ts.Complete();
                    foreach (CATran catran in deleted)
                    {
                        TransferTran.Cache.Remove(catran);
                    }
                    deleted.Clear();
                }
            }

            //Current should be the only one inserted
            PXCache currencycache = Caches[typeof(CM.CurrencyInfo)];

            currencycache.SetStatus(currencycache.Current, PXEntryStatus.Inserted);
        }
コード例 #12
0
        public virtual IEnumerable viewDoc(PXAdapter adapter)
        {
            if (Expenses.Current.AdjRefNbr != null)
            {
                CATranEntry graph = PXGraph.CreateInstance <CATranEntry>();
                graph.Clear();
                Transfer.Cache.IsDirty = false;
                CAAdj adj = PXSelect <CAAdj, Where <CAAdj.adjRefNbr, Equal <Required <CAExpense.adjRefNbr> > > > .Select(this, Expenses.Current.AdjRefNbr);

                graph.CAAdjRecords.Current = adj;
                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            return(adapter.Get());
        }
コード例 #13
0
        public override void CacheAttached(PXCache sender)
        {
            base.CacheAttached(sender);

            sender.Graph.FieldUpdating.AddHandler <CAAdj.hold>((cache, e) =>
            {
                PXBoolAttribute.ConvertValue(e);

                CAAdj item = e.Row as CAAdj;
                if (item != null)
                {
                    UpdateStatus(cache, item, (bool?)e.NewValue);
                }
            });

            sender.Graph.FieldVerifying.AddHandler <CAAdj.status>((cache, e) => { e.NewValue = cache.GetValue <CAAdj.status>(e.Row); });
        }
        public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row)
        {
            CAAdj parentDoc = (CAAdj)orig_Row;

            if ((parentDoc.Released == true) && (catran_Row.TranID != null))
            {
                return(null);
            }
            if (catran_Row.TranID == null || catran_Row.TranID < 0)
            {
                catran_Row.OrigModule   = BatchModule.CA;
                catran_Row.OrigTranType = parentDoc.AdjTranType;

                if (parentDoc.TransferNbr == null)
                {
                    catran_Row.OrigRefNbr = parentDoc.AdjRefNbr;
                }
                else
                {
                    catran_Row.OrigRefNbr = parentDoc.TransferNbr;
                }
            }

            catran_Row.CashAccountID = parentDoc.CashAccountID;
            catran_Row.ExtRefNbr     = parentDoc.ExtRefNbr;
            catran_Row.CuryID        = parentDoc.CuryID;
            catran_Row.CuryInfoID    = parentDoc.CuryInfoID;
            catran_Row.CuryTranAmt   = parentDoc.CuryTranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.TranAmt       = parentDoc.TranAmt * (parentDoc.DrCr == DrCr.Debit ? 1 : -1);
            catran_Row.DrCr          = parentDoc.DrCr;
            catran_Row.TranDate      = parentDoc.TranDate;
            catran_Row.TranDesc      = parentDoc.TranDesc;
            catran_Row.ReferenceID   = null;
            catran_Row.Released      = parentDoc.Released;
            catran_Row.Hold          = parentDoc.Hold;
            catran_Row.FinPeriodID   = parentDoc.FinPeriodID;
            catran_Row.TranPeriodID  = parentDoc.TranPeriodID;
            catran_Row.Cleared       = parentDoc.Cleared;
            catran_Row.ClearDate     = parentDoc.ClearDate;

            SetCleared(catran_Row, GetCashAccount(catran_Row, sender.Graph));

            return(catran_Row);
        }
        private void SetNumbering(PXCache sender, CAAdj row)
        {
            if (row == null)
            {
                return;
            }
            if (Base.IsWithinContext)
            {
                Numbering numbering = PXSelectJoin <Numbering,
                                                    InnerJoin <GLWorkBook, On <GLWorkBook.voucherNumberingID, Equal <Numbering.numberingID> > >,
                                                    Where <GLWorkBook.workBookID, Equal <Required <GLWorkBook.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                AutoNumberAttribute.SetNumberingId <CAAdj.adjRefNbr>(sender, numbering.NumberingID);
                if (numbering.UserNumbering == true)
                {
                    sender.RaiseExceptionHandling <CAAdj.adjRefNbr>(row, row.RefNbr, new PXException(GL.Messages.ManualNumberingDisabled));
                }
            }
        }
コード例 #16
0
        public override void Persist()
        {
            using (PXTransactionScope ts = new PXTransactionScope())
            {
                List <CATran> deleted = new List <CATran>();
                RowPersisting.AddHandler <CATran>((sender, e) =>
                {
                    if (deleted.Contains((CATran)e.Row))
                    {
                        e.Cancel = true;
                    }
                });
                CATranEntry graph = null;
                foreach (CATran catran in TransferTran.Cache.Deleted)
                {
                    if (graph == null)
                    {
                        graph = PXGraph.CreateInstance <CATranEntry>();
                    }
                    CAAdj adj = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID);

                    if (adj != null)
                    {
                        graph.TimeStamp = TimeStamp;
                        graph.CAAdjRecords.Delete(adj);
                        graph.Save.Press();
                        graph.Clear();
                        deleted.Add(catran);
                    }
                }
                base.Persist();
                ts.Complete();
                foreach (CATran catran in deleted)
                {
                    TransferTran.Cache.Remove(catran);
                }
                deleted.Clear();
            }
        }
コード例 #17
0
        protected virtual void CATranExt_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            CATran tran = (CATran)e.Row;

            if (tran.Released == true ||
                tran.OrigModule != BatchModule.CA ||
                tran.OrigTranType != CATranType.CAAdjustment)
            {
                throw new PXException(ErrorMessages.CantDeleteRecord);
            }

            CAAdj adj = caadj_adjRefNbr.Select(tran.OrigRefNbr);

            if (adj != null)
            {
                caadj_adjRefNbr.Delete(adj);
            }
            foreach (CASplit split in casplit_adjRefNbr.Select(tran.OrigRefNbr))
            {
                casplit_adjRefNbr.Delete(split);
            }
        }
コード例 #18
0
 public void UpdateStatus(PXCache cache, CAAdj row, bool?isHold)
 {
     if (isHold == true)
     {
         cache.SetValue(row, _FieldOrdinal, CATransferStatus.Hold);
     }
     else if (row.Approved == false && row.RequestApproval == true)
     {
         cache.SetValue(row, _FieldOrdinal, CATransferStatus.Pending);
     }
     else if (row.Rejected == true)
     {
         cache.SetValue(row, _FieldOrdinal, CATransferStatus.Rejected);
     }
     else if (row.Released == true)
     {
         cache.SetValue(row, _FieldOrdinal, CATransferStatus.Released);
     }
     else
     {
         cache.SetValue(row, _FieldOrdinal, CATransferStatus.Balanced);
     }
 }
コード例 #19
0
        private static void Validate(CATranEntryLight te, CashAccount tlist)
        {
            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    Account account = PXSelect <Account, Where <Account.isCashAccount, Equal <False>,
                                                                And <Account.accountID, Equal <Required <Account.accountID> > > > > .Select(te, tlist.AccountID);

                    if (account != null)
                    {
                        account.IsCashAccount = true;
                        te.account.Update(account);
                        te.account.Cache.Persist(PXDBOperation.Update);
                        te.account.Cache.Persisted(false);
                    }
                    ts.Complete(te);
                }
            }
            te.Clear();

            if (tlist.Reconcile != true)
            {
                te.Clear();
                using (new PXConnectionScope())
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        PXCache adjcache = te.Caches[typeof(CATran)];
                        foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                        {
                            if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null))
                            {
                                catran.Cleared   = true;
                                catran.ClearDate = catran.TranDate;
                            }
                            te.catrancache.Update(catran);
                        }
                        te.catrancache.Persist(PXDBOperation.Update);
                        ts.Complete(te);
                    }
                    te.catrancache.Persisted(false);
                }
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache adjcache = te.Caches[typeof(CAAdj)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> >,
                                                                                            LeftJoin <GLTranDoc, On <GLTranDoc.refNbr, Equal <CAAdj.adjRefNbr>, And <GLTranDoc.tranType, Equal <CAAdj.adjTranType>, And <GLTranDoc.tranModule, Equal <BatchModule.moduleCA> > > > > >,
                                                                           Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull, And <GLTranDoc.refNbr, IsNull> > > > .Select(te, tlist.CashAccountID))
                    {
                        CAAdj caadj = (CAAdj)res;

                        GLTran gltran = PXSelectJoin <GLTran, InnerJoin <CashAccount,
                                                                         On <CashAccount.accountID, Equal <GLTran.accountID>,
                                                                             And <CashAccount.subID, Equal <GLTran.subID>,
                                                                                  And <CashAccount.branchID, Equal <GLTran.branchID> > > > >,
                                                      Where <GLTran.cATranID, Equal <Required <CAAdj.tranID> >,
                                                             And <CashAccount.cashAccountID, Equal <Required <CAAdj.cashAccountID> > > > > .Select(te, caadj.TranID, caadj.CashAccountID);

                        adjcache.SetValue <CAAdj.tranID>(caadj, null);
                        adjcache.SetValue <CAAdj.cleared>(caadj, false);

                        CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj);
                        catran.BatchNbr = gltran?.BatchNbr;

                        long?id = null;

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            te.SelectTimeStamp();

                            adjcache.SetValue <CAAdj.tranID>(caadj, id);
                            adjcache.Update(caadj);
                        }

                        if (id.HasValue && gltran?.TranID != null)
                        {
                            gltran.CATranID = id;
                            te.gltrancache.Update(gltran);
                            te.gltrancache.Persist(PXDBOperation.Update);
                        }
                    }

                    adjcache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                adjcache.Persisted(false);
                te.catrancache.Persisted(false);
                te.gltrancache.Persisted(false);
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache transfercache = te.Caches[typeof(CATransfer)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    transfercache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                transfercache.Persisted(false);
                te.catrancache.Persisted(false);
            }

            te.Clear();

            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false);

            using (new PXConnectionScope())
            {
                const int rowsPerCycle = 10000;
                bool      noMoreTran   = false;
                int?      lastGLTranIDOnPreviousStep = null;
                int       previousCountRows          = 0;

                while (!noMoreTran)
                {
                    noMoreTran = true;
                    int countRows    = 0;
                    int?lastGLTranID = null;
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >,
                                                                                                          InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>,
                                                                                                                                                                          And <Batch.scheduled, Equal <False>, And <Batch.voided, NotEqual <True> > > > > > >,
                                                                                       Where <GLTran.accountID, Equal <Required <GLTran.accountID> >,
                                                                                              And <GLTran.subID, Equal <Required <GLTran.subID> >,
                                                                                                   And <GLTran.branchID, Equal <Required <GLTran.branchID> >,
                                                                                                        And <Ledger.balanceType, Equal <LedgerBalanceType.actual>,
                                                                                                             //ignoring CM because DefaultValues always return null for CM
                                                                                                             And <GLTran.module, NotEqual <BatchModule.moduleCM>,
                                                                                                                  And <GLTran.cATranID, IsNull> > > > > >, OrderBy <Asc <GLTran.tranID> > > .SelectWindowed(te, 0, rowsPerCycle, tlist.AccountID, tlist.SubID, tlist.BranchID))
                        {
                            GLTran gltran = (GLTran)res;
                            lastGLTranID = gltran.TranID;
                            noMoreTran   = false;
                            countRows++;
                            CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran);
                            if (catran != null)
                            {
                                long id;
                                bool newCATRan = false;
                                if (te.catrancache.Locate(catran) == null)
                                {
                                    catran    = (CATran)te.catrancache.Insert(catran);
                                    newCATRan = true;
                                    te.catrancache.PersistInserted(catran);
                                    id = Convert.ToInt64(PXDatabase.SelectIdentity());
                                }
                                else
                                {
                                    catran = (CATran)te.catrancache.Update(catran);
                                    te.catrancache.PersistUpdated(catran);
                                    id = catran.TranID.Value;
                                }

                                gltran.CATranID = id;
                                te.gltrancache.Update(gltran);

                                if (catran.OrigModule != GLTranType.GLEntry)
                                {
                                    switch (catran.OrigModule)
                                    {
                                    case BatchModule.AR:
                                        ARPayment arPayment = PXSelect <ARPayment, Where <ARPayment.docType, Equal <Required <ARPayment.docType> >,
                                                                                          And <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr);

                                        if (arPayment != null && (arPayment.CATranID == null || newCATRan))
                                        {
                                            arPayment.CATranID = id;
                                            arPayment          = (ARPayment)te.Caches[typeof(ARPayment)].Update(arPayment);
                                            te.Caches[typeof(ARPayment)].PersistUpdated(arPayment);
                                        }
                                        break;

                                    case BatchModule.AP:
                                        APPayment apPayment = PXSelect <APPayment, Where <APPayment.docType, Equal <Required <APPayment.docType> >,
                                                                                          And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr);

                                        if (apPayment != null && (apPayment.CATranID == null || newCATRan))
                                        {
                                            apPayment.CATranID = id;
                                            apPayment          = (APPayment)te.Caches[typeof(APPayment)].Update(apPayment);
                                            te.Caches[typeof(APPayment)].PersistUpdated(apPayment);
                                        }
                                        break;
                                    }
                                }
                            }
                        }

                        if (!noMoreTran && countRows == previousCountRows && lastGLTranID == lastGLTranIDOnPreviousStep)
                        {
                            throw new PXException(Messages.ProcessCannotBeCompleted);
                        }

                        previousCountRows          = countRows;
                        lastGLTranIDOnPreviousStep = lastGLTranID;

                        te.gltrancache.ClearQueryCache();
                        te.gltrancache.Persist(PXDBOperation.Update);
                        te.gltrancache.Clear();
                        te.catrancache.Clear();
                        te.catrancache.ClearQueryCache();
                        te.dailycache.Clear();
                        te.Caches[typeof(APPayment)].Clear();
                        te.Caches[typeof(ARPayment)].Clear();
                        ts.Complete(te);
                    }
                }

                PXDatabase.Delete <CADailySummary>(
                    new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ));

                foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                {
                    CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran);
                }

                te.dailycache.Persist(PXDBOperation.Insert);
                te.dailycache.Persist(PXDBOperation.Update);


                te.gltrancache.Persisted(false);
                te.catrancache.Persisted(false);
                te.dailycache.Persisted(false);
            }
        }
コード例 #20
0
        private static void Validate(CATranEntry te, CashAccount tlist)
        {
            if (tlist.Reconcile != true)
            {
                te.Clear();
                using (new PXConnectionScope())
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        PXCache adjcache = te.Caches[typeof(CATran)];
                        foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                        {
                            if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null))
                            {
                                catran.Cleared   = true;
                                catran.ClearDate = catran.TranDate;
                            }
                            te.catrancache.Update(catran);
                        }
                        te.catrancache.Persist(PXDBOperation.Update);
                        ts.Complete(te);
                    }
                    te.catrancache.Persisted(false);
                }
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache adjcache = te.Caches[typeof(CAAdj)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> > >, Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CAAdj caadj = (CAAdj)res;

                        adjcache.SetValue <CAAdj.tranID>(caadj, null);
                        adjcache.SetValue <CAAdj.cleared>(caadj, false);

                        CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            adjcache.SetValue <CAAdj.tranID>(caadj, id);
                            adjcache.Update(caadj);
                        }
                    }

                    adjcache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                adjcache.Persisted(false);
                te.catrancache.Persisted(false);
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache transfercache = te.Caches[typeof(CATransfer)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    transfercache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                transfercache.Persisted(false);
                te.catrancache.Persisted(false);
            }

            te.Clear();

            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false);

            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >,
                                                                                                      InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>,
                                                                                                                                                                      And <Batch.scheduled, Equal <False> > > > > >,
                                                                                   Where <GLTran.accountID, Equal <Required <GLTran.accountID> >, And <GLTran.subID, Equal <Required <GLTran.subID> >,
                                                                                                                                                       And <Ledger.balanceType, Equal <LedgerBalanceType.actual>, And <GLTran.cATranID, IsNull> > > > > .Select(te, tlist.AccountID, tlist.SubID))
                    {
                        GLTran gltran = (GLTran)res;
                        CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            gltran.CATranID = id;
                            te.gltrancache.Update(gltran);
                        }
                    }

                    te.gltrancache.Persist(PXDBOperation.Update);

                    te.dailycache.Clear();

                    PXDatabase.Delete <CADailySummary>(
                        new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ)
                        );

                    foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                    {
                        CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran);
                    }

                    te.dailycache.Persist(PXDBOperation.Insert);
                    te.dailycache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                te.gltrancache.Persisted(false);
                te.catrancache.Persisted(false);
                te.dailycache.Persisted(false);
            }
        }
コード例 #21
0
        private void SetAdjRefNbrVisibility()
        {
            CAAdj adj = PXSelect <CAAdj, Where <CAAdj.transferNbr, Equal <Current <CATransfer.transferNbr> > > > .Select(this);

            PXUIFieldAttribute.SetVisible <CAExpense.adjRefNbr>(Expenses.Cache, null, adj != null);
        }
コード例 #22
0
        private static void ValidateCAAdjustments(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period)
        {
            using (new PXConnectionScope())
            {
                PXCache adjcache = graph.Caches[typeof(CAAdj)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj,
                                                                           LeftJoin <CATran,
                                                                                     On <CATran.tranID, Equal <CAAdj.tranID> >,
                                                                                     LeftJoin <GLTranDoc,
                                                                                               On <GLTranDoc.refNbr, Equal <CAAdj.adjRefNbr>,
                                                                                                   And <GLTranDoc.tranType, Equal <CAAdj.adjTranType>,
                                                                                                        And <GLTranDoc.tranModule, Equal <BatchModule.moduleCA> > > > > >,
                                                                           Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >,
                                                                                  And <CATran.tranID, IsNull,
                                                                                       And <GLTranDoc.refNbr, IsNull,
                                                                                            And <CAAdj.finPeriodID, GreaterEqual <Required <CAAdj.finPeriodID> > > > > > > .Select(graph, cashAccount.CashAccountID, period.FinPeriodID))
                    {
                        CAAdj caadj = (CAAdj)res;

                        GLTran gltran = PXSelectJoin <GLTran, InnerJoin <CashAccount,
                                                                         On <CashAccount.accountID, Equal <GLTran.accountID>,
                                                                             And <CashAccount.subID, Equal <GLTran.subID>,
                                                                                  And <CashAccount.branchID, Equal <GLTran.branchID> > > > >,
                                                      Where <GLTran.cATranID, Equal <Required <CAAdj.tranID> >,
                                                             And <CashAccount.cashAccountID, Equal <Required <CAAdj.cashAccountID> > > > > .Select(graph, caadj.TranID, caadj.CashAccountID);

                        adjcache.SetValue <CAAdj.tranID>(caadj, null);
                        adjcache.SetValue <CAAdj.cleared>(caadj, false);

                        CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj);
                        catran.BatchNbr = gltran?.BatchNbr;

                        long?id = null;

                        if (catran != null)
                        {
                            catran = (CATran)graph.catrancache.Insert(catran);
                            graph.catrancache.PersistInserted(catran);
                            id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            graph.SelectTimeStamp();

                            adjcache.SetValue <CAAdj.tranID>(caadj, id);
                            adjcache.Update(caadj);
                        }

                        if (id.HasValue && gltran?.TranID != null)
                        {
                            gltran.CATranID = id;
                            graph.gltrancache.Update(gltran);
                            graph.gltrancache.Persist(PXDBOperation.Update);
                        }
                    }

                    adjcache.Persist(PXDBOperation.Update);

                    ts.Complete(graph);
                }

                adjcache.Persisted(false);
                graph.catrancache.Persisted(false);
                graph.gltrancache.Persisted(false);
            }
        }