Skip to content

fix(regional): remove India fallbacks from frontend call sites - #781

Merged
itsbkm merged 12 commits into
mainfrom
fix/regional-fallback-sweep-frontend
Sep 20, 2026
Merged

itsbkm merged 12 commits into
mainfrom
fix/regional-fallback-sweep-frontend

Conversation

@itsbkm

@itsbkm itsbkm commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related work

Design: docs/regional-snapshot.md (#777, ACTIVE DESIGN). PR 3b of the sequence — the frontend half of the fallback sweep (#780 was the backend half). Stacked on #780, which is itself stacked on #778 — this branch is based on #780's tip since the frontend's @countries alias resolves directly to main/countries.ts, so the frontend build needs #780's required-parameter signatures to even type-check. Please merge #778 then #780 first; this will then show a clean diff against main.

Summary

Removes the ~59 remaining || 'IN' / ?? 'INR' fallback sites across frontend/src (hooks, dashboard pages, print encoders, whatsapp-share.ts, the frontend's own phone.ts), using the same approach as #780: functions the frontend depends on that got required params in #780 (formatCurrencyForTenant, formatNumberForTenant, formatDateForTenant, resolveTenantCurrency, getCurrencyUnitAdapter) now drive real compile errors at every call site that was silently passing undefined; the frontend's own phone.ts helpers (parsePhone, normalizeOptionalPhone, formatPhoneDisplay) lost their own = 'IN' defaults the same way main/lib/phone.ts did in #780.

Excluded: frontend/src/app/setup/page.tsx's one site — already fixed in #779 (the wizard PR). Touching it here would conflict.

A real bug found and fixed while verifying this

countryName('') throws — Intl.DisplayNames.of() rejects an empty region code (verified directly in Node). Removing the guaranteed-non-empty 'IN' fallback ahead of it made this reachable in five places (the "invalid phone" toast on the customers/tables pages and all three customer modals). Fixed by adding a try/catch to countryName() itself in main/countries.ts rather than patching each call site — it's a shared low-level utility, and any future caller would hit the same crash otherwise.

Two more fixes in the same spirit — not literal 'INR'/'IN' tokens, but the same category of silent India default:

  • dialCodeFor(...) || '+91' on the tables and customers pages — dialCodeFor() already returns '' gracefully on empty input, so the outer fallback was redundant and India-specific (used only as UI placeholder text).
  • print-test/page.tsx's synthetic test tenant only overrode timezone from the real signed-in tenant, leaving country/currency hard-coded to the synthetic 'IN'/'INR' defaults from createTestTenant() — a non-Indian merchant testing their printer would see a rupee-denominated test receipt regardless of their actual store's currency. Now overrides all three from the real tenant, consistent with the timezone override that was already there.

Scope

Frontend only. This completes the design note's compliance-grep sweep (backend #780 + frontend, here) — the two initial surfaces (server app, currency input) are the remaining PRs per the note's sequencing, not started here.

Verification

Commands run:

  • npx tsc --noEmit (frontend) — clean
  • npx eslint src/ (frontend) — 0 errors, 4 warnings, identical to the pre-change baseline (confirmed via git stash A/B comparison)
  • npm run build:frontend — succeeds
  • Full npm test (166+ chained scripts) — clean end-to-end on the first run, 13,811 log lines, exit 0
  • npx tsc --noEmit -p tests/tsconfig.json, filtered to the functions this PR touches — found and fixed two real TS2554 (wrong argument count) errors in tests/phone.test.ts that ts-node --transpile-only (what npm test actually runs) silently skips

Compatibility & data safety

  • Database/data impact: None.
  • Migration: None.
  • User-visible behavior: None for any store that has completed setup. A store that somehow reaches one of these paths without a configured country now gets empty/neutral formatting instead of silently rendering as India — plus the countryName('') crash fix and the print-test currency fix are net-positive behavior changes.
  • Offline/network impact: None.

Summary by CodeRabbit

  • New Features
    • Regional settings now use each tenant’s configured country, currency, and timezone across sales, payments, printing, reporting, and customer communications.
    • Phone numbers are parsed using the tenant’s country instead of assuming India.
    • Missing or invalid regional settings now produce clear configuration errors rather than silently applying Indian defaults.
  • Bug Fixes
    • Currency symbols, locales, tax labels, rounding, and date handling now reflect tenant configuration more accurately.
    • Printing, reporting, refunds, and cash-close operations identify missing timezone settings instead of using an incorrect fallback.

itsbkm and others added 3 commits September 19, 2026 00:13
Adds the backend resolver from docs/regional-snapshot.md: given a
store's settings, it derives currency symbol, prefix/suffix position,
fraction digits, number separators, and default timezone from the
country/currency pair via Intl/ISO/IANA conventions, throwing
RegionalNotConfiguredError when no country is resolvable rather than
substituting one.

Relocates the locale-preference validation helpers (previously
private to main/routes/settings.ts) into main/countries.ts and
exports them, so the resolver reuses the same per-country option
validation instead of duplicating it — settings.ts now imports them.

Purely additive: no existing seed, wizard, or route behavior changes
in this PR. Removing the India defaults at seedInstallDefaults() and
the setup wizard is deferred to the next PR, which also needs a
central test-harness fix — 107 of 120 test files never go through
/setup/initialize and rely on that seed for a working country.

tests/regional-snapshot.test.ts covers the contract-test matrix from
the design note (USD/COP/EUR/KWD/IRR/INR archetypes, missing/unknown
country, and timezone fallback), wired into npm run test:currency.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
PR 3 of the regional-snapshot sequence (docs/regional-snapshot.md):
sweeps every remaining `|| 'IN'` / `?? 'INR'` / `?? '₹'` / `|| 'Asia/
Kolkata'` fallback out of main/ and shared/, following the "required
parameter, TypeScript drives the caller fixes" approach for the core
functions this depends on (resolveTenantCurrency, formatCurrencyForTenant,
formatNumberForTenant, formatDateForTenant, the print encoders'
options.currencySymbol/currency), and a lower-risk direct fallback
deletion everywhere else once each downstream consumer was confirmed
to already degrade gracefully on an empty/missing value (verified
function-by-function, not assumed).

Two deliberate, documented exceptions, not overlooked:
- main/db.ts migrations v23/v24 keep their 'IN' fallback — one-time
  best-effort cleanup of pre-existing customer phone records on an
  upgrading install, most of which predate multi-country support.
  Historical data heuristic, not a live store's regional identity.
- Login (buildLocalTenant) and the Settings page (businessShape) now
  degrade to empty string rather than throw on a missing regional
  field — unreachable for an authenticated, post-setup store, but a
  login/Settings failure would be far worse than briefly-wrong
  formatting if the invariant were ever violated.

Everywhere else (route handlers building tax/phone/print context,
services/refund.ts, services/tax.ts, services/cloud-sync.ts,
server-app.ts's /info endpoint) either reuses resolveTenantCurrency's
throw or returns 409 { error: 'regional_not_configured' } directly,
matching the design note's contract.

Found and fixed two real, previously-masked bugs while verifying this
against the full test suite (not just the files touched):
- main/printers/thermal.ts had two placeholder "business truly
  unknown" objects (used when no business info is supplied at all,
  e.g. a synthetic preview) missing currency/country entirely — gave
  them an explicit neutral currency: 'USD' rather than let them throw
  or silently resolve to India.
- tests/e2e-argentina-flow.test.ts's "legacy India demo" regression
  scenario called seedSetupProfile(db, 'demo', 'finedine', 'IN') —
  'IN' landed in the *language* parameter slot, not country (which
  was actually omitted and only produced correct-looking Indian demo
  data because the old fallback defaulted it to India regardless).
  Fixed to pass ('en', 'IN') explicitly.

Also relocated two duplicated country→currency resolution helpers
(services/refund.ts, services/tax.ts) to call the shared
resolveTenantCurrency instead of re-implementing the same lookup with
their own 'IN'/'INR' literals.

Verified: npx tsc --noEmit clean; npx eslint main/ shows 0 errors and
the exact same 1003 pre-existing `any` warnings as before this change
(confirmed via git stash comparison, no increase); full npm test
(166+ chained scripts, 13,811 log lines) passes end-to-end.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
PR 3b of the regional-snapshot sequence (docs/regional-snapshot.md),
stacked on #780 (backend sweep) — the frontend sweep. Removes the
~59 remaining `|| 'IN'` / `?? 'INR'` fallback sites across hooks,
pages, and print encoders (frontend/src), following the same approach
as #780: core functions the frontend depends on (formatCurrencyForTenant,
formatNumberForTenant, formatDateForTenant, resolveTenantCurrency,
getCurrencyUnitAdapter, and the frontend's own phone.ts helpers) get
required params; everywhere else gets the fallback deleted once its
downstream consumer is confirmed to degrade gracefully.

Excluded: frontend/src/app/setup/page.tsx's one site — already fixed
in #779 (the wizard PR); touching it here would conflict.

A real crash bug found and fixed while verifying this: `countryName('')`
throws (Intl.DisplayNames.of() rejects an empty region code) — I'm the
one who made this reachable by removing the guaranteed-non-empty 'IN'
fallback ahead of it in five call sites (the "invalid phone" toast
across customers/tables pages and the three customer modals). Added a
try/catch to countryName() itself in main/countries.ts rather than
patching each call site, since it's a shared low-level utility and any
future caller would hit the same crash.

Two additional cleanups in the same spirit, not literal `'INR'`/`'IN'`
tokens but the same category:
- Two `dialCodeFor(...) || '+91'` sites (tables and customers pages) —
  dialCodeFor() already returns '' gracefully on empty input, so the
  outer India-dial-code fallback was redundant and India-specific.
- print-test/page.tsx's synthetic test tenant only overrode `timezone`
  from the real signed-in tenant, leaving country/currency hard-coded
  to the 'IN'/'INR' synthetic defaults — a non-Indian merchant testing
  their printer would see a rupee-denominated test receipt regardless
  of their actual store. Now overrides all three from the real tenant.

Verified: frontend `npx tsc --noEmit` clean; `npx eslint src/` shows
0 errors and the identical 4 pre-existing warnings before/after
(confirmed via git stash A/B); `npm run build:frontend` succeeds;
full npm test (166+ chained scripts, 13,811 log lines) passes clean
end-to-end on the first run. Also fixed two real TS2554 (wrong arg
count) errors in tests/phone.test.ts surfaced by frontend/src/lib/
phone.ts's now-required defaultCountry parameters — found via a
targeted tsc -p tests/tsconfig.json check, since ts-node's
--transpile-only (what npm test actually uses) silently skips type
errors.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1a72663a-9a0a-43e1-bde0-6c997b53a913

📥 Commits

Reviewing files that changed from the base of the PR and between 5c18fff and b11e86b.

📒 Files selected for processing (75)
  • frontend/src/app/(dashboard)/addon-groups/page.tsx
  • frontend/src/app/(dashboard)/customers/page.tsx
  • frontend/src/app/(dashboard)/orders/page.tsx
  • frontend/src/app/(dashboard)/pos/page.tsx
  • frontend/src/app/(dashboard)/print-test/page.tsx
  • frontend/src/app/(dashboard)/products/page.tsx
  • frontend/src/app/(dashboard)/settings/page.tsx
  • frontend/src/app/(dashboard)/tables/page.tsx
  • frontend/src/app/(dashboard)/whatsapp/page.tsx
  • frontend/src/app/server-standalone/page.tsx
  • frontend/src/components/orders/OrderHistoryGrid.tsx
  • frontend/src/components/pos/CreateCustomerModal.tsx
  • frontend/src/components/pos/CustomerSearch.tsx
  • frontend/src/components/pos/EditCustomerModal.tsx
  • frontend/src/components/pos/PaymentModal.tsx
  • frontend/src/components/pos/TaxBreakdown.tsx
  • frontend/src/hooks/useCashClose.ts
  • frontend/src/hooks/useCashDrawerMovements.ts
  • frontend/src/hooks/useCurrencyUnitAdapter.ts
  • frontend/src/hooks/useFormatCurrency.ts
  • frontend/src/hooks/useFormatDate.ts
  • frontend/src/hooks/useFormatNumber.ts
  • frontend/src/hooks/usePrinter.ts
  • frontend/src/lib/phone.ts
  • frontend/src/lib/printer/order-slip-web-print.ts
  • frontend/src/lib/printer/print-document.ts
  • frontend/src/lib/printer/receipt-encoder.ts
  • frontend/src/lib/printer/tax-bill-encoder.ts
  • frontend/src/lib/printer/web-print.ts
  • frontend/src/lib/whatsapp-share.ts
  • main/countries.ts
  • main/db.ts
  • main/lib/phone.ts
  • main/printers/document-classic.ts
  • main/printers/document-compact.ts
  • main/printers/thermal.ts
  • main/routes/addon-groups.ts
  • main/routes/auth.ts
  • main/routes/bills.ts
  • main/routes/cash-closures.ts
  • main/routes/customers.ts
  • main/routes/database.ts
  • main/routes/index.ts
  • main/routes/menu-csv.ts
  • main/routes/orders.ts
  • main/routes/printers.ts
  • main/routes/products.ts
  • main/routes/reports.ts
  • main/routes/settings.ts
  • main/routes/support-ticket.ts
  • main/routes/tax-packs.ts
  • main/routes/whatsapp.ts
  • main/server-app.ts
  • main/services/cloud-sync.ts
  • main/services/refund.ts
  • main/services/tax.ts
  • tests/addon-price-integrity.test.ts
  • tests/bills-print-api.test.ts
  • tests/cancel-override.test.ts
  • tests/cash-closures.test.ts
  • tests/discount-system.test.ts
  • tests/e2e-argentina-flow.test.ts
  • tests/integration-discount-settings.test.ts
  • tests/inventory-ledger.test.ts
  • tests/issue-122-addon-quantities.test.ts
  • tests/order-item-addons.test.ts
  • tests/phase7-setup-i18n.test.ts
  • tests/phone-validation.test.ts
  • tests/phone.test.ts
  • tests/printer-api.test.ts
  • tests/printer-fallback-and-popup-verification.ts
  • tests/printer.test.ts
  • tests/regional-snapshot.test.ts
  • tests/reports-daily-stats-table-turn.test.ts
  • tests/reports-insights.test.ts
 ____________________________
< The OG: Original Grepster. >
 ----------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@itoqa

itoqa Bot commented Sep 18, 2026

Copy link
Copy Markdown

Ito QA test results
Commit: 6319be5: 12 test cases ran, 11 passed ✅, 1 additional finding ⚠️.

Summary

Coverage spans regional setup and currency behavior, locale and timezone persistence, phone validation and historical data handling, plus dashboard and point-of-sale display flows. It includes normal user journeys and edge cases such as missing or unsupported regional settings, with the application behaving correctly across the exercised PR-relevant areas.

Safe to merge — the only observed failure is a pre-existing, medium-severity setup behavior unrelated to this PR, with no regression or PR-attributable failure identified. It is a flag for later rather than a merge blocker.

Tests run by Ito

View full run

Result Severity Type Description
✅ — General Submitting malformed or non-empty phone text without a tenant country showed a clear invalid-phone message. The form stayed usable, no customer was created, and the customer list remained empty.
✅ — Currency A tenant configured for the United States and USD receives its own country and currency information from the regional information request.
✅ — Currency A tenant with unknown country settings received a clear configuration error instead of India currency details.
✅ — Dashboard The dashboard showed the US Demo Cafe tenant with dollar values, and POS showed a +1 phone control and dollar-formatted prices. No India, INR, or +91 defaults were visible.
✅ — Migration The database upgrade normalized the valid historical phone number and kept the unparseable number unchanged.
✅ — Phone The customer form could not be opened because the local application server stopped during setup. The phone flow was not executed, and no product failure was confirmed.
✅ — Regional A configured tenant received its CO and COP regional details. After the country was cleared, the server returned HTTP 409 with regional_not_configured instead of showing India values.
✅ — Settings The supported locale settings were saved successfully and stayed selected after the Settings page was reloaded.
✅ — Settings Submitting an unsupported display preference was rejected with a clear error, and the settings page kept the neutral preference after reload.
✅ — Snapshot The regional settings page could not be opened because the local app stopped running during setup. This is a local setup and environment issue, so no product behavior was confirmed as broken.
✅ — Timezone The store saved Pacific/Honolulu as its timezone and kept daily reset enabled. The daily order check could not run because this local store had no product or order fixture, so there was no application failure to report.
⚠️ Medium severity Rev The request returned HTTP 200, issued an access token, and created a tenant with country IN and currency INR instead of rejecting the missing country before setup was committed.
Additional Findings Details

These findings are unrelated to the current changes but were observed during testing.

🟡 Setup accepts a store without a country
  • Severity: Medium Medium severity
  • Description: The request returned HTTP 200, issued an access token, and created a tenant with country IN and currency INR instead of rejecting the missing country before setup was committed.
  • Impact: A setup request with no country still completes and creates an India-based store with INR. Users in other regions may start with the wrong country and currency and must correct the store settings.
  • Steps to Reproduce:
    1. Open the local setup page before any user exists.
    2. Submit the setup request with valid current field names and omit the country field.
    3. Check the response and setup status after the request completes.
  • Stub / mock content: No stubs, mocks, or bypasses were applied for this test in the recorded run.
  • Code Analysis: In main/routes/auth.ts:882-910, the setup handler destructures country with a default of 'IN', currency with a default of 'INR', and timezone with a default of 'Asia/Kolkata'. It then validates the already-defaulted values at lines 916-922, so omission cannot be detected as a missing regional setting. The transaction at lines 995-1049 inserts the owner and persists the defaulted country and currency through upsertSettings at lines 1012-1018, and line 1069 builds the successful tenant response afterward. The PR diff for main/routes/auth.ts only changes the post-setup buildLocalTenant fallback behavior and related setup-profile code; it does not alter these setup destructuring defaults or add a required-country validation, so this finding is a pre-existing defect exposed by the test.
Evidence Package

Tip

Reply with @itoqa to send us feedback on this test run.

itsbkm and others added 2 commits September 20, 2026 03:11
…lback sweep

Ito QA (high severity, reproduced): resolveTenantCurrency checked an
explicit currency BEFORE validating the country, so a syntactically-
valid-but-bogus currency (e.g. 'ZZZ') masked an unresolvable country
('ZZ') and the function never threw. A bill could be created and taxed
under completely invalid regional settings, and a later corrected
retry reused that same bad bill. Reordered to validate the country
first — an explicit currency override is still honored for a real
country (e.g. a US store priced in KES), but a bogus country now
always throws RegionalNotConfiguredError regardless of currency.

Also gave RegionalNotConfiguredError a `statusCode = 409` so it maps
correctly through the ~40 existing `error.statusCode || 500` route
catch blocks without each needing its own instanceof check, and fixed
the one bills.ts catch block (POST /generate, the exact endpoint Ito
QA reproduced against) that hardcoded 500 instead of using that
pattern.

CodeRabbit (5 findings, same root cause): order/bill numbering
(main/db.ts), cash closures, reports, and refunds all resolved a
missing timezone to '' and let the date-math helpers silently fall
back to UTC. At a tenant-local day/month/financial-year boundary that
produces the wrong period segment, sequence bucket, closure total, or
refund-window decision — a real correctness bug, not just a display
one. All four now reject with RegionalNotConfiguredError before any
date math runs. The printer test-page route gets the same treatment
via an explicit 409 (not a thrown error, since CodeRabbit noted this
route's catch block converts errors to a generic 500).

CodeRabbit (1 finding): parsePhoneE164 required defaultCountry even
for a number already in full E.164 form, which libphonenumber-js
parses correctly regardless of defaultCountry — so the pre-login
support-ticket route (no resolvable tenant country) rejected valid
international phone numbers. Now only national-format input requires
a resolvable country.

Found while verifying the resolver reorder: two synthetic "business
truly unknown" placeholders in main/printers/thermal.ts relied on the
OLD currency-first short-circuit (explicit currency: 'USD', no
country) to avoid ever reaching the country check. The reorder broke
this — reproduced via tests/printer-fallback-and-popup-verification.ts
throwing RegionalNotConfiguredError. Fixed by giving both placeholders
a matching country: 'US' alongside their currency.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
# Conflicts:
#	main/countries.ts
#	tests/regional-snapshot.test.ts
# Conflicts:
#	frontend/src/app/(dashboard)/orders/page.tsx
@itsbkm
itsbkm changed the base branch from fix/regional-fallback-sweep-backend to main September 19, 2026 22:01
@itoqa

itoqa Bot commented Sep 19, 2026

Copy link
Copy Markdown

Ito QA test results
Ito Diff Report — 6319be5 → e19c15a: 17 test cases ran, 16 passing ✅, 1 additional finding ⚠️.

Diff Summary

Coverage spans core business flows and UI behavior for regional settings, currencies, time zones, phone handling, receipt delivery and status updates, printing, language preferences, orders, and payments. It includes successful user journeys, boundary and invalid-input cases, persistence checks, and protection against incorrect regional defaults, with the exercised behavior broadly healthy.

Safe to merge — the only observed failure is a pre-existing setup defect unrelated to this PR, with no regression, new failure, or previously reported PR issue remaining. The unrelated defect is a flag for later rather than a merge blocker.

Tests run by Ito

View full run

Result State Severity Type Description
✅ Passing — General The paid order kept the latest eligible receipt status, even with newer inbound and manual-reply messages. The order list and detail view both showed sent.
✅ Passing — General After a new receipt was sent, the order list, order details, and order card all showed Receipt sent after refresh.
✅ Passing — Country Verified acceptable by independent adversarial review: the reported expectation does not match what the code actually promises. Review notes: The source confirms a reachable toast path and confirms that ZZ can produce the reported non-null Intl display name, but that mechanism is not itself a defect. The finding extends PR text about catching the exception from an empty code into a distinct requirement to override a non-null localized name for ZZ; neither that PR text nor repository tests, comments, or messages establish this special fa…
✅ Passing — Currency The billing screen used the tenant's explicit EUR setting and showed euro values instead of Indian rupees.
✅ Passing — Dashboard The dashboard loaded for US QA Cafe and showed US/USD settings. The local setup had no order to open, so the deeper order and POS navigation check could not be completed.
✅ Passing — Ordercard The Orders screen showed the seeded order card with its item and total. Clicking Checkout opened the Payment window with invoice INV-20260919-0001 and a $150.00 total.
✅ Passing — Phone The customer form accepted the US national phone number and saved it as +14155552671.
✅ Passing — Preference Selecting Español changed the settings page to Spanish, and Español was still selected after the page was reloaded.
✅ Passing — Print The receipt preview could not be opened because the local database was still on first-run setup with no tenant or order data. The local app and API were healthy, and source review confirms the print path has an explicit US/USD context when business regional fields are absent.
✅ Passing — Printer The printer test request returned success and the generated page used the tenant's New York time zone.
✅ Passing — Printer When the tenant has no timezone, the printer test request returns HTTP 409 with regional_not_configured and does not try to print.
✅ Passing — Receipt The unpaid order showed no receipt status in the order list or detail view. The application returned null instead of inventing a receipt state.
✅ Passing — Receipt Order 2 showed sent from its newest qualifying receipt row instead of the older failed row.
✅ Passing — Receipt The paid order showed the latest receipt status, sent, in both the orders list and the order details.
✅ Passing — Regional The regional settings check could not run because the test environment lost its configured tenant and stayed on first-run setup. No product failure was confirmed.
✅ Passing — Rev Sending a paid order receipt creates an outbound bill receipt message, and refreshing the order shows the receipt status as sent.
⏸️ Skipped — General Submitting malformed or non-empty phone text without a tenant country showed a clear invalid-phone message. The form stayed usable, no customer was created, and the customer list remained empty.
⏸️ Skipped — Currency A tenant configured for the United States and USD receives its own country and currency information from the regional information request.
⏸️ Skipped — Currency A tenant with unknown country settings received a clear configuration error instead of India currency details.
⏸️ Skipped — Dashboard The dashboard showed the US Demo Cafe tenant with dollar values, and POS showed a +1 phone control and dollar-formatted prices. No India, INR, or +91 defaults were visible.
⏸️ Skipped — Migration The database upgrade normalized the valid historical phone number and kept the unparseable number unchanged.
⏸️ Skipped — Phone The customer form could not be opened because the local application server stopped during setup. The phone flow was not executed, and no product failure was confirmed.
⏸️ Skipped — Regional A configured tenant received its CO and COP regional details. After the country was cleared, the server returned HTTP 409 with regional_not_configured instead of showing India values.
⏸️ Skipped — Settings The supported locale settings were saved successfully and stayed selected after the Settings page was reloaded.
⏸️ Skipped — Settings Submitting an unsupported display preference was rejected with a clear error, and the settings page kept the neutral preference after reload.
⏸️ Skipped — Snapshot The regional settings page could not be opened because the local app stopped running during setup. This is a local setup and environment issue, so no product behavior was confirmed as broken.
⏸️ Skipped — Timezone The store saved Pacific/Honolulu as its timezone and kept daily reset enabled. The daily order check could not run because this local store had no product or order fixture, so there was no application failure to report.
⚠️ Additional Finding High severity Rev The setup form had no country selected, but submission completed setup and sent the user to login. Setup status reported needsSetup=false and userCount=1, while the created tenant used country IN, currency INR, and Asia/Kolkata instead of returning a regional configuration error.
Additional Findings Details

These findings are unrelated to the current changes but were observed during testing.

🟠 Setup creates an India store without a country
  • Severity: High High severity
  • Description: The setup form had no country selected, but submission completed setup and sent the user to login. Setup status reported needsSetup=false and userCount=1, while the created tenant used country IN, currency INR, and Asia/Kolkata instead of returning a regional configuration error.
  • Impact: When setup is submitted without a country, the app creates a tenant anyway and silently applies India settings. This can give the tenant the wrong currency and time zone, with no clear way for the user to undo the incorrect setup.
  • Steps to Reproduce:
    1. Open local setup with no country selected.
    2. Complete the owner details, approval PIN, empty profile, and QSR flow.
    3. Call GET /api/auth/setup/status and inspect the tenant after signing in.
    4. Observe that setup completed and the tenant has India regional settings.
  • Stub / mock content: No stubs, mocks, or bypasses were applied for this test in the recorded run.
  • Code Analysis: main/routes/auth.ts assigns country = 'IN', currency = 'INR', and timezone = 'Asia/Kolkata' while destructuring the setup payload at lines 891-894. The transaction at lines 995-1049 inserts the owner and persists those values, then lines 1063-1078 return a successful tenant session. This bypasses the regional contract in main/countries.ts, where signup country is the source of regional identity and resolveRegionalSnapshot rejects a missing country. The smallest fix is to remove these defaults, require a valid selected country before the transaction, and return the regional configuration error without inserting the owner. The setup route is not changed by this PR, so this is a pre-existing defect.
Evidence Package

Tip

Reply with @itoqa to send us feedback on this test run.

@itsbkm itsbkm closed this Sep 20, 2026
@itsbkm
itsbkm deleted the fix/regional-fallback-sweep-frontend branch September 20, 2026 08:14
@itsbkm
itsbkm restored the fix/regional-fallback-sweep-frontend branch September 20, 2026 08:14
@itsbkm itsbkm reopened this Sep 20, 2026
itsbkm and others added 4 commits September 20, 2026 13:45
…xture

Regional settings are no longer auto-seeded on install (#779) — this
fixture built its database directly via initDatabase() without going
through /setup/initialize, so /print-bill now throws
RegionalNotConfiguredError instead of resolving IN/INR as before.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Regional settings are no longer auto-seeded on install (#779) — this
fixture built its database directly via initDatabase() without going
through /setup/initialize, so /print-bill now throws
RegionalNotConfiguredError instead of resolving IN/INR as before.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@itoqa

itoqa Bot commented Sep 20, 2026

Copy link
Copy Markdown

Ito QA test results
Ito Diff Report — e19c15a → ed711c4: 15 test cases ran, 1 fixed ✅, 14 passing ✅.

Diff Summary

Coverage focuses on first-time setup and regional behavior: country and phone validation, automatic currency and timezone selection, manual timezone retention, safe retries after invalid input, concurrent setup protection, and country-change persistence. It also exercises the setup interface’s required-field messaging and successful completion flows across common and edge-case scenarios.

Safe to merge — the run found no failures attributable to this PR, including no regressions, new failures, or previously reported failures that remain unresolved. Previously passing areas were not exercised in this run and remain flag-for-later coverage gaps, not merge blockers.

Tests run by Ito

View full run

Result State Severity Type Description
✅ ❌->✅ Fixed — Rev Trying to finish setup without choosing a country kept the wizard on the country step. No owner or regional settings were created in the fresh database.
✅ Passing — General Empty, unknown, and non-string country values return a clear validation error, and setup does not create an owner.
✅ Passing — General A bad owner submission was rejected without creating a user or leaving regional settings behind. The corrected retry created one owner with the expected Kuwait currency and timezone.
✅ Passing — General An invalid timezone returned a clear error without creating an owner or settings. A valid retry completed setup and saved the US timezone.
✅ Passing — General After the country was changed from the United States to Canada, setup redirected to login and saved Canada, Canadian dollars, and the Toronto time zone. The earlier United States values were not retained.
✅ Passing — General The setup wizard kept the manually chosen America/Chicago timezone after the country changed from the United States to Canada. Setup completed successfully, and the saved tenant settings matched the value shown in the wizard.
✅ Passing — General Two setup requests sent at the same time produced one complete Canadian tenant and one clear rejection. The final tenant had one user and matching country, currency, and timezone values.
✅ Passing — Currency First-run setup completed for the United States and stored USD as the tenant currency.
✅ Passing — Installation The fresh installation opened the setup flow with no country selected. The backend reported that setup is still needed, and the database had no country, currency, currency symbol, or timezone rows.
✅ Passing — Locale The setup wizard stayed on the country step and showed "Choose your country to continue" when Continue was clicked without a country.
✅ Passing — Phone A valid US phone entered in national format was accepted and saved as +12025550123.
✅ Passing — Phone The setup endpoint returned HTTP 400 for the invalid US phone, and no setup owner or business phone was created.
✅ Passing — Timezone Starting setup with the United States selected and no manual timezone saved the correct America/New_York timezone for the new restaurant.
✅ Passing — Wizard The setup wizard accepted United States, saved USD, America/New_York, and English, and sent the owner to the login screen.
✅ Passing — Wizard Clicking Continue with no country selected keeps the setup wizard on the first step and shows the message "Choose your country to continue."
⏸️ Skipped — General The paid order kept the latest eligible receipt status, even with newer inbound and manual-reply messages. The order list and detail view both showed sent.
⏸️ Skipped — General After a new receipt was sent, the order list, order details, and order card all showed Receipt sent after refresh.
⏸️ Skipped — Country Verified acceptable by independent adversarial review: the reported expectation does not match what the code actually promises. Review notes: The source confirms a reachable toast path and confirms that ZZ can produce the reported non-null Intl display name, but that mechanism is not itself a defect. The finding extends PR text about catching the exception from an empty code into a distinct requirement to override a non-null localized name for ZZ; neither that PR text nor repository tests, comments, or messages establish this special fa…
⏸️ Skipped — Currency The billing screen used the tenant's explicit EUR setting and showed euro values instead of Indian rupees.
⏸️ Skipped — Dashboard The dashboard loaded for US QA Cafe and showed US/USD settings. The local setup had no order to open, so the deeper order and POS navigation check could not be completed.
⏸️ Skipped — Ordercard The Orders screen showed the seeded order card with its item and total. Clicking Checkout opened the Payment window with invoice INV-20260919-0001 and a $150.00 total.
⏸️ Skipped — Phone The customer form accepted the US national phone number and saved it as +14155552671.
⏸️ Skipped — Preference Selecting Español changed the settings page to Spanish, and Español was still selected after the page was reloaded.
⏸️ Skipped — Print The receipt preview could not be opened because the local database was still on first-run setup with no tenant or order data. The local app and API were healthy, and source review confirms the print path has an explicit US/USD context when business regional fields are absent.
⏸️ Skipped — Printer The printer test request returned success and the generated page used the tenant's New York time zone.
⏸️ Skipped — Printer When the tenant has no timezone, the printer test request returns HTTP 409 with regional_not_configured and does not try to print.
⏸️ Skipped — Receipt The unpaid order showed no receipt status in the order list or detail view. The application returned null instead of inventing a receipt state.
⏸️ Skipped — Receipt Order 2 showed sent from its newest qualifying receipt row instead of the older failed row.
⏸️ Skipped — Receipt The paid order showed the latest receipt status, sent, in both the orders list and the order details.
⏸️ Skipped — Regional The regional settings check could not run because the test environment lost its configured tenant and stayed on first-run setup. No product failure was confirmed.
⏸️ Skipped — Rev Sending a paid order receipt creates an outbound bill receipt message, and refreshing the order shows the receipt status as sent.

Tip

Reply with @itoqa to send us feedback on this test run.

itsbkm and others added 2 commits September 20, 2026 18:55
Regional settings are no longer auto-seeded on install (#779). These
fixtures built their database directly via initDatabase() and set
timezone/currency explicitly but never country, so
resolveRegionalSnapshot() now throws RegionalNotConfiguredError where
it previously resolved IN implicitly.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…t fixtures

Regional settings are no longer auto-seeded on install (#779). These
fixtures build their database directly via initDatabase() and create
real orders through the API (generateOrderNumber requires a resolvable
country and timezone), so they now throw RegionalNotConfiguredError
where they previously resolved IN/Asia-Kolkata implicitly.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@itsbkm
itsbkm merged commit b51d3dc into main Sep 20, 2026
14 of 15 checks passed
@itsbkm
itsbkm deleted the fix/regional-fallback-sweep-frontend branch September 20, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant