Skip to content

refactor(regionalization): harden country, regional formatting, and international data boundaries #388

Closed
5 of 5 issues completed

Description

@khaira777

Problem

FloCafe already supports multiple countries, regional phone formatting, currency/time formatting, country tax packs, and UI languages. However, several regional boundaries remain inconsistent:

  • Timezones are currently tied directly to static country profiles, preventing multi-timezone countries (e.g. US, Canada, Australia) from configuring their true store timezone.
  • Regional locale display preferences (such as Iranian Rial/Toman or Persian calendar) are validated against a global union enum rather than country-declared options, risking mismatched state during country transitions.
  • Customer management search fails to match formatted phone inputs on the admin customer list.
  • Country display names in setup and settings remain hardcoded in English regardless of the active UI language.
  • Tax registration validation patterns are embedded in static application code rather than carried by versioned country tax packs.

These regionalization concerns are strictly distinct from the UI-language translation architecture migrating under #372.

Architectural Model

UI LANGUAGE
translated text + text direction
        │
        │ independent
        ▼
COUNTRY PROFILE
regional defaults (currency, format locale, phone dial code, default timezone suggestion)
        │
        ▼
TENANT REGIONAL SETTINGS
authoritative runtime preferences (timezone, calendar, digits, currency display)
        │
        ▼
COMPLIANCE / TAX / PROVIDERS
legal/business behavior (tax packs, rates, invoice rules, fiscal connectors)

Core Domain Boundaries

  1. UI Language: Governs translated UI prose, ICU message formatting, and LTR/RTL layout direction. Does NOT govern store country, currency, tax rules, phone parsing rules, or timezone.
  2. Country Profile: Governs sensible regional defaults (ISO code, default currency, default regional formatting locale, default timezone suggestion, calling code). These are defaults, not permanent tenant truth.
  3. Tenant Regional Settings: Authoritative runtime store configuration. Country default timezone is a suggestion; tenant timezone is authoritative.
  4. Compliance & Tax: Governed by TaxEngine, signed/versioned country tax packs, and fiscal connectors. Separate from UI translation and regional display preferences.

Explicit Invariants

  • UI language does not determine tax behavior.
  • UI language does not determine tenant country.
  • Country default timezone is a suggestion; tenant timezone is authoritative.
  • Canonical storage must remain region/language independent:
    • Money is stored in canonical currency units (e.g. IRR for Iran; Toman is presentation only).
    • Dates are stored as canonical UTC timestamps; timezone/calendar/digits are presentation formatting.
    • Phones are stored in canonical E.164 format.
    • Countries are stored as ISO 3166-1 alpha-2 codes (e.g. CA, BR, US), never translated country names.
    • Historical transaction tax results are immutable snapshots.
  • Tax calculation remains backend authoritative.
  • Tax pack updates remain optional for offline operation once installed.
  • Phone normalization remains based on libphonenumber-js.
  • No countries database table (retains static profiles in application code).
  • No arbitrary currency override or multi-currency checkout.
  • Zero runtime network dependencies; complete offline-first operation.
  • This epic is completely separate from refactor(i18n): migrate to scalable use-intl architecture #372 (UI-language / use-intl migration).

