Rowan
Rowan

Reputation: 55

Acumatica - How can I customize Recalculate Prices formula?

I have been asked to customize the formula that calculates Unit Price when using a Sales Price Worksheet. Instead of discounting on the line qty, they want to discount on the overall SO total qty.

Widget1 gets unitprice of .80 if 100 are ordered. Widget2 gets unitprice of 1.75 if 150 are ordered.

Sales Order line 1 is for Widget1, unitqty of 200...unitprice for that line will be .80. Sales Order line 2 is for Widget2, unitqty of 10...unitprice for that line will be 1.75 because it is based on total unit qty which equals 210 (over 150).

I cannot find the calculation code to override it. I had an idea of /storing SOLine unitqty in OldUnitQty variable /update SOLine untiqty to SOOrder unitqty /call GetPriceCalculationScope /set SOLine unitqty back to OldUnitQty

I am not sure that is a good idea or if it will even work. Can anyone give me some guidance on how to do this?

Upvotes: 0

Views: 219

Answers (1)

Hayk
Hayk

Reputation: 46

You can handle the unitqty updated event(where the header total qty will be already updated), check if total qty is more than 150 and update unit cost for the current line. The code will be like this:

protected virtual void SOLine_OrderQty_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated del)
{
    del?.Invoke(cache, e);

    SOLine line = (SOLine)e.Row;
    if (line != null)
    {
        if (Base.Document.OrderQty > ...)
        {
            line.CuryUnitPrice = ...;
        }
    } 
}

Upvotes: 0

Related Questions