Repository navigation
Description
Summary
The POS phone number field currently uses a hardcoded CURRENCY_DIAL_CODE mapping (currency → dial code) with a phoneDigits setting for max length. This works for a single-country deployment but won't scale for worldwide release. The app needs proper internationalization for phone numbers, and this cascades into needing country/region support across the entire system (currency, timezones, phone formats, etc.).
This is an epic that should be broken into phases.
Current State
In frontend/src/components/pos/CustomerSearch.tsx:
CURRENCY_DIAL_CODEmaps currency codes to dial codes (e.g.,INR → +91,USD → +1)phoneDigitsfrom POS settings controls max digit length (defaults to 10)- On focus, the field auto-prefixes with the dial code based on the tenant's currency
- No real phone validation — just strips non-digits and slices to
maxLen
Problems:
- Dial code is derived from currency, not country — multiple countries share currencies (USD → US + Canada, EUR → 20+ countries)
- No way for user to change dial code if customer is from a different country
phoneDigitsis a single global setting — different countries have different digit counts- No format validation (e.g., some countries require area codes, some have variable-length numbers)
- Same hardcoded approach exists in other places (customer forms, delivery, etc.)
Why This Is Bigger Than Phone Numbers
To do phone validation properly, you need a countries/regions concept in the database. Once that exists, it unlocks:
- Phone: Country-specific dial codes, digit lengths, format patterns
- Currency: Already partly done via
tenants.currency, but needs proper locale-aware formatting - Timezones: Order timestamps, business hours, reporting — all need timezone awareness
- Address formats: Different countries have different address structures
- Date/time formats: MM/DD/YYYY vs DD/MM/YYYY
Proposed Phases
Phase 1 — Quick Win: Better Phone Input (No DB changes)
Issue to create separately
- Add a country/dial code selector dropdown to the phone input (instead of auto-prefixing from currency)
- Use a lightweight library like
libphonenumber-jsor a static country list for dial codes + digit validation - Keep
phoneDigitssetting as a fallback but override per-country when a country is selected - Validate phone format on create (not just length)
Phase 2 — Countries/Regions Table (DB migration + API)
Issue to create separately
- Create a
countriestable:id, code (ISO 3166), name, dial_code, phone_digit_min, phone_digit_max, phone_format_regex, currency_code, timezone, date_format, address_format - Seed with major countries
- Add a
country_idtotenantstable (replacing or supplementingcurrency) - API endpoints:
GET /api/countries,GET /api/countries/:code
Phase 3 — Tenant Country Configuration (Admin UI)
Issue to create separately
- Settings page: select business country → auto-populates currency, timezone, phone defaults
- Allow manual overrides per tenant
- Migrate existing tenants to have a
country_id
Phase 4 — Locale-Aware Formatting (App-wide)
Issue to create separately
- Currency formatting: use
Intl.NumberFormatwith locale from tenant country - Date/time formatting: locale-aware display throughout the app
- Timezone handling: store all timestamps in UTC, display in tenant timezone
- Address forms: country-specific address fields
Phase 5 — Customer Phone Migration (Data cleanup)
Issue to create separately
- Existing customers have phone numbers with inconsistent formatting
- Migration script to normalize phone numbers to E.164 format
- Backfill
country_idon customers based on phone dial code
Scope Boundaries
In scope:
- Phone number validation and dial code selection
- Countries/regions database table
- Tenant country configuration
- Locale-aware currency/date/time formatting
Out of scope (for now):
- Multi-language / i18n translations
- Country-specific tax rules (GST, VAT, etc.)
- Multi-currency transactions (charging in different currencies)
- Country-specific compliance (e.g., India GSTIN, UK VAT numbers)
Notes
- The
CURRENCY_DIAL_CODEmap inCustomerSearch.tsxshould eventually be replaced by thecountriestable phoneDigitsPOS setting should become a derived value from the selected country, not a manual config- Consider using a library like
libphonenumber-jsfor phone validation rather than hand-rolling regex - This feature should be designed with input from users in target markets (not just India)
Activity
khaira777 commentedon Jul 6, 2026
Sub-issues Created
Execution Order: #19 → #20 → #21 → #22 (sequential)
Parallel: #23 can run alongside #20 (both depend on #19)
feat(i18n): country profiles, language-first wizard, Argentina IVA
khaira777 commentedon Jul 13, 2026
Shoutout to @carvalab for getting this epic rolling — PR #103 lays solid groundwork with country profiles, the bilingual setup wizard, and the Argentina IVA tax path. Great first pass on the i18n foundation. Looking forward to seeing the sub-issues (#19–#23) built on top of this. 🎉
feat(i18n): country profiles, language-first wizard, Argentina IVA
fix(printer): pass timezone to thermal.ts date formatting for accurat…
khaira777 commentedon Jul 18, 2026
Status: Fully done.
Many thanks to @carvalab