Acumatica: Sales Order custom calculation inconsis

2019-09-11 00:38发布

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条回答
倾城 Initia
2楼-- · 2019-09-11 00:48

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.

查看更多
登录 后发表回答