Skip to content

hotfix(currency): disable switcher + reset non-UAH prefs (data mislabelling)#631

Merged
barach6662001-bit merged 1 commit intomainfrom
hotfix/disable-currency-switcher
Apr 24, 2026
Merged

hotfix(currency): disable switcher + reset non-UAH prefs (data mislabelling)#631
barach6662001-bit merged 1 commit intomainfrom
hotfix/disable-currency-switcher

Conversation

@barach6662001-bit
Copy link
Copy Markdown
Owner

Why (urgent)

Regression discovered after PRs #613 and #628 shipped: the display hook changes the currency label but does not apply an exchange rate. On /expenses with user currency = USD the rows show 1000.00 USD and the total shows 1 000,00 грн, i.e. the same UAH value is rendered with inconsistent labels and no numeric conversion.

Input forms also store values verbatim as UAH, so a user typing 1000 while USD is selected would corrupt the record.

What this hotfix does (no feature work — display only fix)

  1. Profile currency <Select/> is disabled and wrapped in a <Tooltip/> "Валютна конвертація в розробці, буде доступна найближчим часом".
  2. currencyStore.load() — if the backend returns a non-UAH preference, we silently call updatePreferences('UAH') to reset it server-side. This clears the mislabelling for users who had already switched to USD/EUR.
  3. currencyStore.setPreferredCurrency() is hard-forced to UAH regardless of argument, as a belt-and-braces guard.
  4. New i18n key profile.currencyDisabledTooltip (UK + EN).

What this hotfix does NOT do

  • No new rates endpoint, <Money/> component, or input-side conversion — those are the follow-up PR.
  • No data migration in the DB; the next backend load per user triggers the server-side reset (pragmatic + idempotent).

Verification

  • npx tsc --noEmit → pass.
  • Existing users with USD/EUR preference get auto-reset on next login.
  • New users default to UAH (unchanged).

Please squash-merge. Follow-up PR with real conversion, <Money/> component, input lock to ₴, and Playwright tests is blocked on this.

…to prevent data mislabelling

PR #613 + #628 shipped a conversion layer that changes the currency LABEL
but never multiplies by an exchange rate, so a value saved as 1000 UAH
renders as '1000 USD' on the expenses page, which is a correctness bug
and a potential data-integrity hazard once input-side conversion lands.

Until the conversion layer is rebuilt:
- Profile currency Select is disabled with a tooltip "Валютна конвертація
  в розробці, буде доступна найближчим часом".
- On every currency-store `load()`, if the backend returned a preference
  other than UAH, we silently call updatePreferences('UAH') so stale
  USD/EUR settings do not keep mislabelling values on return visits.
- setPreferredCurrency is hard-forced to UAH regardless of the argument,
  so any code path still invoking it cannot re-introduce a non-UAH state.
@barach6662001-bit barach6662001-bit merged commit 0323154 into main Apr 24, 2026
3 checks passed
@barach6662001-bit barach6662001-bit deleted the hotfix/disable-currency-switcher branch April 24, 2026 13:47
barach6662001-bit added a commit that referenced this pull request Apr 24, 2026
… input lock, switcher re-enable (#634)

* feat(currency): rewrite useFormatCurrency with real rate conversion + <Money/> SSOT

- hook signature: (amountUah, date?|options?) => string, divides by rateToUah
- null/undefined/NaN -> '—', UAH passthrough, warn-once on empty rates
- <Money/> single source of truth with nullText, tabular, perUnit props
- 7/7 unit tests covering UAH, USD/EUR conversion, fallback, null, zero

* feat(currency): lock all amount inputs to UAH (Variant B) + migrate CostRecords render via <Money/>

- hardcode addonAfter='₴' on all amount/price InputNumber (13 files)
- CostRecords table: column render + totals now use <Money/> (fixes the original
  '1000.00 USD' row vs '1 000,00 грн' total regression from PR #628)
- i18n: add common.storedInUah ('Сума зберігається в гривнях' / 'Amount is stored in hryvnia')
- Statistic displays keep dynamic suffix — they track user currency preference

* test(currency): add Playwright E2E test for currency consistency + input lock

* feat(currency): re-enable currency switcher after conversion layer v2 lands

Reverts the PR #631 hotfix guards now that conversion math is implemented and
unit-tested:
- currencyStore.load() honors server's preferredCurrency (no force-UAH reset)
- setPreferredCurrency(c) actually persists the chosen currency
- ProfilePage: remove disabled attr and tooltip wrapper from the Select
- users who previously had USD/EUR can opt back in

* docs: update ROADMAP with PR #631 hotfix + conversion v2 status
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