POS

POS - Operational Workflows & State Machines

Cashier shift lifecycle, high-speed checkout flow, and state transition tables for POS sessions and receipts.

Operational Workflows & State Machines

The POS domain executes retail operations through clearly defined workflows and state transitions. Cashier shifts and individual receipts each follow controlled lifecycles that enforce business invariants and preserve cash accountability.


1. Cashier Shift Lifecycle

The following diagram illustrates the complete operational cycle of a cashier shift, from clock-in through reconciliation and close.

flowchart TD
    A[Cashier Clock-in] --> B[Select Terminal]
    B --> C[Count Opening Float]
    C --> D{Float Matches Expected?}
    D -->|Yes| E[Open Session]
    D -->|No| F[Record Variance with Supervisor]
    F --> E
    E --> G[High-Velocity Sales / Returns]
    G --> H[Mid-Shift Cash Drop]
    H --> I[More Transactions]
    I --> J[Count Closing Cash]
    J --> K{Reconcile Expected vs. Actual}
    K -->|Balanced| L[Close Session]
    K -->|Overage / Shortage| M[Record Discrepancy]
    M --> L
    L --> N[End-of-Day Settlement]

Shift Stage Descriptions

StageDescriptionKey Domain Event
Clock-inCashier authenticates at the terminal or store system.CashierAuthenticated
Opening Float CountCashier counts and declares cash in drawer at shift start.OpeningFloatDeclared
Session OpenedTerminal session activated; drawer unlocked for transactions.PosSessionOpened
Transaction ActivitySales, refunds, voids, drops, and petty expenses occur.PosSaleCompleted, PosSaleRefunded, PosCashDropRecorded
Cash DropExcess cash removed to safe during shift.PosCashDropRecorded
Closing CountCashier counts cash at shift end.ClosingCashDeclared
ReconciliationExpected vs. actual cash compared; discrepancy recorded.PosSessionClosed
SettlementAggregated totals sent to FMS for deposit and ledger posting.PosSessionClosed

Opening Float Exception

If the physical opening float does not match the expected float from the prior session:

ScenarioAction
Shortage from prior closeRecord variance with supervisor approval; prior session discrepancy adjusted via compensating journal.
Overage from prior closeRecord variance; excess may be deposited or counted as current session float.
Unexplained differenceSession may still open with documented variance; investigation initiated.

2. High-Speed Checkout Flow

The following diagram illustrates the typical checkout transaction from scan to receipt.

flowchart TD
    A[Item Barcode Scan] --> B[Retrieve Product Snapshot]
    B --> C[Add Line Item]
    C --> D{Discount / Modifier?}
    D -->|Yes| E[Apply Discount / Modifier]
    D -->|No| F[Subtotal Calculation]
    E --> F
    F --> G[Tax Calculation]
    G --> H[Display Total]
    H --> I[Select Tender Type]
    I --> J{Split Tender?}
    J -->|Yes| K[Capture Multiple Tenders]
    J -->|No| L[Capture Single Tender]
    K --> M[Validate Total Coverage]
    L --> M
    M --> N[Calculate Change]
    N --> O{Payment Authorized?}
    O -->|Yes| P[Print Receipt / Open Drawer]
    O -->|No| Q[Prompt for Alternative Tender]
    Q --> I
    P --> R[Emit Completion Event]

Checkout Stage Descriptions

StageDescriptionBusiness Rule
Barcode ScanProduct identified by barcode or manual lookup.Product must exist in local cache; price snapshot loaded.
Line Item AddedQuantity and unit price added to receipt.Quantity must be positive.
Discount / ModifierPrice adjustment or option applied to line.Discount authorization may be required.
Tax CalculationTaxes computed by product category and jurisdiction.Tax rules active at sale time applied.
Tender SelectionCustomer chooses payment method(s).Tender type must be allowed at terminal.
Total CoverageSystem validates that tenders cover total.Transaction cannot complete if underpaid.
Change CalculationCash change computed if applicable.Change must be non-negative.
Payment AuthorizationCard/wallet payments authorized by acquirer.Offline mode may queue authorization.
Receipt IssuanceReceipt printed or emailed.Receipt snapshot frozen.

Void and Cancel Handling

ActionTimingEffect
Void Line ItemBefore paymentRemoves line from receipt; no inventory or financial impact yet.
Cancel ReceiptBefore paymentAbandons entire transaction; no receipt issued.
Refund / ReturnAfter paymentCreates separate return receipt; reverses sale and restores inventory.

3. POS Session State Transition Table

Current StateTrigger / EventNext StateBusiness Validation Rule
LockedCashier authenticates and selects terminal.Pre-SessionIdentity verified; terminal available.
Pre-SessionOpening float counted and declared.Float DeclaredFloat amount is non-negative and recorded.
Float DeclaredSupervisor approves variance (if any).OpenDrawer assigned; session activated.
OpenFirst transaction initiated.ActiveSession is ready for sales.
ActiveTransaction completed.ActiveTransaction added to session ledger.
ActiveCash drop performed.ActiveDrop reason and amount recorded.
ActivePetty expense recorded.ActiveExpense reason and amount recorded.
ActiveClosing count initiated.ClosingNo new transactions allowed.
ClosingClosing cash count entered.ReconcilingExpected vs. actual cash compared.
ReconcilingDiscrepancy accepted or zero.ClosedSession sealed; totals finalized.
ActiveSupervisor initiates forced close.Forced ClosedForced close reason recorded; discrepancy accepted.
Any active stateTerminal or application crash.Recovery PendingSession restored from local state; transactions replayed.
Recovery PendingLocal state validated.Previous active stateSession continues or closes under supervision.

