I've overridden the RunCaptureActions method of the ARPaymentAfterProcessingManager and intend to add my own logic, such as FunctionA, before base.RunCaptureActions.
FunctionA's logic involves adding a SOLine to the current SOOrder. I also need to modify the Applied To Order and Payment Amount fields under the Payments tab to match the added SOLine. How can I resolve this error?
public class TestARPaymentAfterProcessingManager : ARPaymentAfterProcessingManager
{
[PXOverride]
public override void RunCaptureActions(IBqlTable table, bool success)
{
ARPaymentEntry graph = base.CreateGraphIfNeeded(table);
FunctionA(graph, table);
base.RunCaptureActions(table, success);
}
}
FunctionA:
//---"Another process has updated the 'SOOrder' record. Your changes will be lost."-----
SOLine soLine = new SOLine();
soLine.InventoryID = item.InventoryID;
soLine.OrderNbr = soOrder.OrderNbr;
soLine.OrderType = soOrder.OrderType;
soLine.BranchID = soOrder.BranchID;
soLine.Qty = 1;
soLine.CuryUnitPrice = testamount;
soLine.CuryExtPrice = testamount;
soLine = soEntry.Transactions.Insert(soLine);
soEntry.SelectTimeStamp();
soEntry.Save.Press();
CCProcTran cCProcTran = SelectFrom<CCProcTran>.Where<CCProcTran.refNbr.IsEqual<@P.AsString>.And<CCProcTran.pCTranNumber.IsEqual<@P.AsString>>>.View.ReadOnly.Select(aRPaymentEntry, aRPayment.RefNbr, "key");
if (cCProcTran != null)
{
cCProcTran.Amount = totalamt;
soEntry.ccProcTran.Update(cCProcTran);
}
ExternalTransaction externalTransaction = SelectFrom<ExternalTransaction>.Where<ExternalTransaction.refNbr.IsEqual<@P.AsString>.And<ExternalTransaction.tranNumber.IsEqual<@P.AsString>>>.View.ReadOnly.Select(aRPaymentEntry, aRPayment.RefNbr, "key");
if (externalTransaction != null)
{
externalTransaction.Amount = totalamt;
externalTransaction.SyncMessage = string.Empty;
soEntry.ExternalTran.Update(externalTransaction);
}
aRPayment.CuryOrigDocAmt = totalamt;
aRPaymentEntry.Document.Update(aRPayment);
aRPaymentEntry.SelectTimeStamp();
aRPaymentEntry.Save.Press();
sOAdjust.CuryAdjdAmt= totalamt;
sOAdjust.CuryOrigDocAmt = totalamt;
soEntry.Adjustments.Update(sOAdjust);
soEntry.SelectTimeStamp();
soEntry.Save.Press();
//---
