Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(precision): a per-unit price keeps the digits it was typed with
Sidwebworksfa1ebc2c1678
diff --git a/.claude/rules/numeric-precision.md b/.claude/rules/numeric-precision.mdindex ccba56fc1b..eba3cd2d16 100644--- a/.claude/rules/numeric-precision.md+++ b/.claude/rules/numeric-precision.md@@ -9,7 +9,7 @@ paths:- "packages/form/src/components/Number.tsx"- "packages/ee/src/accounting/providers/xero/serialize.ts"- "apps/erp/app/components/Form/TaxFields.tsx"- - "apps/erp/app/hooks/usePriceFormatter.tsx"+ - "apps/erp/app/hooks/useCurrencies.ts"# Numeric Precision & Formatting@@ -115,12 +115,14 @@ is module-private so the two percent kinds can never drift apart):| Percent points | min 0, max 3 | the same rate typed bare in a field already labelled "%" — `6.25`, caller divides by 100 || Exchange rate | min 0, max 5 | "1.0852", "0.00781" — a plain multiplier, not a percent and not a currency. Intl's decimal default caps at 3, which truncates a stored rate on blur || Quantity | min 0, max 5 | "3", "4.33333", "0.00125" — no "<0.01" placeholder |-| Currency (money AND price) | max = `currency.decimalPlaces`; min = the same by default | "$300.00", "$3.50", "$0.00", "¥63", "BHD 0.563" — ONE kind. A price is an amount in the same currency, so both render at that currency's decimals. PADDED by default: the width states the amount in full, which is the accounting convention. The decimals are also a ceiling, so a stored 300.33323 displays "$300.33"; storage keeps the rest. `usePriceFormatter` is an alias of `useCurrencyFormatter`, not a second implementation |-| ↳ trailing-zero preference | min 0 when set | `companySettings.hideCurrencyTrailingZeros` (default false) drops the non-significant zeros — "$300", "$3.5". DISPLAY and IN-APP only, and it covers EDITABLE fields too: `useCurrencyFormatter` and `MotionMoney` read it once via `useCurrencyMinDecimals`, and `~/components/Form`'s `Number`/`NumberControlled` wrappers (`CurrencyNumber.tsx`) apply it to any `style: "currency"` `formatOptions` — never a call site, which is why the ~80 `INPUT_FORMAT.money/price(...)` calls still pass two arguments. Overriding the MINIMUM is safe on an input even though `formatOptions` is part of the storage round-trip: react-aria commits `parse(format(x))` and only the MAXIMUM can change that. Documents render through the pure `formatMoney` and stay padded — a customer-facing invoice is where fixed-width money matters most — and an unauthenticated context (the public quote share page) has no settings to read, so it pads too |-| Editable currency (`INPUT_FORMAT.money` / `.price`) | same as above | an input formats with the SAME digits it displays with, padding included — an empty cost reads "$0.00". react-aria's blur commit is literally `setNumberValue(parse(format(x)))`, so this is not decoration — it is what a typed amount is STORED at: 300.22121 commits as 300.22 in USD, 63.4 commits as 63 in JPY. A per-unit price is entered and kept at the currency's decimals |+| Money (settlement) | max = min = `currency.decimalPlaces` | "$300.00", "$3.50", "$0.00", "¥63", "BHD 0.563" — what someone PAYS: an invoice total, line amount, payment, tax amount. A currency cannot settle a fraction of its smallest unit, so its decimals are both floor and CEILING; a stored 300.33323 displays "$300.33" and storage keeps the rest. PADDED, because fixed-width money is the accounting convention |+| Price (per-unit rate) | min = `currency.decimalPlaces`, max = `SCALE` | "$300.00", "$3.50" — pads exactly like money, so a price column stays aligned — but the currency's decimals are only its FLOOR. Above them it carries the storage scale: "$0.164", "$0.00123", "$12.34567". A price is what you MULTIPLY BY, not what you settle, and a 2-decimal ceiling silently turned a real $0.00123 fastener price into $0.00 ([#1203](https://github.com/crbnos/carbon/issues/1203)). Every ERP splits these — Xero settles at 2 and takes 4 on `UnitAmount` (opt-in `unitdp=4`), QuickBooks Desktop shows 5 in the Rate column, SAP reaches sub-cent prices with a price unit (per 100/1000) — and none of them widens settlement values. `INPUT_STEP.price` is the scale step, since `money`'s cent step would snap away exactly the digits this keeps |+| ↳ trailing-zero preference | min 0 when set | `companySettings.showCurrencyTrailingZeros` (default true) turned OFF drops the non-significant zeros — "$300", "$3.5". DISPLAY and IN-APP only, and it covers EDITABLE fields too: `useCurrencyFormatter` and `MotionMoney` read it once via `useCurrencyMinDecimals`, and `~/components/Form`'s `Number`/`NumberControlled` wrappers (`CurrencyNumber.tsx`) apply it to any `style: "currency"` `formatOptions` — never a call site, which is why the ~80 `INPUT_FORMAT.money/price(...)` calls still pass two arguments. Overriding the MINIMUM is safe on an input even though `formatOptions` is part of the storage round-trip: react-aria commits `parse(format(x))` and only the MAXIMUM can change that. Documents render through the pure `formatMoney` and stay padded — a customer-facing invoice is where fixed-width money matters most — and an unauthenticated context (the public quote share page) has no settings to read, so it pads too |+| Editable currency (`INPUT_FORMAT.money` / `.price`) | same as its kind above | an input formats with the SAME digits it displays with, padding included — an empty cost reads "$0.00". react-aria's blur commit is literally `setNumberValue(parse(format(x)))`, so this is not decoration — it is what a typed amount is STORED at. `.money` commits 300.22121 as 300.22 in USD and 63.4 as 63 in JPY; `.price` commits 0.00123 as 0.00123, which is the whole point of the price kind |Call sites pick a kind (`formatMoney/Price/Percent/Quantity`, the-`useCurrencyFormatter`/`usePriceFormatter`/`usePercentFormatter`/+`useCurrencyFormatter` (with `price`/`compact`/`wholeUnits` naming the+kind)/`usePercentFormatter`/`useQuantityFormatter` hooks — the first two are the same function) — never `minimumFractionDigits`/`maximumFractionDigits` inline (`no-inline-fraction-digits`), and module-local`*_PRECISION` constants are the same violation. **Editable inputs MUST usediff --git a/apps/erp/app/hooks/useCurrencyFormatter.tsx b/apps/erp/app/hooks/useCurrencyFormatter.tsxindex 47d22cdc68..d539d557df 100644--- a/apps/erp/app/hooks/useCurrencyFormatter.tsx+++ b/apps/erp/app/hooks/useCurrencyFormatter.tsx@@ -1,4 +1,4 @@-import { moneyFormatOptions } from "@carbon/utils";+import { moneyFormatOptions, priceFormatOptions } from "@carbon/utils";import { useLocale } from "@react-aria/i18n";import { useMemo } from "react";import { useCurrencyDecimals, useCurrencyMinDecimals } from "./useCurrencies";@@ -20,6 +20,11 @@ export type CurrencyFormatterOptions = {/** Drop the fraction entirely — a report that deliberately shows whole units.* Combined with `compact` this is "$1M" rather than "$1.2M". */wholeUnits?: boolean;+ /** A per-unit PRICE rather than a settlement amount: still padded to the+ * currency's decimals, but allowed to exceed them up to the storage scale,+ * so a $0.00123 fastener price displays as it is stored rather than as+ * "$0.00". Matches what the price INPUT commits — see priceFormatOptions. */+ price?: boolean;};/**@@ -48,17 +53,17 @@ export function useCurrencyFormatter(options?: CurrencyFormatterOptions) {// identity meant the memo never hit: a new Intl.NumberFormat on every render,// and — since the formatter is itself a dep of the `columns` memo in several// tables — a full column rebuild with it. Depend on the primitive fields.- const { decimalPlaces, compact, wholeUnits } = options ?? {};+ const { decimalPlaces, compact, wholeUnits, price } = options ?? {};return useMemo(() => {// `wholeUnits` is a digit count of zero, expressed as the intent rather than// the number — this hook names kinds, it does not choose digits.const decimals = wholeUnits ? 0 : (decimalPlaces ?? currencyDecimals);+ const min = wholeUnits ? 0 : minDecimals;return new Intl.NumberFormat(locale, {- ...moneyFormatOptions(decimals, {- currency,- minDecimalPlaces: wholeUnits ? 0 : minDecimals- }),+ ...(price && !wholeUnits+ ? priceFormatOptions(currency, decimals, min)+ : moneyFormatOptions(decimals, { currency, minDecimalPlaces: min })),...(compact? { notation: "compact" as const, compactDisplay: "short" as const }: {})@@ -70,6 +75,7 @@ export function useCurrencyFormatter(options?: CurrencyFormatterOptions) {minDecimals,decimalPlaces,compact,- wholeUnits+ wholeUnits,+ price]);}diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsxindex fd5d2e36db..9a68a92c99 100644--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx@@ -287,6 +287,7 @@ const PurchaseInvoiceLineForm = ({decimalPlaces: currencyDecimals});const priceFormatter = useCurrencyFormatter({+ price: true,currency: invoiceCurrency,decimalPlaces: currencyDecimals});diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsxindex 37ef87714f..7025c0f7d1 100644--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx@@ -377,6 +377,7 @@ const SalesInvoiceLineForm = ({decimalPlaces: currencyDecimals});const priceFormatter = useCurrencyFormatter({+ price: true,currency: routeData?.salesInvoice?.currencyCode ?? company.baseCurrencyCode,decimalPlaces: currencyDecimals});diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsxindex 29bf3dd49b..ad12c3ebeb 100644--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx@@ -268,7 +268,10 @@ function PurchaseHistory({baseCurrency: string;}) {const { t } = useLingui();- const priceFormatter = useCurrencyFormatter({ currency: baseCurrency });+ const priceFormatter = useCurrencyFormatter({+ price: true,+ currency: baseCurrency+ });if (history.length === 0) return null;return (diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsxindex 30c84fcd6c..3a9a267ff6 100644--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx@@ -307,6 +307,7 @@ const PurchaseOrderLineForm = ({decimalPlaces: currencyDecimals});const priceFormatter = useCurrencyFormatter({+ price: true,currency: orderCurrency,decimalPlaces: currencyDecimals});diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsxindex b0ccd6c898..a27ac17e6a 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx@@ -49,6 +49,7 @@ const QuoteLineCosting = ({const formatter = useCurrencyFormatter();const unitCostFormatter = useCurrencyFormatter({+ price: true,decimalPlaces: unitPricePrecision});diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsxindex 45bce34ee4..dbd6413b7e 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx@@ -183,6 +183,7 @@ const QuoteLinePricing = ({const formatter = useCurrencyFormatter();const percentFormatter = usePercentFormatter();const unitPriceFormatter = useCurrencyFormatter({+ price: true,currency: routeData?.quote?.currencyCode ?? baseCurrency,decimalPlaces: unitPricePrecision});diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsxindex 618ebd9385..22020ecbaa 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx@@ -65,7 +65,10 @@ const QuoteLinePricingHistory = ({// Default to the tab that has itemsconst defaultTab = hasOrderLines ? "salesOrderLines" : "quoteLines";const [customers] = useCustomers();- const priceFormatter = useCurrencyFormatter({ currency: baseCurrency });+ const priceFormatter = useCurrencyFormatter({+ price: true,+ currency: baseCurrency+ });return (<Card>diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.jsonindex 49d00b403f..ee4a393c9e 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-metadata.json@@ -1,5 +1,5 @@{- "generated": "2026-08-13T13:42:54.728Z",+ "generated": "2026-08-13T15:12:30.047Z","totalTools": 1436,"modules": 15,"tools": [@@ -42804,15 +42804,15 @@}},{- "name": "settings_updateHideCurrencyTrailingZerosSetting",+ "name": "settings_updateShowCurrencyTrailingZerosSetting","module": "settings","classification": "WRITE",- "description": "update hide currency trailing zeros setting",+ "description": "update show currency trailing zeros setting","paramCount": 1,"serviceParams": ["client","companyId",- "hideCurrencyTrailingZeros"+ "showCurrencyTrailingZeros"],"injectAuth": ["companyId",@@ -42821,12 +42821,12 @@"schema": {"type": "object","properties": {- "hideCurrencyTrailingZeros": {+ "showCurrencyTrailingZeros": {"type": "boolean"}},"required": [- "hideCurrencyTrailingZeros"+ "showCurrencyTrailingZeros"]}},diff --git a/packages/utils/AGENTS.md b/packages/utils/AGENTS.mdindex e148be97c1..1871cfa1a8 100644--- a/packages/utils/AGENTS.md+++ b/packages/utils/AGENTS.md@@ -38,8 +38,8 @@ pnpm --filter @carbon/utils typecheck| `date` | Date formatting, parsing, range helpers (uses `@internationalized/date`) || `datetime` | Server-side date derivation with mandatory explicit timezone: `timestamp()`, `today(tz)`, `now(tz)`, `businessDay(instant, tz)`, `weekBounds(tz, offset?, anchor?)` (DST-safe Monday→Sunday instant bounds), `weekNumber(date)`. DST/exotic-zone stress suite in `datetime.test.ts` (gap/overlap disambiguation, midnight-skipping zones, 167/169h weeks, ±30/45-min offsets). Mirrored for Deno at `packages/database/supabase/functions/lib/datetime.ts` — keep in sync || `hash` | The repo's stable content hashes — `fnv1a32`/`fnv1a64` (cache and idempotency keys) and `getBucket`. Browser-safe; never add `node:crypto` here |-| `math` | `clamp`/`lerp`/`inverseLerp`, plus the whole numeric-precision API re-exported from the edge-runtime module: `SCALE`, `EPSILON`, `round`, `sum`, `equals`, `scrapAllowance`, `applyRate`, `deriveRate`, `assertBalanced`, `RoundingMode` |-| `format` | The ONLY place display/input digit counts are chosen: `moneyFormatOptions`, `priceFormatOptions`, `percentFormatOptions`, `percentPointsFormatOptions`, `quantityFormatOptions`, `exchangeRateFormatOptions`, their `format*` helpers, and `INPUT_FORMAT` / `INPUT_STEP` for editable fields. Call sites pick a KIND, never a digit count |+| `math` | `clamp`/`lerp`/`inverseLerp`, plus the whole numeric-precision API re-exported from the edge-runtime module: `SCALE`, `EPSILON`, `round`, `scrapAllowance`, `applyRate`, `deriveRate`, `isBalanced`, `assertBalanced`, `RoundingMode` (re-exported from `precision.ts`) |+| `format` | The ONLY place display/input digit counts are chosen: `moneyFormatOptions` (settlement — the currency's decimals are floor AND ceiling), `priceFormatOptions` (per-unit — those decimals are only the floor, ceiling is `SCALE`), the `PERCENT_FORMAT` / `PERCENT_POINTS_FORMAT` / `SCALE_FORMAT` constants, `cldrCurrencyDecimals`, their `format*` helpers, and `INPUT_FORMAT` / `INPUT_STEP` for editable fields. Call sites pick a KIND, never a digit count || `string` | Slugify, truncate, camelCase/titleCase conversions || `revalidate` | `isSearchParamOnlyNavigation` — shared by both apps' shell `shouldRevalidate` || `status` | Status resolution, status color mapping |diff --git a/packages/utils/src/format.test.ts b/packages/utils/src/format.test.tsindex f4a5494133..842d039a28 100644--- a/packages/utils/src/format.test.ts+++ b/packages/utils/src/format.test.ts@@ -4,7 +4,9 @@ import {formatPercent,formatQuantity,INPUT_FORMAT,- INPUT_STEP+ INPUT_STEP,+ moneyFormatOptions,+ priceFormatOptions} from "./format";describe("formatPercent", () => {@@ -41,7 +43,7 @@ describe("formatMoney", () => {it("gives editable fields the SAME digits they display with", () => {// react-aria's blur commit is setNumberValue(parse(format(x))), so this// options object decides the precision a typed amount is STORED at.- const usd = new Intl.NumberFormat("en-US", INPUT_FORMAT.price("USD", 2));+ const usd = new Intl.NumberFormat("en-US", INPUT_FORMAT.money("USD", 2));expect(usd.format(300)).toBe("$300.00");expect(usd.format(300.22121)).toBe("$300.22");@@ -49,14 +51,17 @@ describe("formatMoney", () => {expect(jpy.format(63.4)).toBe("¥63");});- it("formats money and price inputs identically", () => {- for (const v of [0, 300, 300.22121, 18.75]) {- expect(- new Intl.NumberFormat("en-US", INPUT_FORMAT.price("USD", 2)).format(v)- ).toBe(- new Intl.NumberFormat("en-US", INPUT_FORMAT.money("USD", 2)).format(v)- );+ it("money and price agree until the currency's decimals run out", () => {+ const price = new Intl.NumberFormat("en-US", INPUT_FORMAT.price("USD", 2));+ const money = new Intl.NumberFormat("en-US", INPUT_FORMAT.money("USD", 2));+ // A settlement amount and a per-unit price of the same value look alike...+ for (const v of [0, 300, 18.75]) {+ expect(price.format(v)).toBe(money.format(v));}+ // ...until the value needs more than the currency settles in, where a+ // SETTLEMENT amount rounds and a PRICE keeps its digits (#1203).+ expect(money.format(300.22121)).toBe("$300.22");+ expect(price.format(300.22121)).toBe("$300.22121");});});@@ -98,3 +103,62 @@ describe("INPUT_STEP", () => {expect(INPUT_STEP.money(3)).toBe(0.001);});});++describe("priceFormatOptions — the price kind (issue #1203)", () => {+ const fmt = (v: number, currency = "USD", decimals = 2) =>+ new Intl.NumberFormat(+ "en-US",+ priceFormatOptions(currency, decimals)+ ).format(v);++ it("still PADS to the currency's decimals — a price column stays aligned", () => {+ expect(fmt(300)).toBe("$300.00");+ expect(fmt(3.5)).toBe("$3.50");+ expect(fmt(0)).toBe("$0.00");+ });++ it("but the currency's decimals are a FLOOR, not a ceiling", () => {+ // The whole point: a distributor price that a 2-decimal field would have+ // turned into $0.00 survives.+ expect(fmt(0.164)).toBe("$0.164");+ expect(fmt(0.00123)).toBe("$0.00123");+ expect(fmt(12.34567)).toBe("$12.34567");+ });++ it("never exceeds the storage scale — display cannot imply more than is kept", () => {+ expect(fmt(1.234567891)).toBe("$1.23457");+ });++ it("respects a currency whose own decimals already exceed nothing", () => {+ expect(fmt(63, "JPY", 0)).toBe("¥63");+ expect(fmt(63.4, "JPY", 0)).toBe("¥63.4");+ expect(fmt(0.563, "BHD", 3)).toBe("BHD\u00a00.563");+ });++ it("differs from money ONLY in the ceiling", () => {+ const money = new Intl.NumberFormat(+ "en-US",+ moneyFormatOptions(2, { currency: "USD" })+ );+ const price = new Intl.NumberFormat("en-US", priceFormatOptions("USD", 2));+ // identical where the value fits the currency+ for (const v of [0, 3.5, 300, 1234.5]) {+ expect(price.format(v)).toBe(money.format(v));+ }+ // and only diverges past it+ expect(money.format(0.164)).toBe("$0.16");+ expect(price.format(0.164)).toBe("$0.164");+ });++ it("INPUT_FORMAT.price is that kind, so a typed price commits at its width", () => {+ // react-aria commits parse(format(x)); this is what #1203 was about.+ const opts = INPUT_FORMAT.price("USD", 2);+ expect(opts.maximumFractionDigits).toBe(5);+ expect(opts.minimumFractionDigits).toBe(2);+ });++ it("INPUT_STEP.price cannot snap away the digits the format keeps", () => {+ expect(INPUT_STEP.price).toBe(1e-5);+ expect(INPUT_STEP.money(2)).toBe(0.01);+ });+});diff --git a/packages/utils/src/format.ts b/packages/utils/src/format.tsindex 4df2ae4c96..c548f827cf 100644--- a/packages/utils/src/format.ts+++ b/packages/utils/src/format.ts@@ -7,6 +7,9 @@ export type MoneyFormatOptions = {currency?: string;/** Drops the non-significant zeros when 0. See below. */minDecimalPlaces?: number;+ /** Raises the CEILING above the currency's decimals — see priceFormatOptions.+ * Settlement amounts never pass this; only per-unit prices do. */+ maxDecimalPlaces?: number;};/** The one stand-in when no currency is in play at all. ISO's own default. */@@ -59,7 +62,11 @@ export function cldrCurrencyDecimals(currencyCode: string): number {* field commits at this width too (see INPUT_FORMAT). */export function moneyFormatOptions(decimalPlaces: number,- { currency, minDecimalPlaces = decimalPlaces }: MoneyFormatOptions = {}+ {+ currency,+ minDecimalPlaces = decimalPlaces,+ maxDecimalPlaces = decimalPlaces+ }: MoneyFormatOptions = {}): Intl.NumberFormatOptions {return {// The symbol is the only thing `currency` decides. Digits are the same@@ -70,10 +77,43 @@ export function moneyFormatOptions(? { style: "currency" as const, currency }: { style: "decimal" as const }),minimumFractionDigits: minDecimalPlaces,- maximumFractionDigits: decimalPlaces+ maximumFractionDigits: maxDecimalPlaces};}+/** A per-unit PRICE. Same kind as money and it PADS the same way — a price+ * column still reads "$300.00", "$3.50" — but the currency's decimals are only+ * its FLOOR, not its ceiling. Above that it carries the storage scale.+ *+ * Money and price differ by ROLE, which is why this is a second function and+ * not a second set of digits:+ *+ * settlement (total, line amount, payment, tax) -> what someone PAYS,+ * and a currency cannot settle a fraction of its smallest unit;+ * price/rate -> what you MULTIPLY BY, and $0.00123 per fastener is a real+ * quoted price that a 2-decimal field silently turns into $0.00.+ *+ * Every ERP splits these. Xero settles at 2 but takes 4 on UnitAmount (opt-in+ * `unitdp=4`); QuickBooks Desktop settles at 2 and shows 5 in the Rate column;+ * SAP keeps money at the currency's decimals and reaches sub-cent prices with a+ * price unit (per 100/1000) instead. None of them widens settlement values.+ *+ * On an editable field this is not decoration: react-aria commits+ * `parse(format(x))`, so the ceiling here is what a typed price is STORED at.+ * A 2-decimal ceiling is what issue #1203 reports — the columns already hold+ * five decimals and the input was rounding them away before the save. */+export function priceFormatOptions(+ currency: string,+ decimalPlaces: number,+ minDecimalPlaces?: number+): Intl.NumberFormatOptions {+ return moneyFormatOptions(decimalPlaces, {+ currency,+ minDecimalPlaces,+ maxDecimalPlaces: Math.max(decimalPlaces, SCALE)+ });+}+/** Already-built currency options with a different MINIMUM — the company's* trailing-zero preference, applied by the editable-field wrapper, which sees* a finished options object rather than the kind that produced it.@@ -142,8 +182,10 @@ export const INPUT_FORMAT = {* JPY's 0 a typed 63.4 commits as 63. */money: (currency: string, decimalPlaces: number, minDecimalPlaces?: number) =>moneyFormatOptions(decimalPlaces, { currency, minDecimalPlaces }),- price: (currency: string, decimalPlaces: number, minDecimalPlaces?: number) =>- moneyFormatOptions(decimalPlaces, { currency, minDecimalPlaces })+ /** A per-unit price INPUT. The ceiling is the storage scale, not the+ * currency's — react-aria commits parse(format(x)), so this is what lets a+ * typed 0.00123 reach the column instead of committing as 0.00 (#1203). */+ price: priceFormatOptions};const SCALE_STEP = 1 / 10 ** SCALE;@@ -155,11 +197,14 @@ export const INPUT_STEP = {rate: SCALE_STEP,quantity: SCALE_STEP,exchangeRate: SCALE_STEP,- /** Currency steps in its own smallest unit (1 for JPY, 0.01 for USD) — for- * money and prices alike, since they share one format. There is deliberately- * no finer `price` step: react-aria commits parse(format(x)), so a step below- * the field's own format can only produce values the formatter rounds away. */- money: (decimalPlaces: number) => 1 / 10 ** decimalPlaces+ /** Money steps in its own smallest unit (1 for JPY, 0.01 for USD) — a+ * settlement amount cannot move by less than the currency settles in. */+ money: (decimalPlaces: number) => 1 / 10 ** decimalPlaces,+ /** A price steps at the storage scale, because its FORMAT reaches that far+ * (priceFormatOptions). react-aria snaps the committed value to a multiple of+ * `step`, so `money`'s cent step on a price field would truncate exactly the+ * digits the format was widened to keep. */+ price: SCALE_STEP};export function formatMoney(