Use custom unbound fields (NonPersistedField) as placeholders to display the totals.
First add those custom fields to SOOrder DAC extension:

Total quantity custom field:

Total transactions custom field:

Create a SOOrderEntry graph extension to compute/update totals:

Add custom fields to Sales Order screen, no need to use label controls, DAC DisplayName property will act as the field label:

Locate the Base graph Transactions DataView which contains the detail data needed for computing the totals (for information only):

In your SOOrderEntry extension use the Transactions DataView from Base Graph to compute totals:
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();
}
}
}
Totals are displayed in Sales Order screen, they will update when inserting/removing Transaction rows and modifying order quantities:
