我是Acumatica的新手并尝试探索一些自定义功能。
我在销售订单屏幕上创建了2个标签 - CstLabeltotal和CstLabelqty
我试图找出一种方法,除了总标签将显示文件详细信息选项卡中的总数量交易(第1列),数量标签显示文档详细信息选项卡(第9列)中的总数量
有人可以帮我吗?
答案 0 :(得分:2)
使用自定义未绑定字段(NonPersistedField)作为占位符来显示总计。
将自定义字段添加到“销售订单”屏幕,无需使用标签控件,DAC DisplayName属性将充当字段标签:
找到基本图表交易DataView,其中包含计算总计所需的详细数据(仅供参考):
在您的SOOrderEntry扩展程序中,使用Base Graph中的Transactions DataView来计算总计:
namespace PX.Objects.SO
{
public class SOOrderEntry_Extension:PXGraphExtension<SOOrderEntry>
{
// Initialize unbound values in FieldSelecting events
public void SOOrder_UsrTotalQty_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
e.ReturnValue = GetTotalQty(sender);
}
public void SOOrder_UsrTotalTransactions_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
e.ReturnValue = GetTotalTransactions(sender);
}
// Update values
public void SOLine_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
{
UpdateTotals(sender, e.Row as SOOrder, true, true);
}
public void SOLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
{
UpdateTotals(sender, e.Row as SOOrder, true, true);
}
public void SOLine_OrderQty_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
UpdateTotals(sender, e.Row as SOOrder, true, false);
}
public void UpdateTotals(PXCache sender, SOOrder soOrder, bool isUpdateQty, bool isUpdateTranCount)
{
// Get SOOrder DAC extension
if (soOrder != null)
{
SOOrderExt soOrderExt = sender.GetExtension<SOOrderExt>(soOrder);
if (soOrderExt != null)
{
// Update values
if (isUpdateQty)
{
soOrderExt.UsrTotalQty = GetTotalQty(sender);
}
if (isUpdateTranCount)
{
soOrderExt.UsrTotalTransactions= GetTotalTransactions(sender);
}
}
}
}
// Compute totals
public decimal? GetTotalQty(PXCache sender)
{
decimal? totalQty = 0M;
// Compute quantity from SOOrderEntry base graph Transactions DataView
foreach (SOLine soLine in Base.Transactions.Select())
{
totalQty += soLine.OrderQty;
}
return totalQty;
}
public int? GetTotalTransactions(PXCache sender)
{
return Base.Transactions.Select().Count();
}
}
}