Skip to content
Docs

Command palette

Jump to a page or search the docs.

Changelog

Account preference

How a User reads and changes their locale, main currency, units and reminder channels, and why the data region is read-only.

Markdown

What it does

An Account Preference is one row per User (account_preference), not per Organization: two Members of one household may use different languages and units. It holds the locale (pt-BR, en-US, de-DE), the main currency totals convert into, the distance unit (km/mi), the volume unit (l/gal), the reminder channels (push, email) and the data region (eu, br, us).

The first read creates the row from the device locale the client sends, idempotently: two first reads at once store one row.

Device languageLocaleCurrencyDistanceVolumeRegion
pt-*pt-BRBRLkmlbr
de-*de-DEEURkmleu
anything elseen-USUSDmigalus

Distance is always stored in km and volume in millilitres; the units only change how values are shown. A Vehicle keeps its own currency; totals in the main currency show the rate and its date.

The data region is pinned when the row is created and is not part of update: moving an account between regions is a support process (a data migration), so the profile shows it read-only.

In the app

The Profile tab (M-Perfil) reads the preference once under the tabs and keeps it in one shared query. Until that read returns, the app formats with the device locale's defaults; then the server value wins, including the app language. Language, main currency, units and reminders each open a sheet that sends only the field it changes; the cache updates at once and rolls back if the server refuses. The rows stay disabled until the first read, so an update never meets NOT_FOUND.

Every screen formats amounts, dates, distances and volumes through useFormat() (apps/mobile/src/features/account-preference/account-preference.hooks.ts), which binds the @autofolio/domain formatters to the account locale and units.

Procedures

ProcedureWhoFailures
accountPreference.get { deviceLocale? }Any signed-in User, for their own rowUNAUTHORIZED
accountPreference.update (partial: locale, currency, distanceUnit, volumeUnit, remindByPush, remindByEmail)Any signed-in User, for their own rowUNAUTHORIZED, INPUT_VALIDATION (unknown key such as dataRegion, currency outside BRL/EUR/USD/GBP/CHF), NOT_FOUND (no row yet: call get first)

Both return the whole preference. No Active Organization is needed.

Data and isolation

The account_preference table has row-level security keyed by the session's User (ownedByCurrentUser). app_tenant may insert the row but update only the choice columns, never data_region or user_id. Deleting the User deletes the row.

Key files

Edit on GitHubDocumentation is in English.

We use essential cookies to make our app work. With your consent, we also use optional cookies to improve your experience. Read our Cookie Policy and Privacy Policy.