Skip to content

Commit e430075

Browse files
committed
fix(service-analytics): changeset for the home-field remedy in the record-currency refusal
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbmDUh2Sx7fvaGgu7r
1 parent 6748f74 commit e430075

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/service-analytics': patch
3+
---
4+
5+
fix(service-analytics): the refusal of an ungrouped aggregate over a record-currency amount names the home field as the remedy for a consolidated total (ADR-0144 D6)
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
- **Now.** A `sum`, `avg`, `min` or `max` over a `currencyMode: 'record'` amount that does not group by its code field is still refused `INVALID_FIELD` / 400 before anything is read, with the same code, status, member, field and object. Its message now names both remedies. For one total in the home currency, point the measure at the amount's home field: by name (`homeAmount.field`) when the amount declares `currencyConfig.homeAmount`, or the declaration to add when it does not. For one row per currency, add the dimension over the code field. Before, the message named only the grouping.
11+
- **Unchanged.** A measure over the home field is no record-mode amount, so it is served unchanged: ungrouped, grouped by the code field, and as a `totals` grand total, labelled with the home currency.
12+
- **The widening.** `AnalyticsServiceConfig.sourceFieldMeta` may answer one more optional key, `homeAmountField`: the amount's `currencyConfig.homeAmount.field`, beside a `currencyField` only. `AnalyticsServicePlugin` relays it. A host that does not answer it gets the message without the field's name.

‎packages/services/service-analytics/src/__tests__/home-amount-consolidated-measure.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ const column = (result: AnalyticsResult, name: string) =>
178178
| { name: string; currency?: string; currencyField?: string }
179179
| undefined;
180180

181-
const byCode = (rows: unknown[], measure: string) =>
182-
Object.fromEntries((rows as Array<Record<string, unknown>>).map((r) => [r.currency, Number(r[measure])]));
181+
const byCode = (rows: unknown[], measure: string): Record<string, number> =>
182+
Object.fromEntries((rows as Array<Record<string, unknown>>).map((r) => [String(r.currency), Number(r[measure])]));
183183

184184
/** The live cell's own schema, created or dropped on a connection outside it. */
185185
async function pgSchema(statement: 'create' | 'drop'): Promise<void> {

0 commit comments

Comments
 (0)