The invoicing engine
≈ 25 min150 pts max
Context
Ticket SUP-2291, high priority: “VAT computation crashes for international customers.” An order from a Swiss customer took the checkout down this morning.
The suspect: computeInvoice, written in 2019 by Gérard, who has since left the company. Nobody dares to touch it, but it is covered by a characterization test suite (tests/invoice.test.ts). Support added tests/export.test.ts, which reproduces the ticket. It is red.
Objective
- Turn
tests/export.test.tsgreen: outside the EU, an invoice is issued without VAT (exportmode). - Do not break any test of
tests/invoice.test.ts. - Leave the code more readable than you found it: the cyclomatic complexity of
computeInvoicemust go down to 8 or less. The function keeps its name and stays insrc/invoice.ts.
⌘S / Ctrl+S runs the tests. Submit once everything is green: each failed submission costs points.
- Editor
- Tests
- Terminal
- Cyclomatic complexity