2.4 KiB
2.4 KiB
F-188 — POS pending payment orders and completion states
Allow POS orders to be saved with an outstanding balance, ensure fully paid POS orders reach COMPLETED, and let cashiers apply later payments to clear the outstanding balance.
Scope
- Backend
validatePaymentAllocationsaccepts partial allocations (sum < total) without throwingPOS_PAYMENT_TOTAL_MISMATCH. Overpayment remains rejected. POST /pos/salespersists orders withstate='PENDING'when allocated total < order total, andstate='COMPLETED'when allocations cover the order total.- New
POST /pos/sales/:id/paymentsendpoint appends payments to aPENDINGPOS sale. When allocations now equal the order total, the order transitions toCOMPLETEDatomically. - Stock, reporting lines, payment lines and expected cash balance are updated by every payment, including rest-payment installments.
- Sale list exposes
state,paidCentsandoutstandingCents. Cashier can fetchPENDINGPOS sales for the current session. - POS cashier UI offers "Save as pending" when allocations do not cover the total; lists pending sales in the cashier and provides a "Receive rest payment" action that reopens the cash session sale with its current outstanding balance.
- Audit log records partial creation and pending fulfillment transitions.
bounded shipmentsand refunds remain out of scope (F-189).
Out of scope
- Refunds, partial refunds and return tickets (F-189).
- Daily close reconciliation on top of pending balances (F-191).
- Customer credit, deposit or deposit-paper workflows.
Acceptance
- Backend accepts partial payments on a POS sale and persists the order with
PENDINGandoutstandingCents = total - paid. - Backend still marks fully paid POS orders as
COMPLETEDand rejects overpayment. - Pending POS sales appear in the cashier's session list with the outstanding balance.
- Cashier can apply a follow-up payment to a
PENDINGsale; reaching the total transitions it toCOMPLETEDatomically. - Stock is reserved on POS sale creation (not on full payment) and reporting captures every partial payment.
- Replaying the same idempotency key keeps the original order, its state and its payments intact.
- Non-admin/non-POS users cannot create or modify pending POS sales.
- Migration is reversible (or no migration is needed) and existing fully paid sales stay
COMPLETED. - Tests, typecheck, affected builds and
verify.share green.