公式字段以计算明细总计

时间:2019-05-24 15:35:10

标签: formula acumatica

我有两个DAC,POReceipt和POReceiptLine。我想向POReceipt添加一个字段,以汇总POReceiptLines的总成本。

是否可以使用属性来执行此操作?我可以使用PXFormula还是类似的东西?

该字段应为收据行成本之和。

1 个答案:

答案 0 :(得分:2)

使用PXUnboundFormula计算汇总值

using PX.Data;
namespace PX.Objects.PO
{
public sealed class POReceiptExt : PXCacheExtension<POReceipt>
{
    [PXDBDecimal]
    [PXDefault("0.0", PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Total Cost ")]
    public decimal? TotalCost { get; set; }
    public abstract class totalCost : IBqlField
    {
    }
}
public sealed class POReceiptLineExt : PXCacheExtension<POReceiptLine>
{
    [PXDBDecimal]
    [PXDefault("0.0", PersistingCheck = PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName = "Line Cost")]
    [PXUnboundFormula(typeof(POReceiptLineExt.lineCost), typeof(SumCalc<POReceiptExt.totalCost>))]
    public decimal? LineCost { get; set; }
    public abstract class lineCost : IBqlField
    {
    }
  }
}

Calculating Values of UI Elements