@bobbytherbs Hi,
you can follow below approach hope it will work.
Note: Generated from AI
DAC Extension (Customer)
Create a DAC Extension for Customer.
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.Objects.CM;
namespace Customization
{
public class CustomerExt : PXCacheExtension<Customer>
{
#region UsrOpenInvoices
[PXDecimal]
[PXUIField(DisplayName = "Open Invoices", Enabled = false)]
public decimal? UsrOpenInvoices { get; set; }
public abstract class usrOpenInvoices : PX.Data.BQL.BqlDecimal.Field<usrOpenInvoices> { }
#endregion
}
}
Graph Extension (CustomerMaint)
Now calculate the value.
using PX.Data;
using PX.Objects.AR;
using PX.Objects.AR.Standalone;
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
protected void _(Events.RowSelected<Customer> e)
{
if (e.Row == null) return;
decimal totalOpenInvoices = 0;
foreach (ARInvoice inv in PXSelect<
ARInvoice,
Where<
ARInvoice.customerID, Equal<Required<ARInvoice.customerID>>,
And<ARInvoice.status, Equal<ARDocStatus.open>,
And<ARInvoice.docType, Equal<ARDocType.invoice>>>>>
.Select(Base, e.Row.BAccountID))
{
totalOpenInvoices += inv.CuryDocBal ?? 0;
}
CustomerExt ext = e.Row.GetExtension<CustomerExt>();
ext.UsrOpenInvoices = totalOpenInvoices;
}
}
Add Field to UI
Open Customization Project → Screens → Customers (AR303000)
Add field to the Balance area.
Result
Customer screen will show:
Field Value
Balance 800
Open Invoices 1000
Prepayment Balance -200