Skip to content

Keep the currency of an amount written as money text - #68

Merged
jimhoyd merged 1 commit into
mainfrom
claude/project-thread-68irj3
Oct 8, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/project-thread-68irj3

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

What this changes

Before: an event's amount: €12 was totalled as 12 USD, and amount: 99.50 EUR was left out of the ledger altogether. Only a bare number with a separate currency: field worked. Record prices handled money text, but $1,899 with priceCurrency: AUD was read as USD.

After: event amounts and record prices follow one rule, the new moneyIn in src/core/util.ts:

  • A code written with the number (99.50 EUR) wins.
  • A sign gives way to the document's currency or priceCurrency, so $20 with currency: CAD is 20 CAD.
  • With no currency field, € is EUR, £ GBP, ¥ JPY and $ USD.
  • A bare number takes the currency field, else USD.

Totals stay per currency and are never converted, as before.

Why

Jimmy asked whether GitRoll handles different currencies. Checking showed that money text in amount lost its currency.

How it was tested

  • make check passes (typecheck, tests, build, @gitroll/core build, audit): 415 pass, 0 fail, 1 skipped (the CI-only browser presence check), 0 vulnerabilities.
  • Tests added or updated for every behavior change: a new test in test/ledger.test.ts covers €, £, ¥, a trailing code, a code against a currency field, $ with currency: CAD, bare numbers, priceCurrency: AUD, and a ledger total of two EUR amounts.

Anything a reviewer should look at closely

Format of files in a Roll: SPEC.md's event field table now describes money text in amount and how currency interacts with it. GitRoll itself still writes amount as a number plus currency, so existing Rolls read as before, except for hand-written money text, which was misread until now.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XCVQuXXVJBEB4WExAcfQfD


Generated by Claude Code

amount: €12 was read as 12 USD and amount: 99.50 EUR was dropped. Event
amounts and record prices now share one rule (moneyIn): a code with the
number wins, a sign gives way to a named currency, otherwise the sign's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XCVQuXXVJBEB4WExAcfQfD
@jimhoyd
jimhoyd merged commit ce6ce0a into main Oct 8, 2026
13 checks passed
@jimhoyd
jimhoyd deleted the claude/project-thread-68irj3 branch October 8, 2026 01:20
@jimhoyd jimhoyd mentioned this pull request Oct 8, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants