public virtual IEnumerable prepareAdd(PXAdapter adapter)
        {
            if (Transfer.Current != null && Transfer.Current.Released != true)
            {
                Save.Press();
                Transfer.JustPersisted = true;

                //recreate currencyinfo on CurrencyInfoAttribute.RowUpdating
                AddFilter.Update(AddFilter.Current);

                if (this.Views.ContainsKey("AddFilter"))
                {
                    WebDialogResult result = this.Views["AddFilter"].AskExt(true);
                    if (result == WebDialogResult.OK)
                    {
                        using (new PXTimeStampScope(this.TimeStamp))
                        {
                            CATran catran = null;
                            catran = (catran ?? AddTrxFilter.AddAPTransaction(this, AddFilter, currencyinfo_addfilter));
                            catran = (catran ?? AddTrxFilter.AddARTransaction(this, AddFilter, currencyinfo_addfilter));
                            catran = (catran ?? AddTrxFilter.AddCATransaction(this, AddFilter, currencyinfo_addfilter));
                            AddTrxFilter.Clear(this, AddFilter);

                            catran = TransferTran.Update(catran);
                            Save.Press();
                        }
                    }
                }
            }
            else
            {
                throw new Exception(Messages.DocumentStatusInvalid);
            }
            return(adapter.Get());
        }
Beispiel #2
0
 public CATran CopyTo(CATran destination)
 {
     destination.TranDate      = this.TranDate;
     destination.OrigModule    = BatchModule.AP;
     destination.OrigRefNbr    = this.BatchNbr;
     destination.OrigTranType  = CATranType.CABatch;
     destination.ExtRefNbr     = this.ExtRefNbr;
     destination.TranDesc      = this.TranDesc;
     destination.TranAmt       = -this.DetailTotal;
     destination.CuryTranAmt   = -this.CuryDetailTotal;
     destination.Released      = this.Released;
     destination.Hold          = this.Hold;
     destination.Status        = this.Status;
     destination.Cleared       = this.Cleared;
     destination.ClearDate     = this.ClearDate;
     destination.ReconNbr      = this.ReconNbr;
     destination.ReconDate     = this.ReconDate;
     destination.Reconciled    = this.Reconciled;
     destination.DrCr          = DrCr.Credit;
     destination.TranDesc      = this.TranDesc;
     destination.ExtRefNbr     = this.ExtRefNbr;
     destination.CashAccountID = this.CashAccountID;
     destination.CuryID        = this.CuryID;
     return(destination);
 }
Beispiel #3
0
        protected virtual void CATranExt_Cleared_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            CATran caTran = (CATran)e.Row;

            if (caTran.Cleared == true)
            {
                caTran.ClearDate = this.Accessinfo.BusinessDate;

                if (Filter.Current.IncludeUnreleased == true || caTran.Released == true)
                {
                    Filter.Current.DebitClearedTotal  += caTran.CuryDebitAmt;
                    Filter.Current.CreditClearedTotal += caTran.CuryCreditAmt;
                    Filter.Current.EndClearedBal      += (caTran.CuryDebitAmt - caTran.CuryCreditAmt);
                }
            }
            else
            {
                caTran.ClearDate = null;

                if (Filter.Current.IncludeUnreleased == true || caTran.Released == true)
                {
                    Filter.Current.DebitClearedTotal  -= caTran.CuryDebitAmt;
                    Filter.Current.CreditClearedTotal -= caTran.CuryCreditAmt;
                    Filter.Current.EndClearedBal      -= (caTran.CuryDebitAmt - caTran.CuryCreditAmt);
                }
            }
        }
