Use the shared money field for every amount input

GF
1d ago
+1978-212

Stacked PR. Base is stack/money-field-touch-bar (= head of #6033, which sits on #6032). Review #6032 and #6033 first; once they land, this PR can be retargeted to main and shows only its own part.

Problem

Several amount inputs were still plain type="number" fields instead of the shared money_field introduced for the new-transaction form (upstream PR 3502). In Chromium a number input drops a comma it cannot read, so typing 12,50 into a transfer amount was sent as 1250, and 1.234,56 as 1.23456. Expressions (12,50+4,30) and pasted statement amounts did not work there either.

Change

Every remaining amount input now uses money_field:

  • Transfer amount and both bank charges, plus the exchange-rate destination amount
  • Split rows (transaction split editor and the rule split action's fixed share)
  • Budget allocation and the budget move dialog
  • Credit card limits, account statement balances, convert-to-trade price, Sharesight cash anchor
  • Rule amount condition, the transactions amount filter and the Monarch import balance

Supporting changes:

  • money_field can follow an account picker through a hidden currency source, so the transfer amount and fees show the symbol and precision of the account each side belongs to.
  • JavaScript that sums or compares these fields (split remaining, exchange-rate tabs, rule split summary, convert-to-trade price warning) reads them the way the field submits them. The exchange-rate tabs ask the field's controller for its submitted amount and recompute when a currency lookup lands.
  • Text typed or an ambiguous paste made while a currency switch is still loading is read with the new currency's rules, not the previous one's.
  • Split rows keep the decimals of saved amounts and of the total (capped at four), so an imported JPY 80.4 can still be split into amounts Entry#split! accepts.
  • The budget allocation keeps saving when the field is left (change), as before, rather than on every blur.
  • Saved rule amount conditions keep their stored text when the number is unchanged, so editing a rule does not re-trigger the "conditions changed" notice.

Phone layout

On a phone the credit card's paired rows and the convert-to-trade quantity/price row now put each field on its own line (grid-cols-1 sm:grid-cols-2): half a phone left a money field's input only a few pixels next to its symbol and calculator button. From sm up the rows stay two equal columns.

Validation

  • bin/rails test (unit + controller), system tests, Rubocop, ERB lint, Biome lint and Brakeman are green.
  • New/updated tests: transfers, splits, budget categories and Monarch import controller tests, helper tests for money_field_value, rule condition model test, and test/system/money_fields_test.rb (comma expressions in transfers and splits, fractional JPY split totals, rule condition field, budget allocation on leave, typing during a held currency lookup).

Screenshots

Left: main. Right: this PR. Each image shows the calculator closed, then open with the field focused. Field width and height are measured on desktop and with touch emulation.

New transfer

transfer_new closed
transfer_new open

Split dialog

split_new closed
split_new open

Budget categories

budget_categories closed
budget_categories open

Rule condition (transaction amount)

rule_condition closed
rule_condition open

Measured changes against main (all other fields keep their size, closed and open):

  • Split dialog: the amount is 160 px wide instead of 128 px, so the currency sign and calculator button fit. The name field takes the rest, and every line of a split card now ends at the same edge (the remove button has its own line).
  • Budget categories: amounts are 144 × 38 px instead of 120 × 38 px, including the read-only "Uncategorized" row.
  • Open calculator: the field grows by the operator row (40 px, 56 px on touch screens), as the new transaction amount already does on main. All five buttons fit in a 144 px field.

Notes

  • No migrations.
  • Upstream PR 3224 also touches transfers/_form.html.erb; the overlap is additive.

🤖 Generated with Claude Code

How this fits together

The money field work is split into small PRs that build on each other. Review from the top of this list; each stacked PR's base is a stack/* copy of the PR below it, so its diff shows only its own change.

  1. #6032: bounds checked on the submitted amount, hints for ignored input, parentheses (fixes #5944). Base: main.
  2. #6033: operator bar docked above the on-screen keyboard. Base: #6032.
  3. #5833: every amount input uses the money field. Base: #6033.
  4. #5850: a rejected transfer keeps its input; comma exchange rates. Base: #5833.
  5. #5939: the remaining decimal fields (quantities, rates) read comma decimals. Base: #5850.
  6. #6035: plain-number fields without the calculator for settings, rates and rule/filter limits. Base: #5939.

Standalone: #6034 (phone layout of goal, vehicle and settings number rows). Base: main; it does not depend on the stack.


Summary by cubic

Every remaining amount input now uses the shared money_field instead of a plain type="number" field. Chromium silently drops commas it cannot read, so typing 12,50 in a transfer was submitted as 1250; these fields now accept comma decimals, expressions, and pasted amounts and submit a plain dot number. Saved amounts are formatted as decimals rather than through Float, so large values like 99999999999999.99 keep their digits, an unchanged save never changes the stored amount, and a zero-quantity trade's amount reads as its numeric value rather than its formatted $1,234.56 text.

Behavior

  • Transfer amounts and fees follow the selected accounts' currencies through a hidden source, the Monarch balance follows its Destination picker, and statement balances follow the currency select; each field shows the right symbol and precision and keeps the saved amount's decimals as a minimum.
  • A pasted amount with one separator repeated reads as grouping in any currency (thousands "1.500.000", Indian "1,00,000"); with both separators the last is the decimal point, spaces only group, shapes that don't group ("1,5.25") are refused, and a grouped shape in parentheses reads as the accounting negative.
  • JavaScript that sums or compares these fields (split remaining, exchange-rate tabs, rule split summary, convert-to-trade price) reads the submitted amount from the field's controller, rounded to each field's precision, so expressions like 100/3 balance exactly as Entry#split! validates them.
  • While a currency switch is loading, typed text and an ambiguous whole-amount paste stay invalid until the lookup lands, then are read at the new currency's precision with bounds checked against the submitted amount (a held paste keeps its decimal point); a paste into an expression instead inserts at the caret, read without the new separator. A submit refused while loading is sent once it lands (after derived amounts recompute), unless the text was edited again first, and a paste's change is sent on blur even when it leaves the text unchanged. A failed lookup, or one still out after five seconds, reads the text without the new rules and the preview shows the unrounded amount that will be sent; a second switch before the first lookup lands keeps the first reading; every switch re-renders the preview and hint.
  • Split rows keep saved decimals (capped at four), show large saved amounts with their full digits, and give name and amount each a full-width line; a removable row's remove button gets its own line above the fields.
  • Operator buttons, including ( ), share the field's width and drop side padding in narrow fields, so the row fits a 144 px budget amount without = being cut off.
  • Credit card and trade fields take a full row on phones instead of sharing a half-width line; from sm up they stay two equal columns, with paired fields stretched to equal height.
  • Rule amount conditions and the amount filter allow two decimals in a whole-number family currency, since they compare across currencies; money_field_value caps decimals and rejects extreme exponents.
  • Budget allocation still submits on leaving the field; the uncategorized budget amount is now the same read-only money field as the category rows; unchanged rule amount conditions keep their stored text; the new transfer form starts with a blank amount instead of 0.00, and a transfer rejected for an unavailable exchange rate keeps its entered amount.
  • A statement form rejected for an unknown currency redraws with its saved, account, or family currency instead of raising, and a saved Monarch balance that doesn't parse keeps its entered text on screen instead of being replaced by the suggestion.
  • No migrations.

Dependencies

  • Merges the latest stack/money-field-touch-bar review rounds (exact-value rounding, paste as typed, paste-change on blur), main's dependency updates for the Ruby security advisories (#6113) and main's AI plumbing (#6123); AccountStatement keeps both the currency fallback and the vector store document methods.

Summary by CodeRabbit

  • New Features
    • Currency-aware amount fields are available across transfers, transactions, splits, budgets, rules, imports, and account settings.
    • Amount fields support currency-specific precision, decimal-comma input, expressions, and grouped-number pastes, and reformat when currencies change.
    • Import balances reflect the selected account’s currency, and rule amount conditions have translated labels across supported languages.
  • Bug Fixes
    • Split balances account for fractional amounts and displayed precision.
    • Editing an amount without changing its numeric value preserves its existing formatting.
    • Statement balances retain decimal values when edited, and unknown currencies fall back to a recognized currency.
    • Amount entry and submission remain accurate while currency details load or fail to load.
    • Submitted transfer amounts are preserved when an error occurs, and new transfer forms no longer prefill the amount.