Commit 70609af
feat(analytics): resolve a monetary measure's currency via field config + tenant default (#2121)
* feat(analytics): resolve a monetary measure's currency via field config + 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>
* chore: changeset for analytics measure-currency chain
---------
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 220ce5b commit 70609af
4 files changed
Lines changed: 81 additions & 3 deletions
File tree
- .changeset
- packages/services/service-analytics/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
125 | 164 | | |
126 | 165 | | |
127 | 166 | | |
| |||
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
144 | 152 | | |
145 | 153 | | |
146 | 154 | | |
| |||
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
| 215 | + | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
| |||
222 | 231 | | |
223 | 232 | | |
224 | 233 | | |
| 234 | + | |
225 | 235 | | |
226 | 236 | | |
227 | 237 | | |
| |||
524 | 534 | | |
525 | 535 | | |
526 | 536 | | |
527 | | - | |
528 | | - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
529 | 543 | | |
530 | 544 | | |
531 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
532 | 553 | | |
533 | 554 | | |
534 | 555 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
439 | 446 | | |
440 | 447 | | |
441 | 448 | | |
| |||
0 commit comments