Beispiel #4
0
        public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (_IsIntegrityCheck == false)
            {
                if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
                {
                    object  key   = sender.GetValue(e.Row, _FieldOrdinal);
                    PXCache cache = sender.Graph.Caches[typeof(CATran)];
                    CATran  info  = null;
                    if (key != null)
                    {
                        info = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATran.tranID> > > > .Select(sender.Graph, key);

                        if (info == null)
                        {
                            key = null;
                            sender.SetValue(e.Row, _FieldOrdinal, null);
                        }
                    }
                    if (info != null && !IsCreationNeeded((CADeposit)e.Row))
                    {
                        cache.Delete(info);
                        cache.PersistDeleted(info);
                    }
                }
                base.RowPersisting(sender, e);
            }
        }
        public virtual IEnumerable ViewDoc(PXAdapter adapter)
        {
            CABankTranMatch match =
                PXSelect <CABankTranMatch,
                          Where <CABankTranMatch.tranID, Equal <Required <CABankTran.tranID> >,
                                 And <CABankTranMatch.tranType, Equal <Required <CABankTran.tranType> > > > >
                .Select(this, Result.Current.TranID, Result.Current.TranType);

            if (match.DocModule == BatchModule.EP)
            {
                RedirectionToOrigDoc.TryRedirect(match.DocType, match.DocRefNbr, match.DocModule);
            }
            else
            {
                CATran tran = null;
                if (match.DocModule == BatchModule.AP && match.DocType == CATranType.CABatch)
                {
                    tran = new CATran()
                    {
                        OrigTranType = CATranType.CABatch,
                        OrigModule   = BatchModule.AP,
                        OrigRefNbr   = match.DocRefNbr
                    };
                }
                else
                {
                    tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CABankTranMatch.cATranID> > > > .Select(this, match.CATranID);
                }


                CATran.Redirect(TranFilter.Cache, tran);
            }
            return(adapter.Get());
        }
Beispiel #6
0
        public virtual IEnumerable prepareAdd(PXAdapter adapter)
        {
            if (Transfer.Current != null && Transfer.Current.Released != true)
            {
                Save.Press();
                //Current should be the only one inserted
                PXCache currencycache = Caches[typeof(CM.CurrencyInfo)];
                currencycache.SetStatus(currencycache.Current, PXEntryStatus.Inserted);
                Transfer.JustPersisted = true;

                //recreate currencyinfo on CurrencyInfoAttribute.RowUpdating
                AddFilter.Update(AddFilter.Current);

                WebDialogResult result = AddFilter.AskExt(true);
                if (result == WebDialogResult.OK)
                {
                    using (new PXTimeStampScope(this.TimeStamp))
                    {
                        CATran catran = AddTrxFilter.VerifyAndCreateTransaction(this, AddFilter, currencyinfo_addfilter);
                        catran = TransferTran.Update(catran);
                        Save.Press();
                    }
                }
                AddFilter.Cache.Clear();
            }
            else
            {
                throw new Exception(Messages.DocumentStatusInvalid);
            }
            return(adapter.Get());
        }
Beispiel #7
0
        protected static CashAccount GetCashAccount(CATran catran, PXGraph graph)
        {
            PXSelectBase <CashAccount> selectStatement = new PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > >(graph);
            CashAccount cashacc = (CashAccount)selectStatement.View.SelectSingle(catran.CashAccountID);

            return(cashacc);
        }
 private void update(CATran tran, CADailySummary summary, int sign)
 {
     if (tran.Cleared == true)
     {
         if (tran.Released == true)
         {
             summary.AmtReleasedClearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtReleasedClearedDr += (tran.CuryDebitAmt * sign);
         }
         else
         {
             summary.AmtUnreleasedClearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtUnreleasedClearedDr += (tran.CuryDebitAmt * sign);
         }
     }
     else
     {
         if (tran.Released == true)
         {
             summary.AmtReleasedUnclearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtReleasedUnclearedDr += (tran.CuryDebitAmt * sign);
         }
         else
         {
             summary.AmtUnreleasedUnclearedCr += (tran.CuryCreditAmt * sign);
             summary.AmtUnreleasedUnclearedDr += (tran.CuryDebitAmt * sign);
         }
     }
 }
Beispiel #9
0
 protected static void SetCleared(CATran catran, CashAccount cashAccount)
 {
     if (cashAccount != null && cashAccount.Reconcile == false && (catran.Cleared != true || catran.TranDate == null))
     {
         catran.Cleared   = true;
         catran.ClearDate = catran.TranDate;
     }
 }
