Implementation of http://codekata.com/kata/kata01-supermarket-pricing/
Allows definition of promotions using meta-language. For example:
3 @Coke@ for the price of 2
2 #SNACK# for the price of 1
@Coke@ discount 10%
If the items in the customer's basket can match multiple promotions (for example, 3 soft drinks for the price of 2, but coke is 10% off), the following rules apply:
- An item can participate only in 1 promotion
- The best combination of promotions is selected (the one which saves the customer the most money)
So, for example, if we have: 3 @Coke@ for the price of 2 #SOFT_DRINK# discount 10%
And the Coke costs 1 EUR, if the customer buys 3 cokes, we have:
- variant 1 - 3 cokes for 2 - the customer saves 1 EUR
- variant 2 - 3 cokes at 0.9 each - the customer saves 30 cents.
Therefore, variant 1 is selected.