[
{"name": "12.5% on a whole bill: 71.95 gives 8.99375, rounded half-up to 8.99", "args": [[{"description": "burger", "amount": {"minor": 1850, "currency": "GBP"}, "eligible": true}, {"description": "risotto", "amount": {"minor": 1450, "currency": "GBP"}, "eligible": true}, {"description": "fries", "amount": {"minor": 695, "currency": "GBP"}, "eligible": true}, {"description": "wine", "amount": {"minor": 3200, "currency": "GBP"}, "eligible": true}], 1250, "half-up"], "expect": {"eligibleTotal": {"minor": 7195, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 899, "currency": "GBP"}, "subtotal": {"minor": 7195, "currency": "GBP"}, "total": {"minor": 8094, "currency": "GBP"}}},
{"name": "only the food is eligible", "args": [[{"description": "food", "amount": {"minor": 4000, "currency": "GBP"}, "eligible": true}, {"description": "drinks at the bar", "amount": {"minor": 2500, "currency": "GBP"}, "eligible": false}], 1000, "half-up"], "expect": {"eligibleTotal": {"minor": 4000, "currency": "GBP"}, "basisPoints": 1000, "charge": {"minor": 400, "currency": "GBP"}, "subtotal": {"minor": 6500, "currency": "GBP"}, "total": {"minor": 6900, "currency": "GBP"}}},
{"name": "charged once on the total, not per line: 12.5% of 9.99 is 1.25, not 3 x 0.42", "args": [[{"description": "a", "amount": {"minor": 333, "currency": "GBP"}, "eligible": true}, {"description": "b", "amount": {"minor": 333, "currency": "GBP"}, "eligible": true}, {"description": "c", "amount": {"minor": 333, "currency": "GBP"}, "eligible": true}], 1250, "half-up"], "expect": {"eligibleTotal": {"minor": 999, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 125, "currency": "GBP"}, "subtotal": {"minor": 999, "currency": "GBP"}, "total": {"minor": 1124, "currency": "GBP"}}},
{"name": "rounding up", "args": [[{"description": "a", "amount": {"minor": 999, "currency": "GBP"}, "eligible": true}], 1250, "up"], "expect": {"eligibleTotal": {"minor": 999, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 125, "currency": "GBP"}, "subtotal": {"minor": 999, "currency": "GBP"}, "total": {"minor": 1124, "currency": "GBP"}}},
{"name": "rounding down", "args": [[{"description": "a", "amount": {"minor": 999, "currency": "GBP"}, "eligible": true}], 1250, "down"], "expect": {"eligibleTotal": {"minor": 999, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 124, "currency": "GBP"}, "subtotal": {"minor": 999, "currency": "GBP"}, "total": {"minor": 1123, "currency": "GBP"}}},
{"name": "an exact half rounds up with half-up: 12.5% of 10.12 is 1.265", "args": [[{"description": "a", "amount": {"minor": 1012, "currency": "GBP"}, "eligible": true}], 1250, "half-up"], "expect": {"eligibleTotal": {"minor": 1012, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 127, "currency": "GBP"}, "subtotal": {"minor": 1012, "currency": "GBP"}, "total": {"minor": 1139, "currency": "GBP"}}},
{"name": "an exact half rounds to even with half-even", "args": [[{"description": "a", "amount": {"minor": 1012, "currency": "GBP"}, "eligible": true}], 1250, "half-even"], "expect": {"eligibleTotal": {"minor": 1012, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 126, "currency": "GBP"}, "subtotal": {"minor": 1012, "currency": "GBP"}, "total": {"minor": 1138, "currency": "GBP"}}},
{"name": "a discount line reduces the eligible total", "args": [[{"description": "mains", "amount": {"minor": 3000, "currency": "GBP"}, "eligible": true}, {"description": "voucher", "amount": {"minor": -500, "currency": "GBP"}, "eligible": true}], 1250, "half-up"], "expect": {"eligibleTotal": {"minor": 2500, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 313, "currency": "GBP"}, "subtotal": {"minor": 2500, "currency": "GBP"}, "total": {"minor": 2813, "currency": "GBP"}}},
{"name": "a zero rate is no charge", "args": [[{"description": "burger", "amount": {"minor": 1850, "currency": "GBP"}, "eligible": true}, {"description": "risotto", "amount": {"minor": 1450, "currency": "GBP"}, "eligible": true}, {"description": "fries", "amount": {"minor": 695, "currency": "GBP"}, "eligible": true}, {"description": "wine", "amount": {"minor": 3200, "currency": "GBP"}, "eligible": true}], 0, "half-up"], "expect": {"eligibleTotal": {"minor": 7195, "currency": "GBP"}, "basisPoints": 0, "charge": {"minor": 0, "currency": "GBP"}, "subtotal": {"minor": 7195, "currency": "GBP"}, "total": {"minor": 7195, "currency": "GBP"}}},
{"name": "no eligible lines is no charge", "args": [[{"description": "drinks", "amount": {"minor": 2500, "currency": "GBP"}, "eligible": false}], 1250, "half-up"], "expect": {"eligibleTotal": {"minor": 0, "currency": "GBP"}, "basisPoints": 1250, "charge": {"minor": 0, "currency": "GBP"}, "subtotal": {"minor": 2500, "currency": "GBP"}, "total": {"minor": 2500, "currency": "GBP"}}},
{"name": "the whole amount at 100%", "args": [[{"description": "a", "amount": {"minor": 1000, "currency": "GBP"}, "eligible": true}], 10000, "half-up"], "expect": {"eligibleTotal": {"minor": 1000, "currency": "GBP"}, "basisPoints": 10000, "charge": {"minor": 1000, "currency": "GBP"}, "subtotal": {"minor": 1000, "currency": "GBP"}, "total": {"minor": 2000, "currency": "GBP"}}},
{"name": "euro bill", "args": [[{"description": "menu", "amount": {"minor": 4590, "currency": "EUR"}, "eligible": true}], 1000, "half-up"], "expect": {"eligibleTotal": {"minor": 4590, "currency": "EUR"}, "basisPoints": 1000, "charge": {"minor": 459, "currency": "EUR"}, "subtotal": {"minor": 4590, "currency": "EUR"}, "total": {"minor": 5049, "currency": "EUR"}}},
{"name": "an empty bill is an error", "args": [[], 1250, "half-up"], "expectError": "a bill needs at least one line"},
{"name": "a negative rate is an error", "args": [[{"description": "burger", "amount": {"minor": 1850, "currency": "GBP"}, "eligible": true}, {"description": "risotto", "amount": {"minor": 1450, "currency": "GBP"}, "eligible": true}, {"description": "fries", "amount": {"minor": 695, "currency": "GBP"}, "eligible": true}, {"description": "wine", "amount": {"minor": 3200, "currency": "GBP"}, "eligible": true}], -1, "half-up"], "expectError": "basisPoints must be a whole number from 0 to 10000"},
{"name": "a rate over 100% is an error", "args": [[{"description": "burger", "amount": {"minor": 1850, "currency": "GBP"}, "eligible": true}, {"description": "risotto", "amount": {"minor": 1450, "currency": "GBP"}, "eligible": true}, {"description": "fries", "amount": {"minor": 695, "currency": "GBP"}, "eligible": true}, {"description": "wine", "amount": {"minor": 3200, "currency": "GBP"}, "eligible": true}], 10001, "half-up"], "expectError": "basisPoints must be a whole number from 0 to 10000"},
{"name": "mixed currencies are an error", "args": [[{"description": "a", "amount": {"minor": 100, "currency": "GBP"}, "eligible": true}, {"description": "b", "amount": {"minor": 100, "currency": "EUR"}, "eligible": true}], 1250, "half-up"], "expectError": "currency mismatch"},
{"name": "a negative eligible total is an error", "args": [[{"description": "refund", "amount": {"minor": -500, "currency": "GBP"}, "eligible": true}], 1250, "half-up"], "expectError": "a service charge cannot be negative"}
]