sale, lookup, sale-support, config, return (all admin)
Primary user value
A shop rings up a walk-in sale at the counter and produces an ordinary order with one request
Actors
admin (the operator), system (the draft sweep)
Main entry points
20 admin routes under /api/admin/pos/; the hourly draft sweep
Main outputs
A draft sale, a completed picked_up/ordered sale, an order, a payment_attempt, a receipt email (also re-sendable), a walk-in invitation email, a counter return with its refund and restocked units
There is no customer-facing flow in this module. The walk-in customer is present at the counter
but every action is performed by the administrator on their behalf; the customer-facing
"flows" below are what the customer experiences through the operator.
A customer walks in without an account. The operator finds or creates the customer, scans the
items, decides pickup or delivery, takes the money and hands the goods over — one request at the
end does the money, the stock and the order together.
The walk-in account has no password. The customer receives an emailed link to set one. The link
never expires but is single-use — it stops working the moment a password is successfully set.
A customer brings goods back to the counter. The cashier looks up the sale, enters what is coming back, and confirms once. The return, the refund and the stock restore happen together or not at all.
The cashier holds Pos_UPDATE and PosReturns_CREATE.
The sale is picked_up or ordered and its order is delivered or partially_returned. A delivery order that has not been delivered yet shows returnable: 0 on every line.
reason: quantity_exceeds_returnable, with returnable
Same item twice
Duplicate (product, variant)
Refused
reason: duplicate_line
No terminal reference
Cash refund, or none entered
Server records POS <saleNumber> RET <id> (no terminal ref)
Refund still settles
Nothing refundable on the lines
Fully discounted lines
Return recorded, refund: null
201
Refund method rule. Any method (cash, card_reversal, qr_reversal) is allowed on any POS sale, whatever tender paid for it. When the cashier sends no refundMethod, the default follows how the sale was paid: cash gives cash, card gives card_reversal, QR gives qr_reversal. A card or QR reversal still requires the order's channel to be pos.
Approval rule. The order module normally requires the inspector to differ from the approver. For counter returns this is waived by decision: one cashier performs every step. Each step is called with that cashier's admin id, and the route needs PosReturns_CREATE so the authority is granted on purpose. The return-requested event (with its live admin notification) and the return-decided event are suppressed; the refund-settled event is still sent.
pos_sale → cancelled, event cancelled with mandatory reason
2
Operator opens a new draft
Fresh POS-2026-... number
A draft may also be cancelled by the hourly sweep after 24h idle. Both paths record
cancelled; only the operator's carries actor_admin_id (the sweep writes null).
Stock. A draft holds no stock, so neither cancel nor the sweep releases any. Completion reserves and finalizes stock in its one transaction. The only POS path that puts stock back is a counter return. A Counter Walk-in's typed delivery address is archived on cancel and by the sweep.
updated_at <= now() - 24h, guarded WHERE status='draft'
Event with sweep reason, no actor
There is no awaiting_payment. An online checkout needs that state because the customer
leaves for a gateway and comes back; a counter sale has no such gap — the operator takes the
money and records it in the same request. Modelling a wait that cannot happen would create a
state every query has to handle and no code path can ever produce.
A counter return does not change pos_sale.status: the sale stays picked_up or ordered, and the return moves the order (to partially_returned or returned) and the order's lines.
picked_up is terminal for POS but the order is already delivered; ordered is terminal for
POS but the order is at confirmed and the Order module owns every state after it.
Email lowercased; email or phone required; phone normalised to E.164
Operator
POST /customer
Customer (+ invitation with an email)
No password; email_verified: false; 409 contact codes; phoneDropped
pos-customer.service.ts
Counter Walk-in
One shared customer for buyers with no contact
Operator
GET /config, then POST /sales
Sale on the shared account
No email, no phone; delivery address is one-time and archived
pos-customer.service.ts
Exact SKU scan
Case-insensitive fallback for exactly one match
Operator
GET /lookup/products/by-sku
One sellable configuration
409 on an ambiguous SKU
pos-sale-line.service.ts
Sale search
Substring of sale or order number
Operator
GET /sales?search=
Filtered page
ILIKE with escaped wildcards
pos-sale-query.service.ts
Payment method change
Only on a draft
Operator
PATCH /payment-method
Sale with the new tender
Reference cleared for cash
pos-sale-draft.service.ts
Receipt resend
3 per sale per 24 h
Operator
POST /receipt-email
Email queued
Outbox row; resendKey in the job id
pos-sale-support-admin.service.ts
Saved addresses
Draft only; never for the Counter Walk-in
Operator
GET /customer/addresses
Active addresses
status: "active"
same
Till config
Walk-in id, tenders, 7-day window, NPR
Operator
GET /config
PosConfigDto
—
pos-config-admin.service.ts
Counter return
One transaction, idempotent
Cashier
POST /returns
Return, refund, restock
pos_counter_returns
pos-counter-return.service.ts
Line upsert
Replaces quantity
Operator
PUT /items/{id}
Line at typed quantity
ON CONFLICT DO UPDATE
pos-sale-line.service.ts
Line remove
Hard delete
Operator
DELETE /items/{id}
Line gone; totals recomputed
Hard delete — the sale of record is order_item
same
New address
Saved to the customer's book (a Counter Walk-in's is one-time and archived when the sale ends)
Operator
PATCH /fulfilment
Address reusable later (not for the Counter Walk-in)
is_default: false deliberately; districtId is a uuid
pos-sale-draft.service.ts
Payment reference
Recorded, never validated
Operator
POST /complete
Reference on the receipt
Refused beside pos_cash
pos-sale-completion.service.ts
Receipt
Skipped without email. Emailed copy has the subject Proforma estimate invoice for sale <number>; the printed title "PROFORMA ESTIMATE INVOICE" is a printed-receipt rule (§12.3)
The full till flow diagram (§6.1), the sale lifecycle (§7), the completion sequence (§5.1) and
the queue topology below cover the module's business processes.
A cashier can optionally record one serial number per unit when completing a counter pickup, and pick serials when taking a unit back. Serials are free text, never entered at product creation, unique per product among active serials across retail and POS, and released when the unit comes back. A delivery sale records them at dispatch instead. See /docs/developer/pos/serials for the flows, rules, error codes and runbook.