Repository navigation
fix(cash): file shift close under opening date - #1375
Conversation
Use sessionBusinessDate(db, session) in closeSessionTxn() so manual and stale automatic shift closures record the opening business date in the store timezone and cutoff while preserving actual period_start, period_end, closed_at timestamps, daily reporting windows, and historical closures (fixes #1360).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Assign the session business date main/routes/cash-sessions.ts, docs/architecture/business-time.md |
The route uses sessionBusinessDate to set a session closure’s business date. The documentation distinguishes the shift’s actual UTC closure period from the business date used to file the closure. |
Check closure dates across time boundaries tests/cash-sessions.test.ts |
Tests cover cross-midnight shifts in three timezones, a 04:00 cutoff, a same-day shift, a daylight-saving transition, stale-session auto-close, and historical reprints. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
FreeOpenSourcePOS/FloCafe#1360— The issue concerns cash-session closure dates after midnight; this change sets the closure date from the session’s opening business date.FreeOpenSourcePOS/FloCafe#830— The epic covers cash shifts and business-day cutoffs; this change addresses a business-date error in the cash-session lifecycle.
Merge Risk: 
Low · up to 6d116
-
Changing the business-day cutoff during an open shift can file its closure under the wrong date. The PR is mergeable with awareness of that limitation.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The pull request description is detailed and covers the issue, change summary, scope, risk, verification commands, test coverage, compatibility impact, and live results. It does not use all template headings and does not explicitly complete the cross-cutting surfaces, developer documentation, or contributor checklist sections, but the required information is mostly present.
Full details: Title check
-
Explanation
The title "fix(cash): file shift close under opening date" is specific and matches the main change in the changeset. The PR switches shift-session closures to use sessionBusinessDate so that a cross-midnight shift is filed under the business date it opened on, not the date it closed. The title is short, names the area (cash), and describes the fix. The raw summary and objectives both confirm this change in cash-sessions.ts, the business-time docs, and the regression tests.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
Intent
Fix FloCafe issue #1360 (#1360): cross-midnight shift closures receive the closing business date instead of the opening business date. Verified against 46b6a7c (3.13.13): a shift opened October 25 and closed October 26 at 00:30 saved and printed October 26, while its opening float remained October 25, reproduced in UTC, Montevideo, and Sydney, with expected cash reconciling at $231.64 and zero variance. File future shift closures under the shift's opening business date calculated using the store timezone and business-day cutoff via sessionBusinessDate(db, session), while keeping actual opening/closing timestamps, daily sales attribution, and historical closures unchanged.
Fixes #1360
What Changed
closeSessionTxninmain/routes/cash-sessions.tsto derivecash_closures.business_datefrom the shift's opening timestamp viasessionBusinessDate(db, session)rather than the closing wall-clock date, preserving actualopened_at/closed_atand[period_start, period_end]timestamps, daily sales boundaries, and historical closures.docs/architecture/business-time.mdto document that shift session closures (scope = 'session') record their actual UTC[period_start, period_end]window while filingbusiness_dateunder the shift's opening business date.tests/cash-sessions.test.tscovering cross-midnight shift closures and Z-report print/reprint output acrossUTC,America/Montevideo, andAustralia/Sydney, custombusiness_day_start_timecutoffs, daylight-saving transitions, same-day closures, stale session auto-closures, and historical closures.Risk Assessment
✅ Low: The change replaces the closing-time date calculation in closeSessionTxn with the existing sessionBusinessDate(db, session) helper, affecting only newly closed shift sessions while leaving opening/closing timestamps, daily sales boundaries, and historical closures untouched.
Testing
Ran the focused cash-sessions, cash-closures, business-date, and timezone-report-boundaries test suites, built the backend, and stood up the compiled FloCafe server against an isolated SQLite database to drive cross-midnight shift closures, 04:00 cutoff and Sydney DST transitions, stale-shift auto-close, Z-report ESC/POS printing/reprinting, daily X-report attribution, and historical closure preservation live over HTTP. This backend-only change has no UI, HTML, or CSS surface modifications, and all scenarios passed with API, database, and decoded thermal receipt evidence captured in the evidence directory.
Evidence: Live cross-midnight shift closure HTTP, SQLite, and X-report verification JSON
Evidence: Decoded ESC/POS thermal Z-report receipt at close and later reprint (UTC cross-midnight shift)
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:cash-sessionsnpm run test:cash-closuresnpm run test:business-datenpm run test:timezone-report-boundariesnpm run buildLive HTTP server execution against compileddist/main/server.js(POST /api/auth/login,POST /api/cash-sessions/open,POST /api/bills/:id/payment,GET /api/cash-sessions/current,POST /api/cash-sessions/:id/close,POST /api/cash-closures/:id/print,GET /api/reports/x-report) across UTC,America/Montevideo, andAustralia/Sydney✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests