Skip to content

Commit 1e38614

Browse files
committed
docs(skills): teach the derived-measure fixed-currency refusal beside the two fixed-currency refusals
A derived sum or difference whose operands all resolve to one fixed code refuses another currency at compile (DATASET_INVALID / 400); the prescription is the shipped message's: delete the measure's currency (the column takes the operands' code), or restate it. The two skill texts and the two docs pages teach it in those words, and the docs say the derived column carries that code on the wire too, as main now does. The skills token ratchet is paid by deleting a convention already shown in the example above it (field-types.md) and a retired-key parenthetical the parse refusal and the Dataset-Bound Widgets paragraph already carry (dashboards.md). Claude-Session: https://claude.ai/code/session_01FEkQ5nqSVzKxNiy5ZH2o44 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5da3a8c commit 1e38614

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

‎content/docs/api/data-api.mdx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,12 +518,18 @@ monetary measure column takes the measure's own `currency`; then, only when the
518518
field is `currencyMode: 'fixed'`, that field's `currencyConfig.defaultCurrency`; then the
519519
tenant default currency (the `localization.currency` setting), if one is set. A
520520
`dynamic` field (the default mode) never lends its `defaultCurrency` — only `fixed` does —
521-
so its column shows the tenant default. The cube query on this page carries no column
522-
`currency`.
521+
so its column shows the tenant default. A derived `sum` or `difference` whose monetary
522+
operands all resolve to one `fixed` code takes that code at the field's step; any other
523+
derived measure (a `ratio`, a `product`, operands in the tenant's currency) is monetary
524+
only by its own `currency`, else its column carries none. The cube query on this page
525+
carries no column `currency`.
523526

524527
Over a `fixed` field the measure's `currency` may only restate the field's code. A
525528
different code is refused when the dataset compiles, with `DATASET_INVALID` / 400: delete
526-
the measure's `currency`, and the column takes the field's code. A derived measure whose
529+
the measure's `currency`, and the column takes the field's code. A derived `sum` or
530+
`difference` whose operands resolve to one `fixed` code is held to the same rule: a
531+
different `currency` is refused with `DATASET_INVALID` / 400 — delete the measure's
532+
`currency` (the column takes the operands' code), or restate it. A derived measure whose
527533
monetary operands resolve to two different `fixed` codes is refused the same way, whatever
528534
the operation: derive it from measures in one currency, or drop the operand in the other.
529535
Neither a `fixed` code against the tenant default nor a measure `currency` over a

‎content/docs/data-modeling/currency.mdx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ that column. A `count` column never carries `currencyField`. See the
178178
- **A derived measure whose monetary operands resolve to two different `fixed` codes** is
179179
refused at compile with `DATASET_INVALID` / 400, whatever the operation. Derive it from
180180
measures in one currency, or drop the operand in the other. A derived `sum` or
181-
`difference` over one `fixed` code carries that code, so a measure built on it is judged
182-
the same way.
181+
`difference` over one `fixed` code carries that code, on its result column too, so a
182+
measure built on it is judged the same way.
183+
- **A derived `sum` or `difference` whose `currency` differs from its operands' one `fixed`
184+
code** is refused at compile with `DATASET_INVALID` / 400: `currency: 'USD'` over two
185+
measures fixed to `EUR` would print euros as dollars. Delete the measure's `currency`, and
186+
the column takes the operands' code, or restate that code.
183187
- **Not judged:** a `fixed` code against the tenant currency, which compile does not know,
184188
and a measure `currency` over a `dynamic` field, which wins as the top of the currency
185189
chain.

‎skills/objectstack-data/rules/field-types.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ Stored as JSON on the parent row — no separate table / FK:
170170
`{ value, currency }`. Shown: `'fixed'`, `defaultCurrency`; `'dynamic'`
171171
(default), the tenant `localization.currency`, else a plain number (never
172172
`$`); `'record'`, each record's code in the `text` field `currencyField`
173-
names (by convention `currency_code`), with `valueDomain: 'iso_4217_currency'`. A
174-
dataset measure's own `currency` wins over a `'dynamic'` field; over a `'fixed'` one
175-
it may only restate the code, else `DATASET_INVALID` (objectstack-ui →
173+
names, with `valueDomain: 'iso_4217_currency'`. A
174+
dataset measure's own `currency` wins over a `'dynamic'` field; over a `'fixed'` one,
175+
or a derived sum/difference over one `'fixed'` code, it may only restate that code,
176+
else `DATASET_INVALID`: delete it, and the column takes the code (objectstack-ui →
176177
Dashboards). A `'fixed'` code is not judged against the tenant's. Switched a
177178
stored field to `'record'`? Backfill: `os migrate record-currency-codes`.
178179

‎skills/objectstack-ui/rules/dashboards.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ The **dataset dimension carries the default; a widget's
282282
`options.dateGranularity` overrides it for that widget only.** Give a date
283283
dimension a `dateGranularity` and any presentation that selects it groups by that
284284
bucket server-side — without it every distinct timestamp becomes its own
285-
category, collapsing a 12-row seed into a 12-point flat line. (The old widget-level
286-
`categoryGranularity` was removed in the single-form cutover.)
285+
category, collapsing a 12-row seed into a 12-point flat line.
287286

288287
<!-- os:check -->
289288
```typescript
@@ -301,8 +300,9 @@ defineDataset({
301300
// `currencyMode: 'record'` amount refuses `currency`, and sum/avg/min/max
302301
// unless grouped by its code field; then the column carries
303302
// `currencyField` (the per-row code column); a `count` never does. A `fixed`
304-
// field refuses a different `currency` (delete it; restating is fine), and
305-
// a derived measure refuses operands in two `fixed` codes (derive from one
303+
// field, or a derived sum/difference over one `fixed` code, refuses another
304+
// `currency` (delete it, the column takes that code; restating is fine); a
305+
// derived measure refuses operands in two `fixed` codes (derive from one
306306
// currency or drop one). Not judged: `currency` over a `dynamic` field, a
307307
// `fixed` code against the tenant's.
308308

0 commit comments

Comments
 (0)