Skip to content

🤖 Store amounts of every currency with two implied decimals (upstream #8858) #8

Closed

Description

@rapastranac

🤖 Tracks the upstream fix we'll propose for actualbudget#8858 ("KRW/JPY amounts inflated 100×"). The work is on branch 8858-store-every-currency-at-two-decimals in a local upstream checkout; nothing is pushed or opened upstream yet.

Problem

  • With the experimental currency feature and a currency without decimals (JPY, KRW, IRR), upstream mixes two scales:
    • ×100: the transaction register, mobile entry, imports, bank sync, rule formulas, CSV export and the API.
    • ×1: the shared formatting hook useFormat and everything built on it (balances, totals, budget cells, reports, schedules, rules, filters, reconcile), plus the budget templates and the goal editors.
  • With JPY as the default, two ¥1,500 payments are stored as -150000 each, but the balance shows -¥300,000. Switching the default between USD and JPY multiplies or divides every balance by 100.
  • Maintainer youngcw on KRW/JPY amounts inflated 100× and register shows phantom decimals — decimalPlaces:0 not honoured outside balance views actualbudget/actual#8858: "All numbers are stored in the db as integers, aka *100. That is expected."

Resolved by the fix

  • One rule: every amount is stored ×100, whatever the currency. A currency's decimals only decide how many digits are shown. The rule is named STORED_DECIMAL_PLACES in shared/util.ts.
  • Balances and inputs: useFormat now displays and reads amounts at ×100. This covers balances, totals, budget cells, hold/transfer/cover, rules, schedules, filters, reconcile and reports. JPY balances show -¥3,000 instead of -¥300,000, and a ¥1,500 typed into a budget cell is stored as 150000.
  • Typed digits: the desktop amount input (AmountInput) and the mobile one (FocusableAmountInput) take typed digits as whole units for currencies without decimals.
  • Templates and goals: the goal editors, the server budget templates (category-template-context.ts, schedule-template.ts), formula cards and budget movement notes use the ×100 scale. The template code no longer reads the currency at all, so that plumbing was removed.
  • Helpers: removed amountToCurrencyInteger, which had no callers and encoded the opposite rule. integerToCurrencyWithDecimal(…, code) divides by 100 and shows the currency's digits.
  • Docs: the API docs say amounts are always value * 100; a Bugfix release note is added.
  • Tests:
    • new useFormat tests (USD, JPY, and JPY with decimals hidden);
    • JPY template tests updated to ×100;
    • a JPY movement-notes test;
    • updated util tests.

Not changed, on purpose

  • No data migration. Amounts typed into budget cells, goals or rules in a 0-decimal currency before the fix need to be re-entered (said in the release note).
  • Fractions are kept as typed; only the display rounds.
  • Untouched: the sync-server and the paths that already use ×100.
  • Register rows still show two decimals for JPY unless "hide decimals" is on. Picking JPY in Settings turns it on, so this is a possible follow-up only.

Verification

  • Format, lint and typecheck pass.
  • Focused tests: 262 (core) and 27 (web).
  • Full suites: web 1,386 passed. Core 1,341 passed; the only 2 failures are the known Windows EBUSY ones in main.test.ts.
  • In the app, with JPY as the default:
    • the balance shows -¥3,000 (was -¥300,000);
    • a budget cell typed as 1500 is stored as 150000 and shown as ¥1,500.

Related

Next

AI disclosure: drafted with Claude Code for @rapastranac.

Activity

  1. self-assigned this
    on Oct 24, 2026
  2. added
    bug
    on Oct 24, 2026
  3. rapastranac commented on Oct 27, 2026

    @rapastranac
    OwnerAuthor

    This has been merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions