Skip to content

feat(analytics): resolve a monetary measure's currency via field config + tenant default - #2121

Merged
xuyushun441-sys merged 2 commits into
mainfrom
phase1b-analytics-currency
Jun 21, 2026
Merged

feat(analytics): resolve a monetary measure's currency via field config + tenant default#2121
xuyushun441-sys merged 2 commits into
mainfrom
phase1b-analytics-currency

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Phase 1b — analytics measure-currency chain

Builds on #2119 (ExecutionContext.currency). The dataset measure-currency enrichment honored only an explicit measure currency literal (the original #2102 behavior) — so a measure summing a currency field, or any measure on a tenant with a configured default currency, rendered symbol-less unless the author restated the code on every measure.

Now a monetary measure resolves through the documented chain:

explicit measure `currency`
→ source-field `currencyConfig.defaultCurrency`
→ tenant default (`ctx.currency`, from the localization setting wired in #2119)

A measure is monetary iff it declares a currency or aggregates a currency-type field — so count / avg-of-a-number measures never receive a (wrong) currency code.

Changes

  • analytics-service: AnalyticsServiceConfig.measureCurrency(object, field) → source-field { type, defaultCurrency }; the enrichment applies the chain, gated on monetary type.
  • plugin: wires measureCurrency from the data engine's getObject().fields — the same accessor the dimension label resolver already uses (no new dependency).

Tests

query-dataset15 passed (+4):

  • currency-field measure with no explicit currency → inherits field defaultCurrency
  • currency field with no default → falls back to ctx.currency
  • explicit measure currency wins over field default + tenant ctx
  • a non-currency field measure stays code-less even with a tenant default

Follow-ups

  • Template-engine ({{ x | currency }}) still hard-defaults to USD; threading ctx.currency there is a small separate change (different package).
  • Phase 2 (objectui): one shared resolver/formatter + a client context exposing the tenant default; replace the ~20 ad-hoc client sites.

🤖 Generated with Claude Code

os-zhuangand others added 2 commits June 21, 2026 17:44
…ig + tenant default
Phase 1b of unifying currency resolution (builds on ExecutionContext.currency).
The dataset measure-currency enrichment honored ONLY an explicit measure
`currency` literal — so a measure summing a currency field, or any measure on a
tenant with a configured default currency, rendered symbol-less unless the
author restated the code.
Now a MONETARY measure resolves its display currency through the documented
chain: explicit measure `currency` → source-field `currencyConfig.defaultCurrency`
→ tenant default (`ctx.currency`, from the localization setting wired in #2119).
A measure is monetary iff it declares a currency OR aggregates a `currency`-type
field — so count / avg-of-number measures never get a (wrong) currency code.
- analytics-service: `AnalyticsServiceConfig.measureCurrency(object, field)` →
source-field `{ type, defaultCurrency }`; enrichment applies the chain, gated
on monetary type.
- plugin: wires `measureCurrency` from the data engine's `getObject().fields`
(same accessor the label resolver already uses).
Tests: query-dataset 15 passed (+4: field-default inheritance, tenant-ctx
fallback, explicit-override precedence, and non-currency measures staying
code-less).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJun 21, 2026 9:47am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/s labels Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/guides/packages.mdx(via packages/services)
  • content/docs/guides/runtime-services/audit-service.mdx(via packages/services)
  • content/docs/guides/runtime-services/index.mdx(via packages/services)
  • content/docs/guides/runtime-services/settings-service.mdx(via packages/services)
  • content/docs/protocol/objectos/i18n-standard.mdx(via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@xuyushun441-sys
xuyushun441-sys merged commit 70609af into mainJun 21, 2026
16 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the phase1b-analytics-currency branch June 21, 2026 09:55
xuyushun441-sys added a commit that referenced this pull request Jun 21, 2026
…ode; showcase demo (#2123)
* docs(currency): document the field→tenant resolution chain; fix currencyMode; showcase demo
Follows the currency-resolution work (#2102/#2119/#2121/#2122). Brings the
skills + showcase in line with the now-implemented chain.
- objectstack-ui SKILL: document `DatasetMeasure.currency` (ISO 4217) and its
resolution order (measure → field `currencyConfig` → tenant default).
- objectstack-data field-types: FIX a real doc bug — `currencyMode` was
documented as `'multi'/'single'`, the schema is `'fixed'/'dynamic'`; add a
"Currency resolution (ADR-0053)" note (field default → tenant default → plain
number, never a hardcoded `$`).
- objectstack-i18n SKILL: note the workspace regional defaults (timezone /
locale / currency) — the `localization` settings, resolved onto ExecutionContext
and exposed at `/auth/me/localization`.
- showcase: declare a fixed `currencyConfig.defaultCurrency` on field-zoo's
currency field (demonstrates + smoke-covers the symbol path); refresh the
chart-gallery `budget`/`spent` comment, which claimed an unspecified-currency
amount "must not show a $" — now it falls back to the tenant default.
Verified: app-showcase builds (field + dataset parse); check:skill-docs in sync.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(showcase): currencyConfig requires precision (typecheck)
---------
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/steststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xuyushun441-sys@os-zhuang