Skip to content

fix: use tenant timezone for reports and printing - #619

Merged
khaira777 merged 3 commits into
mainfrom
fm/flocafe-timezone-propagation-r1
Sep 3, 2026
Merged

khaira777 merged 3 commits into
mainfrom
fm/flocafe-timezone-propagation-r1

Conversation

@khaira777

@khaira777 khaira777 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Implement Phase 4 of the FloCafe internationalization and printing remediation plan: make store-authoritative timezone behavior consistent across print and reporting paths. Reproduce the current behavior before editing. Replace the KOT settings-row timezone query with the key/value lookup used by the rest of the application. Propagate the tenant/store timezone through backend receipt, KOT, compliance, and print-test contexts. Reconcile report day boundaries with the tenant-local dashboard day. Add fixed-instant regression tests covering UTC, positive offsets, and negative offsets around midnight. Acceptance criteria: KOT settings read the same authoritative timezone source used elsewhere; receipt, KOT, compliance, and print-test output use the tenant timezone consistently; report day boundaries agree with the tenant-local dashboard day around midnight; tests cover UTC, positive offsets, negative offsets, and boundary instants, with the narrowest relevant existing suites passing; existing print semantics and prior Phase 1-3 financial, thermal-safety, locale, and metadata behavior remain unchanged. Keep this as a timezone-only change. Do not alter locale selection or bootstrap, currency precision or regional currency modeling, tax or service-charge policy, country-pack templates, printer capability architecture, raster output, broad routing, or unrelated UI. Start from the current FloCafe default branch after merged PR #615. Phase 5A country-pack charge-row parity remains separately deferred until its output-contract compatibility decision is settled.

What Changed

  • Propagate the tenant timezone through receipt, KOT, compliance, and print-test rendering, using the authoritative key/value settings lookup.
  • Make report defaults, filters, daily grouping, and insights use tenant-local calendar days with UTC database ranges; document the updated API behavior.
  • Add fixed-instant coverage for UTC, positive offsets, negative offsets, and midnight boundaries, and register the new regression suite.

Risk Assessment

✅ Low: The focused timezone changes are source-consistent and no material defect or intent contradiction was substantiated.

Testing

Installed locked dependencies, ran the narrow timezone/report/print suites, and exercised fixed-instant print plus tenant-midnight report API behavior; all targeted checks passed, temporary fixtures were cleaned, and no UI screenshot was captured because the change affects print output and backend reporting rather than visual layout.

Evidence: Tenant-local print output transcript
Fixed instant 2026-04-21T23:30:00Z rendered consistently in receipt, KOT, and printer-test output: 5:00 AM Asia/Kolkata; 4:30 PM America/Los_Angeles.
Evidence: Tenant-local report API transcript
Tenant-local report API boundary check included only the two orders spanning 2026-04-22 Asia/Kolkata, returning 2 orders and total 300.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • npm run test:timezone-report-boundaries
  • npm run test:reports-insights
  • npm run test:reports-daily-stats-table-turn
  • npm run test:print-parity
  • npm run test:print-document
  • npm run test:printer
  • npm run test:receipt-printing
  • npm run test:bills-print-api
  • npm run test:print-labels
  • npm run test:i18n-ssr-timezone
  • npm run test:kot-locale-cold-start
  • npm run test:issue-389-timezone-override
  • Fixed-instant receipt/KOT/printer-test rendering checks
  • Fixed-boundary /api/reports/summary, /sales, and /recentOrders checks
  • git diff --check and final git status
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes print timestamps and report calendar boundaries use the tenant-configured timezone.

  • Propagates tenant timezone settings into receipt, KOT, compliance, and printer-test rendering.
  • Converts tenant-local report dates into UTC database ranges and groups daily sales by tenant-local date.
  • Adds fixed-instant timezone regression coverage and updates report and printing documentation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
main/db.ts Adds tenant-local date resolution and DST-aware conversion of local calendar-day boundaries into UTC ranges.
main/routes/reports.ts Applies tenant-local defaults, filtering boundaries, and daily grouping throughout reporting endpoints.
main/routes/printers.ts Propagates the configured tenant timezone into printer tests and bill rendering.
main/printers/thermal.ts Uses the authoritative timezone setting for KOT and test-page timestamp formatting.
frontend/src/app/(dashboard)/print-test/page.tsx Builds frontend print-test tenant data with the authenticated tenant timezone.
tests/timezone-report-boundaries.test.ts Adds regression coverage for tenant-local reporting boundaries across UTC and positive and negative offsets.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Tenant timezone setting] --> B[Print contexts]
  A --> C[Tenant-local report date]
  B --> D[Receipt / KOT / compliance / test output]
  C --> E[UTC half-open database range]
  E --> F[Filtered report rows]
  F --> G[Tenant-local daily grouping]
Loading

Reviews (2): Last reviewed commit: "no-mistakes(ci): Fixed the PR-induced te..." | Re-trigger Greptile

…configuring UTC for UTC-based report fixtures in tests/refunds.test.ts and tests/issue-214-payment-integrity.test.ts. Verified: refunds 54/54 passed, issue-214 83/83 passed, neighboring report/timezone suites passed, and git diff --check passed
@khaira777
khaira777 merged commit da99f62 into main Sep 3, 2026
15 checks passed
@khaira777
khaira777 deleted the fm/flocafe-timezone-propagation-r1 branch September 3, 2026 03:56
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