You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2e33533
Browse filesBrowse the repository at this point in the historyBrowse files
feat(ui): show the rate and date a home amount was converted at, and a Studio homeAmount editor (#31638)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbKY5oMZsVopxN5eVhk1kG6N)_
Part-of #27196
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- **改了什么:**
多币种「本位币金额」字段(`currencyConfig.homeAmount.field`)在记录页和表单分区里改为只读金额,下面一行写明「按汇率
0.1389(2026-11-01)折算」,数据取自记录自己的汇率字段和单据日期字段;同币种记录显示「本位币(汇率 1)」。Studio
字段编辑器在 record
模式下新增三个下拉:本位币金额字段、单据日期、汇率字段,只列规范接受的字段;顺手修了一个缺陷:改选币种代码字段时会把已写的
`homeAmount` 静默删掉。
- **为什么改:** 财务对账要看到折算用的是哪条汇率、哪一天;作者在 Studio 里也要能声明这三个指针。
- **风险与回滚:** 只影响声明了 `homeAmount` 的对象:其余币种字段的渲染逐字不变(有对照测试)。新增两个翻译键,属于
widening。回滚即 revert 本 PR。自动布局表单仍然不显示只读字段(含本位币字段),未改。
- **先看:**
`ui/packages/i18n/src/currency.ts`(`homeAmountSourceOf`)、`ui/packages/fields/src/widgets/CurrencyField.tsx`(`HomeAmountHint`)、`ui/packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.tsx`(`homeAmountCandidates`
与改选币种字段时保留 `homeAmount`)。
- **两分钟验证:** `cd ui && pnpm exec vitest run
packages/plugin-detail/src/__tests__/DetailSection.homeAmount-27196.test.tsx
packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.recordMode-27188.test.tsx`,预期全绿,其中记录页一例断言提示为
"Converted at 0.1389 on Nov 1, 2026"。
- **需要你做的:** 无,席位落地(落地前席位欠一次 Clause-② 声明复审)。
## What changes
The ui half of multi-currency M3-2, slice 1 of 2 (Tasks 1 and 3 of the
card). The preview (Task 2) is slice 2, waiting on #31609, which moves
the engine's conversion functions into a package the ui can import.
**Task 1: the home field reads as what it is.** A `record`-mode amount's
`homeAmount.field` is written by the engine alone, and until now nothing
in the ui knew a field was one: the declaration sits on the AMOUNT.
- `@object-ui/i18n` gains one reader, `homeAmountSourceOf(fields,
name)`: the amount, code field, document date and rate field that name
`name` as home. Producers stamp it on the field metadata they hand a
currency renderer (`withHomeAmountSource`, read back with
`readHomeAmountSource`), the way the form stamps a code field's
`usedCurrencyCodes`.
- Producers: the record page (`DetailSection`), the section builder the
record dialog and drawer share (`sectionFields.ts`), and an inline
`ObjectForm`'s own field build (`ObjectForm.tsx`, added to the claim by
amendment 6724257070).
- Consumers: `CurrencyField` draws a stamped field's read face even when
the form hands it `disabled` (it was a disabled number box with no
symbol), and `CurrencyCellRenderer` adds the same line on the record
page. The line is `HomeAmountHint`: "Converted at RATE on DATE" from the
record's own `rateField` / `rateDate` values (the rate unrounded, the
date with its year), or "In the home currency (rate 1)" when the
amount's code is the home currency. Nothing is drawn while the record
holds no rate. Nothing is recomputed in the ui.
- Two new locale keys in all eleven packs
(`fields.currencyHome.convertedAt`, `fields.currencyHome.homeCurrency`;
zh-Hant generated with `gen:zh-hant`) and in `FIELD_DEFAULTS`.
**Task 3: the Studio `homeAmount` editor.** Under `record` mode,
`CurrencyConfigField` shows three pickers: home amount field, document
date, rate field. `homeAmountCandidates` lists what the spec's object
judge (`refuseDishonestHomeAmount`) accepts for each: a stored `dynamic`
`currency` field that is `readonly`, has no `expression` and is no other
amount's home field; a `date` / `datetime`; a `readonly` `number` with
no `expression`, `scale` 12 or none, shared only with an amount on the
same code field and document date. The judge exports no predicate, so
per the amendment the spec is the test oracle (below), and no refusal
text is copied. Unpicking a pointer deletes it, and `homeAmount` goes
once none is left. No editor on a `formula` amount, which the spec
refuses `homeAmount` on.
**Defect fixed in Task 3.** Re-picking an amount's currency code field
committed `{ currencyMode: 'record', currencyField }` and silently
deleted an authored `homeAmount`. It is now kept; leaving `record` mode
still drops it, as the spec requires.
## Tests
-
`ui/packages/fields/src/__tests__/recordCurrency.faces-27188.test.tsx`,
new top-level `describe('home field faces (ADR-0144 D5)')`: the reader
and the no-stamp identity; the form widget draws no input and the line
"Converted at 0.1389 on Nov 1, 2026"; the cell says the same, and "In
the home currency (rate 1)" for a same-currency row; no rate ⇒ no line.
CONTROL: an unstamped readonly amount stays an input in the form and a
bare cell.
-
`ui/packages/plugin-form/src/__tests__/sectionFormHomeAmount-27196.test.tsx`:
the record dialog (edit and view), the drawer and an inline
`ObjectForm`, each with authored sections, draw the home field with its
line and no input. CONTROL: a readonly currency field no amount names
stays the disabled box.
-
`ui/packages/plugin-detail/src/__tests__/DetailSection.homeAmount-27196.test.tsx`:
the record page's home row carries the line, and only that row; rate 1
case.
-
`ui/packages/app-shell/src/views/metadata-admin/inspectors/CurrencyConfigField.recordMode-27188.test.tsx`,
new top-level `describe('Studio homeAmount editor (ADR-0144 D5)')`:
- candidate lists, the rate field judged against the picked document
date and code field;
- **ORACLE, offered ⇒ parses:** every field × document date × rate field
the editor offers on the fixture object parses through `ObjectSchema`
(10 combinations);
- **ORACLE, left out ⇒ refused:** a writable, an `expression`, a
`fixed`-mode and an already-claimed home field, a `scale: 2` and a
writable rate field, a rate field shared across document dates, a text
document date and a `formula` amount are each refused at a `homeAmount`
path (no message asserted);
- picking the three pointers writes `homeAmount` and the object parses;
re-picking the code field keeps `homeAmount`; switching to `dynamic`
drops it; no editor under `dynamic` or on a `formula` amount. CONTROL:
the five existing cases in the file stay green.
- The file now loads `@objectstack/formula` and `@objectstack/lint` at
module top: editing it put it under `check:test-source-alias`'s
source-reach half, which found both reached through the inspector's CEL
authoring.
## Acceptance notes
- **Out of scope, kept as today (amendment 6724151062):** an auto-layout
`ObjectForm` keeps dropping every `readonly` field
(`plugin-form/src/autoLayout.ts`, `filterSystemFields`), the home field
included. Changing that would move every readonly field on every auto
form. The home field shows on the record page and on authored sections.
- The display trusts the stored rate and date; it never recomputes. The
live preview before save is slice 2 (`Blocked-by: #31609`); its
refused-read (403) state is still NOT MEASURED live and is owed there.
- The hint's date is the document-date field's own value, formatted as a
date. For a `datetime` document date the engine takes the calendar day
in `localization.timezone`; the display formats the instant in the
display time zone, which the Console sets from the same setting.
## Verification
Head `68f353bae4e9ac4082d9aa91ac0bdf156bab698c` (origin/main `69244406`
merged in; no file on this PR changed on main in between). 28 files,
+700 / −11.
- **Gates:** `node scripts/pm/dispatch-gates.mjs --ran` reports 39
derived, 39 run, 0 NOT-MEASURED, 0 UNRUN; every recorded exit code is 0.
- **Package suites** (all exit 0, under the verify lock):
- `@object-ui/i18n`: 99 files passed; 1804 tests passed, 13 skipped.
- `@object-ui/fields`: 300 files passed, 1 skipped; 4548 tests passed, 7
skipped.
- `@object-ui/plugin-form`: 226 files passed; 2465 tests passed, 1
skipped.
- `@object-ui/plugin-detail`: 374 files passed, 1 skipped; 3355 tests
passed, 18 skipped.
- app-shell, narrowed to the 54 files naming `CurrencyConfigField` or
`ObjectFieldInspector`: 54 files and 578 tests passed. The rest of
app-shell was not run locally.
- `pnpm --dir ui exec vitest run scripts/`: 170 files passed, 2 skipped;
5002 tests passed, 2 skipped.
- **Ablations** (`ablation-replace.mjs`; each one restored to a blob
equal to HEAD with an empty `git diff HEAD`):
1. `readHomeAmountSource` returns `undefined`: 9 of 22 display pins red,
across the fields, plugin-form and plugin-detail files.
2. The rate-field filter keeps only the `number` type test (no readonly,
expression or sharing check): 2 of 13 Studio pins red.
3. Re-picking the code field drops `homeAmount` again: 1 of 13 Studio
pins red.
<details><summary>Gate list (39, exit codes as recorded)</summary>
```
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:merge-driver :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:role-word :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
```
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01QsR2jQyTLkpKcX2UF8X3Ss
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(ui): a home-currency amount shows the rate and document date it was converted at
9
+
10
+
Clause-②: yes (widening)
11
+
Metadata-protocol: none
12
+
13
+
A `record`-mode amount that declares `currencyConfig.homeAmount` (ADR-0144 D5) has its home field filled by the server when the record is saved. That home field now draws as a read-only amount in the organization's home currency, with the line "Converted at RATE on DATE" taken from the record's own rate and document-date fields, or "In the home currency (rate 1)" when the amount was already in the home currency. This holds on the record page and on authored form sections (the record dialog, the drawer and an inline `ObjectForm`), where it used to be a disabled number box with no currency symbol. A form laid out automatically still leaves readonly fields out, the home field included.
14
+
15
+
`@object-ui/i18n` adds `homeAmountSourceOf`, `withHomeAmountSource`, `readHomeAmountSource`, `HOME_AMOUNT_SOURCE_KEY` and the `HomeAmountSource` type, plus two locale keys in every pack: `fields.currencyHome.convertedAt` and `fields.currencyHome.homeCurrency`. `@object-ui/fields` exports `HomeAmountHint`.
16
+
17
+
The Studio field editor gains the three `homeAmount` pickers under `record` mode (home amount field, document date, rate field), listing only the fields the spec accepts for each. Re-picking an amount's currency code field no longer deletes its `homeAmount`.
0 commit comments