feat(analytics): resolve a monetary measure's currency via field config + tenant default#2121
Merged
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1b — analytics measure-currency chain
Builds on #2119 (
ExecutionContext.currency). The dataset measure-currency enrichment honored only an explicit measurecurrencyliteral (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:
A measure is monetary iff it declares a currency or aggregates a
currency-type field — socount/ avg-of-a-number measures never receive a (wrong) currency code.Changes
AnalyticsServiceConfig.measureCurrency(object, field)→ source-field{ type, defaultCurrency }; the enrichment applies the chain, gated on monetary type.measureCurrencyfrom the data engine'sgetObject().fields— the same accessor the dimension label resolver already uses (no new dependency).Tests
query-dataset→ 15 passed (+4):defaultCurrencyctx.currencyFollow-ups
{{ x | currency }}) still hard-defaults toUSD; threadingctx.currencythere is a small separate change (different package).🤖 Generated with Claude Code