Commit 4cd46eb
feat(analytics): propagate a measure's declared currency to the result field
A dataset measure could declare a `format` (carried onto the analytics result
field so the client renders "$616,000"), but there was NO way to declare a
currency CODE. The analytics result enrichment set `label` + `format` on each
measure field but never `currency` — so the client's currency-aware formatting
(Intl symbol from a declared currency, ADR-0021; objectui DatasetWidget/report
renderer) could never fire against real data: every amount fell back to a plain
number or a "$" literal baked into `format`, regardless of the actual currency.
This adds the missing link, symmetric with `format`:
- spec: `DatasetMeasure.currency` (ISO 4217, optional) — declared on the
semantic layer when the aggregated field is a fixed-currency amount.
- service-analytics: carry `measure.currency` onto the result field alongside
`label`/`format`, so the renderer gets a real currency code.
- example (app-crm): `opportunity_metrics` total/avg amount now declare
`currency: 'USD'` (and drop the legacy `$` from `format`) so the pipeline
reports render a locale-correct symbol via Intl.
Tests: service-analytics 138 passed (+1: a measure's declared currency rides
onto its result field). Spec builds; the new field is additive + optional.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 26d7df4 commit 4cd46eb
4 files changed
Lines changed: 37 additions & 2 deletions
File tree
- examples/app-crm/src/datasets
- packages
- services/service-analytics/src
- __tests__
- spec/src/ui
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
102 | 125 | | |
103 | 126 | | |
104 | 127 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
527 | 532 | | |
528 | 533 | | |
529 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
0 commit comments