Repository navigation
Commit 740720c
fix(components): the edit form's subtotal reads the record's currency, as the record page does (#36293)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XP3RHGWUG7UH3fNa4tBa9UC)_
Part of #36249
Builds Done-when item 2 only. Item 1 (a product's price copied across
currencies) stays open on the card for the maintainer's rule.
Clause-②: no
Metadata-protocol: none
## 维护者速读
在编辑发票表单里,欧元发票的小计原来显示成没有货币符号的「230.00」,现在显示「€230.00」,和记录页、含税合计一致。
这是多币种发票的后续问题,替在示例应用里录入外币发票的用户解决小计看不出币种的问题。
只影响编辑表单里汇总金额的显示,不改存储的数字;出问题可以直接撤回,回到原来的无符号显示。
卡片的另一半(选产品时把本币单价原样抄进欧元明细)需要你定规则,选项和建议在报告里。
## What changes
- `ui/packages/components/src/renderers/form/form.tsx`:
`RECORD_CURRENCY_WIDGET_TYPES` gains `summary`. The form renderer hands
the live form record (`dependentValues`) to a registered widget only
when its type is in that set; `currency` and `formula` were in it,
`summary` was not. `SummaryField` already formats a roll-up that
declares its currency (ADR-0144 D6 as amended) with
`resolveFieldCurrency(field, tenant, dependentValues)`, the same call
the record page's cell (`FormulaCellRenderer` → `CurrencyCellRenderer`)
makes; with no record, a `record`-mode config resolves to no code and
`formatCurrency` prints a bare `230.00`. Now the edit form's subtotal is
drawn by that same code path with the record it needs. The fix is in the
shared host, so every `summary` field that declares a currency on any
form (New / Edit, drawer, modal) gets it; the showcase fixture was
already right (PR #36233 declared `currencyConfig: { currencyMode:
'record', currencyField: 'currency_code' }` on `total`).
-
`ui/packages/fields/src/__tests__/parentCurrency.faces-31912.test.tsx`:
a new top-level `describe` in the existing D6 harness drives the real
form renderer with the real `SummaryField` / `CurrencyField` /
`TextField`: a EUR record's subtotal reads `€230.00` and its
tax-inclusive total `€276.00`; a USD record reads `$230.00` / `$276.00`.
- `.changeset/36249-form-subtotal-currency.md`: `@object-ui/components`
patch.
Read first, by risk: (1) the one-line set change in `form.tsx`
(`SummaryField` spreads no leftover props onto the DOM, so the new prop
leaks nowhere); (2) the new `describe` at the end of the faces harness.
Two-minute check: `pnpm --dir ui exec vitest run
packages/fields/src/__tests__/parentCurrency.faces-31912.test.tsx`
passes 11/11; remove `'summary'` from the set and the two new cases fail
with `expected 'Subtotal230.00' to contain '€230.00'`.
## Tests
<details><summary>Pin and ablation at d5c341f</summary>
- With the fix: `Test Files 1 passed (1)`, `Tests 11 passed (11)`.
- Ablation (`scripts/ablation-replace.mjs`, anchor hit x1 -> x0, blob
44f1fec -> cee0c300): `Tests 2 failed | 9 passed (11)`,
`AssertionError: expected 'Subtotal230.00' to contain '€230.00'` and
`expected 'Subtotal230.00' to contain '$230.00'`. The tax-inclusive
total cases stayed green in both legs (that face already had the
record). Restored: blob == HEAD, `git diff HEAD` empty. The ui test
config aliases `@object-ui/components` to `src`, so no rebuild sits
between the mutation and the run.
</details>
## Acceptance notes
- Item 1 of the card (a picked product's home-currency `unit_price`
copied into a EUR line) is not built here, as the claim says. The
measurement and the options go to the seat in the report.
- Before this change a home-currency (USD) invoice's subtotal was also
bare on the edit form (`230.00`); it now reads `$230.00`, the record
page's format.
- Seen while verifying, not fixed here: the showcase `en` translation
bundle labels `showcase_invoice.total` "Total" while the object metadata
labels it "Subtotal", so the record page and the edit form show the
pre-tax roll-up as "Total" next to "Total incl. Tax", and the line-grid
stack calls the same figure "Subtotal". Listed in the report for the
seat.
## Verification
<details><summary>Booted showcase, INV-1010 (EUR), edit form, 1280
px</summary>
Own stack: `objectstack dev --seed-admin --fresh -p 4361` in
`examples/app-showcase` on this branch's build, the Console from this
tree's source (`vite --port 5361`, `DEV_PROXY_TARGET` at the backend),
admin, Playwright with the preinstalled Chromium. Both servers stopped
after.
- Before (the fix ablated in the source the Console serves): edit form
`total` reads `Total 230.00`; `Total incl. Tax €276.00`; the line-grid
stack `Subtotal €230.00`.
- After: edit form `total` reads `Total €230.00`; the tax-inclusive
total unchanged at `€276.00`.
- Record page on the same boot: `Total €230.00`.
- Screenshots in the project files:
`build-seat4/36249/before-edit-form-1280.png`,
`after-edit-form-1280.png`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 46ad134 commit 740720c
3 files changed
Lines changed: 74 additions & 6 deletions
File tree
- .changeset
- ui/packages
- components/src/renderers/form
- fields/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1379 | 1379 | | |
1380 | 1380 | | |
1381 | 1381 | | |
1382 | | - | |
1383 | | - | |
1384 | | - | |
1385 | | - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1386 | 1387 | | |
1387 | | - | |
| 1388 | + | |
1388 | 1389 | | |
1389 | 1390 | | |
1390 | 1391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
0 commit comments