Nano Store - Ecommerce Docs
Developer ResourcesPOS

POS Features and Flows

Complete feature list, actor journeys, state flows, business rules, edge cases, and diagrams for the POS module.

POS - Features and Flows

1. Documentation Evidence

Source TypeFiles or DocsWhat Was Extracted
Technical design.omc/plans/POS/master-plan.md, consumer-handoff.mdState model, validation, timing, the frozen contract
APIpos-sale-admin.controller.ts, pos-lookup-admin.controller.ts, pos-sale-support-admin.controller.ts, pos-config-admin.controller.ts, pos-return-admin.controller.tsRoute surface, permissions, rate limits
Backendpos-sale-draft.service.ts, pos-sale-completion.service.ts, pos-sale-line.service.ts, pos-customer.service.ts, pos-customer-identity.service.ts, pos-lookup.service.ts, pos-counter-return.service.ts, pos-sale-support-admin.service.tsBusiness behavior and side effects
Schemapackages/db/src/schema/pos/*.tsTables, enums, constraints, the state machine as a CHECK

2. Feature Summary

FieldValue
Modulepos
Submodulesale, lookup, sale-support, config, return (all admin)
Primary user valueA shop rings up a walk-in sale at the counter and produces an ordinary order with one request
Actorsadmin (the operator), system (the draft sweep)
Main entry points20 admin routes under /api/admin/pos/; the hourly draft sweep
Main outputsA 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
Related docsBackend, API

3. Actor Matrix

ActorCan DoCannot DoAuth RequirementNotes
GuestNothingTouch any route—There is no customer-facing POS route
Admin (operator)Open a draft, attach/create a customer, scan lines (by search or exact SKU), choose fulfilment and payment method, complete, cancel, re-send a receiptRe-price a line, modify a completed saleJwtAuthGuard + RoleGuard + Pos_*Every mutation is audited with the acting administrator
Admin (cashier with returns)Everything an operator can, plus take goods back: POST /returnsReturn an online order's goods through this routePos_UPDATE AND PosReturns_CREATEA role with Pos_* but not PosReturns_CREATE is refused with 403 on the return route only
Admin (reader)List, search by sale or order number, view one sale, view the timeline, look up customers/products/SKUs, read config, read what is returnableMutate anythingPos_READLookup is Pos_READ, grantable separately from Users_READ
System (sweep)Cancel drafts idle past 24hTouch a sale being edited, complete a saleQueue/internalOne transaction per draft, guarded UPDATE

4. Capability Matrix

CapabilitySurfaceActorRoute/TriggerState ReadState WrittenLinked API Section
Find a customerAdminOperatorGET /api/admin/pos/lookup/customerscustomers—§8.1
Find a sellable productAdminOperatorGET /api/admin/pos/lookup/productsproducts—§8.2
Scan an exact SKUAdminOperatorGET /api/admin/pos/lookup/products/by-skuproducts, product_variants—§8.16
Read till configAdminOperatorGET /api/admin/pos/configCounter Walk-in customers row—§8.18
Open a draftAdminOperatorPOST /api/admin/pos/salescustomerspos_sale (draft, pickup), event created§8.3
List and search salesAdminOperatorGET /api/admin/pos/sales?search=pos_sale + joins—§8.4
Read one saleAdminOperatorGET /api/admin/pos/sales/{publicId}pos_sale, pos_sale_item—§8.5
Read the timelineAdminOperatorGET /api/admin/pos/sales/{publicId}/timelinepos_sale_event—§8.6
Attach a customerAdminOperatorPATCH /sales/{publicId}/customercustomerspos_sale (customer + reset to pickup), event customer_assigned§8.7
Create a walk-inAdminOperatorPOST /sales/{publicId}/customercustomers (identity check)customers, account only with an email (no password), outbox invite only with an email, event customer_created§8.8
Change the payment methodAdminOperatorPATCH /sales/{publicId}/payment-methodpos_salepos_sale (no event)§8.14
List the customer's addressesAdminOperatorGET /sales/{publicId}/customer/addressescustomer_addresses—§8.15
Set a line quantityAdminOperatorPUT /sales/{publicId}/items/{productPublicId}productspos_sale_item (upsert), pos_sale totals, event item_added/item_quantity_changed§8.9
Remove a lineAdminOperatorDELETE /sales/{publicId}/items/{productPublicId}—pos_sale_item (hard delete), totals, event item_removed§8.10
Choose fulfilmentAdminOperatorPATCH /sales/{publicId}/fulfilmentcustomer_addressespos_sale, customer_addresses (new address), event fulfilment_set§8.11
Complete the saleAdminOperatorPOST /sales/{publicId}/completepos_sale, lines, products (prices), inventorycart, session, payment_attempt, order, reservation finalize, pos_sale terminal, outbox receipt, events§8.12
Cancel a draftAdminOperatorPOST /sales/{publicId}/cancel—pos_sale (cancelled), event cancelled (reason required), one-time walk-in address archived§8.13
Re-send a receiptAdminOperatorPOST /sales/{publicId}/receipt-emailpos_sale, customers, outbox_eventsoutbox row (max 3 per sale per 24 h)§8.17
See what is returnableAdminOperatorGET /sales/{publicId}/returnableorder lines, pos_counter_returns—§8.19
Return goods at the counterAdminCashier with returnsPOST /sales/{publicId}/returnssale, order, order linesorder_return*, order_refund*, stock, pos_counter_returns§8.20
Sweep abandoned draftsSystemSweephourly cron → pos.sweep_abandoned_draftspos_salepos_sale (cancelled), event cancelled§9

5. User-Facing Flows

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.

5.1 A walk-in buys over the counter

Summary

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.

Preconditions

  • The operator holds Pos_CREATE/Pos_UPDATE/Pos_READ and the till has connectivity.
  • The customer either already has an account, supplies a name and an email or phone, or gives no contact and is rung up as the shared Counter Walk-in.

Main Flow

StepActor/SystemActionResultSource
1OperatorLook up the customer by name/email/phoneMatch listpos-lookup.service.ts
2OperatorOpen the draft with payment method + customerpos_sale status draft, fulfilment pickuppos-sale-draft.service.ts
3Operator(New customer) create the walk-in with email or phone, or use the Counter Walk-in id from GET /configCustomer created; invitation queued when an email is storedpos-customer.service.ts
4OperatorScan each item, typing the final quantityLine frozen with the price, totals recomputedpos-sale-line.service.ts
5Operator(Delivery only) choose fulfilment + addressdelivery with address and shipping chargepos-sale-draft.service.ts
6OperatorCompleteMoney, stock, order, hand-over in one transactionpos-sale-completion.service.ts
7SystemReceipt emailReceipt queued via outbox → NOTIFICATIONSpos-email.processor.ts

Sequence Diagram

Branches and Edge Cases

BranchConditionBehaviorError/Result
No matching customerSearch too short400 VALIDATION_FAILEDType ≥ 2 characters
Customer has no accountUnknown walk-inCreate walk-in firstcustomerId required at open
Contact already belongs to a customerExisting, attachable customer409 POS_CUSTOMER_CONTACT_EXISTS with details { customerId, name, matchedOn }Attach that customer with PATCH /customer
Phone could not be savedPhone owned by a closed or unverified customer, free email given201 with phoneDropped: trueTell the cashier the phone was not saved
Receipt wanted againCustomer asks for another copyPOST /receipt-email with a new Idempotency-KeyMax 3 per sale per 24 h; POS_CUSTOMER_NO_EMAIL for phone-only customers
Same item scanned twiceSecond PUTQuantity REPLACED, not addedLine ends at the typed number
Price moved mid-salesellingPrice != frozen unitPrice409 POS_PRODUCT_PRICE_CHANGEDRemove and re-add; nothing charged
Someone else took the stockReserve fails409 POS_INSUFFICIENT_STOCKNothing charged, sale still a draft
Completion replayedSame request twiceSecond attempt collides on unique order/cart/session keys409 POS_SALE_ALREADY_COMPLETED, no second charge

5.2 The customer's set-password journey

Summary

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.

Preconditions

  • The operator created the walk-in (which queued the invitation in the same transaction).

Main Flow

StepActor/SystemActionResultSource
1WorkerRuns pos.send_walk_in_inviteMints token, renders email, queues to NOTIFICATIONSpos-email.processor.ts
2CustomerOpens the emailed linkLand on /set-password?token=...pos-walk-in-invite.email.ts
3CustomerSets a passwordverification.consumed_at stamped; token refused from then onVerificationTokenService

Branches and Edge Cases

BranchConditionBehaviorError/Result
Customer deleted the accountBetween sale and jobWorker skips (outcome: "skip")No retry of an invitation to a closed account
No email on fileCustomer without emailWorker skipsNothing to send to
Link used twiceAfter first setToken consumedRefused; customer logs in normally
Link never usedWeeks laterStill valid — never expiresBy owner policy; bounded by single use

5.3 Counter return

Summary

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.

Preconditions

  • 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.
  • The order's 7-day return window is open.

Main Flow

StepActor/SystemActionResultSource
1OperatorFind the sale (search by sale or order number) and open GET /returnableLines with sold, returned, pending, returnable, unitNetMinor, plus earlier counter returnspos-counter-return.service.ts
2OperatorPick quantities; the client shows an estimate of returnable × unitNetMinorEstimate onlyPosReturnableLineDto
3OperatorConfirm once; the client sends one Idempotency-Key for the dialogPOST /returnspos-return-admin.controller.ts
4SystemOne transaction: open, approve, receive and inspect the return (units restocked), approve and settle the refund, record pos_counter_returnsRefund amount computed from the order, never from the requestcreateInTx
5SystemReturn { returnPublicId, refund, lines, sale }Cashier hands back the money—

Sequence Diagram

Branches and Edge Cases

BranchConditionBehaviorError/Result
Retry after a dropped connectionSame key, same bodyStored result returned; no second refund or stock movement201, even after the Redis key expired
Key reused for another returnSame key, different bodyRefused409 IDEMPOTENCY_KEY_CONFLICT
Sale not completedDraft or cancelledRefused409 POS_COUNTER_RETURN_NOT_ALLOWED, reason: not_completed
Window closedReturn window endedRefusedreason: window_closed
Everything already returnedOrder status returnedRefusedreason: fully_returned
Item not on the saleUnknown (product, variant)Refusedreason: line_not_in_sale
Too many unitsAbove what is still returnableRefusedreason: quantity_exceeds_returnable, with returnable
Same item twiceDuplicate (product, variant)Refusedreason: duplicate_line
No terminal referenceCash refund, or none enteredServer records POS <saleNumber> RET <id> (no terminal ref)Refund still settles
Nothing refundable on the linesFully discounted linesReturn recorded, refund: null201

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.

6. Admin Flows

6.1 The full till flow (activity)

6.2 Abandoning a draft

StepActionResult
1POST /sales/{publicId}/cancel with a reasonpos_sale → cancelled, event cancelled with mandatory reason
2Operator opens a new draftFresh 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.

7. Lifecycle and State Transitions

EntityFromEvent/ActionToGuard ConditionSide Effects
pos_saledraftComplete (pickup)picked_upLines present, customer set, fulfilment pickupStock, payment, order, hand-over
pos_saledraftComplete (delivery)orderedLines present, customer set, address setStock, payment, order
pos_saledraftCancel (operator)cancelledReason non-blankEvent with actor + reason
pos_saledraftSweep (24h idle)cancelledupdated_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.

9. Data and Side Effects by Flow

FlowDB WritesCache EffectsJobsRealtimeAnalyticsNotifications
Open draftpos_sale + event—————
Create walk-incustomers, account (email only), event, archive of the previous one-time address—outbox → pos.send_walk_in_invite (email only)——Set-password email
Set payment methodpos_sale—————
Line upsert/removepos_sale_item (+hard delete), totals, event—————
Set fulfilmentpos_sale, maybe customer_addresses, event—————
Completepos_sale terminal, cart, session, payment_attempt, order, reservation finalize, eventsinventory domain after commitoutbox → pos.send_receipt——Receipt email
Cancelpos_sale + event, archive of the one-time walk-in address—————
Receipt resendoutbox_events—outbox → pos.send_receipt with resendKey——Receipt email
Counter returnorder_return*, order_refund*, stock, pos_counter_returns; Mongo activity record after commitinventory domain after commitorder-module notifications (REFUND_SETTLED)——Refund-settled notice
Sweeppos_sale + event per draft, archive of the one-time walk-in address—direct enqueue (cron exemption)———

10. Error and Recovery Flows

ScenarioTriggerUser/System ExperienceRecoverySource
Rate limitedAbove 180 draft writes/min, 30 completes/min, 20 returns/min or 10 receipt resends/min per user (reads and searches 120/min, SKU scans 300/min)429Wait; the limits are far above genuine till useip-throttler.config.ts
Counter Walk-in alteredSomeone gave the shared row an email or phone, banned or deleted it503 POS_COUNTER_CUSTOMER_MISSING on config and walk-in deliveryAn operations fix restores the rowpos-customer.service.ts
Return retriedNetwork dropped after commitSame Idempotency-Key replays the stored resultRetry with the same key, never a new onepos_counter_returns
Price changedCatalogue moved mid-sale409 POS_PRODUCT_PRICE_CHANGEDRemove and re-add the line; nothing was chargedpos-sale-completion.service.ts
Stock shortTwo tills, one unit409 POS_INSUFFICIENT_STOCKShow remaining stock, reduce the quantitysame
Completion replayRetried after commit409 POS_SALE_ALREADY_COMPLETEDShow the existing order number; do not retryunique indexes
Queue outageRedis/BullMQ downSale still commits; receipt/invite delayedOutbox row is durable; dispatcher relays laterpos-mail-queue.service.ts
Deterministic job failuree.g. sale not foundJob returns { success: false, retryable: false, errorCode }Never retried; visible in BullMQ return valuepos-queue.processor.ts
Transient job failureDB connection dropRethrown for BullMQ retryAutomaticsame

12. Mandatory Feature and Flow Deep-Dive Pack

12.1 Feature Inventory With Minor Behaviors

FeatureMinor BehaviorActorTriggerUser/System ResultBackend Side EffectSource
Customer lookupSearch min 2 charsOperatorGET /lookup/customersBounded, paginated matchesILIKE on name/email/phone, active customers onlypos-lookup.service.ts
Product lookupSKU or nameOperatorGET /lookup/productsBounded, paginated matchespublished + not deleted + price ≤ MRP onlysame
Open draftAlways pickupOperatorPOST /salesDraft with fulfilment: "pickup"fulfilment deliberately not accepted in DTOpos-sale-request.dto.ts
Attach customerResets to pickupOperatorPATCH /customerSale drops address/fulfilment/shippingCLEAR_DELIVERY_ON_CUSTOMER_CHANGEpos-sale-draft.service.ts
Walk-in createEmail lowercased; email or phone required; phone normalised to E.164OperatorPOST /customerCustomer (+ invitation with an email)No password; email_verified: false; 409 contact codes; phoneDroppedpos-customer.service.ts
Counter Walk-inOne shared customer for buyers with no contactOperatorGET /config, then POST /salesSale on the shared accountNo email, no phone; delivery address is one-time and archivedpos-customer.service.ts
Exact SKU scanCase-insensitive fallback for exactly one matchOperatorGET /lookup/products/by-skuOne sellable configuration409 on an ambiguous SKUpos-sale-line.service.ts
Sale searchSubstring of sale or order numberOperatorGET /sales?search=Filtered pageILIKE with escaped wildcardspos-sale-query.service.ts
Payment method changeOnly on a draftOperatorPATCH /payment-methodSale with the new tenderReference cleared for cashpos-sale-draft.service.ts
Receipt resend3 per sale per 24 hOperatorPOST /receipt-emailEmail queuedOutbox row; resendKey in the job idpos-sale-support-admin.service.ts
Saved addressesDraft only; never for the Counter Walk-inOperatorGET /customer/addressesActive addressesstatus: "active"same
Till configWalk-in id, tenders, 7-day window, NPROperatorGET /configPosConfigDto—pos-config-admin.service.ts
Counter returnOne transaction, idempotentCashierPOST /returnsReturn, refund, restockpos_counter_returnspos-counter-return.service.ts
Line upsertReplaces quantityOperatorPUT /items/{id}Line at typed quantityON CONFLICT DO UPDATEpos-sale-line.service.ts
Line removeHard deleteOperatorDELETE /items/{id}Line gone; totals recomputedHard delete — the sale of record is order_itemsame
New addressSaved to the customer's book (a Counter Walk-in's is one-time and archived when the sale ends)OperatorPATCH /fulfilmentAddress reusable later (not for the Counter Walk-in)is_default: false deliberately; districtId is a uuidpos-sale-draft.service.ts
Payment referenceRecorded, never validatedOperatorPOST /completeReference on the receiptRefused beside pos_cashpos-sale-completion.service.ts
ReceiptSkipped 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)Systempos.send_receiptNo email, job logged skipoutcome: "skip"pos-email.processor.ts
InviteSkipped for deleted accountSystempos.send_walk_in_inviteNo email, job logged skipoutcome: "skip"same
SweepBatch capSystemhourly cronStops at 100Warns when the batch fillspos-draft-sweep.processor.ts

12.2 Business Process Diagram Pack

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.

12.3 Business Rules and Policy Traceability

RuleBusiness ReasonActor ImpactEnforced InAPI ImpactBackend ImpactTests
A sale always opens as a pickupopen() cannot know an address yet; delivery needs oneOperator re-chooses deliveryDTO omits the fieldNo fulfilment on POST /salesSchema CHECKpos-sale.int.spec.ts
One live review needs a delivered order— (POS enables it)———Pickup drives order to deliveredorder-counter-handover.service.ts
Every completed sale has every downstream keyNo paid sale without an orderOperator sees orderNumberchk_pos_sale_status_completion——constraint probe
A cancelled sale needs a non-blank reasonAudit answers whyOperator must type a reasonDTO + chk_pos_sale_event_cancel_reasonMandatory body field—probe
Cash has no referenceA reference beside cash is a mis-selected methodOperator clears the fieldDTO + chk_pos_sale_payment_reference_method409—probe
A pickup charges no shippingMoney for a service not renderedOperator sees shipping 0chk_pos_sale_fulfilment_address——probe
The walk-in has no passwordCredentials are the customer's aloneCustomer sets own passwordPosCustomerServiceinvitationQueued only, never a tokenpassword: nullpos-customer path
A draft holds no inventoryReserves only at completion—POS_DRAFT_ABANDON_HOURS semantics—Sweep is housekeeping; cancel and sweep touch no stock; a return restores it—
A counter return is one transactionNo refund without the goods back, no goods back without the refundCashier confirms oncePosCounterReturnService.createInTxPOST /returnsOne serializable-retry transactionpos-counter-return.int.spec.ts
A counter return replays safelyA tired cashier taps twice; a network dropsSame key gives the same resultpos_counter_returns unique (sale, key)Idempotency-Key requiredDurable beyond Redissame
Any refund method on any POS saleThe shop refunds the way that suits the customer, not only the way they paidCashier chooses; the default follows the tenderresolveCounterRefundMethodOptional refundMethodorder_refund_method gained two values; card and QR reversal still need channel = 'pos'pos-counter-return.service.spec.ts
Cash refunds settle without a referenceA cash drawer has no terminalCashier types nothingAuto reference POS <sale> RET <id> (no terminal ref)Optional settlementReference—same
Inspector may equal approver at the counterOne person at a till does every stepFewer stepsComposition in PosCounterReturnService; permission-level rule waivedNeeds PosReturns_CREATEEach step called with the same admin id—
The receipt is a proforma estimate invoiceThe shop does not issue tax invoices from the tillPrinted receipt is headed "PROFORMA ESTIMATE INVOICE" (return: "PROFORMA ESTIMATE INVOICE - RETURN") with "Non-taxable receipt - not a tax invoice"Desktop printed receipt (product decision)None; the backend emails Proforma estimate invoice for sale <number>—nano-store-pos/src/shared/receipt/layout.ts; pos-receipt.email.ts:50

12.4 Tradeoffs and Product Rationale

Product DecisionUser BenefitEngineering BenefitAlternativeTradeoffRisk
POS reuses the online pipelineOne order domain, one return/refund pathNo second ledgerA parallel counter-only recordMaterializer complexityChannel is a label, never a branch
Drafts are separate rows, not cartsA phone cart and a till sale coexistNo collision with uq_cart_customer_id_liveReusing cart_itemCart born converted is unusualDocumented on the schema
No awaiting_paymentOperator never sees a stuck stateOne less state everywhereModelling the wait——
Never-expiring single-use linkA walk-in can always get inNo support backlog24h TTLLong-lived link if email is stolenSingle use; no OTP
Price freeze + loud refusalThe quoted price is the price paidNo silent re-pricingCharge stale priceMid-sale 409sOperator + customer are both present
Hard-deleted draft lines—SimplerSoft deleteDraft history lostorder_item is the record of sale
Counter return composes the order servicesMoney, stock and return state stay consistentNo second return ledgerA POS-only return tableWaived separation of dutiesCashier authority is granted by PosReturns_CREATE
One shared Counter Walk-inA sale needs a customer even when the buyer gives nothingNo junk accountsA customer per saleDelivery addresses are one-timeA tampered row yields 503

12.5 Flow Edge-Case Matrix

FlowEdge CaseTriggerExpected BehaviorUser/System FeedbackSource
OpenCustomer soft-deletedAttach a closed account404 POS_SALE_NO_CUSTOMEROperator looks elsewherepos-sale-draft.service.ts
Walk-inEmail owned by a closed or deleted accountCreate walk-in409 POS_CUSTOMER_CONTACT_UNAVAILABLEUse a different addresspos-customer-identity.service.ts
Walk-inNeither email nor phoneCreate walk-in400 POS_WALK_IN_CONTACT_REQUIREDAsk for onepos-sale-draft.service.ts
Walk-inEmail and phone owned by two customersCreate walk-in409 POS_CUSTOMER_CONTACT_CONFLICTCorrect onesame
FulfilmentaddressPublicId with the Counter Walk-inSend a saved id409 POS_WALK_IN_SAVED_ADDRESS_NOT_ALLOWEDType the addresssame
FulfilmentUnknown districtdistrictId matches nothing404 POS_DISTRICT_NOT_FOUNDRe-picksame
SKUSame SKU on two productsScan409 POS_SKU_AMBIGUOUSChoose by handpos-sale-line.service.ts
ReceiptFourth resend inside 24 hPOST /receipt-email409 POS_RECEIPT_RESEND_LIMITWaitpos-sale-support-admin.service.ts
FulfilmentBoth addressPublicId and addressSend both409 POS_DELIVERY_ADDRESS_REQUIREDPick onepos-sale-draft.service.ts
FulfilmentAddress not this customer'sSend another's addressPublicId404 POS_ADDRESS_NOT_FOUNDRe-fetch their addressessame
LineQuantity 0 or 100PUT with bad number400 POS_QUANTITY_OUT_OF_RANGEClamp in UIpos-sale-line.service.ts
LineProduct unpublished mid-salePUT a delisted product404/409 POS_PRODUCT_NOT_SELLABLERemove the linesame
CompleteEmpty basketComplete with no lines409 POS_SALE_EMPTYBlock until a line existscompletion service
CompleteDelivery with no addressComplete delivery draft409 POS_DELIVERY_ADDRESS_REQUIREDOpen the address formsame
CompleteSale already terminalReplay completion409 POS_SALE_ALREADY_COMPLETEDShow existing order numberunique indexes
SweepOperator resumes a claimed draftRace between sweep and operatorGuarded UPDATE cancels nothing; operator winsDraft stays livepos-draft-sweep.processor.ts

12.6 Flow-to-Data Trace

FlowReadsWritesCacheJobs/EventsResponse Fields
Opencustomerspos_sale, event——PosSaleDto (empty items)
Walk-incustomerscustomers, account (email only), event, outbox (email only)—pos.send_walk_in_invitesale, customerId, invitationQueued, phoneDropped
Counter returnsale, order, order linesorder_return*, order_refund*, stock, pos_counter_returnsinventory (after commit)order notificationsreturnPublicId, refund, lines, sale
Line upsertproductspos_sale_item, totals, event——PosSaleDto
Completesale, lines, products, inventorycart, session, payment_attempt, order, reservation, pos_sale, events, outboxinventory (after commit)pos.send_receiptsale, orderNumber, orderPublicId
Timelinepos_sale_event———events[]

12.7 Experience Quality Checklist

  • The doc explains what the operator is trying to accomplish (a walk-in sale end to end).
  • The doc explains what the backend does the actor does not see (one transaction, unique-key replay protection, outbox emails).
  • Every minor flow and branch is covered (lookup minimum, reset-on-customer-change, skip outcomes, batch caps).
  • Admin and system flows are included; there is no user flow by design.
  • Business logic, tradeoffs and rationale are explained (§12.3, §12.4).
  • Every flow maps to API routes and backend side effects (§4, §9, §12.6).
  • Diagrams fit each flow type (sequence, activity, state, queue topology).
  • Edge cases and failure recovery are covered (§5.1, §10, §12.5).

13. Completion Checklist

  • Every feature, minor action, and submodule capability is listed (§4, §12.1).
  • Every actor has allowed and forbidden behavior (§3).
  • Every major and minor flow includes steps, branches, and diagrams (§5, §6, §12.2).
  • Every lifecycle has a transition table and state diagram (§7).
  • Every flow links to the API and backend docs (§4, §12.6).
  • TDD dependencies are called out where they shape behavior (constraint probe, §12.3).

14. Serial Numbers

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.

See Also

  • API doc: /docs/developer/pos/api
  • Backend doc: /docs/developer/pos/backend
  • Serial numbers: /docs/developer/pos/serials
  • TDD: not yet published