Skip to content

fix(fields): after a same-edit currency change, a pick's amounts stay and their notes follow the new currency - #37284

Draft
objectstack-fleet[bot] wants to merge 2 commits into
mainfrom
claude/issue-36412-currency-change-notes
Draft

objectstack-fleet[bot] wants to merge 2 commits into
mainfrom
claude/issue-36412-currency-change-notes

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #36412

repo:objectstack#4 · os-justin · session_01QSeKYnagJvGbCtNg2PhvgW

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户可见变化:在报价、订单、发票里选产品带出价格后,如果在同一次编辑中改了币种,价格不会被改动或清空,下方会说明这笔价格是按哪个币种带入的、记录现在是哪个币种;没带入的价格提示会跟着换成新币种;改回与产品价格相同的币种时,提示保留、价格仍空,并提示重新选取即可带入。
  • 为什么做:这是「选产品不跨币种抄价格」那张卡里最后一项(「保留金额并提示」及其 B 方案),替多币种单据的使用者补上改币种后的说明。
  • 出错会怎样:只影响价格下方的提示文字,不写入、不清除任何金额;手动输入的金额不显示提示;可以直接撤回这一个合并。
  • 要你做什么:无。

What changes

The ruling item on this card (comment 7118795825, 「保留金额并提示」) and its branch B (comment 7158109013), on both hosts: the line-item grid (GridFieldWidget) and the record form (LookupField with the declared pairs). Scope is bounded by ADR-0144 D2: new records, records with no saved lines, lines staged in the same edit, and declared pairs on the record's own amounts. Items 1–4 landed in #36918. With this PR the card's last open item is done.

  • Point 1: a currency change in the same edit never changes or clears a filled amount. Measured first. This already holds on main (057cedfa9b6): nothing writes an amount when the code changes. The new pins were run against main's source files, and every amount assertion passed there; the only failures were the note lines that come after them (see Tests). Pinned either way, on both hosts. This PR adds no write.
  • Point 2: an amount a pick copied gets a note once the currencies differ. judgePickWrites now records each amount it copies as CopiedAutofill (target, source, value, under: the code the target was in at the write). The plan gains copied. Each host keeps these beside the withheld values of the same pick. When drawing, it shows "Unit Price was copied as $100.00, but the record is now in EUR. Enter Unit Price in EUR if it should change." only when all of these hold (copiedAutofillNow): the field still holds that pick, the target still holds the copied value, and the code the target is in now is known and differs from under. A currency change back ends the note.
  • Point 3: a withheld note already shown refreshes to the record's new currency. withheldAutofillNow judges each shown withheld item again with crossCurrencyRefusal, using the picked amount's own currency (its from) against the target's currency as it is now. The note follows the new code, and its reason too: a code cleared reads "no currency is chosen".
  • Point 4: a hand-typed amount gets no note. Only a pick records a copied amount, and the note needs the target to still hold the copied value. So an amount typed by hand, or typed over a copied one, says nothing.
  • Branch B. When the record's currency turns to the picked amount's own, the re-judgement copies nothing. The item takes the new reason nowSameCurrency, the note stays and the cell stays empty: "Unit Price was not filled when it was picked. The record is now in USD: pick again to fill $100.00." A pick again fills it (pinned as the control on the record form).
  • "Now" on each host is the same context the pick used, with no picked row. On the grid that is gridAutofillCurrency on the current line, with columnCurrencies (a header-following line) or columnFields (the line's own code). On the record form it is currencyFor on the live record, followed parent included. So a code written later in the edit is read exactly as a pick would read it.
  • i18n: two sentences, lookup.autofillNowSameCurrency and lookup.autofillCopiedUnder, in all 11 packs (zh-Hant generated by gen:zh-hant) and in FIELD_DEFAULTS.
  • One changeset, .changeset/36412-currency-change-notes.md: @object-ui/fields and @object-ui/i18n, both patch. The fix(fields): a pick says why it kept a filled amount, the opening fill stops waiting on an unreadable parent, and a code-plus-amount pick copies both #36918 changeset is left untouched. @object-ui/plugin-form changes in its test file only, which is not published.

Tests

Tests on head 482148532, all under os-verify-lock: pnpm --dir ui exec vitest run --maxWorkers=2 packages/fields/ packages/plugin-form/ packages/i18n/ gives Test Files 686 passed, 1 skipped (687), and Tests 9840 passed, 21 skipped (9861), VERDICT command-exit 0. type-check of @object-ui/fields, @object-ui/plugin-form and @object-ui/i18n exits 0, after the closure build. Both pin files are in the tsconfig.test.json program (--listFiles: 1 hit each).

New pins, the point 1 measurement, and ablations
  • ObjectForm.lookupAutofill-28245.test.tsx, new describe "a same-edit currency change keeps amounts and says so", 4 tests through ObjectForm. (1) A USD quote picks a $100 product. Changed to EUR, it keeps 100 and shows the copied note with its exact text. Control: before the change there is no note, and changing back to USD ends it. (2) A JPY quote's withheld note names GBP and no longer JPY after the code becomes GBP, and the price stays empty. (3) Branch B: a EUR quote's withheld note reads exactly "Unit Price was not filled when it was picked. The record is now in USD: pick again to fill $100.00." once the code becomes USD, and the price stays empty. Control: the pick again fills 100 and no note remains. (4) A typed 55 gets no note through a currency change, and neither does 55 typed over a copied 100.
  • GridField.lookupAutofill-28245.test.tsx, new describe of the same name, 5 tests. The same four cases through GridField, with the header currency handed in as columnCurrencies and changed by a rerender, for a product priced in EUR. One more is pure: withheldAutofillNow follows the currency now, nowSameCurrency applies when it matches, and with no currency known the item is returned unchanged; copiedAutofillNow names a differing code only while the target holds the copied value. The Cross-currency pick follow-ups: no note on a re-pick over a filled cell, an unbounded opening wait, record forms outside the gate, and a code-plus-amount pick #36412 declared-pairs pin now also asserts copied (the price is recorded under the code the same pick wrote).
  • Point 1 measured on main's code. The five source files were restored to 057cedfa9b6 in the tree only, the -t ruling pins were run, and the files were restored with git checkout HEAD (git diff HEAD empty afterwards). Result: 7 failed, 2 passed. The two hand-typed pins passed. Both copied-amount pins failed on the note line after their amount assertion (ObjectForm line 745, GridField line 641): the amount kept its value through the currency change on main. The refresh and branch B pins failed on their note text, and the pure pin failed on the missing export. Point 1 has no implementing line to ablate: nothing writes an amount on a currency change, before or after this PR.
  • Ablations on the committed tree with scripts/ablation-replace.mjs (lookupAutofill.ts; vitest aliases @object-ui/* to src, so no dist sits between mutation and run), -t ruling, each restored to the HEAD blob 18535d11faef:
    • if (!now) return item; becomes return item; (no refresh): Tests 5 failed, 4 passed. Refresh and branch B on both hosts, plus the pure pin.
    • return to && to !== item.under ? to : undefined; becomes return undefined; (no copied note): Tests 3 failed, 6 passed. Copied note on both hosts, plus the pure pin.
    • if (!sameValue(current, item.value) || !now) return undefined; becomes if (!now) return undefined; (a typed-over amount keeps the note): Tests 3 failed, 6 passed. Hand-typed on both hosts, plus the pure pin.

Acceptance notes

  • Clause-② measured no: the diff touches no packages/spec/** and no metadata. On the published @object-ui/fields surface it adds exports and widens one union (WithheldAutofill.reason), and LookupAutofillPlan gains a required copied. git grep at 482148532 finds LookupAutofillPlan built or read only inside ui/packages/fields (6 hits, 2 files), so no consumer anywhere builds one.
  • Branch B over a filled target: a re-pick over an earlier value, held, keeps the kept sentence after the branch B sentence. For a declared pair without overwrite, a pick again of the same record does not replace that earlier value (the spec's overwrite rule: it was not filled by this record), so "pick again" is then true only after the cell is cleared. The ruling describes the empty-cell case, which is what is pinned. Noted, not filed.
  • A copied amount whose record's currency becomes unset or unreadable gets no note (no current code to name). Only a known, different code is named, as the ruling's example reads.
  • N9 (record-page editor re-renders): not measured. The new work per render is one re-judgement per shown note, and nothing runs when no pick left a note.

Verification

Gates

Read first, by risk: (1) judgeCopy, withheldAutofillNow and copiedAutofillNow in lookupAutofill.ts; (2) the note block at the end of LookupField.tsx (pickStands, currencyNow); (3) the per-row note block in GridFieldWidget.tsx (lineCurrencyNow).

Two-minute check: pnpm --dir ui exec vitest run packages/plugin-form/src/ObjectForm.lookupAutofill-28245.test.tsx -t ruling passes 4 tests. In them, a USD quote picks a $100 product, changes its currency to EUR, keeps 100, and shows "Unit Price was copied as $100.00, but the record is now in EUR."

https://claude.ai/code/session_01QSeKYnagJvGbCtNg2PhvgW

🤖 Generated with Claude Code


Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants