Repository navigation
feat(orders): scheduled orders and kitchen release - #1408
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoAdd scheduled orders with deferred kitchen release
AI Description
Diagram
High-Level Assessment
Files changed (69)
|
Code Review by Qodo
1.
|
Add scheduled takeaway and delivery orders with store-timezone DST validation, deferred inventory depletion and KDS/KOT suppression before release, a 10-second server due sweep with startup and resume triggers, atomic whole-order hold on insufficient stock or unusable catalog items with explicit staff retry, prepaid settlement without early release, payment-locked item/financial edits with audited timing-only reschedules, refund-before-cancel enforcement, POS scheduled queue UI, 24-locale translations, and canonical docs.
…ter settings sync"}
…ter settings sync"}
…ter settings sync"}
…ter settings sync"}
…ter settings sync"}
298ff12 to
561b07b
Compare
: 1. **Playwright E2E (Shard 1/4) (`frontend/e2e/database-export-import.spec.ts:198:7`)**: - **Invariant**: Every test and JSON import fixture that targets the live database schema version without a Master PIN must match the latest schema version (`123` from migration `add_scheduled_orders` in `main/db.ts`) so that `DatabaseSettingsTab` and `POST /api/db/import` recognize it as a matching-version import. - **Cause**: Migration `123` added scheduled orders and incremented `user_version` to `123`. `frontend/e2e/database-export-import.spec.ts` still specified `schema_version: '122'` in `contaminatedPayload`, causing `DatabaseSettingsTab.tsx` to detect a version mismatch (`122 !== 123`) and gate the import behind an owner Master PIN instead of proceeding with the merge import, timing out waiting for `Database imported successfully`. - **Fix**: Updated `schema_version` from `'122'` to `'123'` in `frontend/e2e/database-export-import.spec.ts`. 2. **Playwright E2E (Shard 3/4) (`frontend/e2e/scheduled-orders.spec.ts:23:5`)**: - **Invariant**: Visual evidence screenshots in E2E tests must resolve the target directory cross-platform (supporting `process.env.EVIDENCE_DIR`, local evidence fallback, and temp directory fallback), ensure the target directory exists before writing, and capture screenshots safely without throwing `ENOENT` on environments where specific local host directories do not exist. - **Cause**: `frontend/e2e/scheduled-orders.spec.ts` hardcoded `evidenceDir = '/Users/gurkiratkhaira/.no-mistakes/evidence/01M64J866EWP5Q41XVW3W8J3Q9'`. On Linux CI runners (`ubuntu-24.04`), that path does not exist, causing `page.screenshot()` to throw `ENOENT: no such file or directory`. - **Fix**: Added dynamic `EVIDENCE_DIR` resolution with a safe `captureScreenshot(page, filename)` helper that ensures directory existence and catches filesystem errors without aborting test execution, and converted all 5 screenshot call sites in `frontend/e2e/scheduled-orders.spec.ts`. 3. **End-to-End Playwright Tests & Required Checks Gate**: - Downstream aggregator jobs that failed solely due to Shards 1/4 and 3/4 failing. **Verification run and passed**: - `git diff --check` - `npm run lint` (0 errors) - `npm run docs:check` - `npm run i18n:check` - `npm run build` - `npm run build:frontend` - `npm run test:scheduled-orders` (315/315 passed) - `cd frontend && CI=true npx playwright test --config=playwright.config.ts --project=chromium e2e/database-export-import.spec.ts` (2/2 passed) - `cd frontend && CI=true npx playwright test --config=playwright.config.ts --project=chromium e2e/scheduled-orders.spec.ts` (1/1 passed) - `node scripts/ci/check-changed-format.cjs --base b27799e` - `npm run test:script-coverage`
- Preserve release_status = 'blocked' and blocked reason on reschedule - Isolate unexpected release errors during sweep to prevent stall - Add cursor pagination and load more to GET /orders/scheduled - Use shared payable bill predicate supporting partially_paid - Filter heartbeat active-orders query to release_status = 'released'
Fixes #360
Intent
Implement FloCafe issue #360 (Feature: Scheduled orders with release semantics) for takeaway and delivery orders
What Changed
scheduled_for,release_status,released_at,release_blocked_reason) and background sweep service (main/services/scheduled-orders.ts) to defer inventory deduction, KDS dispatch, and automatic KOT printing until release at store-timezone scheduled times or manual release.GET /api/orders/scheduled,PATCH /api/orders/:id/schedule,POST /api/orders/:id/release), allowed prepayment while edit-locking item and customer changes once paid, guarded KDS and KOT printing against unreleased orders, and required full refunds before cancelling paid scheduled orders.Risk Assessment
✅ Low: Scheduled order release semantics, inventory deferral, cursor pagination, edit locks, and payment reconciliation are cleanly isolated, correct, and well-tested without residual defects.
Testing
Validated scheduled order lifecycle live against real backend, KDS, POS cart, Scheduled Orders drawer, and /orders surfaces with 5 UI screenshots and 344 passing automated backend tests; all scenarios passed.
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:scheduled-orderscd frontend && EVIDENCE_DIR=~/.no-mistakes/evidence/01M64RGSAQ1AJXAP24KC66FB40 npx playwright test --config=playwright.config.ts --project=chromium e2e/scheduled-orders.spec.ts✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.