ADR-027 — Business time zone and currency per tenant
Date: 2026-11-16
Status: Accepted
Extends: ADR-023 (hierarchical settings).
Library side: DevPack 10.29.0 — Helpers.TimeZoneHelper.IsIanaId, Helpers.CurrencyHelper.IsIso4217Code.
Origin: Azure DevOps US 10333; plan docs/plans/2026-11-16-feat-fuso-horario-moeda-por-tenant-plano.md.
Context
The SPA formatted every date in one business time zone and every amount in one currency, both fixed at build time
(VITE_BUSINESS_TIME_ZONE, VITE_CURRENCY). Serving a tenant in another zone or currency took another build.
Decision
The zone and the currency are settings Business.TimeZone and Business.Currency
(Application/Tenants/BusinessSettings/BusinessSettingDefinitions.cs; levels Global and Tenant,
EditableBy = System, ExposeToClient). They show up in the system settings screens with their origin; there is no
new screen.
- The default is fixed:
America/Sao_PauloandBRL, the values builds shipped with. The screen shows the value actually in force. - Only the system administrator edits them. Amounts are stored without a currency, so changing
Business.Currencyrelabels every amount already recorded; the zone moves the day boundaries every filter sends. A tenant administrator does not see the two rows, like the authentication ones. - No
Userlevel. The business zone exists so that "which day is it" is the same for every user of the tenant. - Validated for the browser, not for .NET.
TimeZoneHelper.IsIanaIdrefuses a Windows id and a fixed offset, whichBusinessTimeZone.TryResolveresolves andIntl.DateTimeFormatthrows on.CurrencyHelper.IsIso4217Codeholds the active ISO 4217 codes: .NET has no such list, andIntl.NumberFormatformats any three letters. Both are generic, so they live in the DevPack (G-01). A refused value is400 settings.invalid_valuefor its key; a stored value the host no longer accepts reads as the inherited one (FallBackToNextLayer), since the client read is strict. - The SPA reads
GET {Bff}/settings/effective?group=business, the generic read ofExposeToClientvalues, keyed by user and tenant like the preferences./auth/mestays free of settings groups. - The
libkeeps the values in a module store (lib/business-context.ts) thatsystem/settings'BusinessContextProviderfills.todayAsIsoDateand the day boundaries are plain functions called outside components, andlib/does not import fromsystem/.useDateFormatters,useCurrencyFormatterandFieldCurrencysubscribe, so a tenant switch re-renders them without a reload. A component that calls a day function while rendering readsuseBusinessContext()too. - The build's values remain before sign-in, when the read fails, and for a value this browser cannot format (an older time zone database). On a tenant switch the previous tenant's values stay until the new ones arrive.
Consequences
- A build with a non-default
VITE_*changes behaviour after sign-in: it showsAmerica/Sao_Paulo/BRLuntil someone sets the platform value. Recipe: setBusiness.TimeZone/Business.Currencyat the Plataforma level with the build's values. - Before sign-in (the login screen) zone and currency still come from the build, like the language.
- A signed-in user sees an administrator's change on the next read (sign-in, tenant switch, or the query going stale), not at once.
TimeZoneHelper.IsIanaIdreads the host's time zone database: the API image needs ICU/tzdata, and a host inInvariantGlobalizationwould refuse every zone.
Out of scope
Server-side use of the business zone (no handler computes a business day today), multi-currency amounts, a per-user
zone, and resolving zone and currency before sign-in (e.g. through /auth/config).