Beispiel #10
0
        public override CATran DefaultValues(PXCache sender, CATran catran_Row, object orig_Row)
        {
            CATransfer parentDoc = (CATransfer)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.OrigRefNbr = parentDoc.TransferNbr;
            }

            if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDOut>()))
            {
                catran_Row.CashAccountID = parentDoc.OutAccountID;
                catran_Row.OrigTranType  = CATranType.CATransferOut;
                catran_Row.ExtRefNbr     = parentDoc.OutExtRefNbr;
                catran_Row.CuryID        = parentDoc.OutCuryID;
                catran_Row.CuryInfoID    = parentDoc.OutCuryInfoID;
                catran_Row.CuryTranAmt   = -parentDoc.CuryTranOut;
                catran_Row.TranAmt       = -parentDoc.TranOut;
                catran_Row.DrCr          = DrCr.Credit;
                catran_Row.Cleared       = parentDoc.ClearedOut;
                catran_Row.ClearDate     = parentDoc.ClearDateOut;
                catran_Row.TranDate      = parentDoc.OutDate;
                SetPeriodsByMaster(sender, catran_Row, parentDoc.OutTranPeriodID);
            }
            else if (object.Equals(_FieldOrdinal, sender.GetFieldOrdinal <CATransfer.tranIDIn>()))
            {
                catran_Row.CashAccountID = parentDoc.InAccountID;
                catran_Row.OrigTranType  = CATranType.CATransferIn;
                catran_Row.ExtRefNbr     = parentDoc.InExtRefNbr;
                catran_Row.CuryID        = parentDoc.InCuryID;
                catran_Row.CuryInfoID    = parentDoc.InCuryInfoID;
                catran_Row.CuryTranAmt   = parentDoc.CuryTranIn;
                catran_Row.TranAmt       = parentDoc.TranIn;
                catran_Row.DrCr          = DrCr.Debit;
                catran_Row.Cleared       = parentDoc.ClearedIn;
                catran_Row.ClearDate     = parentDoc.ClearDateIn;
                catran_Row.TranDate      = parentDoc.InDate;
                SetPeriodsByMaster(sender, catran_Row, parentDoc.InTranPeriodID);
            }
            else
            {
                throw new PXException(AP.Messages.UnknownDocumentType);
            }

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

            catran_Row.TranDesc    = parentDoc.Descr;
            catran_Row.ReferenceID = null;
            catran_Row.Released    = parentDoc.Released;
            catran_Row.Hold        = parentDoc.Hold;

            return(catran_Row);
        }
        public static CATran DefaultValues(PXCache sender, CATran catran_Row, CADepositDetail orig_Row)
        {
            CADepositDetail parentDoc = orig_Row;
            CADeposit       deposit   = PXSelect <CADeposit, Where <CADeposit.tranType, Equal <Required <CADeposit.tranType> >,
                                                                    And <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> > > > > .Select(sender.Graph, parentDoc.TranType, parentDoc.RefNbr);

            if ((parentDoc.Released == true) && (catran_Row.TranID != null) ||
                parentDoc.CuryTranAmt == null ||
                parentDoc.CuryTranAmt == 0)
            {
                return(null);
            }

            catran_Row.OrigModule   = BatchModule.CA;
            catran_Row.OrigTranType = parentDoc.TranType;
            catran_Row.OrigRefNbr   = parentDoc.RefNbr;

            catran_Row.CashAccountID = parentDoc.AccountID;

            catran_Row.CuryID      = parentDoc.OrigCuryID;
            catran_Row.CuryInfoID  = parentDoc.CuryInfoID;
            catran_Row.CuryTranAmt = parentDoc.CuryOrigAmtSigned * (parentDoc.DrCr == CADrCr.CADebit ? 1 : -1);
            catran_Row.TranAmt     = parentDoc.OrigAmtSigned * (parentDoc.DrCr == CADrCr.CADebit ? 1 : -1);
            catran_Row.DrCr        = parentDoc.DrCr;
            catran_Row.TranDesc    = parentDoc.TranDesc;
            catran_Row.ReferenceID = null;
            catran_Row.Released    = parentDoc.Released;
            if (parentDoc.DetailType == CADepositDetailType.CheckDeposit || parentDoc.DetailType == CADepositDetailType.VoidCheckDeposit)
            {
                catran_Row.TranDesc = string.Format("{0}-{1}", parentDoc.OrigDocType, parentDoc.OrigRefNbr);
            }
            if (deposit != null)
            {
                catran_Row.Hold         = deposit.Hold;
                catran_Row.FinPeriodID  = deposit.FinPeriodID;
                catran_Row.TranPeriodID = deposit.TranPeriodID;
                catran_Row.ExtRefNbr    = deposit.ExtRefNbr;
                catran_Row.TranDate     = deposit.TranDate;
                catran_Row.Cleared      = deposit.Cleared;
                catran_Row.ClearDate    = deposit.ClearDate;
            }
            if (parentDoc.DetailType == CADepositDetailType.VoidCheckDeposit)
            {
                CADepositDetail voidedDoc = PXSelectReadonly <CADepositDetail, Where <CADepositDetail.refNbr, Equal <Required <CADepositDetail.refNbr> >,
                                                                                      And <CADepositDetail.tranType, Equal <Required <CADepositDetail.tranType> >,
                                                                                           And <CADepositDetail.lineNbr, Equal <Required <CADepositDetail.lineNbr> > > > > > .Select(sender.Graph, parentDoc.RefNbr, CATranType.CADeposit, parentDoc.LineNbr);

                if (voidedDoc != null)
                {
                    catran_Row.VoidedTranID = voidedDoc.TranID;
                }
            }

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

            return(catran_Row);
        }
        public virtual IEnumerable Unmatch(PXAdapter adapter)
        {
            CABankTran detail = Details.Current;

            if (detail.DocumentMatched == true)
            {
                if (detail.Processed == true)
                {
                    if (Details.Ask(Messages.ClearMatch, Messages.UnmatchTranMsg, MessageButtons.OKCancel) == WebDialogResult.Cancel)
                    {
                        return(adapter.Get());
                    }
                    detail.Processed = false;
                }
                foreach (CABankTranMatch match in TranMatch.Select(detail.TranID))
                {
                    if (match.DocModule == GL.BatchModule.AP && match.DocType == CATranType.CABatch)
                    {
                        foreach (CATran tran in CATransInBatch.Select(match.DocRefNbr))
                        {
                            if (tran != null && tran.TranID != null && tran.ReconNbr == null)
                            {
                                tran.ClearDate = null;
                                tran.Cleared   = false;
                                CATransInBatch.Update(tran);
                            }
                        }
                    }
                    else
                    {
                        CATran tran = CATrans.Select(match.CATranID);
                        if (tran != null && tran.TranID != null && tran.ReconNbr == null)
                        {
                            tran.ClearDate = null;
                            tran.Cleared   = false;
                            CATrans.Update(tran);
                        }
                    }
                    TranMatch.Delete(match);
                }
                foreach (var adj in TranAdj.Select(detail.TranID))
                {
                    TranAdj.Delete(adj);
                }
                foreach (var split in CABankTranSplits.Select(detail.TranID))
                {
                    CABankTranSplits.Delete(split);
                }
                CABankTransactionsMaint.ClearFields(detail);
                Details.Cache.SetDefaultExt <CABankTran.curyApplAmt>(detail);
                Details.Cache.SetDefaultExt <CABankTran.curyApplAmtCA>(detail);
                Details.Update(detail);
            }
            return(adapter.Get());
        }
        protected virtual IEnumerable result()
        {
            PXSelectBase <CABankTran> cmd = new PXSelectJoin <CABankTran, LeftJoin <CABankTranMatch,
                                                                                    On <CABankTranMatch.tranID, Equal <CABankTran.tranID>,
                                                                                        And <CABankTranMatch.tranType, Equal <CABankTran.tranType> > >,
                                                                                    LeftJoin <CATran, On <CATran.tranID, Equal <CABankTranMatch.cATranID> > > >,
                                                              Where <CABankTran.cashAccountID, Equal <Current <Filter.cashAccountID> >,
                                                                     And <CABankTran.tranDate, GreaterEqual <Current <Filter.startDate> >,
                                                                          And <CABankTran.tranDate, LessEqual <Current <Filter.endDate> >,
                                                                               And <CABankTran.tranType, Equal <Current <Filter.tranType> >,
                                                                                    And <CABankTran.processed, Equal <True>,
                                                                                         And <Where <CABankTran.headerRefNbr, Equal <Current <Filter.headerRefNbr> >, Or <Current <Filter.headerRefNbr>, IsNull> > > > > > > > >(this);

            foreach (PXResult <CABankTran, CABankTranMatch, CATran> res in cmd.Select())
            {
                CABankTran      tran  = (CABankTran)res;
                CABankTranMatch match = (CABankTranMatch)res;
                tran.MatchedToInvoice = CABankTranStatus.IsMatchedToInvoice(tran, match);
                CATran catran = (CATran)res;
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                yield return(res);
            }
        }
