Rounding With Promotion Engine: Part 1 - Introduction
How different promotion engines implement rounding
In e-commerce, applying discounts across multiple line items in an order can be complex, especially when dealing with non-divisible amounts. For example, consider a promotion where spending £100 grants a £20 discount on the entire order. If this discount needs to be spread across three items costing £10 each, the challenge becomes apparent. You cannot simply apply £6.6667 to each item due to currency rounding limitations.
Rounding Strategies
Naive Rounding
The simplest approach is to round each discount amount individually. For example, if the calculated discount per item is £6.6667, rounding could lead to £6.67 for each item. This method is straightforward but can result in minor inaccuracies across the total order.
Aggregate Rounding
A slightly more sophisticated method involves waiting until all discounts have been applied to each line item before rounding. This approach helps maintain mathematical accuracy but might not always reflect the actual monetary amounts due to cumulative rounding errors.
Iterative Rounding
The ideal strategy involves rounding each item’s price after applying each discount. This method ensures that the discount distribution remains accurate and fair. For instance, if three items each receive a £6.6667 discount, rounding might distribute the discounts as £6.67, £6.67, and £6.66. Selecting which items to adjust can depend on their value, ensuring the most equitable distribution.
Currency Considerations
Rounding becomes even more critical when dealing with different currencies. For example, the Japanese Yen and Icelandic Krona have no decimal places, while the Kuwaiti Dinar has three. Each currency requires tailored rounding strategies to handle discounts accurately.
Addressing Overlapping Discounts
Items can have multiple, overlapping discounts, adding complexity. It’s essential to develop a system that rounds appropriately after each discount application to prevent inaccuracies. This might mean setting up warnings in your discounting tools to flag non-divisible discounts or creating a specialized rounding engine.