Non-Goals

  • No UI translation architecture rewrite (owned by refactor(i18n): migrate to scalable use-intl architecture #372).
  • No TaxEngine arithmetic rewrite.
  • No multi-currency checkout or foreign currency exchange.
  • No IP-based or browser geolocation timezone auto-detection.
  • No database-backed country registry.
  • No replacement of native Intl or libphonenumber-js.
  • No new SaaS dependencies or remote formatting APIs.
  • No single monolithic migration PR.

Phases & Sub-issues

Phase 1 — Regional Correctness

Phase 2 — International Data Ergonomics

Phase 3 — Presentation Integration

Phase 4 — Compliance Boundary Cleanup

Epic Acceptance Criteria

  • Multi-timezone countries can configure and persist their authoritative timezone independently of country profile defaults.
  • Stored regional preferences are strictly validated against the active country's declared localeOptions with clean backward-compatible normalization for legacy databases.
  • Customer search in admin list matches both formatted and unformatted phone inputs across international numbering formats.
  • Country names in setup and settings render localized in the active UI language using native Intl.DisplayNames.
  • Country tax packs can optionally provide versioned tax registration number validation patterns.
  • All operations remain 100% functional offline with zero runtime network calls.
  • Canonical storage contracts (UTC dates, E.164 phones, ISO country codes, canonical money units) remain intact.

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    enhancement
    area:frontend
    area:backend
    epic
    on Aug 18, 2026
  2. khaira777 commented on Aug 20, 2026

    @khaira777
    ContributorAuthor

    Epic status snapshot — 2026-08-20

    Current delivery stage across the regionalization work:

    Phase Issue Stage Evidence / next step
    Phase 1 — Regional Correctness #389 ✅ Complete Merged via PR #432; issue closed.
    Phase 1 — Regional Correctness #390 ⚠️ Validation blocked Implementation commit 282948b1 exists, but the no-mistakes review step failed before a PR was opened; rerun/follow-up validation is needed.
    Phase 2 — International Data Ergonomics #391 🔄 Validation in progress Implementation committed; no-mistakes review is currently running, with no PR opened yet.
    Phase 3 — Presentation Integration #392 ⏳ Ready / not started Dependency #373 is merged; no implementation branch, PR, or pipeline run is currently present.
    Phase 4 — Compliance Boundary Cleanup #393 ✅ Complete Merged via PR #405; issue already closed.

    Epic overall: 2 of 5 child issues are complete, 1 is in active validation, 1 is blocked in validation, and 1 is ready to start. The epic remains open until #390, #391, and #392 are completed.

  3. khaira777 commented on Aug 20, 2026

    @khaira777
    ContributorAuthor

    Epic status snapshot — 2026-08-20

    Child issue Current stage Evidence / next step
    #389 ✅ Complete / closed PR #432 merged; issue closed.
    #390 🔄 Validation active / parked Commit 282948b1; run 01M0GRWKXPW6DQW22YGCG29CH8 is waiting on a real timezone-preservation regression finding before tests, push, and PR creation.
    #391 ✅ Complete / closed PR #433 merged at e5ddfd3c, including the mixed digit-bearing name/email search correction.
    #392 🔄 Validation in progress Commit e624e729; run 01M0GQR716R7VQGW1S7E2MESWM passed rebase, review, and tests and is running documentation before push/PR.
    #393 ✅ Complete / closed; hardening follow-up active PRs #405/#407 merged. Follow-up PR #434 is open at 75883b36 with CI in progress.

    Epic overall: 3 of 5 child issues are complete/closed, #390 is blocked at review by a regression finding, and #392 is progressing through final gate stages. The epic remains open until #390 and #392 are delivered; PR #434 is the outstanding compliance hardening follow-up.

  4. khaira777 commented on Aug 21, 2026

    @khaira777
    ContributorAuthor

    Epic status snapshot — 2026-08-21

    Child issue Current stage Evidence / next step
    #389 ✅ Complete / closed PR #432 merged; issue closed.
    #390 🔄 Validation active Restarted run 01M0GRWKXPW6DQW22YGCG29CH8 is applying the timezone-preservation regression fix at review. No PR yet.
    #391 ✅ Complete / closed PR #433 merged at e5ddfd3c; mixed digit-bearing name/email search correction included.
    #392 🔄 Validation in progress Run 01M0GQR716R7VQGW1S7E2MESWM passed rebase, review, and tests and is running documentation before lint, push, and PR creation.
    #393 ✅ Complete / closed PR #434 merged at 8730fc04, completing the tax-registration hardening follow-up.

    Epic overall: 3 of 5 child issues are complete/closed. #390 is actively resolving its final review regression, and #392 is progressing through final validation. The epic remains open only for #390 and #392.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendarea:frontendenhancementepic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions