Repository navigation
fix(pos): keep scheduled order retry attempt - #1488
Conversation
Preserve unresolved scheduled order attempts and their scheduled_for payload and idempotency key when reading scheduled_orders_enabled fails and recovers or when scheduling is disabled and re-enabled before reconciliation. Fixes #1470
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoPreserve scheduled order retries across scheduling-setting changes
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
Reconcile definitive schedule rejections (not_applied) by retiring the saved order attempt so cashiers can clear or replace the schedule across postpaid, send-to-payment, and prepaid flows. Scope saved order attempts to their originating store so switching stores with a matching unscheduled cart does not import the prior store's schedule, while preserving legacy attempts in their origin store. Assert business settings restoration in the scheduled-orders E2E cleanup.
Fixes #1470
Intent
Verify and fix
[P1] Preserve unresolved order attempts when scheduling settings fail(frontend/src/app/(dashboard)/pos/page.tsx:1434): when a scheduled order commits on the server but its response is lost, a failed scheduling-setting read or disabling and re-enabling scheduling previously cleared the cart schedule so retry generated a new idempotency key and created a duplicate 201 order.What Changed
frontend/src/lib/order-attempt.ts(parseStoredAttemptScheduledFor,fingerprintsMatchAcrossScheduleToggle,doesAttemptMatchStore,resolveRetryScheduledFor, andresolveCartScheduledForAfterSettingRead).frontend/src/app/(dashboard)/pos/page.tsxto persiststoreIdon postpaid and prepaid order attempts, retain a matching unresolved attempt'sscheduled_forvalue and idempotency key across failed or toggledscheduled_orders_enabledreads, and clear stored attempts when the server returns a definitive schedule validation rejection (isDefinitiveScheduleRejection).tests/issue-788-order-attempt-storage.test.tsand Playwright E2E coverage infrontend/e2e/scheduled-orders.spec.tsfor scheduled order retry idempotency and rejection reconciliation.Risk Assessment
✅ Low: The change cleanly preserves unresolved scheduled order attempts (both payload scheduled_for and idempotency key) across scheduling-setting read failures and setting toggles, scopes attempts by store to prevent cross-store schedule bleed, retires attempts upon definitive server-side schedule rejection, and adds comprehensive unit and E2E test coverage.
Testing
Ran the targeted order-attempt storage unit suite (
npm run test:issue-788-order-attempt-storage), scheduled-orders integration suite (npm run test:scheduled-orders), cart/append retry suite (npm run test:issue-255), and live Chromium Playwright E2E suite (e2e/scheduled-orders.spec.ts), capturing visual screenshots and request/response idempotency traces in the evidence directory; all scenarios passed.Evidence: Captured request/response idempotency trace across all live browser scenarios
{ "scenario1_failed_setting_read_recovery": { "firstCommittedOrderId": 1, "replayedOrderId": 1, "replayStatus": 200, "initialRequest": { "idempotencyKey": "eb71d121-2a9d-419f-81a4-fc3eadfa2dd5", "scheduled_for": "2026-11-07T09:00" }, "replayRequest": { "idempotencyKey": "eb71d121-2a9d-419f-81a4-fc3eadfa2dd5", "scheduled_for": "2026-11-07T09:00" } }, "scenario2_disable_reenable_toggle": { "secondCommittedOrderId": 2, "replayedOrderId": 2, "replayStatus": 200, "initialRequest": { "idempotencyKey": "7b25f83c-8de8-48ae-a1b1-90f1b84840dc", "scheduled_for": "2026-11-07T09:20" }, "replayRequest": { "idempotencyKey": "7b25f83c-8de8-48ae-a1b1-90f1b84840dc", "scheduled_for": "2026-11-07T09:20" } }, "scenario3_definitive_schedule_rejection_retires_attempt": { "rejectedStatus": 409, "rejectedCode": "SCHEDULED_ORDERS_DISABLED", "rejectedOutcome": "not_applied", "initialAttemptKey": "4eb3be40-3da2-4215-8262-a0f12ea94274", "rejectedRetryKey": "4eb3be40-3da2-4215-8262-a0f12ea94274", "subsequentImmediateOrderStatus": 201, "subsequentImmediateOrderId": 3, "subsequentImmediateKey": "7c290bcc-53f3-4040-a770-d221e74afd42" } }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:issue-788-order-attempt-storagenpm run test:scheduled-ordersnpm run test:issue-255cd frontend && npx playwright test e2e/scheduled-orders.spec.ts --config=playwright.config.ts --project=chromium✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.