Skip to content

fix(dashboard): there is no default currency - #327

Open
modernitconsultants wants to merge 1 commit into
TelivityAI:mainfrom
modernitconsultants:fix/dashboard-no-default-currency
Open

fix(dashboard): there is no default currency#327
modernitconsultants wants to merge 1 commit into
TelivityAI:mainfrom
modernitconsultants:fix/dashboard-no-default-currency

Conversation

@modernitconsultants

Copy link
Copy Markdown
Contributor

Follow-up to #301, which fixed the formatting and left the fallback.

lib/money.ts explains, correctly and at length, why a hardcoded currency symbol is wrong for a property trading in anything but dollars — and then exports DEFAULT_CURRENCY = 'USD' two lines later and falls back to it whenever a record carries no code. The comment describing the bug sits directly above the bug.

The consequence isn't cosmetic: on a JPY property a missing code renders a real ¥151,110 balance as a dollar figure with two minor units. Authoritative-looking, and materially wrong, on a live ledger.

There is now no fallback

An absent code renders the number plainly — grouped, unsymbolled. That's honest about what's known and odd enough that someone asks. A symbol we invented is worse than no symbol precisely because it looks decided.

PropertyContext returns null rather than substituting, including in portfolio mode, where properties may genuinely differ and null is the answer.

The more serious half, which removing the default surfaced

Six pages POST the context currency into request bodies. The old default could create a deposit, an AR ledger or a rate plan denominated in USD against a yen property — a wrong record, with no error anywhere.

requireCurrency() guards those writes, following the existing requirePropertyId idiom. Applied only to mutations that actually send a currency: guarding every mutation beside a requirePropertyId would block unrelated actions like a room move, and the bulk-import parser has its own local currencyCode from the pasted rows.

Specs assert behaviour, not glyphs

ICU renders JPY as ¥ in some versions and JP¥ in others. Pinning the symbol would fail on a runner upgrade while saying nothing about the defect. What's pinned: a missing code never yields a dollar sign, JPY carries no decimal part, an absent amount is an em dash and a zero balance is not, and a bad code degrades to a number instead of throwing a page away.

lib/money.ts explained, correctly and at length, why a hardcoded currency
symbol is wrong for a property trading in anything but dollars — and then
exported DEFAULT_CURRENCY = 'USD' two lines later and fell back to it whenever a
record carried no code. The comment describing the bug sat directly above it.

The consequence is not cosmetic. On a JPY property a missing code renders a real
¥151,110 balance as a dollar figure with two minor units: authoritative-looking
and materially wrong, on a live ledger.

There is now no fallback. An absent code renders the number plainly — grouped,
unsymbolled — which is honest about what is known and odd enough that someone
asks. A symbol we invented is worse than no symbol precisely because it looks
decided. PropertyContext returns null rather than substituting, including in
portfolio mode, where properties may genuinely differ and null IS the answer.

That surfaced the more serious half: six pages POST the context currency into
request bodies, so the old default could create a deposit, an AR ledger or a
rate plan denominated in USD against a yen property — a wrong record, with no
error anywhere. requireCurrency() guards those writes, following the existing
requirePropertyId idiom. Applied only to mutations that actually send a
currency: guarding every mutation beside a propertyId assert would block
unrelated actions like a room move, and the bulk-import parser has its own local
currencyCode from the pasted rows.

Specs assert behaviour, not glyphs — ICU renders JPY as ¥ in some versions and
JP¥ in others, and pinning the symbol would fail on a runner upgrade while
saying nothing about the defect.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant