private static void SetAdjustmentStubNumber(APPaymentEntry pe, APPayment doc, APAdjust adj, string StubNbr) { adj.StubNbr = StubNbr; adj.CashAccountID = doc.CashAccountID; adj.PaymentMethodID = doc.PaymentMethodID; pe.Adjustments.Cache.Update(adj); }
public static void AssignNumbersWithNoAdditionalProcessing(APPaymentEntry pe, APPayment doc) { PaymentMethod method = pe.paymenttype.Select(doc.PaymentMethodID); if (method == null || method.PrintOrExport == true) { // To persist the manual changes from "Release Checks" screen (AC-94830) pe.Document.Cache.MarkUpdated(doc); return; } pe.RowPersisting.RemoveHandler <APAdjust>(pe.APAdjust_RowPersisting); pe.Clear(); pe.Document.Current = pe.Document.Search <APPayment.refNbr>(doc.RefNbr, doc.DocType); PaymentMethodAccount det = pe.cashaccountdetail.Select(); pe.Document.Current.StubCntr = 1; pe.Document.Current.BillCntr = 0; pe.Document.Current.ExtRefNbr = doc.ExtRefNbr; foreach (APAdjust adj in pe.Adjustments_print.Select()) { pe.Document.Current.BillCntr++; SetAdjustmentStubNumber(pe, doc, adj, doc.ExtRefNbr); } det.APLastRefNbr = doc.ExtRefNbr; pe.cashaccountdetail.Update(det); pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); }
public LienWaiverGenerationDataProviderBase(PXGraph graph) { Graph = (APPaymentEntry)graph; LienWaiverSetup = graph.GetExtension <ApPaymentEntryLienWaiverExtension>().LienWaiverSetup.Current; LienWaiverDataProvider = graph.GetService <ILienWaiverDataProvider>(); TransactionRetriever = graph.GetService <ILienWaiverTransactionRetriever>(); }
public virtual void AssignNumbers(APPaymentEntry paymentEntry, APPayment payment, ref string nextCheckNumber, bool skipStubs = false, AssignNumbersDelegate baseHandler = null) { lienWaiverProcessingValidationService.ValidateLienWaivers(payment, LienWaiverSetup.Current?.ShouldStopPayments); baseHandler?.Invoke(paymentEntry, payment, ref nextCheckNumber, skipStubs); }
protected void CreatePaymentEntry(APPaymentEntry paymentEntry = null) { PaymentEntry = paymentEntry ?? PXGraph.CreateInstance <APPaymentEntry>(); var paymentEntryExtension = PaymentEntry.GetExtension <ApPaymentEntryExt>(); PaymentEntry.RowPersisting.RemoveHandler <APAdjust>(paymentEntryExtension.APAdjust_RowPersisting); }
public JointCheckPreparePaymentCreator(APInvoiceEntry invoiceEntry, APPaymentEntry paymentEntry, ApPayBillsExt apPayBillsExt) : base(invoiceEntry) { this.apPayBillsExt = apPayBillsExt; CreatePaymentEntry(paymentEntry); }
private const bool AutoReleaseDebitAdjustments = true; //TODO: now (26.10.2017) we can't apply nonreleased debit adjustment public static APInvoice CreateAndReleasePPDDebitAdj(APInvoiceEntry ie, APPPDDebitAdjParameters filter, List <PendingPPDDebitAdjApp> list, bool autoReleaseDebitAdjustments) { APInvoice invDebitAdj; try { ie.Clear(PXClearOption.ClearAll); PXUIFieldAttribute.SetError(ie.Document.Cache, null, null, null); using (var ts = new PXTransactionScope()) { invDebitAdj = ie.CreatePPDDebitAdj(filter, list); if (invDebitAdj != null) { if (autoReleaseDebitAdjustments == true) { using (new PXTimeStampScope(null)) { APDocumentRelease.ReleaseDoc(new List <APRegister> { invDebitAdj }, false); APPaymentEntry paymentEntry = PXGraph.CreateInstance <APPaymentEntry>(); APPayment debitAdj = PXSelect <APPayment, Where <APPayment.docType, Equal <Required <APPayment.docType> >, And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(paymentEntry, invDebitAdj.DocType, invDebitAdj.RefNbr) .First(); paymentEntry.Document.Current = debitAdj; paymentEntry.SelectTimeStamp(); CreatePPDApplications(paymentEntry, list, debitAdj); paymentEntry.Persist(); APDocumentRelease.ReleaseDoc(new List <APRegister> { invDebitAdj }, false); // It needs to release applications } } foreach (PendingPPDDebitAdjApp adj in list) { PXProcessing <PendingPPDDebitAdjApp> .SetInfo(adj.Index, ActionsMessages.RecordProcessed); } } ts.Complete(); } } catch (Exception e) { foreach (PendingPPDDebitAdjApp adj in list) { PXProcessing <PendingPPDDebitAdjApp> .SetError(adj.Index, e); } invDebitAdj = null; } return(invDebitAdj); }
public static IEnumerable <int?> GetProjectIds(APPaymentEntry graph, JointPayee jointPayee) { var adjustments = graph.Adjustments.SelectMain(); var jointPayeeAdjustments = jointPayee.BillLineNumber == 0 ? adjustments.SelectMany(adjustment => GetTransactions(graph, adjustment)) : adjustments.Select(adjustment => GetTransaction(graph, jointPayee, adjustment)); return(jointPayeeAdjustments.Select(tran => tran.ProjectID)); }
private static void SetAdjustmentStubNumber(APPaymentEntry pe, APPayment doc, IAdjustmentStub adj, string StubNbr) { adj.StubNbr = StubNbr; adj.CashAccountID = doc.CashAccountID; adj.PaymentMethodID = doc.PaymentMethodID; if (adj.Persistent) { pe.Caches[adj.GetType()].Update(adj); } }
public virtual IEnumerable viewAPDocument(PXAdapter adapter) { CABatchDetail detail = this.BatchPayments.Current; if (detail == null) { return(adapter.Get()); } APRegister apDocument = PXSelect <APRegister, Where <APRegister.docType, Equal <Required <APRegister.docType> >, And <APRegister.refNbr, Equal <Required <APRegister.refNbr> > > > > .Select(this, detail.OrigDocType, detail.OrigRefNbr); if (apDocument == null) { return(adapter.Get()); } if (apDocument.DocType == APDocType.Check) { APPaymentEntry apGraph = PXGraph.CreateInstance <APPaymentEntry>(); apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType); if (apGraph.Document.Current != null) { throw new PXRedirectRequiredException(apGraph, true, "") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (apDocument.DocType == APDocType.QuickCheck) { APQuickCheckEntry apGraph = PXGraph.CreateInstance <APQuickCheckEntry>(); apGraph.Document.Current = apGraph.Document.Search <APRegister.refNbr>(apDocument.RefNbr, apDocument.DocType); if (apGraph.Document.Current != null) { throw new PXRedirectRequiredException(apGraph, true, "") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } return(adapter.Get()); }
private void LinkComplianceDocumentsToCheck(APPaymentEntry paymentEntry) { paymentEntry.Persist(); Base.Persist(); Base.Caches <ComplianceDocument>().ClearQueryCache(); Base.Caches <ComplianceDocument>().Clear(); PXDBTimestampAttribute timestampAttribute = Base.Caches <ComplianceDocument>() .GetAttributesOfType <PXDBTimestampAttribute>(null, nameof(ComplianceDocument.Tstamp)) .First(); timestampAttribute.RecordComesFirst = true; var complianceDocuments = complianceDocumentsService.GetComplianceDocumentsToLink(); complianceDocumentsService.UpdateComplianceDocumentsForVendorCheck(complianceDocuments, paymentEntry.Document.Current); complianceDocumentsService.ClearLinkToPaymentFlag(complianceDocuments); }
public virtual void StoreStubNumber(APPaymentEntry pe, APPayment doc, PaymentMethodAccount det, string StubNbr, int stubOrdinal) { if (doc.VoidAppl == true || StubNbr == null) { return; } pe.CACheck.Insert(new CashAccountCheck { AccountID = doc.CashAccountID, PaymentMethodID = doc.PaymentMethodID, CheckNbr = StubNbr, DocType = doc.DocType, RefNbr = doc.RefNbr, FinPeriodID = doc.FinPeriodID, DocDate = doc.DocDate, VendorID = doc.VendorID }); det.APLastRefNbr = StubNbr; }
protected static void CreatePPDApplications(APPaymentEntry paymentEntry, List <PendingPPDDebitAdjApp> list, APPayment debitAdj) { foreach (PendingPPDDebitAdjApp doc in list) { var adj = new APAdjust(); adj.AdjdDocType = doc.AdjdDocType; adj.AdjdRefNbr = doc.AdjdRefNbr; adj = paymentEntry.Adjustments_Raw.Insert(adj); adj.CuryAdjgAmt = doc.InvCuryDocBal; adj = paymentEntry.Adjustments_Raw.Update(adj); string refNbr = debitAdj.RefNbr; PXUpdate <Set <APAdjust.pPDDebitAdjRefNbr, Required <APAdjust.pPDDebitAdjRefNbr> >, APAdjust, Where <APAdjust.adjdDocType, Equal <Required <APAdjust.adjdDocType> >, And <APAdjust.adjdRefNbr, Equal <Required <APAdjust.adjdRefNbr> >, And <APAdjust.adjgDocType, Equal <Required <APAdjust.adjgDocType> >, And <APAdjust.adjgRefNbr, Equal <Required <APAdjust.adjgRefNbr> >, And <APAdjust.released, Equal <True>, And <APAdjust.voided, NotEqual <True>, And <APAdjust.pendingPPD, Equal <True> > > > > > > > > .Update(paymentEntry, refNbr, doc.AdjdDocType, doc.AdjdRefNbr, doc.AdjgDocType, doc.AdjgRefNbr); } }
private bool ProcessJointPayment(APInvoiceEntry invoiceEntry, APPaymentEntry paymentEntry, IReadOnlyCollection <APAdjust> adjustments, PayBillsFilter filter) { var invoice = InvoiceDataProvider.GetInvoice( Base, adjustments.First().AdjdDocType, adjustments.First().AdjdRefNbr); if (IsPaymentCycleWorkflow(invoice)) { PXProcessing <APAdjust> .SetError(JointCheckMessages.PaymentCycleWorkflowIsStarted); return(false); } paymentEntry.Clear(); var jointCheckPreparePaymentCreator = new JointCheckPreparePaymentCreator(invoiceEntry, paymentEntry, Base1); jointCheckPreparePaymentCreator.GenerateChecks(invoice, adjustments, filter); if (Base.APSetup.Current.HoldEntry == false) { lienWaiverHoldPaymentService.HoldPaymentsIfNeeded(invoice.RefNbr, LienWaiverSetup.Current.ShouldStopPayments); Base.Caches <APPayment>().Persist(PXDBOperation.Update); } return(true); }
public static void ReleasePayments(List <APPayment> list, string Action) { APReleaseChecks releaseChecksGraph = CreateInstance <APReleaseChecks>(); APPaymentEntry pe = CreateInstance <APPaymentEntry>(); CABatchEntry be = CreateInstance <CABatchEntry>(); bool failed = false; bool successed = false; List <APRegister> docs = new List <APRegister>(list.Count); foreach (APPayment payment in list) { if (payment.Passed == true) { releaseChecksGraph.TimeStamp = pe.TimeStamp = payment.tstamp; } switch (Action) { case ReleaseChecksFilter.action.ReleaseChecks: payment.Printed = true; break; case ReleaseChecksFilter.action.ReprintChecks: case ReleaseChecksFilter.action.VoidAndReprintChecks: payment.ExtRefNbr = null; payment.Printed = false; break; default: continue; } PXProcessing <APPayment> .SetCurrentItem(payment); if (Action == ReleaseChecksFilter.action.ReleaseChecks) { try { pe.Document.Current = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (pe.Document.Current?.ExtRefNbr != payment.ExtRefNbr) { APPayment payment_copy = PXCache <APPayment> .CreateCopy(pe.Document.Current); payment_copy.ExtRefNbr = payment.ExtRefNbr; pe.Document.Update(payment_copy); } if (PaymentRefAttribute.PaymentRefMustBeUnique(pe.paymenttype.Current) && string.IsNullOrEmpty(payment.ExtRefNbr)) { throw new PXException(ErrorMessages.FieldIsEmpty, typeof(APPayment.extRefNbr).Name); } payment.IsReleaseCheckProcess = true; APPrintChecks.AssignNumbersWithNoAdditionalProcessing(pe, payment); pe.Save.Press(); object[] persisted = PXTimeStampScope.GetPersisted(pe.Document.Cache, pe.Document.Current); if (persisted == null || persisted.Length == 0) { //preserve timestamp which will be @@dbts after last record committed to db on previous Persist(). //otherwise another process updated APAdjust. docs.Add(payment); } else { if (payment.Passed == true) { pe.Document.Current.Passed = true; } docs.Add(pe.Document.Current); } successed = true; } catch (PXException e) { PXProcessing <APPayment> .SetError(e); docs.Add(null); failed = true; } } if (Action == ReleaseChecksFilter.action.ReprintChecks || Action == ReleaseChecksFilter.action.VoidAndReprintChecks) { try { payment.IsPrintingProcess = true; using (PXTransactionScope transactionScope = new PXTransactionScope()) { #region Update CABatch if ReprintChecks CABatch caBatch = PXSelectJoin <CABatch, InnerJoin <CABatchDetail, On <CABatch.batchNbr, Equal <CABatchDetail.batchNbr> > >, Where <CABatchDetail.origModule, Equal <Required <APPayment.origModule> >, And <CABatchDetail.origDocType, Equal <Required <APPayment.docType> >, And <CABatchDetail.origRefNbr, Equal <Required <APPayment.refNbr> > > > > > . Select(be, payment.OrigModule, payment.DocType, payment.RefNbr); if (caBatch != null) { be.Document.Current = caBatch; int DetailCount = be.Details.Select().Count; // load CABatchDetail detail = be.Details.Locate(new CABatchDetail() { BatchNbr = be.Document.Current.BatchNbr, OrigModule = payment.OrigModule, OrigDocType = payment.DocType, OrigRefNbr = payment.RefNbr, OrigLineNbr = CABatchDetail.origLineNbr.DefaultValue, }); if (detail != null) { // payment.Status is recalculated in CABatchEntry.Delete if (DetailCount == 1) { be.Document.Delete(be.Document.Current); // Details will delete by PXParent } else { be.Details.Delete(detail); // recalculated batch totals } } be.Save.Press(); } else { PXCache cacheAPPayment = releaseChecksGraph.APPaymentList.Cache; cacheAPPayment.SetValueExt <APPayment.printed>(payment, false); cacheAPPayment.SetValueExt <APPayment.hold>(payment, false); cacheAPPayment.SetValueExt <APPayment.extRefNbr>(payment, null); // APPayment.Status is recalculated by SetStatusCheckAttribute cacheAPPayment.MarkUpdated(payment); cacheAPPayment.PersistUpdated(payment); cacheAPPayment.Persisted(false); } #endregion // TODO: Need to rework. Use legal CRUD methods of caches! releaseChecksGraph.TimeStamp = PXDatabase.SelectTimeStamp(); // delete check numbers only if Reprint (not Void and Reprint) PaymentMethod pm = pe.paymenttype.Select(payment.PaymentMethodID); if (pm.APPrintChecks == true && Action == ReleaseChecksFilter.action.ReprintChecks) { APPayment doc = payment; new HashSet <string>(pe.Adjustments_Raw.Select(doc.DocType, doc.RefNbr) .RowCast <APAdjust>() .Select(adj => adj.StubNbr)) .ForEach(nbr => PaymentRefAttribute.DeleteCheck((int)doc.CashAccountID, doc.PaymentMethodID, nbr)); // sync PaymentMethodAccount.APLastRefNbr with actual last CashAccountCheck number PaymentMethodAccount det = releaseChecksGraph.cashaccountdetail.SelectSingle(payment.CashAccountID, payment.PaymentMethodID); PaymentRefAttribute.LastCashAccountCheckSelect.Clear(releaseChecksGraph); CashAccountCheck cacheck = PaymentRefAttribute.LastCashAccountCheckSelect.SelectSingleBound(releaseChecksGraph, new object[] { det }); det.APLastRefNbr = cacheck?.CheckNbr; releaseChecksGraph.cashaccountdetail.Cache.PersistUpdated(det); releaseChecksGraph.cashaccountdetail.Cache.Persisted(false); } // END TODO if (string.IsNullOrEmpty(payment.ExtRefNbr)) { //try to get next number releaseChecksGraph.APPaymentList.Cache.SetDefaultExt <APPayment.extRefNbr>(payment); } transactionScope.Complete(); } } catch (PXException e) { PXProcessing <APPayment> .SetError(e); } docs.Add(null); } } if (successed) { APDocumentRelease.ReleaseDoc(docs, true); } if (failed) { throw new PXOperationCompletedWithErrorException(GL.Messages.DocumentsNotReleased); } }
protected virtual void PrintPayments(List <APPayment> list, PrintChecksFilter filter, PaymentMethod paymenttype) { if (list.Count == 0) { return; } bool printAdditionRemit = false; if (paymenttype.APCreateBatchPayment == true) { CABatch batch = CreateBatchPayment(list, filter); if (batch != null) { bool failed = false; APPaymentEntry pe = PXGraph.CreateInstance <APPaymentEntry>(); string NextCheckNbr = filter.NextCheckNbr; for (int i = 0; i < list.Count; i++) { try { AssignNumbers(pe, list[i], ref NextCheckNbr, true); if (list[i].Passed == true) { pe.TimeStamp = list[i].tstamp; } pe.Save.Press(); list[i].tstamp = pe.TimeStamp; pe.Clear(); APPayment seldoc = (APPayment)pe.Document.Search <APPayment.refNbr>(list[i].RefNbr, list[i].DocType); printAdditionRemit = seldoc.BillCntr > paymenttype.APStubLines; } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); failed = true; } } if (failed) { throw new PXOperationCompletedException(Messages.APPaymentsAreAddedToTheBatchButWasNotUpdatedCorrectly, batch.BatchNbr); } else { RedirectToResultWithCreateBatch(batch); } } } else { APReleaseChecks pp = PXGraph.CreateInstance <APReleaseChecks>(); ReleaseChecksFilter filter_copy = PXCache <ReleaseChecksFilter> .CreateCopy(pp.Filter.Current); filter_copy.PayAccountID = filter.PayAccountID; filter_copy.PayTypeID = filter.PayTypeID; filter_copy.CuryID = filter.CuryID; pp.Filter.Cache.Update(filter_copy); APPaymentEntry pe = PXGraph.CreateInstance <APPaymentEntry>(); bool failed = false; List <APPayment> paylist = new List <APPayment>(list.Count); Dictionary <string, string> d = new Dictionary <string, string>(); string NextCheckNbr = null; if (filter != null) { NextCheckNbr = filter.NextCheckNbr; } int idxReportFilter = 0; for (int i = 0; i < list.Count; i++) { try { AssignNumbers(pe, list[i], ref NextCheckNbr); if (list[i].Passed == true) { pe.TimeStamp = list[i].tstamp; } pe.Save.Press(); list[i].tstamp = pe.TimeStamp; pe.Clear(); APPayment seldoc = (APPayment)pe.Document.Search <APPayment.refNbr>(list[i].RefNbr, list[i].DocType); seldoc.Selected = true; seldoc.Passed = true; seldoc.tstamp = list[i].tstamp; pp.APPaymentList.Cache.Update(seldoc); pp.APPaymentList.Cache.SetStatus(seldoc, PXEntryStatus.Updated); printAdditionRemit = seldoc.BillCntr > paymenttype.APStubLines; StringBuilder sbDocType = new StringBuilder("APPayment.DocType"); sbDocType.Append(Convert.ToString(idxReportFilter)); StringBuilder sbRefNbr = new StringBuilder("APPayment.RefNbr"); sbRefNbr.Append(Convert.ToString(idxReportFilter)); idxReportFilter++; d[sbDocType.ToString()] = list[i].DocType == APDocType.QuickCheck ? APDocType.QuickCheck : APDocType.Check; d[sbRefNbr.ToString()] = list[i].RefNbr; } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); failed = true; } } if (failed) { if (d.Count > 0) { d[ReportMessages.CheckReportFlag] = ReportMessages.CheckReportFlagValue; var requiredException = new PXReportRequiredException(d, paymenttype.APCheckReportID, PXBaseRedirectException.WindowMode.New, "Check"); throw new PXException(GL.Messages.DocumentsNotReleased, requiredException); } throw new PXOperationCompletedException(GL.Messages.DocumentsNotReleased); } else { if (d.Count > 0) { RedirectToResultNoBatch(pp, d, paymenttype, printAdditionRemit, NextCheckNbr); } } } }
protected ValidationServiceBase(APPaymentEntry graph) { Graph = graph; }
public CashDiscountValidationService(APPaymentEntry graph) : base(graph) { }
public JointAmountToPayValidationService(APPaymentEntry graph) : base(graph) { jointPayeeAmountsCalculationService = new JointPayeeAmountsCalculationService(graph); jointPayeePaymentCache = graph.Caches <JointPayeePayment>(); }
public ComplianceDocumentsService(APPaymentEntry graph) { this.graph = graph; }
protected virtual void PrintPayments(List <APPayment> list, PrintChecksFilter filter, PaymentMethod paymentMethod) { if (list.Count == 0) { return; } if (paymentMethod.UseForAP == true) { if (paymentMethod.APPrintChecks == true && string.IsNullOrEmpty(paymentMethod.APCheckReportID)) { throw new PXException(Messages.FieldNotSetInPaymentMethod, PXUIFieldAttribute.GetDisplayName <PaymentMethod.aPCheckReportID>(paymenttype.Cache), paymentMethod.PaymentMethodID); } if (paymentMethod.APPrintChecks == true && paymentMethod.APPrintRemittance == true && string.IsNullOrEmpty(paymentMethod.APRemittanceReportID)) { throw new PXException(Messages.FieldNotSetInPaymentMethod, PXUIFieldAttribute.GetDisplayName <PaymentMethod.aPRemittanceReportID>(paymenttype.Cache), paymentMethod.PaymentMethodID); } } bool printAdditionRemit = false; if (paymentMethod.APCreateBatchPayment == true) { CABatch batch = CreateBatchPayment(list, filter); if (batch != null) { bool failed = false; APPaymentEntry pe = CreateInstance <APPaymentEntry>(); string NextCheckNbr = filter.NextCheckNbr; foreach (APPayment pmt in list) { APPayment payment = pmt; PXProcessing <APPayment> .SetCurrentItem(payment); try { payment = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (payment.PrintCheck != true) { throw new PXException(Messages.CantPrintNonprintableCheck); } if ((payment.DocType == APDocType.Check || payment.DocType == APDocType.QuickCheck) && payment.Status != APDocStatus.PendingPrint) { throw new PXException(Messages.ChecksMayBePrintedInPendingPrintStatus); } AssignNumbers(pe, payment, ref NextCheckNbr, true); if (payment.Passed == true) { pe.TimeStamp = payment.tstamp; } pe.Save.Press(); payment.tstamp = pe.TimeStamp; pe.Clear(); } catch (PXException e) { PXProcessing <APPayment> .SetError(e); failed = true; } } if (failed) { throw new PXOperationCompletedWithErrorException(Messages.APPaymentsAreAddedToTheBatchButWasNotUpdatedCorrectly, batch.BatchNbr); } RedirectToResultWithCreateBatch(batch); } } else { APReleaseChecks pp = CreateInstance <APReleaseChecks>(); ReleaseChecksFilter filter_copy = PXCache <ReleaseChecksFilter> .CreateCopy(pp.Filter.Current); filter_copy.PayAccountID = filter.PayAccountID; filter_copy.PayTypeID = filter.PayTypeID; filter_copy.CuryID = filter.CuryID; pp.Filter.Cache.Update(filter_copy); APPaymentEntry pe = CreateInstance <APPaymentEntry>(); bool failed = false; Dictionary <string, string> d = new Dictionary <string, string>(); string nextCheckNbr = filter.NextCheckNbr; string prevCheckNbr = nextCheckNbr; int idxReportFilter = 0; foreach (APPayment pmt in list) { APPayment payment = pmt; PXProcessing <APPayment> .SetCurrentItem(payment); try { prevCheckNbr = nextCheckNbr; if (filter.IsNextNumberDuplicated(this, nextCheckNbr)) { string duplicate = nextCheckNbr; nextCheckNbr = AutoNumberAttribute.NextNumber(nextCheckNbr); throw new PXException(Messages.ConflictWithExistingCheckNumber, duplicate); } payment = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (payment.PrintCheck != true) { throw new PXException(Messages.CantPrintNonprintableCheck); } if ((payment.DocType == APDocType.Check || payment.DocType == APDocType.QuickCheck) && payment.Status != APDocStatus.PendingPrint) { throw new PXException(Messages.ChecksMayBePrintedInPendingPrintStatus); } AssignNumbers(pe, payment, ref nextCheckNbr); if (payment.Passed == true) { pe.TimeStamp = payment.tstamp; } pe.Save.Press(); payment.tstamp = pe.TimeStamp; pe.Clear(); APPayment seldoc = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); seldoc.Selected = true; seldoc.Passed = true; seldoc.tstamp = payment.tstamp; pp.APPaymentList.Cache.Update(seldoc); pp.APPaymentList.Cache.SetStatus(seldoc, PXEntryStatus.Updated); printAdditionRemit |= seldoc.BillCntr > paymentMethod.APStubLines; StringBuilder sbDocType = new StringBuilder("APPayment.DocType"); sbDocType.Append(Convert.ToString(idxReportFilter)); StringBuilder sbRefNbr = new StringBuilder("APPayment.RefNbr"); sbRefNbr.Append(Convert.ToString(idxReportFilter)); idxReportFilter++; d[sbDocType.ToString()] = payment.DocType == APDocType.QuickCheck ? APDocType.QuickCheck : APDocType.Check; d[sbRefNbr.ToString()] = payment.RefNbr; PXProcessing <APPayment> .SetProcessed(); } catch (PXException e) { PXProcessing <APPayment> .SetError(e); failed = true; nextCheckNbr = prevCheckNbr; } } if (failed) { PXReportRequiredException report = null; if (d.Count > 0) { d[ReportMessages.CheckReportFlag] = ReportMessages.CheckReportFlagValue; report = new PXReportRequiredException(d, paymentMethod.APCheckReportID, PXBaseRedirectException.WindowMode.New, "Check"); } throw new PXOperationCompletedWithErrorException(GL.Messages.DocumentsNotReleased, report); } else { if (d.Count > 0) { RedirectToResultNoBatch(pp, d, paymentMethod, printAdditionRemit, nextCheckNbr); } } } }
public DebitAdjustmentsValidationService(APPaymentEntry graph) : base(graph) { }
public static void ReleasePayments(List <APPayment> list, string Action) { APReleaseChecks graph = CreateInstance <APReleaseChecks>(); APPaymentEntry pe = CreateInstance <APPaymentEntry>(); bool failed = false; bool successed = false; List <APRegister> docs = new List <APRegister>(list.Count); for (int i = 0; i < list.Count; i++) { if (list[i].Passed == true) { graph.TimeStamp = pe.TimeStamp = list[i].tstamp; } switch (Action) { case "R": list[i].Printed = true; break; case "D": case "V": list[i].ExtRefNbr = null; list[i].Printed = false; break; default: continue; } if ((bool)list[i].Printed) { try { APPrintChecks.AssignNumbersWithNoAdditionalProcessing(pe, list[i]); pe.Save.Press(); object[] persisted = PXTimeStampScope.GetPersisted(pe.Document.Cache, pe.Document.Current); if (persisted == null || persisted.Length == 0) { //preserve timestamp which will be @@dbts after last record committed to db on previous Persist(). //otherwise another process updated APAdjust. docs.Add(list[i]); } else { if (list[i].Passed == true) { pe.Document.Current.Passed = true; } docs.Add(pe.Document.Current); } successed = true; } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); docs.Add(null); failed = true; } } else { try { list[i].Hold = true; // TODO: Need to rework. Use legal CRUD methods of caches! graph.APPaymentList.Cache.PersistUpdated(list[i]); graph.APPaymentList.Cache.Persisted(false); graph.TimeStamp = PXDatabase.SelectTimeStamp(); // delete check numbers only if Reprint (not Void and Reprint) PaymentMethod pm = pe.paymenttype.Select(list[i].PaymentMethodID); if (pm.APPrintChecks == true && Action == "D") { APPayment doc = list[i]; new HashSet <string>(pe.Adjustments_Raw.Select(doc.DocType, doc.RefNbr, doc.LineCntr) .RowCast <APAdjust>() .Select(adj => adj.StubNbr)) .ForEach(nbr => PaymentRefAttribute.DeleteCheck((int)doc.CashAccountID, doc.PaymentMethodID, nbr)); // sync PaymentMethodAccount.APLastRefNbr with actual last CashAccountCheck number PaymentMethodAccount det = graph.cashaccountdetail.SelectSingle(list[i].CashAccountID, list[i].PaymentMethodID); PaymentRefAttribute.LastCashAccountCheckSelect.Clear(graph); CashAccountCheck cacheck = PaymentRefAttribute.LastCashAccountCheckSelect.SelectSingleBound(graph, new object[] { det }); det.APLastRefNbr = cacheck == null ? null : cacheck.CheckNbr; graph.cashaccountdetail.Cache.PersistUpdated(det); graph.cashaccountdetail.Cache.Persisted(false); } // END TODO if (string.IsNullOrEmpty(list[i].ExtRefNbr)) { //try to get next number graph.APPaymentList.Cache.SetDefaultExt <APPayment.extRefNbr>(list[i]); } } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); } docs.Add(null); } } if (successed) { APDocumentRelease.ReleaseDoc(docs, true); } if (failed) { throw new PXException(GL.Messages.DocumentsNotReleased); } }
public static void ReleasePayments(List <APPayment> list, string Action) { APReleaseChecks releaseChecksGraph = CreateInstance <APReleaseChecks>(); APPaymentEntry pe = CreateInstance <APPaymentEntry>(); bool failed = false; bool successed = false; List <APRegister> docs = new List <APRegister>(list.Count); foreach (APPayment payment in list) { if (payment.Passed == true) { releaseChecksGraph.TimeStamp = pe.TimeStamp = payment.tstamp; } switch (Action) { case ReleaseChecksFilter.action.ReleaseChecks: payment.Printed = true; break; case ReleaseChecksFilter.action.ReprintChecks: case ReleaseChecksFilter.action.VoidAndReprintChecks: payment.ExtRefNbr = null; payment.Printed = false; break; default: continue; } PXProcessing <APPayment> .SetCurrentItem(payment); if (Action == ReleaseChecksFilter.action.ReleaseChecks) { try { pe.Document.Current = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (PaymentRefAttribute.PaymentRefMustBeUnique(pe.paymenttype.Current) && string.IsNullOrEmpty(payment.ExtRefNbr)) { throw new PXException(ErrorMessages.FieldIsEmpty, typeof(APPayment.extRefNbr).Name); } payment.IsReleaseCheckProcess = true; APPrintChecks.AssignNumbersWithNoAdditionalProcessing(pe, payment); pe.Save.Press(); object[] persisted = PXTimeStampScope.GetPersisted(pe.Document.Cache, pe.Document.Current); if (persisted == null || persisted.Length == 0) { //preserve timestamp which will be @@dbts after last record committed to db on previous Persist(). //otherwise another process updated APAdjust. docs.Add(payment); } else { if (payment.Passed == true) { pe.Document.Current.Passed = true; } docs.Add(pe.Document.Current); } successed = true; } catch (PXException e) { PXProcessing <APPayment> .SetError(e); docs.Add(null); failed = true; } } if (Action == ReleaseChecksFilter.action.ReprintChecks || Action == ReleaseChecksFilter.action.VoidAndReprintChecks) { try { payment.IsPrintingProcess = true; releaseChecksGraph.APPaymentList.Cache.SetValueExt <APPayment.printed>(payment, false); releaseChecksGraph.APPaymentList.Cache.SetValueExt <APPayment.hold>(payment, false); releaseChecksGraph.APPaymentList.Cache.SetValueExt <APPayment.extRefNbr>(payment, null); releaseChecksGraph.APPaymentList.Cache.RaiseRowSelected(payment); //We need payment's status to be set correctly before persisting // TODO: Need to rework. Use legal CRUD methods of caches! releaseChecksGraph.APPaymentList.Cache.PersistUpdated(payment); releaseChecksGraph.APPaymentList.Cache.Persisted(false); releaseChecksGraph.TimeStamp = PXDatabase.SelectTimeStamp(); // delete check numbers only if Reprint (not Void and Reprint) PaymentMethod pm = pe.paymenttype.Select(payment.PaymentMethodID); if (pm.APPrintChecks == true && Action == ReleaseChecksFilter.action.ReprintChecks) { APPayment doc = payment; new HashSet <string>(pe.Adjustments_Raw.Select(doc.DocType, doc.RefNbr) .RowCast <APAdjust>() .Select(adj => adj.StubNbr)) .ForEach(nbr => PaymentRefAttribute.DeleteCheck((int)doc.CashAccountID, doc.PaymentMethodID, nbr)); // sync PaymentMethodAccount.APLastRefNbr with actual last CashAccountCheck number PaymentMethodAccount det = releaseChecksGraph.cashaccountdetail.SelectSingle(payment.CashAccountID, payment.PaymentMethodID); PaymentRefAttribute.LastCashAccountCheckSelect.Clear(releaseChecksGraph); CashAccountCheck cacheck = PaymentRefAttribute.LastCashAccountCheckSelect.SelectSingleBound(releaseChecksGraph, new object[] { det }); det.APLastRefNbr = cacheck?.CheckNbr; releaseChecksGraph.cashaccountdetail.Cache.PersistUpdated(det); releaseChecksGraph.cashaccountdetail.Cache.Persisted(false); } // END TODO if (string.IsNullOrEmpty(payment.ExtRefNbr)) { //try to get next number releaseChecksGraph.APPaymentList.Cache.SetDefaultExt <APPayment.extRefNbr>(payment); } } catch (PXException e) { PXProcessing <APPayment> .SetError(e); } docs.Add(null); } } if (successed) { APDocumentRelease.ReleaseDoc(docs, true); } if (failed) { throw new PXOperationCompletedWithErrorException(GL.Messages.DocumentsNotReleased); } }
public virtual void AssignNumbers(APPaymentEntry pe, APPayment doc, ref string NextCheckNbr, bool skipStubs = false) { pe.RowPersisting.RemoveHandler <APAdjust>(pe.APAdjust_RowPersisting); pe.Clear(); doc = pe.Document.Current = pe.Document.Search <APPayment.refNbr>(doc.RefNbr, doc.DocType); PaymentMethodAccount det = pe.cashaccountdetail.Select(); doc.IsPrintingProcess = true; // indicates that the payment under printing process (to prevent update by PaymentRefAttribute) if (string.IsNullOrEmpty(NextCheckNbr)) { throw new PXException(Messages.NextCheckNumberIsRequiredForProcessing); } if (string.IsNullOrEmpty(pe.Document.Current.ExtRefNbr)) { pe.Document.Current.StubCntr = 1; pe.Document.Current.BillCntr = 0; pe.Document.Current.ExtRefNbr = NextCheckNbr; if (pe.Document.Current.DocType == APDocType.QuickCheck && pe.Document.Current.CuryOrigDocAmt <= 0m) { throw new PXException(Messages.ZeroCheck_CannotPrint); } if (!skipStubs) // print check { APAdjust[] adjustments = pe.Adjustments_print.Select().RowCast <APAdjust>().ToArray(); PaymentMethod pt = pe.paymenttype.Select(); int stubCount = (int)Math.Ceiling(adjustments.Length / (decimal)(pt.APStubLines ?? 1)); if (stubCount > 1 && pt.APPrintRemittance != true) { string endNumber = AutoNumberAttribute.NextNumber(NextCheckNbr, stubCount - 1); string[] duplicates = PXSelect <CashAccountCheck, Where <CashAccountCheck.accountID, Equal <Required <PrintChecksFilter.payAccountID> >, And <CashAccountCheck.paymentMethodID, Equal <Required <PrintChecksFilter.payTypeID> >, And <CashAccountCheck.checkNbr, GreaterEqual <Required <PrintChecksFilter.nextCheckNbr> >, And <CashAccountCheck.checkNbr, LessEqual <Required <PrintChecksFilter.nextCheckNbr> > > > > > > .Select(this, det.CashAccountID, det.PaymentMethodID, NextCheckNbr, endNumber) .RowCast <CashAccountCheck>() .Select(check => check.CheckNbr) .ToArray(); if (duplicates.Any()) { throw new PXException( Messages.TooSmallCheckNumbersGap, stubCount, NextCheckNbr, endNumber, string.Join(",", duplicates)); } } short ordinalInStub = 0; int stubOrdinal = 0; foreach (APAdjust adj in adjustments) { pe.Document.Current.BillCntr++; if (ordinalInStub > pt.APStubLines - 1) { //AssignCheckNumber only for first StubLines in check, other/all lines will be printed on remittance report if (pt.APPrintRemittance == true) { adj.StubNbr = null; pe.Adjustments.Cache.Update(adj); continue; } NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.StubCntr++; ordinalInStub = 0; stubOrdinal++; } SetAdjustmentStubNumber(pe, doc, adj, NextCheckNbr); StoreStubNumber(pe, doc, det, NextCheckNbr, stubOrdinal); ordinalInStub++; } } else // create batch payment { //Update last number det.APLastRefNbr = NextCheckNbr; } pe.cashaccountdetail.Update(det); // det.APLastRefNumber was modified in StoreStubNumber method NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } else { if (pe.Document.Current.Printed != true || pe.Document.Current.Hold == true) { pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } } }
public static void Redirect(PXCache sender, CATran catran) { if (catran == null) { return; } if (catran.OrigTranType == CAAPARTranType.GLEntry) { JournalEntry graph = PXGraph.CreateInstance <JournalEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.BatchModule.Current = PXSelect <Batch, Where <Batch.module, Equal <Required <Batch.module> >, And <Batch.batchNbr, Equal <Required <Batch.batchNbr> > > > > .Select(graph, catran.OrigModule, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && (catran.OrigTranType == AP.APDocType.QuickCheck || catran.OrigTranType == AP.APDocType.VoidQuickCheck)) { APQuickCheckEntry graph = PXGraph.CreateInstance <APQuickCheckEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <APQuickCheck, Where <APQuickCheck.refNbr, Equal <Required <APQuickCheck.refNbr> >, And <APQuickCheck.docType, Equal <Required <APQuickCheck.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && catran.OrigTranType == CATranType.CABatch) { CABatchEntry graph = PXGraph.CreateInstance <CABatchEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP) { APPaymentEntry graph = PXGraph.CreateInstance <APPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (APPayment)PXSelect <APPayment, Where <APPayment.refNbr, Equal <Required <APPayment.refNbr> >, And <APPayment.docType, Equal <Required <APPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AR && (catran.OrigTranType == ARDocType.CashSale || catran.OrigTranType == ARDocType.CashReturn)) { ARCashSale document = (ARCashSale)PXSelect <ARCashSale, Where <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> >, And <ARCashSale.docType, Equal <Required <ARCashSale.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); if (document.OrigModule == BatchModule.SO && document.Released == false) { SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>(); graph.Clear(); sender.IsDirty = false; graph.Document.Current = (ARInvoice)PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >, And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = document; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (catran.OrigModule == GL.BatchModule.AR) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (ARPayment)PXSelect <ARPayment, Where <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> >, And <ARPayment.docType, Equal <Required <ARPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CAAdjustment) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CATransferExp) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjTranType, Equal <CAAPARTranType.cATransferExp>, And <CAAdj.transferNbr, Equal <Required <CATran.origRefNbr> > > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA) { if (catran.OrigTranType == CATranType.CADeposit || catran.OrigTranType == CATranType.CAVoidDeposit) { CADepositEntry graph = PXGraph.CreateInstance <CADepositEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CADeposit, Where <CADeposit.tranType, Equal <Required <CADeposit.tranType> >, And <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> > > > > .Select(graph, catran.OrigTranType, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { CashTransferEntry graph = PXGraph.CreateInstance <CashTransferEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Transfer.Current = PXSelect <CATransfer, Where <CATransfer.tranIDOut, Equal <Required <CATransfer.tranIDOut> >, Or <CATransfer.tranIDIn, Equal <Required <CATransfer.tranIDIn> > > > > .Select(graph, catran.TranID, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } }
public LienWaiverTransactionRetriever(PXGraph graph) { this.graph = (APPaymentEntry)graph; }
public ReversedJointPayeePaymentsValidationService(APPaymentEntry graph) : base(graph) { }
public AdjustmentAmountPaidValidationService(APPaymentEntry graph) : base(graph) { jointAmountToPayCalculationService = new JointAmountToPayCalculationService(graph); }
public static void ReleasePayments(List <APPayment> list, string Action) { APReleaseChecks graph = PXGraph.CreateInstance <APReleaseChecks>(); APPaymentEntry pe = PXGraph.CreateInstance <APPaymentEntry>(); bool failed = false; bool successed = false; string NextCheckNbr = null; List <APRegister> docs = new List <APRegister>(list.Count); List <string> numbers = new List <string>(); Dictionary <string, int> stubs = new Dictionary <string, int>(); for (int i = 0; i < list.Count; i++) { if (list[i].Passed == true) { graph.TimeStamp = pe.TimeStamp = list[i].tstamp; } switch (Action) { case "R": list[i].Printed = true; break; case "D": PaymentMethodAccount det = PXSelect <PaymentMethodAccount, Where <PaymentMethodAccount.cashAccountID, Equal <Required <PaymentMethodAccount.cashAccountID> >, And <PaymentMethodAccount.paymentMethodID, Equal <Required <PaymentMethodAccount.paymentMethodID> > > > > .Select(graph, list[i].CashAccountID, list[i].PaymentMethodID); if (det == null || det.APAutoNextNbr == false) { numbers.Add(list[i].ExtRefNbr); stubs[list[i].ExtRefNbr] = (int)list[i].StubCntr; //null out Check Number and delete used check number if StubCounter == 1 list[i].ExtRefNbr = null; } list[i].Printed = false; break; case "V": //null out Check Number but do not delete it list[i].StubCntr = -1; list[i].ExtRefNbr = null; list[i].Printed = false; break; default: continue; } if ((bool)list[i].Printed) { try { APPrintChecks.AssignNumbers(pe, list[i], ref NextCheckNbr); pe.Save.Press(); object[] persisted = PXTimeStampScope.GetPersisted(pe.Document.Cache, pe.Document.Current); if (persisted == null || persisted.Length == 0) { //preserve timestamp which will be @@dbts after last record committed to db on previous Persist(). //otherwise another process updated APAdjust. docs.Add(list[i]); } else { if (list[i].Passed == true) { pe.Document.Current.Passed = true; } docs.Add(pe.Document.Current); } successed = true; } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); docs.Add(null); failed = true; } } else { try { list[i].Hold = true; graph.APPaymentList.Cache.PersistUpdated(list[i]); graph.APPaymentList.Cache.Persisted(false); graph.TimeStamp = PXDatabase.SelectTimeStamp(); if (string.IsNullOrEmpty(list[i].ExtRefNbr)) { //try to get next number graph.APPaymentList.Cache.SetDefaultExt <APPayment.extRefNbr>(list[i]); if (string.IsNullOrEmpty(list[i].ExtRefNbr) == false) { list[i].StubCntr = 1; graph.APPaymentList.Cache.PersistUpdated(list[i]); graph.APPaymentList.Cache.Persisted(false); } } } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); } docs.Add(null); } } if (successed) { APDocumentRelease.ReleaseDoc(docs, true); } numbers.Sort(); for (int i = numbers.Count - 1; i >= 0; i--) { PaymentMethodAccount det = PXSelect <PaymentMethodAccount, Where <PaymentMethodAccount.cashAccountID, Equal <Required <PaymentMethodAccount.cashAccountID> >, And <PaymentMethodAccount.paymentMethodID, Equal <Required <PaymentMethodAccount.paymentMethodID> > > > > .Select(graph, list[0].CashAccountID, list[0].PaymentMethodID); string lastnumber = AutoNumberAttribute.NextNumber(numbers[i], stubs[numbers[i]] - 1); if (string.Equals(lastnumber, det.APLastRefNbr)) { det.APLastRefNbr = AutoNumberAttribute.NextNumber(det.APLastRefNbr, -stubs[numbers[i]]); graph.cashaccountdetail.Cache.PersistUpdated(det); graph.cashaccountdetail.Cache.Persisted(false); } } if (failed) { throw new PXException(GL.Messages.DocumentsNotReleased); } }