Question

Apply prepayment to a sales order

  • 2 January 2024
  • 3 replies
  • 74 views

Badge

In my customization code I create a prepayment, after the sales order is persisted.  How can I insert the prepayment record into the Adjustments cache?  I insert an SOAdjust record and attempt to persist.  But an error returns - a complaint about the field CuryInfoID.

public delegate void PersistDelegate();
        [PXOverride]
        public void Persist(PersistDelegate baseMethod)
        {  
                        baseMethod()

                        ARPaymentEntry entryGraph = PXGraph.CreateInstance<ARPaymentEntry>();
                        entryGraph.Clear();
                        ARPayment payment = new ARPayment { DocType = ARDocType.Prepayment,                                  CustomerID = c.BAccountID };                        
                        payment.CuryOrigDocAmt = doc.CuryOrderTotal;
                        payment.AdjDate = doc.OrderDate;
                        payment.ExtRefNbr = doc.OrderNbr;
                        payment.PaymentMethodID = detail.PaymentMethodID;                        
                        //entryGraph.Document.View.Answer = WebDialogResult.Yes;
                        entryGraph.Document.Insert(payment);
                        entryGraph.Save.Press();

                       SOAdjust adj = new SOAdjust();
                       adj.AdjgDocType = payment.DocType;
                       adj.AdjgRefNbr = payment.RefNbr;
                       adj.CuryAdjdAmt = doc.CuryOrigDocAmt;
                       adj.AdjgCuryInfoID = doc.CuryInfoID;
                       Base.Adjustments.Insert(adj);
                       Base.Save.Press();


3 replies

Userlevel 7
Badge

Hi @Chris Hardgrove were you able to find a solution? Thank you!

Badge

Here is the Error messsage:  PX.Data.PXRowPersistingException: 'Error: 'AdjgCuryInfoID' cannot be empty.'  The error  continues if my  custom code does not assign a value to the field.

Userlevel 7
Badge +5

@Chris Hardgrove  I don’t think this line is correct 

        adj.AdjgCuryInfoID = doc.CuryInfoID

Adjg is for the payment part, so that must be payment.CuryInfoID

But I also do not think you need to fill this field manually at all. 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved