Repository navigation
fix(example-crm): the opportunity dataset's amount measures inherit the tenant currency - #27205
Conversation
…he tenant currency `total_amount` and `avg_amount` aggregate `opportunity.amount`, a dynamic currency field, yet each hard-coded `currency: 'USD'`, so a tenant whose books are in EUR or CNY saw `$` on the pipeline tiles. With the key gone the measures inherit the field -> tenant-default chain (ADR-0104 D1). The pipeline dashboard comment that quoted the key now says where the currency comes from. Claude-Session: https://claude.ai/code/session_01QSeKYmLevd91XpqGmYf7fU Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYmLevd91XpqGmYf7fU Co-authored-by: Claude <noreply@anthropic.com>
…a currency 'Total Pipeline ($)' and 'Open Pipeline by Stage ($)' printed a dollar sign over measures that now follow the tenant's currency; the tile's own number face carries the symbol. Claude-Session: https://claude.ai/code/session_01QSeKYmLevd91XpqGmYf7fU Co-authored-by: Claude <noreply@anthropic.com>
席位核对 — ACCEPT · domain:devx#2 · head
|
Fixes #27158
Clause-②: no
Metadata-protocol: none
维护者速读
opportunity.dataset.ts两个金额度量(total_amount、avg_amount)上的currency: 'USD',并把pipeline.dashboard.ts里引用这个键的注释改成币种的实际来源;并去掉看板两个金额标题里写死的 ($)。amount是动态币种字段,写死 USD 会让非美元组织在管道看板上看到$;去掉后度量走「字段 → 组织默认币种」链(ADR-0104 D1,裁决 6464202770 的 G4)。examples/app-crm/src/datasets/opportunity.dataset.ts(两行度量);examples/app-crm/src/dashboards/pipeline.dashboard.ts(注释)。git grep -n "currency: 'USD'" -- examples/app-crm预期零命中;pnpm --filter @objectstack/example-crm test预期 46/46 通过。What changes
examples/app-crm/src/datasets/opportunity.dataset.ts: thetotal_amountandavg_amountmeasures overcrm_opportunity.amountlosecurrency: 'USD'. They now inherit the analytics chainpackages/services/service-analytics/src/analytics-service.ts:3127, measurecurrencythen the field'sdefaultCurrency(fixed mode only) then the tenant defaultctx.currency.amountis a dynamicField.currencywith nocurrencyConfig, so the tiles show the tenant default currency. A three-line comment abovemeasuressays why the key is absent.examples/app-crm/src/dashboards/pipeline.dashboard.ts: the KPI-tile comment said the measures "declareformat+currency". It now says they declareformat, and that their currency is theamountfield's (the tenant default). Comment only.examples/app-crmisprivate: true, so this PR carriesskip-changeset.pipeline.dashboard.ts: thetotal_pipelineandpipeline_by_industrytitles drop their hard-coded($)('Total Pipeline','Open Pipeline by Stage'); the tiles' number face carries the tenant's symbol. Same family, fixed in place on the seat's patch round (addendum 6467121533).Q3: confirming the claim's premise (no docs edit)
Both sentences the card named already read as shipped on
main(2f96d874, and unchanged at the merged head031ff70c):content/docs/protocol/objectql/index.mdx:121: "Money, in the field's fixed currency or the tenant default", example "1000(a bare number)".content/docs/protocol/objectql/types.mdx:30: "Store a bare number, no per-record currency code". The section at L290 agrees ("stored as a bare number. The currency is field configuration, never stored per value").Neither "exchange rates" nor "amount + currency code" survives on either page. That half of the card shipped earlier, so this PR only does G4.
Tests
At head
8f724ac7(the title patch):pnpm --filter @objectstack/example-crm test6/6 files, 46/46 tests; typecheck exit 0;objectstack validatepassed; the 34 derived gates all exit 0 (addendum 6467121533). The readings below are the previous head's.No CRM test, pin or generated artifact asserts or quotes the removed keys. I checked with
git grepforopportunity_metrics,OpportunityDatasetandopportunity.datasetacross the tree, then for currency or USD in every file it hit. The one service-analytics test that expectscurrencyUSD(measure-column-aggregate.test.ts:144) uses its own fixture and a tenant context ofUSD, not the CRM dataset. No assertion was changed.The run on the final head
031ff70c(after mergingorigin/mainb322b5da):pnpm --filter @objectstack/example-crm test: Test Files 6 passed (6), Tests 46 passed (46).pnpm --filter @objectstack/example-crm typecheck:tsc --noEmitexit 0.objectstack validate(CRM): "Validation passed". It reports no diagnostic that names a currency, a dataset oropportunity_metrics. Thefield-no-consumerswarnings are pre-existing.pnpm --filter @objectstack/spec check:generated: exit 0.packages/specmoved in the merge, so this re-check was needed.No ablation: the change is example metadata and a comment, and it changes no tested behaviour.
Acceptance notes
$. This is the ruled Q2 = X outcome: no explicit currency and no tenant default means DISPLAY carries no symbol.content/docs/data-modeling/field-type-decision-tree.mdx:228says "Money needs currency code and decimal handling". This loosely implies a per-value code.content/docs/references/data/field.mdx(CurrencyValue section) is generated from the@deprecatedCurrencyValueSchema(packages/spec/src/data/field.zod.ts:581). It publishes a{ value, currency }shape with no deprecation note. ADR-0104 D1 deletes that schema, and its removal rides the next spec major.Verification
Derived gates (
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack): 34 commands. I ran all 34 on head031ff70cand each exited 0.--ranreconciliation: "34 derived famil(ies) accounted for — 34 run, 0 NOT-MEASURED (a DERIVED zero — all 34 recorded an exit code and none of them is 3)". On the first pass,check:dual-build-cjs-loadsandcheck:i18n-coverageexited 3 with PREREQUISITE NOT MET because some packages were unbuilt. I built./packages/**and both then exited 0.node scripts/docs-audit/affected-docs.mjs: "0 docs name something this change touched".CI runs the families outside the derived list.
Derived gate list, each with its exit on 031ff70
Not governed: the diff touches only
examples/app-crm/src/**.Generated by Claude Code