Context: We use the Commerce (CSU) OData API to get prices and send orders in D365 from a home-made website.
We are calling API endpoint "CalculateSalesDocument" to get prices for products. When there is a discount, we would like to get the discounted unit price to display it, even if the quantity is greater than 1.
Example: my product price is 3.27€, with a 15% discount. My discounted unit price is 2.78€.
When I call the API for quantity 1, no problem, I use "ExtendedPrice" to get the discounted unit price. But when quantity is greater than 1, I can't get the "2.78" value. It's not in CalculateSalesDocument endpoint response. Would it be possible to add it? It's very important value IMO.
POST xxxx/Commerce/CalculateSalesDocument
Content-Type: application/json
{
"salesDocument": {
"Id": "CalculateSalesDocument",
"CustomerId": "CS000003",
"CartLines": [
{
"ProductId": 5637197959,
"Quantity": 1,
"UnitOfMeasureSymbol": "Pcs"
}
]
}
}
Response:
{
"@odata.context": "...",
"CartLines": [
{
"Quantity": 1,
"Price": 3.27,
"ExtendedPrice": 2.78,
"TotalAmount": 2.78,
"NetAmountWithoutTax": 2.78,
"DiscountAmount": 0.49,
"LineDiscount": 0.49,
"LinePercentageDiscount": 15.000000000000000000000000,
"PriceLines": [
// ...
{
"RecordId": 5652434827,
"Value": 3.27,
"PriceMethod": "Fixed"
}
],
"DiscountLines": [
{
"EffectiveAmount": 0.49,
"EffectivePercentage": 14.98,
"Percentage": 15.000000000000000000000000
// ...
}
]
// ...
}
]
// ...
}
When I change quantity to 2, I can't find "2.78" anywhere in the response.
{
"@odata.context": "...",
"CartLines": [
{
"Quantity": 2,
"Price": 3.27,
"ExtendedPrice": 5.56,
"TotalAmount": 5.56,
"NetAmountWithoutTax": 5.56,
"DiscountAmount": 0.98,
"LineDiscount": 0.98,
"LinePercentageDiscount": 15.000000000000000000000000,
"PriceLines": [
// ...
{
"RecordId": 5652434827,
"Value": 3.27,
"PriceMethod": "Fixed"
}
],
"DiscountLines": [
{
"EffectiveAmount": 0.98,
"EffectivePercentage": 14.98,
"Percentage": 15.000000000000000000000000
// ...
}
]
// ...
}
]
// ...
}
Having "2.78" value in a new field "DiscountedUnitPrice" would be great.
Comments
Sorry for the bad format, but we can't put code blocks on this website (detected as malicious input)...
Category: Pricing, Discounts, and Taxes