Beispiel #14
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);
        }
        public virtual void RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            CATran tran = (CATran)e.Row;

            if (tran.CashAccountID != null && tran.TranDate != null)
            {
                CADailySummary summary = new CADailySummary();
                summary.CashAccountID = tran.CashAccountID;
                summary.TranDate      = tran.TranDate;
                summary = (CADailySummary)sender.Graph.Caches[typeof(CADailySummary)].Insert(summary);
                update(tran, summary, -1);
            }
        }
Beispiel #16
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);
        }
Beispiel #17
0
        public static CATran DefaultValues(PXCache sender, CATran catran_Row, CADeposit parentDoc, string fieldName)
        {
            if ((parentDoc.Released == true) && (catran_Row.TranID != null) ||
                IsCreationNeeded(parentDoc) == false)
            {
                return(null);
            }

            catran_Row.OrigModule   = BatchModule.CA;
            catran_Row.OrigTranType = parentDoc.TranType;
            catran_Row.OrigRefNbr   = parentDoc.RefNbr;

            catran_Row.CashAccountID = parentDoc.ExtraCashAccountID;
            catran_Row.ExtRefNbr     = parentDoc.ExtRefNbr;
            catran_Row.CuryID        = parentDoc.CuryID;
            catran_Row.CuryInfoID    = parentDoc.CuryInfoID;
            catran_Row.DrCr          = parentDoc.DrCr == CADrCr.CADebit ? CADrCr.CACredit : CADrCr.CADebit;
            catran_Row.CuryTranAmt   = parentDoc.CuryExtraCashTotal * (catran_Row.DrCr == CADrCr.CADebit ? 1 : -1);
            catran_Row.TranAmt       = parentDoc.ExtraCashTotal * (catran_Row.DrCr == CADrCr.CADebit ? 1 : -1);

            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;
            if (parentDoc.DocType == CATranType.CAVoidDeposit)
            {
                CADeposit voidedDoc = PXSelectReadonly <CADeposit, Where <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> >,
                                                                          And <CADeposit.tranType, Equal <Required <CADeposit.tranType> > > > > .Select(sender.Graph, parentDoc.RefNbr, CATranType.CADeposit);

                if (voidedDoc != null)
                {
                    catran_Row.VoidedTranID = (long?)sender.GetValue(voidedDoc, fieldName);
                }
            }

            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);
        }
