Pular para o conteúdo principal
Versão: main (dev) 🚧

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_Paulo and BRL, 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.Currency relabels 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 User level. 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.IsIanaId refuses a Windows id and a fixed offset, which BusinessTimeZone.TryResolve resolves and Intl.DateTimeFormat throws on. CurrencyHelper.IsIso4217Code holds the active ISO 4217 codes: .NET has no such list, and Intl.NumberFormat formats any three letters. Both are generic, so they live in the DevPack (G-01). A refused value is 400 settings.invalid_value for 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 of ExposeToClient values, keyed by user and tenant like the preferences. /auth/me stays free of settings groups.
  • The lib keeps the values in a module store (lib/business-context.ts) that system/settings' BusinessContextProvider fills. todayAsIsoDate and the day boundaries are plain functions called outside components, and lib/ does not import from system/. useDateFormatters, useCurrencyFormatter and FieldCurrency subscribe, so a tenant switch re-renders them without a reload. A component that calls a day function while rendering reads useBusinessContext() 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 shows America/Sao_Paulo/BRL until someone sets the platform value. Recipe: set Business.TimeZone/Business.Currency at 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.IsIanaId reads the host's time zone database: the API image needs ICU/tzdata, and a host in InvariantGlobalization would 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).