Repository navigation
fix(cash-sessions): enforce open-session guard - #1129
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
@greptile review |
|
|
The production fix looks correct. I verified that the shift-opening transaction reuses the existing Before merging, please strengthen the regression tests:
Keep the existing production approach unless testing reveals an actual defect. Do not modify the day-close accounting formulas or introduce unrelated changes. |
2e7632f to
297f036
Compare
Check closedDayExists inside POST /api/cash-sessions/open using the store's configured business timezone and day-start boundary, and return 409 (day_already_closed) when the business day is already closed. Fixes #1085
Add deterministic fixed-clock regression coverage using America/New_York and a 04:00 business_day_start_time where calendar date differs from effective business date, verifying closed adjacent calendar days do not block opening and closed effective business day rejects both positive and zero opening floats with 409 (day_already_closed) without creating sessions or movements.
297f036 to
a0bcfac
Compare
Fixes #1085
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1085 ("Cash shift can be opened on an already-closed business day"): in
main/routes/cash-sessions.ts, checkclosedDayExistsinside the open-shift transaction using the store's configured business timezone and day-start boundary, and return409(day_already_closed) when the business day is already closed. Deliver via theno-mistakespipeline as its own PR withFixes #1085in the PR summary. Strengthen regression tests intests/cash-sessions.test.tswith a deterministic fixed clock, non-UTC timezone, and custombusiness_day_start_timecovering calendar-vs-effective business date boundaries and both zero and positive opening floats.What Changed
POST /api/cash-sessions/openwith409(day_already_closed) inside the open-shift transaction whenclosedDayExistsis true for the current effective business date (localDateInTimezone(new Date(), tenantTimezone(), tenantBusinessDayStartTime(db))), and allowday_already_closedinCASH_SESSION_OPEN_DISPLAY_CODES.409(session_already_openandday_already_closed) responses forPOST /api/cash-sessions/openindocs/reference/api.md.tests/cash-sessions.test.tsverifying closed-day shift-open rejection across a non-UTC timezone (America/New_York) and custombusiness_day_start_time(04:00) for both positive and zero opening floats.Fixes #1085
Risk Assessment
✅ Low: The change is a small, well-bounded guard inside the shift-open transaction using existing business-date and closed-day helpers, accompanied by matching diagnostic-code allowlist updates, API documentation, and deterministic boundary tests.
Testing
Built the backend (
npm run build), executed the targetednpm run test:cash-sessions(181/181 assertions passed, including Section 9) andnpm run test:cash-closures(359/359 assertions passed) suites, and stood up the live FloCafe HTTP server (startServer()frommain/server.ts) against an isolated SQLite database to drive all three boundary and closed-day shift-open scenarios over HTTP, capturing the responses and database state in~/.no-mistakes/evidence/01M4VTVCKC1GZ9V1TVDJGC1N0M/issue-1085-live-verification.json(no screenshot or visual artifact applies because this is a backend API route change with no UI surface change).Evidence: cash-sessions-section-9-test-output
Evidence: issue-1085-live-verification-json
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 buildnpm run test:cash-sessionsnpm run test:cash-closuresnode -e '<live Electron + main/server.ts HTTP verification script for issue #1085>'✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.