{
  "id": "ledger-api/fix-rounding-in-tax-calculation",
  "slug": "fix-rounding-in-tax-calculation",
  "title": "Session: fix-rounding-in-tax-calculation — 2026-10-06",
  "type": "source",
  "project": "ledger-api",
  "date": "2026-10-06",
  "started": "2026-10-06T10:30:00+00:00",
  "ended": "2026-10-06T11:42:00+00:00",
  "model": "claude-opus-4-7",
  "cwd": "/home/dev/code/ledger-api",
  "git_branch": "fix/tax-rounding",
  "permission_mode": "default",
  "user_messages": 1,
  "tool_calls": 4,
  "tools_used": [
    "Bash",
    "Edit",
    "Write"
  ],
  "is_subagent": false,
  "wikilinks_out": [
    "BankersRounding",
    "Decimal",
    "Hypothesis",
    "ledger-api"
  ],
  "body_text": "Project: ledger-api · Branch: fix/tax-rounding · Mode: default · Model: claude-opus-4-7\n\nSummary\n\nTracked 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.\n\nConversation\n\nTurn 1 — User\n\nCustomers report invoices off by one cent vs the PDF.\n\nTurn 1 — Assistant\n\nRoot 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.\n\nTools used in this turn:\n\n- Bash: pytest -k tax -q — 1 failed (reproduces)\n- Edit: ledger/tax.py\n- Write: tests/test_tax_properties.py\n- Bash: pytest -q — 41 passed\n\nConnections\n\n- ledger-api\n- Decimal\n- Hypothesis\n- BankersRounding",
  "sha256": "3e75c00c96d0b472",
  "source_url": "sessions/ledger-api/2026-10-06-fix-rounding-in-tax-calculation.html"
}