0
votes

With some help and a lot of trial and error I was able to create a customization that allowed for the following:

  1. "Total Profit" field on the Sales Order summary area
  2. "GP %" field on the Sales Order summary area
  3. "Total Profit" field on the Sales Order details area (by line)
  4. "GP %" field on the Sales Order details area (by line)

Total Profit = Ext. Price - Ext. Cost GP % = (Total Profit / Ext. Price) * 100

The calculation for these four fields works some of the time, but I have noticed when I commit the line either by entering a new line or with Control + Enter, and then go back and change the Ext. Cost, the Total Profit and GP% don't update. Even when I save and refresh it does this. The only time it seems to work 100% is when I enter it in very methodically going one step at a time. But this is not how the out of the box totals are calculated. It doesn't matter which order you enter in your quantity, price, etc. - the out of the box totals always update. How do I make my four custom fields like this in Acumatica?

SOLine Custom fields (each field separated by a blank line):

[PXDBCurrency(typeof(SOLine.curyInfoID), typeof(SOLineExt.usrTotalProfit))]
[PXUIField(DisplayName = "Total Profit", Enabled = false)]
[PXFormula(typeof(Sub<SOLine.curyLineAmt, SOLine.curyExtCost>))]
[PXDefault(TypeCode.Decimal, "0.0")]
[PXFormula(null, typeof(SumCalc<SOOrderExt.usrCuryOrderTotalProfit>))]

[PXDBDecimal(4)]
[PXDefault(TypeCode.Decimal, "0.0")]

[PXFormula(typeof(Switch<Case<Where<SOLine.curyLineAmt, Equal<decimal0>>, decimal0>, Div<SOLineExt.usrTotalProfit, SOLine.curyLineAmt>>))]
[PXDefault(TypeCode.Decimal, "0.0")]

[PXUIField(DisplayName = "GP %", Enabled = false)] 
[PXFormula(typeof(Mult<SOLineExt.usrGPPercent, decimal100>))]
[PXDefault(TypeCode.Decimal, "0.0")]

SOOrder Custom fields (each field separated by a blank line):

[PXDBCurrency(typeof(SOOrder.curyInfoID), typeof(SOOrderExt.usrOrderTotalProfit))] 
[PXUIField(DisplayName = "Total Profit", Enabled = false)] 
[PXDefault(TypeCode.Decimal, "0.0")]

[PXDBDecimal(4)]
[PXDefault(TypeCode.Decimal, "0.0")]

[PXFormula(typeof(Switch<Case<Where<SOOrder.curyOrderTotal, Equal<decimal0>>, decimal0>, Div<SOOrderExt.usrOrderTotalProfit, SOOrder.curyOrderTotal>>))]
[PXDefault(TypeCode.Decimal, "0.0")]

[PXUIField(DisplayName = "GP %", Enabled = false)] 
[PXFormula(typeof(Mult<SOOrderExt.usrOrderGPPercent, decimal100>))]
1
Can you provide source code for your solution? Include all custom DAC fields and attributes you used.Gabriel
Gabriel - I updated my original post. Let me know if you need anything else!Kyle Rilling
If your company has support subscription, I recommend that you create a case for Acumatica Support. This can significantly speed up the solution of the issue.Alexander Kochetov

1 Answers

0
votes

PXFormula should have no problems with DAC extensions and custom fields. It's really hard to tell what the issue is by looking only at field attributes. Please, at least, update your code snippet with DAC field declarations, so it becomes more clear what attributes belong to what field.