With the introduction of the Unified Pricing Management (UPM) module in Dynamics 365 Finance & Operations version 10.0.41, Microsoft significantly improved how pricing and discounts are managed. Discounts can now be defined and maintained in a single, centralized location, ensuring consistent pricing behavior across the application.
On the Sales order form, users can already see individual discounts applied to each sales line. However, the standard Sales Invoice report still shows only the total discount amount and does not display line-level discount details.
In this guide, we show how to include line-level discount information on the Sales Invoice report with a few simple code changes. This makes invoices more transparent for customers and allows for better use of UPM capabilities.
Code Changes
To address this, we added a small piece of logic to make those discount details available in the Sales Invoice report data source.
You’ll find this example included in our upcoming release (version 3.5.0.2) as commented reference code. From there, developers can easily apply the same approach in their own environments, using extensions or any other customization pattern that fits their development standards.
Uncomment the following code in the sil_addMainLines() method in the DSP class:
//Uncomment this code to display individual discount amounts for each line. These additional fields will be populate when the Unified Pricing Management module is enabled in Feature Management.
/*CustInvoiceTrans custInvoiceTrans = this.custInvoiceTrans(_currentLine.JourTransRecId_DR);
RetailSalesQuotationDiscountLineView discountLineView;
boolean discountLinesFound;
while select discountLineView
where discountLineView.InventTransId == custInvoiceTrans.InventTransId
{
discountLinesFound = true;
this.sil_addRetailSalesDiscountLine(_addingRecord, discountLineView);
}
if (!discountLinesFound && !this.isRuntime())
{
this.sil_addRetailSalesDiscountLine(_addingRecord, discountLineView);
}
*/
This will then call the sil_addRetailSalesDiscountLine() method.
/// <summary>
/// Adds Retail sales discount line fields to the SalesInvoiceLines record.
/// </summary>
/// <param name = "_addingRecord">Data record in the record tree based on the currently adding RDP record table buffer.</param>
/// <param name = "_discountLineView">RetailSalesQuotationDiscountLineView table buffer.</param>
protected void sil_addRetailSalesDiscountLine(DocXmlRecord _addingRecord, RetailSalesQuotationDiscountLineView _discountLineView)
{
_addingRecord.addChildRecord(_discountLineView).addFields([
fieldStr(RetailSalesQuotationDiscountLineView, Amount),
fieldStr(RetailSalesQuotationDiscountLineView, CustomerDiscountType),
fieldStr(RetailSalesQuotationDiscountLineView, DealPrice),
fieldStr(RetailSalesQuotationDiscountLineView, DiscountAmount),
fieldStr(RetailSalesQuotationDiscountLineView, DiscountCode),
fieldStr(RetailSalesQuotationDiscountLineView, DiscountOriginType),
fieldStr(RetailSalesQuotationDiscountLineView, InventTransId),
fieldStr(RetailSalesQuotationDiscountLineView, DiscountOriginType),
fieldStr(RetailSalesQuotationDiscountLineView, ManualDiscountType),
fieldStr(RetailSalesQuotationDiscountLineView, Percentage),
fieldStr(RetailSalesQuotationDiscountLineView, PeriodicDiscountofferId)]);
}
Updating the Report Template
After implementing the code changes:
-
Build the solution
-
Run the Sales Invoice report
-
Generate the DDSP file
-
Import the new DDSP into your Sales Invoice report template
Once the pricing data is available in the report data source, you can display it in the template. For example, add a List tagging element bound to RetailSalesQuotationDiscountLineView, and Field tagging elements bound to the required fields.
Result
After these changes, each Sales Invoice line displays its individual UPM discount amounts instead of just a total.
This gives customers clearer invoice details and ensures the Sales Invoice report accurately reflects the pricing set up in UPM.
For more details about the Unified Pricing Management, refer to the official documentation.



