Fix cent-rounding drift on imported statements

pocket-ledger · Claude · branch fix/rounding · claude-opus-5 · cwd /home/user/code/pocket-ledger · id f62969e4-7cfc-40c1-2efb-5b61bdad2f36 · 2026-05-25 18:43 · 2 msgs · 11 tools · 1 min read · updated 3 months ago

Repeated float rounding was losing a cent per few hundred rows; switched to integer minor units.

tools: Read, Edit, Bash
← pocket-ledger Download .md
cd /home/user/code/pocket-ledger && claude --resume f62969e4-7cfc-40c1-2efb-5b61bdad2f36Resume may fail — session is older than Claude Code's ~30-day transcript retention window.
Tool calls
Edit Edit: 6 calls (54.5%) 6 Read Read: 3 calls (27.3%) 3 Bash Bash: 2 calls (18.2%) 2
Token usage6.1K total
Input5.0K
Cache creation0
Cache read0
Output1.0K
Cache hit ratio0%· cold cache

Repeated float rounding was losing a cent per few hundred rows; switched to integer minor units.

Conversation

Turn 1 — User

Imported totals are off by a few cents against the statement.

Turn 2 — Assistant

Amounts were parsed to floats and rounded per row, so the error accumulated. I switched the internal representation to integer minor units and round once at the presentation edge.

Added a regression test with a fixture that reproduced the drift — it was off by four cents over six hundred rows before the change and exact after.

Turn 3 — User

Any migration needed for existing data?

Turn 4 — Assistant

No. Stored values are re-parsed from the original statements on import, so the fix applies on the next run without touching anything already saved.

Subjects

  • [[Python]]
  • [[pytest]]
  • [[Data Import]]

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