Session: fix-rounding-in-tax-calculation — 2026-10-06

ledger-api · Claude · branch fix/tax-rounding · claude-opus-4-7 · 2026-10-06 10:30 · 1 msgs · 4 tools · 1 min read · updated 4 weeks ago

tools: Bash, Edit, Write
← ledger-api Download .md .txt .json
Tool calls
Bash Bash: 2 calls (50.0%) 2 Edit Edit: 1 call (25.0%) 1 Write Write: 1 call (25.0%) 1
Token usage67.2K total
Input7.2K
Cache creation14.4K
Cache read43.2K
Output2.4K
Cache hit ratio67%· warming up

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.py
  • Write: tests/test_tax_properties.py
  • Bash: pytest -q — 41 passed

Connections

  • [[ledger-api]]
  • [[Decimal]]
  • [[Hypothesis]]
  • [[BankersRounding]]

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date