Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/app-showcase/src/datasets/chart-gallery.dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ export const ShowcaseProjectDataset = defineDataset({
],
measures: [
{ name: 'project_count', label: 'Projects', aggregate: 'count' },
// `budget`/`spent` are currency fields with NO declared currency code, so a
// hardcoded "$" misrepresents the amount (an amount with unspecified
// currency must not show a $ symbol). Use a plain grouped-number format;
// declare a `currency` on the field to get a locale-correct symbol via Intl.
// `budget`/`spent` are currency fields with NO declared currency code. The
// renderer resolves the symbol through the field's `currencyConfig.default-
// Currency` → the tenant `localization.currency` default (ADR-0053); with
// neither set it shows a plain grouped number (never a hardcoded "$"). To
// pin a symbol, set a field `currencyConfig` or a measure `currency`.
{ name: 'budget_sum', label: 'Total Budget', aggregate: 'sum', field: 'budget', format: '0,0' },
{ name: 'spent_sum', label: 'Total Spent', aggregate: 'sum', field: 'spent', format: '0,0' },
],
Expand Down
2 changes: 1 addition & 1 deletion examples/app-showcase/src/objects/field-zoo.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const FieldZoo = ObjectSchema.create({

// ── Numbers ──────────────────────────────────────────────────────────
f_number: Field.number({ label: 'Number', min: 0, max: 1000 }),
f_currency: Field.currency({ label: 'Currency', scale: 2, min: 0 }),
f_currency: Field.currency({ label: 'Currency', scale: 2, min: 0, currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD', precision: 2 } }),
f_percent: Field.percent({ label: 'Percent', min: 0, max: 100, defaultValue: 50 }),

// ── Date & time ──────────────────────────────────────────────────────
Expand Down
11 changes: 9 additions & 2 deletions skills/objectstack-data/rules/field-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,19 @@ What kind of data?
type: 'currency',
currencyConfig: {
precision: 2,
currencyMode: 'multi', // or 'single'
defaultCurrency: 'USD',
currencyMode: 'fixed', // 'fixed' = one currency for the column;
// 'dynamic' = per-record `{ value, currency }`
defaultCurrency: 'USD', // ISO 4217
},
}
```

**Currency resolution (ADR-0053).** A displayed amount resolves its symbol
through: the field's own `currencyConfig.defaultCurrency` → the tenant
`localization.currency` default. With neither set, renderers show a plain
grouped number (never a hardcoded `$`). The same chain backs analytics measures
(a measure's explicit `currency` wins over the field/tenant default).

### Select with Default

```typescript
Expand Down
5 changes: 5 additions & 0 deletions skills/objectstack-i18n/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ and integration with the I18nService.
- You need to **detect missing or stale translations** (coverage analysis).
- You are integrating **AI-powered translation suggestions**.
- You are implementing **locale-specific formatting** (dates, numbers, currency).
> Workspace regional defaults — reference `timezone`, `locale`, and **`currency`**
> — live in the `localization` SETTINGS (tenant-scoped), are resolved onto every
> request's `ExecutionContext`, and are exposed to the client at
> `GET /api/v1/auth/me/localization`. `localization.currency` is the fallback a
> currency field/measure uses when it omits its own (ADR-0053).
- You need to understand **translation file organization strategies** (bundled, per_locale, per_namespace).

---
Expand Down
5 changes: 5 additions & 0 deletions skills/objectstack-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,11 @@ defineDataset({
dimensions: [{ name: 'signed_date', field: 'signed_date', type: 'date', dateGranularity: 'month' }],
measures: [{ name: 'signed_count', aggregate: 'count' }],
});
// A monetary measure may declare `currency` (ISO 4217) for a locale-correct
// symbol: `{ name: 'revenue', aggregate: 'sum', field: 'amount', currency: 'USD' }`.
// It resolves measure `currency` → the aggregated field's
// `currencyConfig.defaultCurrency` → the tenant `localization.currency` default
// (ADR-0053). Omit it for non-money measures (count, avg-of-hours).

// The widget just selects the dimension by name:
{ id: 'signed_by_month', type: 'line',
Expand Down