6. Fix the order service (7 bugs)
HardDebugging & productionDebugging
This ~140-line order service parses order lines, applies a buy-one-get-one-free rule, a 10% discount at $100.00, 8.25% tax on the discounted amount, all-or-nothing stock reservation and idempotent batch processing.
Customers report wrong totals, oversold stock and duplicate charges. Run the tests, read the failures, and fix the service. Seven separate bugs are hidden in it. Do not change the test entry point at the bottom.
Example 1
Input: runScenario('socks')
Output: 1000
Explanation: 3 socks at 500 cents: pay for 2Example 2
Input: runScenario('threshold')
Output: discount applies at exactly 10000 centsConstraints
Money is integer cents; rounding is half-upEach test runs one named scenario through runScenario(name)