Repository navigation
feat(billing): payment method correction - #1394
Conversation
Allow 4-6 digit PINs for all staff roles to support tile-based PIN quick user switching on the lock/login screen while keeping all approval paths strictly restricted to active owner/manager PINs. Fixes #1338
- Use non-blocking per-request rate limit on POST /api/auth/pin-login while preserving per-user lockout - Serialize per-user PIN verification with withPinVerificationLock and audit missing credential requests - Re-read bill/order state and compute charge breakdowns inside the write transaction on PATCH /api/bills/:id/charges - Guard GET /api/settings/auto_lock_minutes with requireAnyPermission across staff roles - Pass explicit Bearer token to POST /auth/logout before clearing storage on lock/logout - Exclude autoLockMinutes from localStorage persistence, reset on session changes, and guard stale save rollbacks - Update kitchenDeliveryOverrideInvalid across all 24 locales to use Staff Approval PIN wording
…c.ts` line 270 to assert `page.getByText('Invalid Staff Approval PIN')` instead of `'Invalid manager PIN'`, matching the updated `pos.kitchenDeliveryOverrideInvalid` translation (`"Invalid Staff Approval PIN. Please try again."`) rendered by `PaymentModal.tsx` when `POST /api/bills/:id/payments` returns 403 `Invalid manager PIN`. The downstream `End-to-End Playwright Tests` and `Required Checks Gate` CI failures were caused by this Shard 1/4 E2E failure. Verification run and passed: - `npm run lint` - `npm run build && npm run build:frontend` - `npm run i18n:check` - `cd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/approval-manager-selection.spec.ts e2e/pin-quick-switch.spec.ts` (4 passed) - `cd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/kitchen-delivery-payment-retry.spec.ts e2e/kitchen/kitchen-delivery-billing-gate.spec.ts` (5 passed) - `node scripts/ci/check-changed-format.cjs --base 1278f91` - `git diff --check`
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoCorrect paid-bill payment methods with approval and PIN quick switching
AI Description
Diagram
High-Level Assessment
Files changed (61)
|
Code Review by Qodo
1.
|
…heck (`test:orders-search`): - **Invariant**: Frontend components imported by `OrdersPage` must resolve `OrderDetailPanel` through the `@/components/orders/OrderDetailPanel` module specifier rather than a relative `./OrderDetailPanel` path, so Node-based `OrdersPage` unit tests that stub `@/components/orders/OrderDetailPanel` and provide a minimal `react` hook stub do not load the real `OrderDetailPanel` module and its `@radix-ui/react-slot` (`React.forwardRef`) dependency at module-load time. - **Root-cause fix**: Updated `frontend/src/components/orders/CorrectPaymentMethodModal.tsx` line 13 to import `normalizeBillPaymentDetails` from `'@/components/orders/OrderDetailPanel'` instead of `'./OrderDetailPanel'`. **Verification**: - `npm run test:orders-search` (passed) - `npm run test:payment-method-correction` (passed) - `npm run test:card-transaction-id` (passed) - `npm run test:ui-regressions-621-623-626` (passed) - `npm run test:password-policy` (passed) - `npm run lint` (passed) - `node scripts/ci/check-changed-format.cjs --base 1278f91` (passed) - `npm run build:frontend` (passed) - `git diff --check` (passed)
… shift-verified payments
e1e8890 to
3cf1afc
Compare
3cf1afc to
e1e8890
Compare
Fixes #1337
Intent
Implement FloCafe issue #1337 (
feat(billing): correct the payment method on a paid bill while its shift is open), stacked on top of#1338(origin/fm/flocafe-1338-pin-quick-switch):409and a clear reason.payment_method_id/ cardtransaction_id) on one payment line (PATCH /api/bills/:id/payments/:index/method).old_method,new_method,actor,approver,reason,timestamp), make replays of the same request idempotent, ensure open-shift expected cash and payment-method totals recalculate automatically, ensure receipt reprint shows the corrected method, add UI inOrderDetailPanel.tsxwith approver picker and PIN prompt, updatedocs/reference/roles-and-permissions.mdanddocs/reference/api.md, and addtests/payment-method-correction.test.ts.Firstmate spec
What Changed
PATCH /api/bills/:id/payments/:index/methodinmain/routes/bills.ts(and sharetenantTimezonefrommain/services/cash-drawer-movements.ts) so activeownerandmanagercallers withpayments.takeand a verifiedowner/managerStaff Approval PIN can change a paid bill line's non-wallet payment method and optionaltransaction_idwithout altering the amount, while enforcing open-shift, open-business-day, refund, and split-sibling checks, updatingpayment_transaction_refs, recordingbill.payment_method.correctedaudit entries, and handling idempotent replays.CorrectPaymentMethodModaland wire it intoOrderDetailPanelandOrdersPagewith translations across all 24 locale message files so eligible owners and managers can select a paid bill and payment line, pick the replacement method and optional reference or reason, and submit with an approver selection and Staff Approval PIN.onRateLimitedhook toauthRateLimitinmain/middleware/security.tsto audit rate-limitedpin_loginrequests inmain/routes/auth.ts, update the architecture and API reference docs, and add coverage intests/payment-method-correction.test.ts.Risk Assessment
✅ Low: The payment-method correction endpoint, UI modal, shift/day/refund/split-sibling guards, owner/manager role and PIN authorization, idempotency, audit logging, documentation, and behavioral test suite are well-bounded and satisfy all stated acceptance criteria without introducing regressions.
Testing
Built the backend and static desktop frontend, executed the targeted integration suites (
test:payment-method-correction,test:pin-quick-switch, andtest:script-coverage), ran the Playwrightpin-quick-switch.spec.tsbrowser suite, and drove the live Orders UI andPATCH /api/bills/:id/payments/:index/methodendpoint in Chromium across open-shift Cash-to-Card correction, shift/X-report recalculation, receipt reprint, idempotent replay, role/PIN authorization boundaries, closed-shift/closed-day refusals, and immutable-amount/refund/split-sibling guards, capturing five screenshots and a structured JSON evidence trace.npm run test:payment-method-correctionEvidence: Live API, shift expected cash, X-report, audit log, idempotency, and adversarial check trace
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:payment-method-correctionnpm run test:payment-method-correctionnpm run test:pin-quick-switchnpm run test:script-coveragenpm run build && npm run build:frontendcd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/pin-quick-switch.spec.tsLive Playwright Chromium session drivingOrderDetailPanelandCorrectPaymentMethodModalagainsttests/e2e-server.cjswith screenshot and JSON evidence capture in~/.no-mistakes/evidence/01M62F362WHNB6SAXD0S7PPZ48✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.