Solved

How to override Ext.Price calculation formula in Sales Orders Invoices(SO303000)

  • 22 November 2023
  • 2 replies
  • 48 views

Userlevel 4
Badge

As shown in the above screenshot i have inserted a new field named Claim Percentage for the ARTran. After enter the values for the Quantity and Unit Price fields the Ext.Price should be calculated based on that two fields. Then If a value is entered to the Claim Percentage the Ext.Price should be updated as “Qty*UnitPrice*Claim Percenatge”. This is the my expected scenario.

In order to achieve this i have used a event handler in SOInvoiceEntry as shown in below.

public virtual void ARTran_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
{
ARTran row = (ARTran)e.Row;

if (row != null && row.Qty != null && row.CuryUnitPrice != null)
{
ARTranExt tranExt = PXCache<ARTran>.GetExtension<ARTranExt>(row);

if (tranExt != null && tranExt.UsrClaimPercentage != null)
{
decimal claimExtPrice = (decimal)(row.Qty * row.CuryUnitPrice * (tranExt.UsrClaimPercentage / 100));

sender.SetValue<ARTran.curyExtPrice>(row, claimExtPrice);
}
}
}

This is aligned with my requirement. However, right after entering the values for the Quantity,Unit Price and Claim Percentage fields the Ext.Price is not calculated. As shown in the above screenshot when another new blank record is inserted by double-clicking, the Ext.Price is getting updated as “Qty*UnitPrice*Claim Percenatge”.

But I'm expecting to update the Ext.Price immediately right after entering the values. So can I know how to achieve this?     

  

icon

Best answer by Vignesh Ponnusamy 22 November 2023, 17:51

View original

2 replies

Userlevel 7
Badge +4

Hi @malinthawarnakulasooriya08,

You can use the FieldUpdated event of the custom field like below,

		protected void ARTran_UsrClaimPercenatge_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (ARTran)e.Row;
if (row != null && row.Qty != null && row.CuryUnitPrice != null)
{
ARTranExt tranExt = PXCache<ARTran>.GetExtension<ARTranExt>(row);

if (tranExt != null && tranExt.UsrClaimPercenatge != null)
{
decimal claimExtPrice = (decimal)(row.Qty * row.CuryUnitPrice * (tranExt.UsrClaimPercenatge / 100));

cache.SetValue<ARTran.curyExtPrice>(row, claimExtPrice);
}
}
}

Also, set CommitChanges to True for the field, so each time user tabs out of the field, call to the server is made,

 

Feel free to post if you have any questions. Good Luck.!

Userlevel 4
Badge

Thank you @Vignesh Ponnusamy .It worked very well.

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