Beispiel #18
0
        public static void Redirect(PXCache sender, CATran catran)
        {
            if (catran == null)
            {
                return;
            }

            if (sender != null)
            {
                sender.IsDirty = false;
            }

            Common.RedirectionToOrigDoc.TryRedirect(catran.OrigTranType, catran.OrigRefNbr, catran.OrigModule);
        }
        public static void Redirect(PXGraph graph, CABankTranMatch match)
        {
            if (match.DocModule == GL.BatchModule.AP && match.DocType == CATranType.CABatch && match.DocRefNbr != null)
            {
                CABatchEntry docGraph = PXGraph.CreateInstance <CABatchEntry>();
                docGraph.Clear();
                docGraph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(docGraph, match.DocRefNbr);

                throw new PXRedirectRequiredException(docGraph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (match.CATranID != null)
            {
                CATran catran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CABankTranMatch.cATranID> > > > .Select(graph, match.CATranID);

                CATran.Redirect(null, catran);
            }
            else if (match.DocModule != null && match.DocType != null && match.DocRefNbr != null)
            {
                if (match.DocModule == GL.BatchModule.AP)
                {
                    AP.APInvoiceEntry docGraph = PXGraph.CreateInstance <AP.APInvoiceEntry>();
                    docGraph.Clear();
                    AP.APInvoice invoice = PXSelect <AP.APInvoice, Where <AP.APInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AP.APInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

                    docGraph.Document.Current = invoice;
                    throw new PXRedirectRequiredException(docGraph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else if (match.DocModule == GL.BatchModule.AR)
                {
                    AR.ARInvoiceEntry docGraph = PXGraph.CreateInstance <AR.ARInvoiceEntry>();
                    docGraph.Clear();
                    AR.ARInvoice invoice = PXSelect <AR.ARInvoice, Where <AR.ARInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AR.ARInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

                    docGraph.Document.Current = invoice;
                    throw new PXRedirectRequiredException(docGraph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
        }
Beispiel #20
0
        public virtual void RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            if (sender.Graph.Views.Caches.Contains(typeof(CATran)))
            {
                object  key   = sender.GetValue(e.Row, _FieldOrdinal);
                PXCache cache = sender.Graph.Caches[typeof(CATran)];
                if (key != null)
                {
                    CATran info = new CATran {
                        TranID = (long?)key
                    };
                    cache.Delete(info);

                    sender.SetValue(e.Row, _FieldOrdinal, null);
                }
            }
        }
Beispiel #21
0
        protected override void ClosePeriodProc(FinPeriod p)
        {
            PXSelectBase select = new PXSelect <CATran,
                                                Where <CATran.finPeriodID, Equal <Required <CATran.finPeriodID> >,
                                                       And <CATran.origModule, Equal <GL.BatchModule.moduleCA>,
                                                            And <CATran.released, Equal <boolFalse> > > > >(this);
            CATran doc = (CATran)select.View.SelectSingle(p.FinPeriodID);

            if (doc != null)
            {
                throw new PXException(Messages.PeriodHasUnreleasedDocs);
            }

            p.CAClosed = true;
            Caches[typeof(FinPeriod)].Update(p);

            Actions.PressSave();
        }
        public virtual IEnumerable viewDoc(PXAdapter adapter)
        {
            CATran catran = (CATran)(TransferTran.Current);

            if (catran != null)
            {
                CATranEntry graph = PXGraph.CreateInstance <CATranEntry>();
                graph.Clear();
                Transfer.Cache.IsDirty     = false;
                graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CATran.tranID> > > > .Select(this, catran.TranID);

                throw new PXRedirectRequiredException(graph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            return(adapter.Get());
        }
Beispiel #23
0
        protected virtual void CATranExt_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            CATran catran = (CATran)e.Row;

            if (catran == null)
            {
                return;
            }

            bool cashAccountNeedReconcilation = (cashaccount.Current != null) && (bool)cashaccount.Current.Reconcile;
            bool isClearEnable = catran.Reconciled != true;

            PXUIFieldAttribute.SetEnabled(cache, catran, false);
            PXUIFieldAttribute.SetEnabled <CATran.selected>(cache, catran, true);
            PXUIFieldAttribute.SetEnabled <CATran.reconciled>(cache, catran, false);
            PXUIFieldAttribute.SetEnabled <CATran.cleared>(cache, catran, isClearEnable && cashAccountNeedReconcilation);
            PXUIFieldAttribute.SetEnabled <CATran.clearDate>(cache, catran, isClearEnable && cashAccountNeedReconcilation && (catran.Cleared == true));
        }
        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);
        }
Beispiel #25
0
        public static CATran DefaultValues(PXCache sender, CATran catran_Row, CADeposit parentDoc, string fieldName)
        {
            if ((parentDoc.Released == true) && (catran_Row.TranID != null) ||
                IsCreationNeeded(parentDoc) == false)
            {
                return(null);
            }

            catran_Row.OrigModule   = BatchModule.CA;
            catran_Row.OrigTranType = parentDoc.TranType;
            catran_Row.OrigRefNbr   = parentDoc.RefNbr;

            catran_Row.CashAccountID = parentDoc.ExtraCashAccountID;
            catran_Row.ExtRefNbr     = parentDoc.ExtRefNbr;
            catran_Row.CuryID        = parentDoc.CuryID;
            catran_Row.CuryInfoID    = parentDoc.CuryInfoID;
            catran_Row.DrCr          = parentDoc.DrCr == CADrCr.CADebit ? CADrCr.CACredit : CADrCr.CADebit;
            catran_Row.CuryTranAmt   = parentDoc.CuryExtraCashTotal * (catran_Row.DrCr == CADrCr.CADebit ? 1 : -1);
            catran_Row.TranAmt       = parentDoc.ExtraCashTotal * (catran_Row.DrCr == CADrCr.CADebit ? 1 : -1);

            catran_Row.TranDate    = parentDoc.TranDate;
            catran_Row.TranDesc    = parentDoc.TranDesc;
            catran_Row.ReferenceID = null;
            catran_Row.Released    = parentDoc.Released;
            catran_Row.Hold        = parentDoc.Hold;
            SetPeriodsByMaster(sender, catran_Row, parentDoc.TranPeriodID);
            catran_Row.Cleared   = parentDoc.Cleared;
            catran_Row.ClearDate = parentDoc.ClearDate;
            if (parentDoc.DocType == CATranType.CAVoidDeposit)
            {
                CADeposit voidedDoc = PXSelectReadonly <CADeposit, Where <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> >,
                                                                          And <CADeposit.tranType, Equal <Required <CADeposit.tranType> > > > > .Select(sender.Graph, parentDoc.RefNbr, CATranType.CADeposit);

                if (voidedDoc != null)
                {
                    catran_Row.VoidedTranID = (long?)sender.GetValue(voidedDoc, fieldName);
                }
            }

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

            return(catran_Row);
        }
Beispiel #26
0
        public virtual IEnumerable DoubleClick(PXAdapter adapter)
        {
            CAEnqFilter filterCur = Filter.Current;

            if (filterCur.ShowSummary == true)
            {
                CATran tran = (CATran)(CATranListRecords.Current);
                filterCur.LastStartDate = filterCur.StartDate;
                filterCur.LastEndDate   = filterCur.EndDate;
                filterCur.StartDate     = tran.TranDate;
                filterCur.EndDate       = tran.TranDate;
                filterCur.ShowSummary   = false;

                CATranListRecords.Cache.Clear();
                Caches[typeof(CADailySummary)].Clear();
            }

            return(adapter.Get());
        }
        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);
            }

            Save.Press();
            CheckExpensesOnHold();

            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);
        }
Beispiel #28
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);
            }
        }
Beispiel #29
0
        public virtual IEnumerable addDet(PXAdapter adapter)
        {
            AddFilter.AskExt(true);
            if (AddFilter.View.Answer == WebDialogResult.OK)
            {
                using (new PXTimeStampScope(this.TimeStamp))
                {
                    CATran catran = AddTrxFilter.VerifyAndCreateTransaction(this, AddFilter, currencyinfo);
                    if (catran != null)
                    {
                        CATranExt copy = new CATranExt();
                        PXCache <CATran> .RestoreCopy(copy, catran);

                        CATranListRecords.Update(copy);
                        Save.Press();
                    }
                }
                CATranListRecords.Cache.Clear();
                Caches[typeof(CADailySummary)].Clear();
                Filter.Current.BegBal = null;
            }
            AddFilter.Cache.Clear();
            return(adapter.Get());
        }
Beispiel #30
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);
            }
        }