4. POS Receipt State Transition Table

Current StateTrigger / EventNext StateBusiness Validation Rule
DraftItems scanned or added.In ProgressLine items present; total calculated.
In ProgressLine item voided.In ProgressVoid recorded; total recalculated.
In ProgressEntire receipt cancelled.CancelledNo payment processed; cancellation audited.
In ProgressTender selected and validated.Awaiting PaymentTotal coverage confirmed.
Awaiting PaymentPayment authorized or cash accepted.PaidNon-negative change calculated.
Awaiting PaymentPayment declined.In ProgressAlternative tender required.
PaidReceipt printed or emailed.CompletedReceipt snapshot frozen; completion event emitted.
CompletedCustomer requests return.Return InitiatedOriginal receipt referenced; return eligibility verified.
Return InitiatedItems accepted and refund tendered.RefundedSeparate return receipt created; inventory restored.
CompletedManager voids receipt after close.Voided by ReturnReturn receipt created; original remains visible.

5. Offline Transaction Workflow

When a terminal loses connectivity, it continues operating using local state and queues transactions for replay.

flowchart TD
    A[Network Disconnection Detected] --> B[Switch to Offline Mode]
    B --> C[Use Local Product / Price Cache]
    C --> D[Assign Monotonic Sequence]
    D --> E[Store Transaction Locally]
    E --> F[Issue Local Receipt]
    F --> G{Network Restored?}
    G -->|No| H[Continue Offline Operation]
    H --> D
    G -->|Yes| I[Replay Queued Transactions]
    I --> J{Sequence Valid?}
    J -->|Yes| K[Central Acceptance]
    J -->|Gap / Duplicate| L[Conflict Resolution]
    L --> M[Manual Review or Auto-Reconciliation]
    M --> K
    K --> N[Sync Completed]

Offline Operational Rules

RuleInvariant
Cache FreshnessLocal cache is refreshed when online; stale cache must be flagged after a configured age.
Sequence ContinuityOffline transactions continue the same monotonic sequence as online transactions.
Local Receipt IssuanceCustomers receive a local receipt; central receipt number may be assigned on sync.
Stock IndicatorLocal stock indicators may be decremented optimistically; central WMS reconciles on sync.
High-Risk TendersSome tender types (e.g., gift cards, store credit) may be blocked offline if balance cannot be verified.

6. Cash Drop Workflow

Cash drops reduce drawer exposure by moving excess cash to a safe during the shift.

flowchart TD
    A[Drawer Cash Exceeds Threshold] --> B[Cashier Initiates Drop]
    B --> C[Supervisor Authorization]
    C --> D[Count Drop Amount]
    D --> E[Place Cash in Safe]
    E --> F[Record Drop Slip]
    F --> G[Update Drawer Expected Balance]
    G --> H[Emit PosCashDropRecorded]

Cash Drop Rules

RuleInvariant
Threshold PolicyDrops may be triggered automatically when drawer cash exceeds a configured threshold.
Dual ControlDrops typically require cashier and supervisor verification.
Immediate LogDrop amount and timestamp are recorded immediately, before cash leaves the drawer.
Safe ReceiptPhysical safe receipt or slip number is captured for audit.

7. End-of-Day Settlement Workflow

After all sessions in a store are closed, totals are aggregated for financial settlement.

Settlement ElementSource
Gross SalesSum of all completed sale receipts across sessions.
RefundsSum of all return/refund receipts.
Net SalesGross Sales minus Refunds.
Cash CollectedCash tenders minus cash refunds and change.
Card CollectedCard/digital wallet tenders minus refunds.
Other TendersGift cards, store credit, checks, etc.
Tax CollectedSum of tax lines by category.
Cash DiscrepanciesSum of overages and shortages across sessions.
Depositable CashCash collected minus drops and petty expenses, adjusted for discrepancies.

Settlement Reconciliation

$$ \text{Depositable Cash} = \text{Opening Floats} + \text{Cash Sales} - \text{Cash Refunds} - \text{Cash Drops} - \text{Petty Expenses} \pm \text{Net Discrepancy} $$

The settlement payload is emitted to FMS via the PosSessionClosed event for ledger posting and bank deposit reconciliation.


8. Exception Handling

ExceptionHandling Rule
Cashier unable to reconcile drawerSupervisor reviews discrepancy; session may be forced closed with documented reason.
Terminal crash during active sessionSession state recovered from local cache; transactions replayed; session continues or closes under supervision.
Product not found in local cacheCashier may use fallback lookup or escalate; transaction may be queued offline if central lookup fails.
Payment terminal offlineCash tender encouraged; card transactions may be queued for offline authorization where acquirer supports it.
Customer disputes changeAudit trail of tender and change calculation reviewed; receipt is authoritative.
Duplicate receipt printedReprint audited; no financial duplicate created.

These workflows and state machines ensure that every retail transaction is executed, recorded, and reconciled through a consistent, auditable, and invariant-preserving process.

Our Premium Sponsors

Obelaw is proudly open-source. Continued development, bug fixes, and community support are made possible by the generosity of our sponsors.

Sponsor Obelaw