Skip to content

Commit 8da2b7e

Browse files
fix(fields): a pick leaves an amount in another currency empty and says why (#36351)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbDp9TQDrBRFrgCwckUd7BG3)_ repo:objectstack#7 · zhuangjianguo · session_01QsR2jTM6Q7J3o7taPraVR2 Fixes #36249 Builds Done-when item 1 as ruled. Item 2 landed in PR #36293. Clause-②: yes (narrowing) — a cross-currency price copy that happens today stops and the line is left empty with a stated reason (ruled B); widened: three new `@object-ui/i18n` `lookup.autofill*` keys in every locale pack, new `@object-ui/fields` exports from `lookupAutofill.ts` (`planDeclaredLookupAutofill`, `crossCurrencyRefusal`, `amountCurrencyOf`, `pickedAmountCurrencyOf`, `withheldAutofillMessage`, `withLookupAutofillTargets`, `readLookupAutofillTargets`, `LOOKUP_AUTOFILL_TARGETS_KEY` and their types), an optional second argument on `onSelectRecord`, an optional trailing `currency` parameter on `declaredLookupAutofillPatch` and `lookupAutofillPatch`, and the optional `columnFields` prop on `GridField` Metadata-protocol: semantic Skills-docs: follow-up #36349 Ruling-ref: 7075336705 (maintainer 「B 币种不同就不填并说明」, 2026-11-22T06:26Z, card #36249) ## 维护者速读 在外币发票(例如欧元发票)里选产品时,单价不再把本币价格原样抄成欧元,而是留空,并在该行下方写明产品原价和两种币种,由用户手动填写;本币发票照旧自动填。 这是多币种发票卡片的第一项,按你选的方案(币种不同就不填并说明)执行。 如果规则有误,外币明细的单价会多一步手填,本币单据不受影响;可以直接撤回这一个合并。 无 ## What changes - **One rule, three fill paths.** `crossCurrencyRefusal` in `ui/packages/fields/src/widgets/lookupAutofill.ts` decides whether a picked value may be copied into the field it fills. An amount is a `currency` field or a `formula` returning `currency`. Both in the home currency: copies, also with no home currency configured. Otherwise it copies only when both sides name the same known code (`fixed`, the record's code, or the `master_detail` parent's code; the home currency counts as its configured code). A `number` copies as before. A target following a record with no code yet is not filled. Nothing converts. - Grid same-named copy and grid declared pairs: `planLookupAutofill` (`GridField.tsx`). The picked value's currency is its field's on the referenced object, which the lookup cell already reads for its labels and now hands to `onSelectRecord` as a second argument. The cell's currency is the column's. `columnCurrencies` decides a line amount that follows its header. Any other currency column is judged by its child field, which the hosts (`LineItemsPanel`, `MasterDetailForm`) now hand the grid as `columnFields` (`currencyFieldDefsOf`). It reads `amountCurrencyOf` on the line, as the form does, so it gives a `fixed` code, a sibling code on the line, or the home currency. - Record form declared pairs, on a pick and on the opening fill: `LookupField.tsx` via `planDeclaredLookupAutofill`. Target definitions are stamped on the lookup's field by the record form (`withLookupAutofillTargets`, applied in `recordFormStamp.ts`, the one step every layout draws through). Each one carries the label the form draws for it (already translated), so the note names the field as the form does. A target following its parent's currency reads the parent's code with `useFollowedParentRecord`, as the amount box does. The opening fill waits for the referenced schema and the parent read. - **The reason.** A note under the line (grid) or under the lookup (form) names the field, the picked amount in its own currency and the field's currency, while the pick still stands and the field is still empty. Three new `lookup.autofill*` sentences in all 11 packs (zh-Hant generated) and in `FIELD_DEFAULTS`. - **Contract text.** The describes of `FieldSchema.lookupAutofill` and the grid column key `autofill` state the rule; the spec pin of the `autofill` describe follows; references regenerated. `content/docs/data-modeling/fields.mdx` gains a Currency rule bullet. Showcase comments say "when the currencies match"; seeds unchanged. - Not done, as ruled: no conversion, no per-currency price, no build-time refusal. Read first, by risk: (1) `crossCurrencyRefusal` and `amountCurrencyOf` in `lookupAutofill.ts`; (2) the currency context and opening-fill wait in `LookupField.tsx`; (3) `gridAutofillCurrency` in `GridField.tsx`. Two-minute check: `pnpm --dir ui exec vitest run packages/fields/src/widgets/GridField.lookupAutofill-28245.test.tsx` passes; in it, a EUR line's pick leaves the price `null` and shows the note naming `$100.00` and EUR, and a USD line fills `100`. ## Tests <details><summary>Local runs at 1e8a71d</summary> - Under `os-verify-lock`: `pnpm --filter @object-ui/fields run type-check`, `pnpm --filter @object-ui/plugin-form run type-check`, then `pnpm exec vitest run --maxWorkers=1` (from `ui/`) on `GridField.lookupAutofill-28245.test.tsx`, `GridField.test.tsx`, `ObjectForm.lookupAutofill-28245.test.tsx` and every `LookupField*` test: `Test Files 27 passed (27)`, `Tests 288 passed (288)`, VERDICT command-exit 0. - New pins: the rule's truth table; an amount's currency per mode; same-named copy and declared pair on a EUR line (price withheld, description fills, reason listed) and a USD line (fills); a header with no code; through the grid (EUR line: price `null`, note names `$100.00` and EUR; USD line fills `100`); through `ObjectForm` (EUR quote: price empty, note; USD quote fills `100`; the opening fill on a EUR quote fills no price). - Ablation (`scripts/ablation-replace.mjs`, `lookupAutofill.ts`, anchor `if (!source || !target) return undefined;` x1 to x0, mutation makes every pick copy): `Tests 7 failed | 26 passed (33)` over the two new-pin files. Restored blob `0ce4a7231bed` equals HEAD, `git diff HEAD` empty. The tests import the source directly (vitest aliases `@object-ui/*` to `src`), so no dist sits between the mutation and the run. - Spec: `pnpm --filter @objectstack/spec build && gen:schema && gen:docs && check:generated`: all 14 generated artifacts up to date, VERDICT command-exit 0. </details> ## Acceptance notes - A record form drawn outside `ObjectForm` (a bare SDUI form) carries no target stamp, so its lookup copies as before; every record-form layout goes through `gateFormFields` and is covered. - Carried by follow-up card #36412, as the L2 directed: S2 (a re-pick over a filled target gives no note), S3 (the opening fill waits when the followed parent cannot be read) and S4 (a form outside `gateFormFields` gets no stamp). - When the referenced object's schema could not be read, a numeric picked value counts as "currency unknown": it still copies into a home-currency field and is withheld from a field in another currency. ## Verification <details><summary>Gates</summary> - **Derived sweep:** `dispatch-gates --commands` derived 119 commands, all run. `dispatch-gates --ran` reconciles `119 derived, 119 run, 0 NOT-MEASURED, 0 UNRUN`. The sweep ran at 1e8a71d. Head a78cca8 changes only the changeset's declaration lines, and the three changeset gates (`check-adr-0087-registration`, `check-changeset-no-major`, `check-empty-changeset`, each `--base origin/main`) were re-run at a78cca8, all exit 0. - **Prerequisite reruns:** four commands first exited 3 on missing prerequisites and were re-run after they were in place, all exit 0. `check-plugin-teardown-shape --self-test` needed the depth-1 fetch of its pinned commit. `check:skill-examples`, `check:dual-build-cjs-loads` and `check:i18n-coverage` needed a full `pnpm build`. - **Dogfood battery (owed by the narrowing arm):** `os-verify-lock.sh -c 'pnpm build && pnpm --filter @objectstack/dogfood test'`, whole battery with no shard, at a78cca8: `Test Files 484 passed | 3 skipped (487)`, `Tests 4107 passed | 68 skipped (4175)`, VERDICT command-exit 0. - **ui i18n:** `all-locales-key-parity`, `en-zh-key-parity`, `untranslated-identity-4376`, `count-families-11445` and `product-neutral-renderer.ratchet`: `Test Files 5 passed (5)`, `Tests 94 passed (94)`. `check-i18n-en-drift.mjs`: no en value changed. - **PR-event gates:** `check-changeset-no-major`, `check-adr-0087-registration` and `check-closing-keyword-parity` on this body's event, all exit 0. `check-prior-rulings` exit 0 cites 7075336705. - **Overlap:** `overlap-check` exit 1 against #36324 in `LookupField.tsx`, limited to imports and two `useCallback` dependency arrays. Whichever lands second needs a trivial merge. The seat has been told. - **CI** at a78cca8: 61 success, 9 skipped, none failing. - **Merge of main at 3b268ec (head a111a0a):** #36324 landed first and conflicted in `LookupField.tsx`, in the imports and the `onSelectRecord` call of the picker's single-pick path. Both sides are kept: main's `rememberPickedRecords` import and call, and this PR's currency imports and `sourceFields` argument. `gen:zh-hant` is current, and `dispatch-gates --commands` derives the same 119 commands. `overlap-check` at the new head: VERDICT clean exit 0. - **Re-verification at a111a0a**, under `os-verify-lock`, VERDICT command-exit 0: `pnpm build` exit 0, `@object-ui/fields` and `@object-ui/plugin-form` type-check exit 0. vitest over the fields lookup and grid suites, all of `plugin-form/src`, main's new `inCellFaces-35688`, `userCell.pickedRecord-36046` and `personDisplay` tests, and the five i18n parity suites: `Test Files 278 passed (278)`, `Tests 3178 passed | 1 skipped (3179)`. `check-i18n-en-drift` reports no en value changed. The three changeset gates exit 0. - **Dogfood battery at a111a0a** (whole battery, no shard): `Test Files 485 passed | 3 skipped (488)`, `Tests 4108 passed | 68 skipped (4176)`. - **CI at a111a0a:** every job is success or skipped. One `PR-body guards` run was cancelled because the body edit superseded it, and its re-run is success. `mergeable_state: clean`. - **Round 2 (L1-d 7077931050, L2 7077947187) at b6dafa6:** M1, the grid judges each currency column by its own child field. It is pinned through the grid: a fixed EUR price into a fixed EUR column fills under a USD home and under no home, a home price into a fixed EUR column is withheld, and a home price onto a line whose own code is JPY is withheld. Ablation on the committed tree (`const def = columnFields?.[c.name];` x1 to x0) gives `Tests 4 failed | 19 passed (23)`, restored blob `10d8999bda5b` == HEAD. L1-d 2, the form note uses the form's translated label: the zh test names `单价`. Ablation (the `labels` argument dropped) gives `Tests 1 failed | 14 passed (15)`, restored blob `f688c4c31af4` == HEAD. `Clause-②` is respelled `yes (narrowing)` and names the widenings. The changeset no longer names `planLookupAutofill` as an export. The grid `autofill` describe names the column's own currency, and the references are regenerated (`check:generated` VERDICT command-exit 0). Re-verification at b6dafa6, under `os-verify-lock` (VERDICT command-exit 0): `pnpm build` exit 0, and the `@object-ui/fields` and `@object-ui/plugin-form` type-checks exit 0. vitest over every `GridField*` and `LookupField*` suite, all of `plugin-form/src`, main's three new field tests and the five i18n parity suites: `Test Files 296 passed (296)`, `Tests 3309 passed | 1 skipped (3310)`. `check-i18n-en-drift` reports no en value changed. - **Dogfood battery at b6dafa6** (whole battery, no shard): `Test Files 485 passed | 3 skipped (488)`, `Tests 4108 passed | 68 skipped (4176)`. - **Derived sweep at b6dafa6:** `dispatch-gates --commands` now derives 120 commands; the new one is `check:error-status-conformance`. All 120 were run and all exit 0. `dispatch-gates --ran` reconciles `120 derived, 120 run, 0 NOT-MEASURED`. `overlap-check` VERDICT clean exit 0 before the push. CI at b6dafa6: no suite failed. - **Merge of main at bcdd021, after #36417:** #36417 moved the grid body to `widgets/grid-field/GridFieldWidget.tsx` and its pure helpers to the eager face `widgets/GridField.ts`. This PR's grid hunks are re-applied there. `gridAutofillCurrency`, the withheld state and note row, `columnFields`, and the `onSelectRecord` second argument are in the body. `planLookupAutofill`, with `lookupAutofillPatch` as its wrapper, is in the face. `index.tsx` still exports `lookupAutofillPatch` alone from it. The test imports the body as `GridFieldWidget as GridField`. - **Re-verification at bcdd021**, under `os-verify-lock` (VERDICT command-exit 0): `pnpm build` exit 0, and the fields and plugin-form type-checks exit 0. vitest over all of `packages/fields/` and `packages/plugin-form/`, plus the five i18n parity suites: `Test Files 571 passed | 1 skipped (572)`, `Tests 7707 passed | 8 skipped (7715)`. `check-i18n-en-drift`: no en value changed. Dogfood battery (whole, no shard): `Test Files 485 passed | 3 skipped (488)`, `Tests 4108 passed | 68 skipped (4176)`. The derived sweep is the same 120 commands; all exit 0, and `--ran` reconciles `120 run, 0 NOT-MEASURED`. CI at bcdd021: no suite failed. `overlap-check`: #36392 overlaps in `GridFieldWidget.tsx`, from the same move #36417 named. - **Round 3 (L2 delta 7081121014) at 970da9c:** M1 on the third host, `RecordBodyTableEditor` (the record page's line table): it now passes `columnCurrencies` (from `followedColumnCurrencies` over the line object's header-following fields) and `columnFields` (from `currencyFieldDefsOf`), as `LineItemsPanel` and `MasterDetailForm` already do. Pinned in `RecordBodyTableEditor.crossCurrency-36249.test.tsx`: a USD-home price onto a EUR invoice's line is withheld with a note naming $100.00 and EUR, onto a USD invoice it fills, a fixed EUR price into a fixed EUR column fills, and a home price into a fixed EUR column is withheld. Ablations on the committed tree: dropping `columnFields` gives `2 failed` of 4, dropping `columnCurrencies` gives `2 failed` of 4, each restored blob == HEAD. S6: a declared autofill target the grid does not draw is judged by its own child field through `columnFields[target]`, pinned in the grid suite (an undrawn `net_price` fixed EUR target is withheld); mutating the fallback gives `1 failed` of 24, restored blob == HEAD. N6: the changeset names the optional trailing `currency` parameter. S5 is carried by #36412 as item 4 (comment 7081194132). Re-verification at 970da9c under `os-verify-lock` (VERDICT command-exit 0): `pnpm build` exit 0, the fields and plugin-form type-checks exit 0, vitest over all of `packages/fields/` and `packages/plugin-form/` plus the five i18n parity suites `Test Files 572 passed | 1 skipped (573)`, `Tests 7712 passed | 8 skipped (7720)`, `check-i18n-en-drift` no en value changed, dogfood battery (whole, no shard) `Test Files 485 passed | 3 skipped (488)`, `Tests 4108 passed | 68 skipped (4176)`. Derived sweep: the same 120 commands, all exit 0, `--ran` reconciles `120 run, 0 NOT-MEASURED`. `overlap-check` VERDICT clean exit 0 before the push. CI: `Test Core (9/10)` is red outside this diff, explained in comment 7082279204: its eight non-cli packages pass locally at 970da9c (`Tasks: 75 successful, 75 total`); every other job is success or skipped. - **Round 4 (L2 delta 7082866706, S7) at 9ac9c94:** the record page's line table judges its followed columns against the record as the user has it in the open edit: `RecordBodyTableEditor` builds its header row as `{ ...data, ...draft }` from `useInlineEdit()`, the reading rule `InlineEditContext` states, so a currency code staged in the edit and saved with the new lines in the same batch is the code the pick is judged by. Pinned through the host under an `InlineEditProvider` with the code staged before the pick: stored USD with EUR staged withholds the home price with a note naming $100.00 and EUR, and stored EUR with USD staged fills it. Ablation on the committed tree (the draft overlay dropped, `() => savedRow`) gives `Tests 2 failed | 4 passed (6)`, restored blob `bcb2b1569030` == HEAD. N8 (the note names an undrawn target by its API name) stands as an accepted deviation. Re-verification at 9ac9c94 under `os-verify-lock` (VERDICT command-exit 0): `pnpm build` exit 0, the fields and plugin-form type-checks exit 0, vitest over all of `packages/fields/` and `packages/plugin-form/` plus the five i18n parity suites `Test Files 572 passed | 1 skipped (573)`, `Tests 7714 passed | 8 skipped (7722)`, `check-i18n-en-drift` no en value changed, dogfood battery (whole, no shard) `Test Files 485 passed | 3 skipped (488)`, `Tests 4108 passed | 68 skipped (4176)`. Derived sweep: the same 120 commands, all exit 0, `--ran` reconciles `120 run, 0 NOT-MEASURED`. `overlap-check` VERDICT clean exit 0 before the push. CI at 9ac9c94: check suite completed with nothing failed. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jTM6Q7J3o7taPraVR2 <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jTM6Q7J3o7taPraVR2 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 65ce798 commit 8da2b7e

35 files changed

Lines changed: 1288 additions & 62 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@object-ui/fields': minor
4+
'@object-ui/i18n': minor
5+
'@object-ui/plugin-form': minor
6+
---
7+
8+
fix(fields): a lookup pick no longer copies an amount into a field in another currency; the field stays empty and the form says why
9+
10+
Clause-②: yes (narrowing) — a cross-currency price copy that happens today stops and the line is left empty with a stated reason (ruled B); widened: three new `@object-ui/i18n` `lookup.autofill*` keys in every locale pack, new `@object-ui/fields` exports from `lookupAutofill.ts` (`planDeclaredLookupAutofill`, `crossCurrencyRefusal`, `amountCurrencyOf`, `pickedAmountCurrencyOf`, `withheldAutofillMessage`, `withLookupAutofillTargets`, `readLookupAutofillTargets`, `LOOKUP_AUTOFILL_TARGETS_KEY` and their types), an optional second argument on `onSelectRecord`, an optional trailing `currency` parameter on `declaredLookupAutofillPatch` and `lookupAutofillPatch`, and the optional `columnFields` prop on `GridField`
11+
Metadata-protocol: semantic
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed or renamed, and nothing stored is rewritten: what moved is what a pick copies in the browser. The fix for an author is in the body: the price on a line in another currency is entered by hand. -->
14+
15+
**BREAKING** for forms and line-item grids that relied on a pick copying an amount across currencies. On a EUR invoice, picking a product whose price is in the home currency used to copy the number as euros (a $100 product became a €100 line). Nothing converted it. Now the price is not copied: the cell or field stays empty, and a note under the line (in a grid) or under the lookup (in a form) names the picked amount with its currency and the currency of the field, so the price can be entered by hand. The other fields of the same pick (a description) still fill.
16+
17+
**The rule.** It applies to the grid's same-named copy (the column key `autofill`), to the grid's declared `lookupAutofill` pairs, and to the record form's declared pairs, on a pick and on a create form's opening fill:
18+
19+
- an amount is a `currency` field or a `formula` returning `currency`; a `number` carries no currency and copies as before;
20+
- both sides in the home currency (neither declares one) copy as before, also when no home currency is configured;
21+
- otherwise the value copies only when both sides name the same known code: a `fixed` code, the code the record holds, or the code its `master_detail` parent holds (ADR-0144 D2 as amended), with the home currency counting as its configured code;
22+
- a field that follows a record's currency while that record holds none yet is not filled, and the note says no currency is chosen yet.
23+
24+
Nothing is converted at any rate, and no build-time check is added: the line's currency is known only while the form is open.
25+
26+
**`@objectstack/spec`.** The describes of `FieldSchema.lookupAutofill` and of the inline grid column key `autofill` state the rule.
27+
28+
**`@object-ui/fields`.** `planDeclaredLookupAutofill` returns the writes and the withheld values of a pick; `declaredLookupAutofillPatch` and `lookupAutofillPatch` keep returning the writes alone. `LookupField` hands a host that owns the pick (`onSelectRecord`) the referenced object's field map as a second argument. `GridField` takes `columnFields`, the child field behind each currency column, so a `fixed` code or a code on the line decides that column's currency as on the record form.
29+
30+
**`@object-ui/plugin-form`.** The record form stamps the definitions of a lookup's `lookupAutofill` targets on the lookup's field metadata, each with the name the form shows for it, so the lookup can read each target's currency and names it as the form does. The line-item hosts hand their grid each currency column's child field.
31+
32+
**`@object-ui/i18n`.** Three new `lookup.autofill*` sentences, in every locale pack.

‎content/docs/data-modeling/fields.mdx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ product's `list_price`.
296296
- **Overwrite rule.** By default a pick never replaces a value somebody wrote: the
297297
target is filled only while it is empty or still holds the value an earlier pick
298298
filled in. A pair with `overwrite: true` replaces the target on every pick.
299+
- **Currency rule.** An amount of money (a `currency` field, or a `formula` returning
300+
`currency`) is copied only into a target in the same currency: both in the home
301+
currency, or both naming the same code (a `fixed` code, or the code the record or
302+
its `master_detail` parent holds). Otherwise the target is left as it is and the
303+
form says why, naming both currencies and the picked amount so the price can be
304+
entered by hand. Nothing is converted. A `number` carries no currency and copies
305+
as before. The grid's same-named copy follows the same rule.
299306
- **Client-side only.** The fill edits the form, and the filled value is saved as an
300307
ordinary write. Nothing on the write path reads the key: an import or an API
301308
write that sets the lookup fills nothing.

‎content/docs/references/data/field.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const result = CurrencyConfigSchema.parse(data);
9696
| **lookupFilters** | `{ field: string; operator: Enum<'eq' \| 'ne' \| 'gt' \| 'lt' \| 'gte' \| 'lte' \| 'contains' \| 'in' \| 'notIn'>; value: any; orEmpty?: boolean }[]` | optional | Base filters restricting which records are selectable (e.g. only active). The structured, picker-honoured lookup filter. Each entry compares a column of the CANDIDATE record (`field`, on the referenced object) with `value`. A value may read the record being edited as `{ $record: "field" }` or `{ $record: "lookup_field.field" }` (at most one lookup hop). In a record form, whatever its layout, the picker sends that value in its place and re-queries whenever a referenced field changes; every other picker host leaves every `{ $record }` entry out: inline edit on a record page, a record page's header or related list, an action's parameter dialog, and a picker with no single record being edited (a bulk action over selected rows). The referenced fields are implied: do not list them in `dependsOn`, which also scopes the candidate query by equality (`dependsOn: ['quote_date']` adds `quote_date = …` to the query over the referenced object). While the value is empty or cannot be read (the hop's row or field does not come back, no object is named for the hop, or the host has no single-row reader), the entry is left out. A `{ $record }` is the whole value, never a member of an `in` / `notIn` list. `orEmpty: true` also matches a candidate whose column is null. A `{ $record }` that reaches a server unresolved is refused (INVALID_FILTER), never read as null: by name, naming the field and the path, when it arrives as the eq shorthand on a column other than a date, datetime or time column; any other operator, and eq on a date, datetime or time column, is refused earlier, in generic words. The picker narrows the choice only: a rule the save must enforce belongs on the server too. |
9797
| **dependsOn** | `(string \| { field: string; param?: string })[]` | optional | Declares that this field's available values depend on the value of other field(s) on the same record — the form gates the field until they are set and re-evaluates as they change. For `lookup`/`master_detail` it scopes the candidate query (string = same local/remote key; `{field,param}` when the remote filter key differs — the `{field,param}` form is lookup-only). For `select`/`multiselect`/`radio` the actual per-option rule lives in each option's `visibleWhen`; list the referenced fields here (string form) so the option list gates and refreshes with the parent. |
9898
| **allowCreate** | `boolean` | optional | Allow inline quick-create from the record picker: when no match exists the user can create a record from the typed text (optimistic dataSource.create with the display field). Best for simple objects whose only required field is the display field. |
99-
| **lookupAutofill** | `{ target: string; source: string; overwrite?: boolean }[]` | optional | Fields a pick in this lookup fills on the record being edited: each `{ target, source }` pair copies the picked record's `source` field (a field of the `reference` object) into this object's `target` field — e.g. `[{ target: 'unit_price', source: 'list_price' }]` on a quote line's product lookup. Read wherever this field is picked: the record form, and a line-item grid column over it. OVERWRITE RULE — the default, `overwrite` absent or false: a pick never replaces a value somebody wrote. The target is filled only while it is empty or still holds the value an earlier pick filled in; a value the user typed, or one the record already stored, stays. Only a pair that declares `overwrite: true` replaces the target on every pick, whatever it holds. Client-side only: it fills the form, and nothing on the write path reads it — the filled value is saved as an ordinary write, and an import or API write that sets the lookup fills nothing. Only on a single-value `lookup` / `master_detail`. Each target is a field of this object other than this one, written by its author — not `readonly`, not computed (`formula`, `summary`, `autonumber`, or an `expression`) — and named once. Each source is a field of the referenced object that the record carries (not `internal`) and whose value the target can hold; `os validate` / `os build` judge the source. In a line-item grid the column key `autofill` still governs only the same-named copy and is unchanged; a declared pair takes its target out of that copy. |
99+
| **lookupAutofill** | `{ target: string; source: string; overwrite?: boolean }[]` | optional | Fields a pick in this lookup fills on the record being edited: each `{ target, source }` pair copies the picked record's `source` field (a field of the `reference` object) into this object's `target` field — e.g. `[{ target: 'unit_price', source: 'list_price' }]` on a quote line's product lookup. Read wherever this field is picked: the record form, and a line-item grid column over it. OVERWRITE RULE — the default, `overwrite` absent or false: a pick never replaces a value somebody wrote. The target is filled only while it is empty or still holds the value an earlier pick filled in; a value the user typed, or one the record already stored, stays. Only a pair that declares `overwrite: true` replaces the target on every pick, whatever it holds. CURRENCY RULE: an amount of money (a `currency` field, or a `formula` returning `currency`) is copied only into a target in the same currency, both in the home currency or both naming the same ISO 4217 code (a `fixed` code, or the code the record or its `master_detail` parent holds). Otherwise the target is left as it is and the form says why, naming both currencies and the picked amount; nothing is converted. A `number` carries no currency and copies as before. Client-side only: it fills the form, and nothing on the write path reads it — the filled value is saved as an ordinary write, and an import or API write that sets the lookup fills nothing. Only on a single-value `lookup` / `master_detail`. Each target is a field of this object other than this one, written by its author — not `readonly`, not computed (`formula`, `summary`, `autonumber`, or an `expression`) — and named once. Each source is a field of the referenced object that the record carries (not `internal`) and whose value the target can hold; `os validate` / `os build` judge the source. In a line-item grid the column key `autofill` still governs only the same-named copy, under the same currency rule; a declared pair takes its target out of that copy. |
100100
| **expression** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | CEL expression the field's value is computed from, e.g. F`record.amount * 0.1`. On a `formula` field: computed on read, no column. On any other (stored) field: computed by the engine from the row the write stores and stored, so a client-sent value never stands and a `summary` can roll the column up — on every insert and every update by id (the stored row merged with the patch), and on a predicate update only when the patch moves an input (one value for every matched row, else the update is refused). |
101101
| **returnType** | `Enum<'number' \| 'text' \| 'boolean' \| 'date' \| 'currency' \| 'percent'>` | optional | Value type of a formula field (number/text/boolean/date/currency/percent). Authoring stamps `number`, `text`, `boolean` or `date` from the expression's inferred type and leaves it absent when none is proven; `percent` is declared by the author, and a verdict that proves no other type (`number`, or none) keeps it, as does a money verdict: a declared `percent` is never re-stamped `currency`. Otherwise `currency` is stamped when the expression provably computes money, and withdrawn for `number` (its `currencyConfig` dropped) when an edit leaves it a plain number; an unproven verdict keeps it. `currency`: an amount of money, in the currency the formula's own `currencyConfig` declares, as a currency field declares it (no `currencyConfig`: dynamic, the tenant default currency). `percent`: a ratio, read and displayed as a `percent` field reads its stored value — a fraction (0.25 shows 25%, so the expression divides and does not multiply by 100) unless the formula declares a `max` above 1, then percentage points; its `scale` is the decimal places of the displayed percentage (absent: 0), and its `percentDisplay` picks the bar or the plain face. |
102102
| **summaryOperations** | `{ object: string; field?: string; function: Enum<'count' \| 'sum' \| 'min' \| 'max' \| 'avg'>; relationshipField?: string; … }` | optional | Roll-up summary definition. The engine recomputes the value when child records are inserted/updated/deleted. |
@@ -236,7 +236,7 @@ const result = CurrencyConfigSchema.parse(data);
236236
| **computed** | `boolean` | optional | Read-only computed column, recomputed live from sibling cells via `expr` and written back into the row. |
237237
| **expr** | `string` | optional | Arithmetic expression for a computed column — a BARE string over `+ - * / %`, parentheses, numeric literals and field refs (`record.qty` or `qty`), evaluated by the grid's own safe evaluator. Deliberately NOT a CEL Expression envelope; `{ dialect, source }` is refused here. |
238238
| **scale** | `integer` | optional | Decimal places to round a computed numeric result to (integer 0-100). REFUSED on a column declaring `type: 'currency'` — delete it there: the currency's CLDR fraction digits decide. The upper bound is the renderer's: the grid rounds with `toFixed`, which throws a RangeError above 100. |
239-
| **autofill** | `boolean` | optional | For `lookup` columns: picking a record copies its same-named fields into sibling columns (a product's unit_price/description). On by default; set false to disable. |
239+
| **autofill** | `boolean` | optional | For `lookup` columns: picking a record copies its same-named fields into sibling columns (a product's unit_price/description). On by default; set false to disable. An amount of money is copied only into a cell in the same currency: a picked amount in another currency than its cell (its child field's: a `fixed` code, the code the line or its header holds, or the home currency) is not copied, the cell stays empty and the grid says why. Nothing is converted. |
240240
| **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — the cell is read-only when TRUE, evaluated per row against the row as `record` plus the header as `parent` (e.g. P`parent.status == 'paid'`). |
241241
| **requiredWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — the cell is required when TRUE. Same `record` + `parent` scope as `readonlyWhen`. PRESENTATION ONLY: this flags the cell inline-invalid in the grid; nothing on the write path reads it. The server-enforced contract is the child FIELD's own `requiredWhen` — a transition gate, see `Field.requiredWhen` — which hydration copies onto an identity-only column, so declaring the requirement here alone enforces nothing. |
242242

@@ -434,7 +434,7 @@ Allowed Values: `phone`, `id_card`, `bank_account`, `email`, `name`
434434
| **computed** | `boolean` | optional | Read-only computed column, recomputed live from sibling cells via `expr` and written back into the row. |
435435
| **expr** | `string` | optional | Arithmetic expression for a computed column — a BARE string over `+ - * / %`, parentheses, numeric literals and field refs (`record.qty` or `qty`), evaluated by the grid's own safe evaluator. Deliberately NOT a CEL Expression envelope; `{ dialect, source }` is refused here. |
436436
| **scale** | `integer` | optional | Decimal places to round a computed numeric result to (integer 0-100). REFUSED on a column declaring `type: 'currency'` — delete it there: the currency's CLDR fraction digits decide. The upper bound is the renderer's: the grid rounds with `toFixed`, which throws a RangeError above 100. |
437-
| **autofill** | `boolean` | optional | For `lookup` columns: picking a record copies its same-named fields into sibling columns (a product's unit_price/description). On by default; set false to disable. |
437+
| **autofill** | `boolean` | optional | For `lookup` columns: picking a record copies its same-named fields into sibling columns (a product's unit_price/description). On by default; set false to disable. An amount of money is copied only into a cell in the same currency: a picked amount in another currency than its cell (its child field's: a `fixed` code, the code the line or its header holds, or the home currency) is not copied, the cell stays empty and the grid says why. Nothing is converted. |
438438
| **readonlyWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — the cell is read-only when TRUE, evaluated per row against the row as `record` plus the header as `parent` (e.g. P`parent.status == 'paid'`). |
439439
| **requiredWhen** | `string \| { dialect: Enum<'cel' \| 'cron' \| 'template'>; source: string; ast?: any; meta?: object }` | optional | Predicate (CEL) — the cell is required when TRUE. Same `record` + `parent` scope as `readonlyWhen`. PRESENTATION ONLY: this flags the cell inline-invalid in the grid; nothing on the write path reads it. The server-enforced contract is the child FIELD's own `requiredWhen` — a transition gate, see `Field.requiredWhen` — which hydration copies onto an identity-only column, so declaring the requirement here alone enforces nothing. |
440440

0 commit comments

Comments
 (0)