I'm overriding the Persist method in the Invoices and Memos (AR301000) screen. I'm using a foreach loop to update the unit price of an item. However, the loop is executing twice, resulting in incorrect calculations. The values before calling baseMethod() are correct, as verified using PXTrace. Therefore, I suspect the issue occurs during the execution of baseMethod(). I've tried various approaches to resolve this, but none have been successful. How can I fix this?
Any detailed instructions, tips, or code snippets would be greatly appreciated. Thank you!
[PXOverride]
public virtual void Persist(Action baseMethod){
PXResultset<ARTran> TransactionLines = PXSelect<ARTran,
Where<ARTran.refNbr, Equal<Required<ARTran.refNbr>>,
And<ARTran.tranType, Equal<Required<ARTran.tranType>>>>>
.Select(this.Base, currentView.RefNbr, currentView.DocType)
var multiplicationFactor = contractExt.UsrAdjustmentDays //Custom field where user enters an integer. I retrieve this value to here
if (TransactionLines != null){
foreach (ARTran TransactionLine in TransactionLines)
{
TransactionLine.CuryUnitPrice = TransactionLine.CuryUnitPrice * multiplicationFactor;
Base.Transactions.Update(TransactionLine);
}
}
baseMethod();
}