Project: ledger-api · Branch: fix/tax-rounding · Mode: default · Model: claude-opus-4-7
Summary
Tracked down a one-cent mismatch between invoice totals and the PDF: tax was rounded per line instead of per invoice. Switched to Decimal with banker's rounding at the invoice level and added a property-based test with Hypothesis.
Conversation
Turn 1 — User
Customers report invoices off by one cent vs the PDF.
Turn 1 — Assistant
Root cause: tax is rounded on every line item, then summed. Rounding once per invoice with ROUND_HALF_EVEN fixes it. Adding a Hypothesis test that the sum of lines always equals the invoice total.
Tools used in this turn:
Bash: pytest -k tax -q — 1 failed (reproduces)Edit: ledger/tax.pyWrite: tests/test_tax_properties.pyBash: pytest -q — 41 passed
Connections
- [[ledger-api]]
- [[Decimal]]
- [[Hypothesis]]
- [[BankersRounding]]