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 availablePayments() { PaymentFilter flt = this.filter.Current; CABatch doc = this.Document.Current; if (doc == null || doc.CashAccountID == null || doc.Released == true) { yield break; } PXSelectBase <ARPayment> paymentSelect = new PXSelectJoin <ARPayment, LeftJoin <CADepositDetail, On <CADepositDetail.origDocType, Equal <ARPayment.docType>, And <CADepositDetail.origRefNbr, Equal <ARPayment.refNbr>, And <CADepositDetail.tranType, Equal <CATranType.cADeposit> > > >, LeftJoin <CABatch, On <CABatch.tranType, Equal <CADepositDetail.tranType>, And <CABatch.refNbr, Equal <CADepositDetail.refNbr> > >, InnerJoin <CashAccountDeposit, On <CashAccountDeposit.depositAcctID, Equal <ARPayment.cashAccountID>, And <Where <CashAccountDeposit.paymentMethodID, Equal <ARPayment.paymentMethodID>, Or <CashAccountDeposit.paymentMethodID, Equal <BQLConstants.EmptyString> > > > > > > >, Where <CashAccountDeposit.accountID, Equal <Current <CABatch.cashAccountID> >, And <ARPayment.docType, NotEqual <ARPaymentType.voidPayment>, And <ARPayment.docType, NotEqual <ARPaymentType.cashReturn>, And <ARPayment.released, Equal <boolTrue>, And <ARPayment.voided, Equal <boolFalse>, And <ARPayment.depositAsBatch, Equal <boolTrue>, And <ARPayment.depositNbr, IsNull, And <ARPayment.depositAfter, LessEqual <Current <CABatch.tranDate> >, And <Where <CADepositDetail.refNbr, IsNull, Or <CABatch.voided, Equal <boolTrue> > > > > > > > > > > >, OrderBy <Asc <ARPayment.docType, Asc <ARPayment.refNbr, Desc <CashAccountDeposit.paymentMethodID> > > > >(this); if (flt.CashAccountID.HasValue) { paymentSelect.WhereAnd <Where <ARPayment.cashAccountID, Equal <Current <PaymentFilter.cashAccountID> > > >(); } if (!String.IsNullOrEmpty(flt.PaymentMethodID)) { paymentSelect.WhereAnd <Where <ARPayment.paymentMethodID, Equal <Current <PaymentFilter.paymentMethodID> > > >(); } ARPayment last = null; foreach (PXResult <ARPayment, CADepositDetail, CABatch, CashAccountDeposit> it in paymentSelect.Select()) { ARPayment payment = it; CADepositDetail detail = it; bool exist = false; if (last != null && last.DocType == payment.DocType && last.RefNbr == payment.RefNbr) { continue; //Skip duplicates } last = payment; //Add filter for CashAccountDeposit.paymentMethodID according to priorities foreach (CADepositDetail iDet in this.Details.Select()) { if (iDet.OrigDocType == payment.DocType && iDet.OrigRefNbr == payment.RefNbr) { exist = true; break; } } if (exist) { continue; } yield return(it); } }