Skip to main content
Question

Receiving PXLockException When Updating Payment Prior to Capture

  • October 4, 2023
  • 0 replies
  • 49 views

Forum|alt.badge.img

Hello,

 

I am trying to update the AR Payment when the capture button is clicked, prior to capturing. I need to add Entry Charges programmatically and then let the capture do the rest of its base processing. I have the below code but during the Save, I am receiving a PXLockException error, and a message that another process has updated the ARRegister. Can you please provide guidance on how I can properly update the record prior to the base method and let basemethod do its process based on the updated record?

public class ARPaymentEntry_PaymentTransactionExt : PXGraphExtension<ARPaymentEntryPaymentTransaction, ARPaymentEntry>
{
public static bool IsActive() => PXAccess.FeatureInstalled<PX.Objects.CS.FeaturesSet.integratedCardProcessing>();
public override void Initialize() => base.Initialize();
public delegate IEnumerable CaptureCCPaymentDelegate(PXAdapter adapter);

[PXOverride]
public virtual IEnumerable CaptureCCPayment(PXAdapter adapter, CaptureCCPaymentDelegate baseDelegate)
{
Base.Save.Press();
//List<ARRegister> ret = new List<ARRegister>();

foreach (ARPayment ardoc in adapter.Get<ARPayment>())
{

var ext = ardoc.GetExtension<BMEPARRegisterExt>();
ARPayment payment = Base.Document.Current;
ARPaymentChargeTran Charge = new ARPaymentChargeTran
{
DocType = payment.DocType,
RefNbr = payment.RefNbr,
EntryTypeID = "TEST",
CuryTranAmt = 20.00m
};


Base.PaymentCharges.Insert(Charge);
Base.Document.Update(payment);
Base.Persist();
}

var ret = baseDelegate?.Invoke(adapter);

return ret;
}

}