Repository navigation
fix(main): include closing-second unpaid bills in shift-close guard - #1278
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 |
|
@greptileai review this at apex |
[Medium impact] The PR appears safe to merge; no new actionable issue was found.
|
…e guard Include already-committed bills in the closing-second unpaid guard by changing the upper bound to <= closedAt, preventing shifts from closing with open unpaid or partially paid balances. Fixes #1275
28a9915 to
801f5ca
Compare
|
@greptileai review this at apex |
Fixes #1275
Intent
Fix the closing-second unpaid bill guard defect from the FloCafe 3.13.1 release-readiness audit at
36575453(Issue #1275):main/routes/cash-sessions.ts:125, Issue fix(cash-sessions): include closing-second unpaid bills in shift-close guard #1275): Shift closing can miss unpaid bills created in the closing second.now()inmain/db.tsuses 1-second timestamp strings (YYYY-MM-DD HH:MM:SS). IncloseSessionTxn(main/routes/cash-sessions.ts:125), the unpaid-bill guard checksb.created_at >= ? AND b.created_at < ?(closedAt). BecausecloseSessionTxnruns inside a serialized SQLite transaction (withTxn), anybillsrow visible to that query was already committed before the close transaction began, so< closedAtexcludes unpaid or partially paid bills committed during the same wall-clock second (b.created_at === closedAt), allowingPOST /api/cash-sessions/:id/closeto return200and close the shift with an open balance. Change the unpaid-bill close guard upper bound tob.created_at <= ?(closedAt) while keeping financial reporting period intervals half-open (< closedAt) orcash_session_id-attributed so adjacent shifts never double-count.What Changed
closeSessionTxn(main/routes/cash-sessions.ts) to use an inclusive upper bound (b.created_at <= ?), preventing unpaid or partially paid bills committed during the closing second from bypassing the shift close block.docs/reference/api.mdto document thePOST /api/cash-sessions/:id/closerequest payload, response shape, and409 unpaid_bills_remainingerror condition.tests/cash-sessions.test.tscovering closing-second and preceding-second unpaid or partially paid bills, and an E2E test infrontend/e2e/cashier-status-bar.spec.tsverifying the shift-close modal displays the 409 error banner and keeps the shift open.Risk Assessment
✅ Low: The change surgically adjusts the shift-close unpaid-bill query upper bound to inclusive (<= closedAt) to prevent closing-second unpaid bills from slipping through, preserves half-open reporting intervals, and includes focused API and E2E regression tests with proper cleanup.
Testing
Exercised the inclusive closing-second unpaid bill guard across 5 live scenarios against the running FloCafe Express API server and Next.js POS UI in Chromium. Verified same-second unpaid and partial bills trigger HTTP 409 unpaid_bills_remaining and leave the shift open; verified same-second cancelled orders and paid bills permit closure (HTTP 200); verified adjacent shifts remain isolated without double-counting; and verified the POS ShiftCloseModal displays the error banner, captured in evidence screenshot r4-shift-close-unpaid-guard.png. All 5 scenarios passed.
Evidence: Live Server Same-Second Shift Close Execution Log
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 build:frontendnpm run test:cash-sessionsnpm run test:cash-closurescd frontend && npx playwright test e2e/cashier-status-bar.spec.ts --project=chromiumLive HTTP boundary validation against standalone FloCafe server on http://localhost:3001✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.