Pricing Administration Guide > Pricing in the Run-Time Application > Spread Discount Pricing >
About the Spread Discount Algorithm
This section contains a high-level description of the algorithm used by the spread discount service:
- Get the BasePrice (List Price or Net Price).
- Convert all prices (BasePrice, Min, Max) to BaseCurrency. (Defaults to system, but user chooses from dialog box.)
- Add up all BasePrices up (multiplying each by Qty) to get TotalBasePrice.
- Get TargetPrice (calculated from AmtToDiscount or PercentToDiscount if necessary).
- Calculate total to discount: TotalToDiscount = TotalBasePrice - TargetPrice.
- Loop through the discounts one at a time:
- Loop through all Rows that have not reached min/max
- Discount each amount by (BasePrice/TotalBasePrice)*TotalToDiscount
- If that discount pushes price beyond min/max: (1) Set the final price of item to its min/max (2) Remove that row from further discounts
- After round completes, make adjustment so maxed out rows are not taken into account in the next round's calculation. For each of these rows:
- Its BaseValue*Qty will be subtracted from TotalBasePrice
- Its DiscountAmt*Qty will be subtracted from TotalToDiscount
- Looping continues until:
- TotalToDiscount can be spread evenly across all remaining line items, or
- All items have been discounted to their respective min/max
- Loop through all rows to convert each back to the line item currency and to round each to line item precision.
- Add up rounding remainders and amount discounted.
- The rounding remainder is added to element with highest BasePrice*Qty that has not already reached its min/max.
- This continues until the rounding remainder rounds to 0 or until no items can be discounted further.