Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Changed dashboard money fields to follow the admin's own number format
Damian Legawiec3525c0044007
diff --git a/.changeset/money-in-the-admins-number-format.md b/.changeset/money-in-the-admins-number-format.mdnew file mode 100644index 0000000000..98e0940550--- /dev/null+++ b/.changeset/money-in-the-admins-number-format.md@@ -0,0 +1,6 @@+---+"@spree/dashboard": patch+"@spree/dashboard-core": patch+---++Money fields are now shown and read in the number format of the person using the dashboard, whatever the currency or market: an admin whose dashboard is in German types `1.234,56` for dollars and euros alike. Previously the format followed the currency's market, which was ambiguous when two markets shared a currency. `useFormCurrencyLocale` and the panel client's `markets` entry are removed; use `useMoneyLocale()`.diff --git a/CLAUDE.md b/CLAUDE.mdindex 8a7624d9a0..376e2892d0 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -510,6 +510,7 @@ Money is never a float — not in Ruby, not in TypeScript (see `docs/plans/6.0-m- Round with `Spree::Money::Rounding.to_currency(amount, currency)` (the currency's ISO 4217 exponent from `spree/core/config/currency_exponents.json`), never `.round(2)`; split in minor units with `to_minor_units` / `from_minor_units`, never `* 100` / `/ 100`. Round only when persisting, calling a gateway, or serializing — not in intermediate math.- Read an amount from an API request with `Spree::Money::Rounding.parse_canonical(value, currency)`: canonical decimal strings only (`"1234.56"`), no locale parsing on the server. `Spree::LocalizedNumber` is deprecated; never add a model setter that re-parses numbers.- Write amounts out with `Spree::Money::Rounding.format(amount, currency)`.+- In the dashboards, show and read money in the admin's own number format: `useMoneyLocale()` with `currencyParts` / `normalizeMoneyInput`, never a market's locale.- A third party that needs a JSON number gets `.to_f` once, on the line that hands it over, with a comment saying why.### Time zonesdiff --git a/docs/api-reference/admin-api/monetary-amounts.mdx b/docs/api-reference/admin-api/monetary-amounts.mdxindex d89daeeb03..49d7b51195 100644--- a/docs/api-reference/admin-api/monetary-amounts.mdx+++ b/docs/api-reference/admin-api/monetary-amounts.mdx@@ -46,7 +46,7 @@ JSON numbers are also accepted (`"amount": 29.99`), but strings are recommended:Amounts are **canonical**: a period decimal separator and no thousands grouping (`"1234.56"`), independent of any locale. The Admin API does **not** parse locale-specific formats — do not send `"1.234,56"` or `"1,234.56"`.-If you are taking input from a merchant in a localized format, normalize it to canonical form **before** sending. The Spree dashboard does this in the browser: a EUR price typed as `1.234,56` becomes `1234.56` on the wire. This matches how other commerce APIs handle money (canonical decimal or minor-unit integers; localization is a presentation concern).+If you are taking input from a merchant in a localized format, normalize it to canonical form **before** sending. The Spree dashboard does this in the browser, in the number format of the person using it: an admin who writes German types `1.234,56`, in any currency, and `1234.56` goes on the wire. This matches how other commerce APIs handle money (canonical decimal or minor-unit integers; localization is a presentation concern).## Affected typesdiff --git a/docs/changelog.mdx b/docs/changelog.mdxindex 6ff68bc93d..8ff443af63 100644--- a/docs/changelog.mdx+++ b/docs/changelog.mdx@@ -20,6 +20,8 @@ Keep up with the latest features and improvements in Spree Commerce!Taxes and discounts in yen are now rounded to whole yen, and partial captures in yen are recorded at their real amount.+ The dashboard now shows and reads amounts in your own number format, whatever the currency: if your dashboard is in German you type `1.234,56` for dollars and euros alike.+If you edited prices in such a store before this update, check them.**Learn more:** [Upgrade guide](/developer/upgrades/5.6-to-6.0#money)diff --git a/docs/plans/5.5-client-side-money-normalization.md b/docs/plans/5.5-client-side-money-normalization.mdindex 27be30f5ee..fd18f17913 100644--- a/docs/plans/5.5-client-side-money-normalization.md+++ b/docs/plans/5.5-client-side-money-normalization.md@@ -47,7 +47,7 @@ Consequences (binding):## Key Decisions (do not deviate without discussion)- **Admin API money contract is canonical decimal strings.** Read and write: `"19.99"` — period decimal, no thousands separator, matching what serializers already emit (see `docs/api-reference/admin-api/monetary-amounts.mdx`). This is already the *read* format; this plan makes it the explicit *write* format too.-- **The React dashboard normalizes localized input → canonical before sending.** A shared util parses the merchant's input in the active display locale (currency's market locale) and emits `"1234.56"`. Built on `Intl.NumberFormat(...).formatToParts` to derive the locale's separators, then strip grouping and standardize the decimal to `.`.+- **Superseded 2026-10-09 (`6.0-money-correctness.md`): the display locale is the admin's own dashboard language, not the currency's market locale.** Original decision: **The React dashboard normalizes localized input → canonical before sending.** A shared util parses the merchant's input in the active display locale (currency's market locale) and emits `"1234.56"`. Built on `Intl.NumberFormat(...).formatToParts` to derive the locale's separators, then strip grouping and standardize the decimal to `.`.- **No `x-spree-locale` is sent to drive money parsing.** Revert the per-form locale overrides AND the client-level admin-sdk locale support added on the feature branch. The admin-sdk has no `setLocale`/`setCurrency`/`AdminClientConfig.locale` (see "Two independent locales" above) — deliberate per-locale/per-currency calls use the generic per-request `options.locale`/`options.currency`.- **Superseded 2026-10-09 (`6.0-money-correctness.md`): the locale-parsing setters are removed and `LocalizedNumber` is deprecated, because the legacy admin is gone and the setters corrupted canonical input in comma-decimal stores.** Original decision: **`Spree::LocalizedNumber.parse` is NOT removed and NOT changed.** It remains the parser for the legacy Rails admin and any other locale-formatted caller. Because canonical `"19.99"` is locale-invariant, no model/controller change is required for the dashboard pivot.- **Rails admin (legacy `spree/admin`) is out of scope.** It keeps submitting locale-formatted values parsed server-side under the session locale. Untouched.diff --git a/docs/plans/6.0-money-correctness.md b/docs/plans/6.0-money-correctness.mdindex df189bb4b4..56c5f2b3cf 100644--- a/docs/plans/6.0-money-correctness.md+++ b/docs/plans/6.0-money-correctness.md@@ -31,6 +31,7 @@ All decided 2026-10-08; the ones marked *review* were changed or added after the- **The rule lives in `CLAUDE.md`, not in a lint tool** (decided 2026-10-09; supersedes the first pass's RuboCop cop and Biome twin). A cop was built and then dropped: the repository runs no RuboCop, and a name-matching rule needs an allowlist that is mostly noise. `CLAUDE.md` "Money" states it for people and agents alike.- **Open carts in zero- and three-decimal currencies change on their next recalculation.** Accepted trade-off: a yen total can move by under one yen mid-checkout. Completed orders are frozen and do not change.- **Spree stops parsing numbers by locale** (decided 2026-10-09; supersedes the 5.5 plan's "`LocalizedNumber` is not removed" and this plan's first-pass "out of scope"). The model setters that re-parsed strings with `Spree::LocalizedNumber` under the request locale are removed, and Rails' decimal type reads the value as sent. Why: the legacy admin they served is gone, and under a store whose language writes a comma decimal they misread the dashboard's canonical `"49.50"` as 4950 and grew an untouched `"99.0"` tenfold on every save (a reported bug). `Spree::LocalizedNumber.parse` stays one release as a deprecated method nothing in Spree calls, and is removed in 6.1. The variant's `cost_price`/`weight`/`width`/`height`/`depth` writers keep ignoring a blank value. Ships in PR A.+- **The dashboard shows and reads money in the admin's own number format** (decided 2026-10-09, following Shopify; supersedes the 5.5 plan's "currency's market locale"). `useMoneyLocale()` returns the dashboard language; every money field formats and normalizes through it, whatever the currency or market. Why: a store can have several markets with one currency and different conventions (EUR in Germany and Ireland), so the market-based format depended on which market loaded first; the person typing knows their own convention, and the old reason against it, server re-parsing, is gone. Accepted trade-off: a German-speaking admin of a US store sees `1234,56` for dollars. Ships in PR A.- **PR A applies the ISO table to Spree's own rounding only; registering it over the Money gem moves to A2** (decided 2026-10-09). Registering changes `Money#cents` for HUF, which Stripe payment sessions read, and A2 is the only PR that may change what a gateway receives.## Design Details@@ -170,7 +171,7 @@ None changes a stored value of an existing two-decimal order.**PR A — floats out.** No wire, schema or gateway-interface change.1. Add `currency_exponents.json` and read it in `Spree::Money::Rounding`; add `parse_canonical`, `parse_canonical_decimal`, `format`, `format_decimal`, and a `mode:` parameter on `to_currency`.2. Fix every **money** row of the Ruby inventory and the hard-coded hundredths. Capture events record `hundredths / 100` in BigDecimal.-3. Remove the locale-parsing model setters and deprecate `Spree::LocalizedNumber`.+3. Remove the locale-parsing model setters and deprecate `Spree::LocalizedNumber`; the dashboard formats money in the admin's own language (`useMoneyLocale`), with end-to-end tests for English and German admins and for a store whose market writes a comma decimal.4. Add `spree:money:audit_capture_events` (report only).5. Add the "Money" rule to `CLAUDE.md`.6. Rounding conformance specs that do not depend on column width.diff --git a/docs/plans/decisions.md b/docs/plans/decisions.mdindex 3154c410de..67cb26e670 100644--- a/docs/plans/decisions.md+++ b/docs/plans/decisions.md@@ -2,7 +2,7 @@**Context:** Price, variant, payment, refund, store credit, gift card and adjustment setters re-parsed every string with `Spree::LocalizedNumber` under the request's locale, for the legacy Rails admin. That admin is gone. In a store whose language writes a comma decimal (nl, de, fr) the setters read the dashboard's canonical `"49.50"` as 4950, and an untouched `"99.0"` grew tenfold on every save.-**Decision:** The locale-parsing setters are removed; Rails' decimal type stores the value as sent. `Spree::LocalizedNumber.parse` is deprecated with a warning and removed in 6.1. Clients normalize localized input before sending (5.5 plan).+**Decision:** The locale-parsing setters are removed; Rails' decimal type stores the value as sent. `Spree::LocalizedNumber.parse` is deprecated with a warning and removed in 6.1. Clients normalize localized input before sending (5.5 plan). The dashboard shows and reads money in the admin's own dashboard language, whatever the currency or market (as Shopify does), instead of the currency's market locale, which was ambiguous when markets share a currency.**Consequences:** A localized string sent to a model (`"1.234,56"`) is no longer understood; the Admin API never accepted it by contract. Supersedes the 5.5 plan's "`LocalizedNumber.parse` is NOT removed". See `6.0-money-correctness.md`.diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.tsindex 11024c23f1..b268650fec 100644--- a/packages/dashboard-core/src/api-client.ts+++ b/packages/dashboard-core/src/api-client.ts@@ -304,16 +304,6 @@ export interface PanelApiClient {tags?: {list(params?: Record<string, unknown>): Promise<{ data: Array<{ name: string }> }>}- /**- * Currency-to-locale pairs, which is what tells a money field whether- * `34,56` is thirty-four and a half or three thousand. The operator's- * markets answer it; a panel that registers none falls back to the UI- * language, the same answer the operator's hook gives for an unmatched- * currency.- */- markets?: {- list(params?: Record<string, unknown>): Promise<{ data: PanelMarket[] }>- }}export interface PanelDeliveryProfile extends PanelNamedRecord {@@ -481,13 +471,6 @@ export interface PanelImportCompleteMappingParams {mappings?: Array<{ schema_field: string; file_column: string | null }>}-/** A market, as the money fields read it. */-export interface PanelMarket {- id: string- currency?: string | null- default_locale?: string | null-}-/*** What either panel sends to queue an export.*diff --git a/packages/dashboard-core/src/index.ts b/packages/dashboard-core/src/index.tsindex 85e9312fa7..c2b5219cf1 100644--- a/packages/dashboard-core/src/index.ts+++ b/packages/dashboard-core/src/index.ts@@ -126,6 +126,7 @@ export * from './products/product-form-cards'export * from './products/product-form-mapping'export * from './products/product-schema'export * from './products/product-types'+export * from './products/use-money-locale'export * from './products/use-product-form-data'export * from './products/variants-matrix'export * from './products/video-url'diff --git a/packages/dashboard-core/src/products/product-bulk-price-editor.tsx b/packages/dashboard-core/src/products/product-bulk-price-editor.tsxindex fcc1f78032..9112a8fab3 100644--- a/packages/dashboard-core/src/products/product-bulk-price-editor.tsx+++ b/packages/dashboard-core/src/products/product-bulk-price-editor.tsx@@ -6,10 +6,8 @@ import { useTranslation } from 'react-i18next'import { composeOptionsText } from '../products/variants-matrix'import { currencyParts } from './currency-parts'import { normalizeMoneyInput } from './normalize-money'-import {- useFormCurrencyLocale as useCurrencyLocale,- useFormOptionTypes as useOptionTypes,-} from './use-product-form-data'+import { useMoneyLocale } from './use-money-locale'+import { useFormOptionTypes as useOptionTypes } from './use-product-form-data'interface Props {// eslint-disable-next-line @typescript-eslint/no-explicit-any@@ -39,21 +37,13 @@ export function ProductBulkPriceEditor({ form, currency, productName }: Props) {const variants = useWatch({ control: form.control, name: 'variants' }) ?? []const { data: optionTypesData } = useOptionTypes()const optionTypes = useMemo(() => optionTypesData?.data ?? [], [optionTypesData])- const localeForCurrency = useCurrencyLocale()-- // Format the grid in the currency's market locale (e.g. EUR → `de`, comma- // decimal). The same locale normalizes the merchant's input back to canonical- // form on commit (see `handleChange`), so form state — like the API value it- // hydrates from — is ALWAYS canonical `"1234.56"`. Untouched prices therefore- // never get re-normalized on save.- //- // Fall back to `en` (canonical period-decimal), NOT the UI language: money- // formatting/parsing must never depend on the dashboard's language, or a USD- // value under a German UI would be parsed as `40.00` → 4000.- const marketLocale = localeForCurrency(currency) || 'en'+ // Shown and read in the person's own number format (see useMoneyLocale). Form+ // state, like the API value it hydrates from, is always canonical "1234.56",+ // so an untouched price is never re-read on save.+ const moneyLocale = useMoneyLocale()const { symbol, decimal } = useMemo(- () => currencyParts(currency, marketLocale),- [currency, marketLocale],+ () => currencyParts(currency, moneyLocale),+ [currency, moneyLocale],)// Project the form's variants into BulkPriceRow[] for the picked currency.@@ -95,7 +85,7 @@ export function ProductBulkPriceEditor({ form, currency, productName }: Props) {// whitespace, OR malformed input (normalizes to `''`) all mean "no value"// — never persist `''` as a real amount.const trimmed = next == null ? '' : next.trim()- const normalized = trimmed === '' ? '' : normalizeMoneyInput(trimmed, marketLocale)+ const normalized = trimmed === '' ? '' : normalizeMoneyInput(trimmed, moneyLocale)const raw = normalized === '' ? null : normalizedconst nextPrices: VariantPriceFormValues[] = [...current]@@ -132,7 +122,7 @@ export function ProductBulkPriceEditor({ form, currency, productName }: Props) {shouldDirty: true,})},- [form, currency, marketLocale],+ [form, currency, moneyLocale],)return (diff --git a/packages/dashboard-core/src/products/use-money-locale.ts b/packages/dashboard-core/src/products/use-money-locale.tsnew file mode 100644index 0000000000..1dd70cef83--- /dev/null+++ b/packages/dashboard-core/src/products/use-money-locale.ts@@ -0,0 +1,14 @@+import { useTranslation } from 'react-i18next'++/**+ * The locale money is shown and typed in: the dashboard language of the person+ * using it, whatever the currency or market. Someone who writes `1.234,56`+ * types that for dollars too, and the field reads it back the same way it+ * displayed it. The API only ever receives canonical `"1234.56"`.+ *+ * @returns a BCP 47 locale such as `de` or `en`+ */+export function useMoneyLocale(): string {+ const { i18n } = useTranslation()+ return i18n.language || 'en'+}diff --git a/packages/dashboard-core/src/products/use-product-form-data.ts b/packages/dashboard-core/src/products/use-product-form-data.tsindex c853b3950f..2a0c45d50c 100644--- a/packages/dashboard-core/src/products/use-product-form-data.ts+++ b/packages/dashboard-core/src/products/use-product-form-data.ts@@ -2,7 +2,6 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'import type {PanelCollection,PanelDeliveryProfile,- PanelMarket,PanelNamedRecord,PanelOptionType,PanelPackageType,@@ -244,30 +243,3 @@ export function collectionAutocompleteProps(queryKey: string) {getOptionLabel: (collection: PanelCollection) => collection.name ?? collection.id,}}--/**- * Resolves a currency to the locale its amounts are typed and shown in, so a- * EUR field accepts `1.234,56` and normalizes it to `1234.56`. Mirrors the- * operator dashboard's `useCurrencyLocale`, reading through the registered- * client so the shared price editor works in either panel; a panel with no- * markets answers undefined and callers fall back to the UI language.- */-export function useFormCurrencyLocale(): (currency: string | undefined) => string | undefined {- const client = getApiClient()-- const { data } = useQuery({- queryKey: useResourceKey('markets', 'panel-form'),- queryFn: async (): Promise<{ data: PanelMarket[] }> =>- (await client.markets?.list({ limit: 100 })) ?? { data: [] },- enabled: Boolean(client.markets),- staleTime: FIVE_MINUTES,- })-- const markets = data?.data ?? []-- return (currency) => {- if (!currency) return undefined-- return markets.find((market) => market.currency === currency)?.default_locale ?? undefined- }-}diff --git a/packages/dashboard/e2e/customers.spec.ts b/packages/dashboard/e2e/customers.spec.tsindex a9104a3ab7..5e99c665ec 100644--- a/packages/dashboard/e2e/customers.spec.ts+++ b/packages/dashboard/e2e/customers.spec.ts@@ -135,13 +135,11 @@ test.describe('customers', () => {await expect(page.getByText(/25\.00/).first()).toBeVisible({ timeout: 15_000 })})- // Store credits are multi-currency AND localized. Selecting EUR drives both- // the credit's currency and (via the EUR market's `de` locale) the amount's- // display/parse format. The amount is entered comma-decimal (`1.234,56` =- // 1234.56); the dashboard normalizes it to canonical form before sending, so- // it persists as 1234.56 and renders €1,234.56 (en display locale) — not the- // mangled 123456.- test('issues store credit in EUR with a localized (comma-decimal) amount', async ({ page }) => {+ // The amount is typed in the admin's own number format whatever the+ // currency: an English-speaking admin writes `1,234.56` for euros too. It is+ // normalized to canonical form before sending, so it persists as 1234.56 and+ // renders €1,234.56, not a mangled 1.23 or 123456.+ test('issues store credit in EUR typed in the admin’s own number format', async ({ page }) => {const creds = await login(page)await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)@@ -151,11 +149,9 @@ test.describe('customers', () => {await page.getByRole('button', { name: /issue store credit/i }).click()await expect(page.getByRole('heading', { name: /issue store credit/i })).toBeVisible()- // Switch to EUR first so the form's locale resolves before submit.await page.locator('#sc-currency').click()await page.getByRole('option', { name: /EUR/ }).click()- // German-formatted amount: dot thousands, comma decimal.- await page.locator('#sc-amount').fill('1.234,56')+ await page.locator('#sc-amount').fill('1,234.56')await page.locator('#sc-memo').fill('E2E EUR localized credit')await page@@ -163,18 +159,14 @@ test.describe('customers', () => {.getByRole('button', { name: /^issue store credit$/i }).click()- // Persisted as 1234.56 EUR (not 123456): renders €1,234.56 in the en display- // locale. The comma-decimal input round-tripped through client normalization.await expect(page.getByText(/€\s?1,234\.56/).first()).toBeVisible({ timeout: 15_000 })- // Guard against the mangled value (comma treated as thousands → 123456).await expect(page.getByText(/123,456/)).toHaveCount(0)})- // Regression: typing a USD-style `25.00`, THEN switching the currency to EUR- // must not re-read the `.` as a thousands separator on submit (→ 2500). The- // form reformats the amount to the new currency's locale on switch, so it- // persists as €25.00.- test('reformats the amount when the store-credit currency switches', async ({ page }) => {+ // Switching the currency after typing keeps the amount as typed: the format+ // follows the admin, not the currency, so `25.00` persists as €25.00, never+ // €2,500.00.+ test('keeps the amount when the store-credit currency switches', async ({ page }) => {const creds = await login(page)await gotoIndex(page, CUSTOMERS_PATH(creds.store_id), CTA)diff --git a/packages/dashboard/e2e/global-setup.ts b/packages/dashboard/e2e/global-setup.tsindex 6d8ffa712f..04c912d20b 100644--- a/packages/dashboard/e2e/global-setup.ts+++ b/packages/dashboard/e2e/global-setup.ts@@ -164,12 +164,16 @@ const BOOTSTRAP_RUBY = ['transfer_source.stock_levels.where(variant: inventory_product.default_variant).first_or_create!.update!(count_on_hand: 500)','inventory_level = transfer_destination.stock_levels.where(variant: inventory_product.default_variant).first_or_create!',`unless inventory_level.stock_reservations.exists?; inventory_cart = Spree::Cart.create!(store: s, currency: s.default_currency, email: '[email protected]'); inventory_line = inventory_cart.line_items.create!(variant: inventory_product.default_variant, quantity: ${FIXTURE_INVENTORY_RESERVED}); inventory_level.stock_reservations.create!(cart: inventory_cart, line_item: inventory_line, quantity: ${FIXTURE_INVENTORY_RESERVED}, expires_at: 10.years.from_now); end`,- // A store whose language writes a comma decimal (Dutch) and prices in EUR:- // the server reads every request in the store's language, so this is where- // a price is misread if anything parses money by locale. Its name sorts after- // the default store's, so signing in still opens the default store first.- `comma_store = Spree::Store.find_by(code: 'e2e-nl') || Spree::Store.create!(code: 'e2e-nl', name: 'Winkel', url: 'nl.example.com', mail_from_address: '[email protected]', default_currency: 'EUR', default_locale: 'nl')`,+ // A store whose market writes a comma decimal (Dutch) and prices in EUR: the+ // server reads every request in the market's language, so this is where a+ // price is misread if anything parses money by locale. Its name sorts after+ // the default store's, so signing in still opens the default store first, and+ // its dashboard stays in English so the specs' labels match.+ `comma_store = Spree::Store.find_by(code: 'e2e-nl') || Spree::Store.create!(code: 'e2e-nl', name: 'Winkel', url: 'nl.example.com', mail_from_address: '[email protected]', preferred_admin_locale: 'en')`,'Spree::Seeds::StoreResources.call(store: comma_store); Spree::Stores::ProvisionDefaults.call(store: comma_store, country: Spree::Country.find_by_iso!("NL"), locale: "nl", currency: "EUR") unless comma_store.stock_locations.exists?',+ // A second market in USD, so the store sells in a currency written with a+ // period as well as its own.+ `comma_store.markets.find_or_create_by!(name: 'United States') { |m| m.currency = 'USD'; m.default_locale = 'en'; m.countries = [Spree::Country.find_by_iso!('US')] } unless comma_store.markets.exists?(currency: 'USD')`,'comma_store.add_user(admin, Spree::Role.default_admin_role(comma_store)) unless comma_store.role_users.exists?(user: admin)','port = ENV.fetch("PORT", 3010)','puts JSON.generate(api_url: "http://localhost:#{port}", admin_email: admin.email, admin_password: "spree123", store_id: s.prefixed_id, store_name: s.name, comma_store_id: comma_store.prefixed_id)',diff --git a/packages/dashboard/e2e/helpers.ts b/packages/dashboard/e2e/helpers.tsindex ae074ed896..b558544fda 100644--- a/packages/dashboard/e2e/helpers.ts+++ b/packages/dashboard/e2e/helpers.ts@@ -205,7 +205,7 @@ export interface E2ECredentials {admin_password: stringstore_id: stringstore_name: string- /** A store whose language writes a comma decimal (nl) and prices in EUR. */+ /** A store whose market writes a comma decimal (nl) and prices in EUR. */comma_store_id: string}diff --git a/packages/dashboard/e2e/price-lists.spec.ts b/packages/dashboard/e2e/price-lists.spec.tsindex 967967c6c1..f1ee4b8bb5 100644--- a/packages/dashboard/e2e/price-lists.spec.ts+++ b/packages/dashboard/e2e/price-lists.spec.ts@@ -537,10 +537,9 @@ test.describe('price lists', () => {await dialog.getByRole('button', { name: /^save prices$/i }).click()await expect(dialog.getByText(/unsaved change/i)).toBeHidden({ timeout: 15_000 })- // Switch to EUR — the grid reloads with that currency's (empty) prices and- // formats in the EUR market locale (de: comma decimal). A period typed- // there is still a decimal point: `19.50` shows and saves as 19,50, never- // 1950.+ // Switch to EUR — the grid reloads with that currency's (empty) prices,+ // still in the admin's own (English) number format: `19.50` saves as+ // 19.50, never 1950.await currencyTrigger.click()await page.getByRole('option', { name: 'EUR' }).click()await expect(currencyTrigger).toContainText('EUR')@@ -548,27 +547,27 @@ test.describe('price lists', () => {await priceCell().dblclick()await priceCell().fill('19.50')await priceCell().press('Enter')- await expect(priceCell()).toHaveValue('19,50')+ await expect(priceCell()).toHaveValue('19.50')await dialog.getByRole('button', { name: /^save prices$/i }).click()await expect(dialog.getByText(/unsaved change/i)).toBeHidden({ timeout: 15_000 })- // Reload EUR from the server, then enter a localized amount `55,55`; it- // must persist as 55.55 (not 5555).+ // Reload EUR from the server, then enter `55,55`: a comma before two digits+ // cannot be grouping, so it is read as the decimal and persists as 55.55,+ // not 5555.await currencyTrigger.click()await page.getByRole('option', { name: 'USD' }).click()await expect(currencyTrigger).toContainText('USD')await currencyTrigger.click()await page.getByRole('option', { name: 'EUR' }).click()await expect(currencyTrigger).toContainText('EUR')- await expect(priceCell()).toHaveValue(/^19,50?$/, { timeout: 15_000 })+ await expect(priceCell()).toHaveValue(/^19\.50?$/, { timeout: 15_000 })await priceCell().dblclick()await priceCell().fill('55,55')await priceCell().press('Enter')await dialog.getByRole('button', { name: /^save prices$/i }).click()await expect(dialog.getByText(/unsaved change/i)).toBeHidden({ timeout: 15_000 })- // Round-trips as the comma-decimal `55,55`, proving locale-aware parsing.- await expect(priceCell()).toHaveValue('55,55')+ await expect(priceCell()).toHaveValue('55.55')// Switch back to USD — its value is independent of the EUR edit and shown// period-decimal.diff --git a/packages/dashboard/e2e/products-helpers.ts b/packages/dashboard/e2e/products-helpers.tsindex 4160ad2d10..2c4814b069 100644--- a/packages/dashboard/e2e/products-helpers.ts+++ b/packages/dashboard/e2e/products-helpers.ts@@ -109,7 +109,7 @@ export async function addOptionToVariants(* Title matches are exact to avoid catching "Categorization" when the caller* asked for "Categories" or similar prefix collisions.*/-function card(page: Page, title: RegExp): Locator {+export function card(page: Page, title: RegExp): Locator {return page.locator('[data-slot="card"]').filter({ has: page.locator('[data-slot="card-title"]', { hasText: title }) })diff --git a/packages/dashboard/e2e/products-prices-inventory.spec.ts b/packages/dashboard/e2e/products-prices-inventory.spec.tsindex e9544140b9..584a63b38d 100644--- a/packages/dashboard/e2e/products-prices-inventory.spec.ts+++ b/packages/dashboard/e2e/products-prices-inventory.spec.ts@@ -1,7 +1,11 @@+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'import { expect, type Locator, type Page, test } from '@playwright/test'-import { gotoIndex, login } from './helpers'+import { getCredentials, gotoIndex, login } from './helpers'+import { E2E_DIR } from './paths'import {addOptionToVariants,+ card,createProduct,inventoryCard,pricesCard,@@ -152,11 +156,10 @@ test.describe('product prices — single variant', () => {).toHaveValue('12')})- // Multi-currency + localized. The inline Prices card switches currency via- // its header selector; each currency's prices ride the SAME product PATCH.- // Enter a USD price (period) and a EUR price comma-decimal (`34,56`), save- // once, and confirm each round-trips in its own currency/locale — proving the- // per-currency client-side normalization in the batched product update.+ // Multi-currency. The inline Prices card switches currency via its header+ // selector; each currency's prices ride the SAME product PATCH. A USD price+ // with a period and a EUR price with a comma (`34,56`, a comma before two+ // digits being read as the decimal) both round-trip from one save.test('sets prices in two currencies (USD period + EUR comma) in one save', async ({ page }) => {const creds = await login(page)@@ -167,8 +170,7 @@ test.describe('product prices — single variant', () => {// USD default — period decimal.await fillGridCell(card.getByRole('textbox', { name: /^price for default$/i }), '12.50')- // Switch the Prices card to EUR; the grid formats in the EUR market locale- // (de: comma decimal). Enter `34,56` → must persist as 34.56.+ // Switch the Prices card to EUR. Enter `34,56` → must persist as 34.56.await card.getByRole('combobox').first().click()await page.getByRole('option', { name: 'EUR' }).click()await fillGridCell(card.getByRole('textbox', { name: /^price for default$/i }), '34,56')@@ -181,7 +183,7 @@ test.describe('product prices — single variant', () => {await page.reload()const reloaded = pricesCard(page)// EUR cell is shown after reload (card defaults back to USD); switch to EUR- // and confirm the comma-decimal value persisted as 34,56 (not 3456).+ // and confirm the comma-typed value persisted as 34.56 (not 3456).await reloaded.getByRole('combobox').first().click()await page.getByRole('option', { name: 'EUR' }).click()await expect(reloaded.getByRole('textbox', { name: /^price for default$/i })).toHaveValue(@@ -196,10 +198,9 @@ test.describe('product prices — single variant', () => {})// Regression: a save that includes an UNTOUCHED EUR price must not re-parse- // it. Form state holds the canonical API value (`34.56`); under the EUR- // market locale `.` is a thousands separator, so re-normalizing on save would- // mangle `34.56` → `3456`. Editing a non-price field must leave the EUR price- // intact.+ // it. Form state holds the canonical API value (`34.56`); re-normalizing it+ // on save under a comma-decimal format would mangle it to `3456`. Editing a+ // non-price field must leave the EUR price intact.test('preserves an untouched EUR price when saving an unrelated field', async ({ page }) => {const creds = await login(page)@@ -237,17 +238,40 @@ test.describe('product prices — single variant', () => {})// ----------------------------------------------------------------------------// Money entry — separators, currencies and the store's language+// Money entry — the person's own number format, any currency, any market// ----------------------------------------------------------------------------// Prices typed with either separator must persist exactly, in every currency,-// and saving the product again must leave them as they are. The API returns-// "49.5" for 49.50 until amounts are written to the currency's decimals, so the-// expectations allow the trailing zero to be missing; what they rule out is a-// separator read the wrong way (4950, 990).-test.describe('product prices — separators and currencies', () => {- function priceCell(card: Locator): Locator {- return card.getByRole('textbox', { name: /^price for default$/i })+// Prices are shown and typed in the number format of the person using the+// dashboard, whatever the currency or market, and saving the product again must+// leave them as they are. The API returns "49.5" for 49.50 until amounts are+// written to the currency's decimals, so the expectations allow the trailing+// zero to be missing; what they rule out is a separator read the wrong way.+test.describe('product prices — number format', () => {+ // The German labels the product page shows, read from the dashboard's own+ // translations so the spec follows them.+ const germanLocale = JSON.parse(+ readFileSync(resolve(E2E_DIR, '../../dashboard-core/src/locales/de.json'), 'utf-8'),+ ) as Record<string, unknown>+ const inGerman = (key: string): string =>+ key+ .split('.')+ .reduce<unknown>(+ (node, part) => (node as Record<string, unknown>)[part],+ germanLocale,+ ) as string+ const german = {+ prices: inGerman('admin.common.prices'),+ priceForDefault: new RegExp(+ `^${inGerman('admin.pages.products.price_lists.edit_prices.price_aria').replace(+ '{{label}}',+ inGerman('admin.pages.products.price_lists.edit_prices.variant_default'),+ )}$`,+ ),+ save: inGerman('admin.products.save_label'),+ }++ function priceCell(card: Locator, name: string | RegExp = /^price for default$/i): Locator {+ return card.getByRole('textbox', { name })}async function showCurrency(page: Page, card: Locator, currency: string): Promise<void> {@@ -255,11 +279,9 @@ test.describe('product prices — separators and currencies', () => {await page.getByRole('option', { name: currency }).click()}- async function saveProduct(page: Page): Promise<void> {- await page.getByRole('button', { name: /save product/i }).click()- await expect(page.getByRole('button', { name: /save product/i })).toBeDisabled({- timeout: 30_000,- })+ async function saveProduct(page: Page, label: string | RegExp = /save product/i): Promise<void> {+ await page.getByRole('button', { name: label }).click()+ await expect(page.getByRole('button', { name: label })).toBeDisabled({ timeout: 30_000 })}// Saves the product with only its name changed, the way a merchant saves it@@ -270,19 +292,18 @@ test.describe('product prices — separators and currencies', () => {await saveProduct(page)}- test('USD and EUR prices typed with either separator persist exactly and survive repeated saves', async ({+ test('an English-speaking admin types every currency with a period, and repeated saves keep it', async ({page,}) => {const creds = await login(page)- const productName = `E2E Separators ${Date.now()}`+ const productName = `E2E Period ${Date.now()}`await createProduct(page, creds.store_id, productName)const card = pricesCard(page)- // USD is shown in English: a comma groups thousands.await fillGridCell(priceCell(card), '1,234.56')- // EUR is shown in German: a period groups thousands, a comma is the decimal.+ // EUR's market writes German, but the person typing writes English.await showCurrency(page, card, 'EUR')- await fillGridCell(priceCell(card), '1.234,56')+ await fillGridCell(priceCell(card), '49.50')await saveProduct(page)await saveAgainUntouched(page, `${productName} (2)`)@@ -292,59 +313,102 @@ test.describe('product prices — separators and currencies', () => {const reloaded = pricesCard(page)await expect(priceCell(reloaded)).toHaveValue('1234.56')await showCurrency(page, reloaded, 'EUR')- await expect(priceCell(reloaded)).toHaveValue('1234,56')+ await expect(priceCell(reloaded)).toHaveValue(/^49\.50?$/)})- test('a EUR price typed with a comma, a period or no decimals persists exactly', async ({- page,- }) => {- const creds = await login(page)+ test.describe('in German', () => {+ let savedLocale: string | null = null++ async function authHeaders(page: Page) {+ const creds = getCredentials()+ const res = await page.request.post('/api/v3/admin/auth/login', {+ data: { email: creds.admin_email, password: creds.admin_password },+ })+ const { token } = (await res.json()) as { token: string }+ return { Authorization: `Bearer ${token}` }+ }++ // Switch the shared account and the browser together: when they disagree+ // the dashboard reloads mid-boot (see validation-messages.spec.ts).+ async function speakGerman(page: Page): Promise<void> {+ await page.addInitScript(() => localStorage.setItem('spree-admin-locale', 'de'))+ const headers = await authHeaders(page)+ const me = await page.request.get('/api/v3/admin/me', { headers })+ savedLocale = ((await me.json()) as { user: { selected_locale: string | null } }).user+ .selected_locale+ await page.request.patch('/api/v3/admin/me', { headers, data: { selected_locale: 'de' } })+ }++ test.afterEach(async ({ page }) => {+ const headers = await authHeaders(page)+ await page.request.patch('/api/v3/admin/me', {+ headers,+ data: { selected_locale: savedLocale },+ })+ })- for (const [typed, shown] of [- ['49,50', /^49,50?$/],- // A period before two digits cannot be grouping: it is the decimal.- ['19.50', /^19,50?$/],- ['99', /^99(,0+)?$/],- ] as const) {- const productName = `E2E EUR ${typed} ${Date.now()}`+ test('a German-speaking admin types every currency with a comma, and repeated saves keep it', async ({+ page,+ }) => {+ const creds = await login(page)+ const productName = `E2E Comma ${Date.now()}`await createProduct(page, creds.store_id, productName)- const card = pricesCard(page)- await showCurrency(page, card, 'EUR')- await fillGridCell(priceCell(card), typed)- await saveProduct(page)- await saveAgainUntouched(page, `${productName} (2)`)+ await speakGerman(page)+ await page.reload()++ const prices = germanPricesCard(page)+ // USD's market writes English, but the person typing writes German.+ await fillGridCell(priceCell(prices, german.priceForDefault), '1.234,56')+ await showCurrency(page, prices, 'EUR')+ await fillGridCell(priceCell(prices, german.priceForDefault), '49,50')+ await saveProduct(page, german.save)++ for (const round of [2, 3]) {+ await page.reload()+ await page.getByLabel(/^name$/i).fill(`${productName} (${round})`)+ await saveProduct(page, german.save)+ }await page.reload()- const reloaded = pricesCard(page)+ const reloaded = germanPricesCard(page)+ await expect(priceCell(reloaded, german.priceForDefault)).toHaveValue('1234,56')await showCurrency(page, reloaded, 'EUR')- await expect(priceCell(reloaded)).toHaveValue(shown)+ await expect(priceCell(reloaded, german.priceForDefault)).toHaveValue(/^49,50?$/)+ })++ function germanPricesCard(page: Page): Locator {+ return card(page, new RegExp(`^${german.prices}$`))}})- // The reported bug: in a store whose language writes a comma decimal, the- // server read "49.50" as 4950, and every save of an unchanged 99 added a zero.- test('a store whose language writes a comma decimal saves its prices exactly', async ({- page,- }) => {- const creds = await login(page)-- for (const [typed, shown] of [- ['49,50', /^49,50?$/],- ['99', /^99(,0+)?$/],- ['1.234,56', /^1234,56$/],- ] as const) {+ // The reported bug: in a store whose default market writes a comma decimal,+ // the server read "49.50" as 4950, and every save of an unchanged 99 added a+ // zero. The store also sells in USD through a second market.+ for (const [typed, shown] of [+ ['49.50', /^49\.50?$/],+ ['99', /^99(\.0+)?$/],+ ['1,234.56', /^1234\.56$/],+ ] as const) {+ test(`a store whose market writes a comma decimal saves ${typed} exactly`, async ({ page }) => {+ const creds = await login(page)const productName = `E2E Dutch ${typed} ${Date.now()}`await createProduct(page, creds.comma_store_id, productName)- await fillGridCell(priceCell(pricesCard(page)), typed)+ const card = pricesCard(page)+ await fillGridCell(priceCell(card), typed)+ await showCurrency(page, card, 'USD')+ await fillGridCell(priceCell(card), typed)await saveProduct(page)await saveAgainUntouched(page, `${productName} (2)`)await saveAgainUntouched(page, `${productName} (3)`)await page.reload()- await expect(priceCell(pricesCard(page))).toHaveValue(shown)- }- })+ const reloaded = pricesCard(page)+ await expect(priceCell(reloaded)).toHaveValue(shown)+ await showCurrency(page, reloaded, 'USD')+ await expect(priceCell(reloaded)).toHaveValue(shown)+ })+ }})// ---------------------------------------------------------------------------diff --git a/packages/dashboard/src/api-client-setup.ts b/packages/dashboard/src/api-client-setup.tsindex 5e37cffc04..2634829377 100644--- a/packages/dashboard/src/api-client-setup.ts+++ b/packages/dashboard/src/api-client-setup.ts@@ -80,7 +80,6 @@ setApiClient({},deleteProductMedia: (productId, mediaId) => adminClient.products.media.delete(productId, mediaId),mediaLibrary: { list: (params) => adminClient.media.list(params) },- markets: { list: (params) => adminClient.markets.list(params) },tags: {list: (params) => adminClient.tags.list(params as { taggable_type: string; q?: string }),},diff --git a/packages/dashboard/src/components/spree/bulk-price-editor/bulk-price-editor.tsx b/packages/dashboard/src/components/spree/bulk-price-editor/bulk-price-editor.tsxindex fe6c9dcc8e..bb2f08297c 100644--- a/packages/dashboard/src/components/spree/bulk-price-editor/bulk-price-editor.tsx+++ b/packages/dashboard/src/components/spree/bulk-price-editor/bulk-price-editor.tsx@@ -3,13 +3,13 @@ import {adminClient,currencyParts,normalizeMoneyInput,+ useMoneyLocale,useResourceKey,} from '@spree/dashboard-core'import { type BulkPriceRow, BulkPriceTable, toastManager } from '@spree/dashboard-ui'import { useQuery } from '@tanstack/react-query'import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'-import { useCurrencyLocale } from '../../../hooks/use-currency-locale'import { useBulkUpsertPrices } from '../../../hooks/use-prices'import { MAXIMUM_QUANTITY_TIERS } from '../../../schemas/price-list'@@ -141,7 +141,7 @@ export function BulkPriceEditor({// wrapper would put a fresh reference in every callback's dep array// and tank the parent via the `onStateChange` effect below.const { mutateAsync: bulkUpsertAsync, isPending: isSaving } = useBulkUpsertPrices(priceListId)- const localeForCurrency = useCurrencyLocale()+ const moneyLocale = useMoneyLocale()const [page, setPage] = useState(1)const [search, setSearch] = useState('')const deferredSearch = useDeferredValue(search)@@ -149,15 +149,12 @@ export function BulkPriceEditor({const sanitizedFilter = useMemo(() => sanitizeFilter(filter), [filter])const filterKey = useMemo(() => stableFilterKey(sanitizedFilter), [sanitizedFilter])- // Format the grid in the currency's market locale (e.g. EUR → `de`, comma- // decimal). The same locale normalizes each typed amount to canonical form as the- // cell commits (see `handleChange`), so the grid shows what Save sends. Falls- // back to `en` (canonical period-decimal), NOT the UI language — money- // formatting/parsing must never depend on the dashboard's language.- const marketLocale = localeForCurrency(currency) || 'en'+ // The grid is shown in the person's own number format, and the same locale+ // normalizes each typed amount as the cell commits (see `handleChange`), so+ // the grid shows what Save sends.const { symbol, decimal } = useMemo(- () => currencyParts(currency, marketLocale),- [currency, marketLocale],+ () => currencyParts(currency, moneyLocale),+ [currency, moneyLocale],)const { data, isLoading } = useQuery({@@ -470,7 +467,7 @@ export function BulkPriceEditor({// Normalized on commit, from the currency's market locale, so an edit// holds the same canonical `"1234.56"` the API returns. The cell then// shows exactly what Save will send (docs/plans/5.5-client-side-money-normalization.md).- const canonical = normalizeMoneyInput(next, marketLocale) || null+ const canonical = normalizeMoneyInput(next, moneyLocale) || nullsetEdits((prev) => {// A draft rung has no stored row, so it is found by its own id.@@ -510,7 +507,7 @@ export function BulkPriceEditor({return out})},- [baselineRows, marketLocale, promoteBlankRow],+ [baselineRows, moneyLocale, promoteBlankRow],)// The plus on the blank row does the same thing a keystroke does — it isdiff --git a/packages/dashboard/src/components/spree/customers/customer-lifetime-stats-card.tsx b/packages/dashboard/src/components/spree/customers/customer-lifetime-stats-card.tsxindex 7d61844d22..030dfe0583 100644--- a/packages/dashboard/src/components/spree/customers/customer-lifetime-stats-card.tsx+++ b/packages/dashboard/src/components/spree/customers/customer-lifetime-stats-card.tsx@@ -3,13 +3,11 @@ import { useStore } from '@spree/dashboard-core'import { Card, CardContent, RelativeTime } from '@spree/dashboard-ui'import type { ReactNode } from 'react'import { useTranslation } from 'react-i18next'-import { useCurrencyLocale } from '../../../hooks/use-currency-locale'import { formatAmount } from '../../../lib/delivery-method-summary'export function CustomerLifetimeStatsCard({ customer }: { customer: Customer }) {const { t, i18n } = useTranslation()const { defaultCurrency } = useStore()- const localeForCurrency = useCurrencyLocale()const orders = customer.orders_count ?? 0const totalSpent = Number(customer.total_spent ?? '0')// Format the average from the number rather than rewriting the digits inside@@ -17,11 +15,7 @@ export function CustomerLifetimeStatsCard({ customer }: { customer: Customer })// period-decimal figure into it mixes separators (`1.234,56 €` → `1234.57 €`).const aovDisplay =orders > 0 && totalSpent > 0- ? formatAmount(- totalSpent / orders,- defaultCurrency,- localeForCurrency(defaultCurrency) || i18n.language,- )+ ? formatAmount(totalSpent / orders, defaultCurrency, i18n.language): '—'return (diff --git a/packages/dashboard/src/components/spree/store-credits/edit-store-credit-dialog.tsx b/packages/dashboard/src/components/spree/store-credits/edit-store-credit-dialog.tsxindex 7191a32e52..44a3384ad0 100644--- a/packages/dashboard/src/components/spree/store-credits/edit-store-credit-dialog.tsx+++ b/packages/dashboard/src/components/spree/store-credits/edit-store-credit-dialog.tsx@@ -5,6 +5,7 @@ import {currencyParts,mapSpreeErrorsToForm,normalizeMoneyInput,+ useMoneyLocale,} from '@spree/dashboard-core'import {Button,@@ -27,7 +28,6 @@ import {} from '@spree/dashboard-ui'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'-import { useCurrencyLocale } from '../../../hooks/use-currency-locale'import {type StoreCreditUpdateParams,useUpdateCustomerStoreCredit,@@ -52,14 +52,11 @@ export function EditStoreCreditDialog({// as a 422 store_credit_in_use.const amountLocked = Number(credit.amount_used ?? 0) > 0- const localeForCurrency = useCurrencyLocale()- // Currency is locked on edit, so resolve its market locale once. The amount- // hydrates from the canonical API value (`"50.00"`) but is displayed/edited- // in that locale's format (`"50,00"` for EUR); on submit we normalize back to- // canonical. Displaying in the same locale we normalize from keeps an- // untouched amount from being mangled on save.- const creditLocale = localeForCurrency(credit.currency) || 'en'- const { decimal, symbol } = currencyParts(credit.currency, creditLocale)+ // The amount hydrates from the canonical API value ("50.00") and is shown in+ // the person's own number format ("50,00" in German); submit normalizes it+ // back under the same locale, so an untouched amount is never mangled.+ const moneyLocale = useMoneyLocale()+ const { decimal, symbol } = currencyParts(credit.currency, moneyLocale)const form = useForm<EditStoreCreditFormValues>({// eslint-disable-next-line @typescript-eslint/no-explicit-any@@ -78,10 +75,8 @@ export function EditStoreCreditDialog({if (!amountLocked) {const amountValue = values.amount.toString().trim()- // Normalize from the credit's display locale to the canonical- // `"1234.56"` the API expects.if (amountValue) {- params.amount = normalizeMoneyInput(amountValue, creditLocale)+ params.amount = normalizeMoneyInput(amountValue, moneyLocale)}}diff --git a/packages/dashboard/src/components/spree/store-credits/issue-store-credit-dialog.tsx b/packages/dashboard/src/components/spree/store-credits/issue-store-credit-dialog.tsxindex 1057e93550..ea3352fc11 100644--- a/packages/dashboard/src/components/spree/store-credits/issue-store-credit-dialog.tsx+++ b/packages/dashboard/src/components/spree/store-credits/issue-store-credit-dialog.tsx@@ -6,6 +6,7 @@ import {mapSpreeErrorsToForm,normalizeMoneyInput,ResourceCombobox,+ useMoneyLocale,useStore,} from '@spree/dashboard-core'import {@@ -30,7 +31,6 @@ import {import { useEffect } from 'react'import { Controller, useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'-import { useCurrencyLocale } from '../../../hooks/use-currency-locale'import { useCreateCustomerStoreCredit } from '../../../hooks/use-customer-store-credits'import { customerAutocompleteProps } from '../../../hooks/use-customers'import {@@ -72,9 +72,9 @@ export function IssueStoreCreditDialog({const { errors } = form.formStateconst mutation = useCreateCustomerStoreCredit()- const localeForCurrency = useCurrencyLocale()+ const moneyLocale = useMoneyLocale()const selectedCurrency = form.watch('currency')- const { symbol } = currencyParts(selectedCurrency, localeForCurrency(selectedCurrency) || 'en')+ const { symbol } = currencyParts(selectedCurrency, moneyLocale)// Clear any prior submission state when the dialog re-opens so a fresh form// is presented (otherwise stale "Issue $20" values linger across opens).@@ -83,33 +83,13 @@ export function IssueStoreCreditDialog({if (open) form.reset(emptyValues)}, [open, form, defaultCurrency, customerId])- // Switching currency re-displays the amount in the new currency's locale- // format, so the value the merchant sees always matches the locale it will be- // normalized under on submit. Without this, `25.00` typed under USD would be- // re-read under EUR's `de` locale (where `.` groups thousands) and persist as- // 2500. Canonicalize from the old locale, then swap to the new locale's- // decimal separator.- function handleCurrencyChange(- next: string,- field: { value: string; onChange: (v: string) => void },- ) {- const prev = field.value- field.onChange(next)- const raw = form.getValues('amount')?.trim()- if (!raw) return- const canonical = normalizeMoneyInput(raw, localeForCurrency(prev) || 'en')- const { decimal } = currencyParts(next, localeForCurrency(next) || 'en')- form.setValue('amount', decimal === '.' ? canonical : canonical.replace('.', decimal))- }-async function onSubmit(values: IssueStoreCreditFormValues) {try {const credit = await mutation.mutateAsync({customerId: values.customer_id,- // Normalize the merchant's localized input (entered under the selected- // currency's market locale) to the canonical `"1234.56"` the API- // expects. The server never parses comma-vs-period.- amount: normalizeMoneyInput(values.amount, localeForCurrency(values.currency) || 'en'),+ // The API takes canonical "1234.56"; the amount was typed in the+ // person's own number format.+ amount: normalizeMoneyInput(values.amount, moneyLocale),currency: values.currency,memo: values.memo || undefined,})@@ -190,7 +170,7 @@ export function IssueStoreCreditDialog({<CurrencySelectid="sc-currency"value={field.value || ''}- onChange={(next) => handleCurrencyChange(next, field)}+ onChange={field.onChange}required/>)}diff --git a/packages/dashboard/src/hooks/use-currency-locale.ts b/packages/dashboard/src/hooks/use-currency-locale.tsdeleted file mode 100644index 03862d9afd..0000000000--- a/packages/dashboard/src/hooks/use-currency-locale.ts+++ /dev/null@@ -1,25 +0,0 @@-import { useAllMarkets } from './use-markets'--/**- * Resolves a currency code to the locale used to display and normalize amounts- * entered in it. Money forms format the field in this locale (so a EUR amount- * shows/accepts `1.234,56`) and normalize the merchant's input to canonical- * `"1234.56"` under the same locale before sending — the API only ever receives- * canonical decimal strings (client-side normalization; the server does not- * parse locale formats). See docs/plans/5.5-client-side-money-normalization.md.- *- * The mapping is the store's markets: each market pairs a `currency` with a- * `default_locale`. Returns `undefined` when no market matches (callers fall- * back to the UI language / `en`).- *- * @returns a `localeForCurrency(currency)` resolver- */-export function useCurrencyLocale(): (currency: string | undefined) => string | undefined {- const { markets } = useAllMarkets()-- return (currency) => {- if (!currency) return undefined- const market = markets.find((m) => m.currency === currency)- return market?.default_locale ?? undefined- }-}