Skip to main content
Question

Apply prepayment to a sales order

  • January 2, 2024
  • 3 replies
  • 156 views

Chris Hardgrove
Jr Varsity I

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

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • January 2, 2024

@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. 


Chris Hardgrove
Jr Varsity I

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.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • March 11, 2024

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