POS

POS - Domain Invariants & Business Rules

The immutable business laws governing POS sessions, drawer balancing, tender validation, and offline transaction integrity.

Domain Invariants & Business Rules (“The Law”)

The POS domain enforces a strict set of business invariants. These rules are non-negotiable constraints that protect cash accountability, transaction integrity, checkout correctness, and auditability across every retail location.


1. Active Session Prerequisite

Zero commercial transactions or receipt issuances can occur on a terminal without an explicitly opened session and a recorded opening float.

Session Prerequisite Rules

RuleInvariant
Session RequiredEvery sale, refund, cash drop, and petty expense must belong to an active shift session.
Opening Float DeclarationA session cannot be opened until the cashier declares and confirms the opening float amount.
Terminal LockA terminal without an active session operates in a locked or training mode only; no financial transactions are recorded.
Single Active SessionOnly one session may be active on a terminal/drawer at a time.
Cashier AuthenticationThe cashier must be authenticated against Identity policies before opening a session.

Business Consequence

If a terminal attempts to process a transaction without an active session:

  • The transaction is blocked.
  • An audit event is recorded.
  • The cashier is instructed to open a session or escalate to a supervisor.

2. Immutability of Closed Shifts

Once a POS session is closed and the cash drawer is reconciled, the session ledger, recorded sales, cash movements, and closing counts are permanently sealed against retroactive edits.

Closed Shift Rules

RuleInvariant
No Post-Close EditingTransaction lines, tender amounts, cash drops, petty expenses, and closing counts cannot be edited after session close.
Sealed DiscrepancyThe overage or shortage amount recorded at close is final; corrections occur downstream via compensating journal vouchers.
No DeletionSession records and receipts are never deleted; corrections require compensating documents.
Audit ChainEvery closed session links opening count, all movements, closing count, and discrepancy into an immutable chain.

Correction Path

Errors discovered after session closure are corrected through:

  • Compensating Variance Journal in FMS for drawer discrepancies.
  • Refund Receipt in a subsequent session for customer returns.
  • Manager Adjustment Note for operational explanations, linked but non-mutating.

The original session remains sealed.


3. Non-Negative Tender Validation

Tendered amounts and calculated change cannot be negative. Total tenders received must equal or exceed the receipt value before transaction completion.

Tender Validation Rules

RuleInvariant
Non-Negative TenderEvery tender amount must be zero or positive.
Non-Negative ChangeChange due cannot be negative.
Total Tender CoverageSum of tender amounts must be greater than or equal to the receipt total.
Exact Change for Non-CashCard, wallet, and gift card tenders typically must match the charged amount exactly.
Cash OverpaymentCash tender may exceed the total to enable change; change is calculated as tendered minus total.
No Refund Without ReturnNegative tender (refund) is only permitted within a return/refund transaction context.

Change Calculation Formula

$$ \text{Change Due} = \sum \text{Tender Amounts} - \text{Receipt Total} $$

Change due must satisfy:

$$ \text{Change Due} \geq 0 $$

If the result is negative, the transaction cannot complete until additional tender is provided.


4. Strict Offline Monotonicity

Offline transactions generated during network disconnection must possess strictly ascending sequential counters per terminal to eliminate replay attacks and gap duplicates.

Monotonicity Rules

RuleInvariant
Strictly AscendingEach new transaction on a terminal uses the previous sequence number plus one.
No ReassignmentSequence numbers are assigned at transaction creation time and never reused or reordered.
Gap DetectionCentral systems reject or flag any sequence that skips ahead of the expected next value.
Duplicate RejectionA transaction with a sequence already accepted is rejected as a replay.
Offline ContinuitySequence counters persist across reboots and application restarts on the terminal.

Replay Protection

ScenarioHandling
Same sequence, same payloadIdempotently accepted; no double processing.
Same sequence, different payloadRejected as conflict; requires manual investigation.
Sequence gapCentral system flags missing transactions; terminal must backfill before advancing.
Future sequenceRejected until all intermediate sequences are received.

5. Cash Drawer Accountability

Every cash movement affecting the drawer must be recorded with a timestamp, operator, reason, and amount.

Cash Movement Rules

RuleInvariant
All Movements RecordedSales, refunds, drops, petty expenses, and float adjustments are all logged.
Reason RequiredCash drops and petty expenses require a reason code or supervisor authorization.
Operator AttributionEvery cash movement is attributed to the active session operator.
No Drawer Removal Without LogPhysical removal of cash from the drawer must correspond to a recorded drop or expense.
Supervisor OverrideDrawer overrides (e.g., forced open) require supervisor credentials and are audited.

6. Receipt Snapshot Immutability

Line item snapshots on a completed receipt are frozen at transaction time and cannot be altered.

Snapshot Rules

RuleInvariant
Frozen PricesUnit prices, taxes, and discounts are frozen on the receipt at completion.
Frozen DescriptionsProduct descriptions and barcodes are frozen to preserve historical accuracy.
No Post-Sale EditA completed receipt cannot be edited to change amounts or items.
Correction via ReturnErrors after completion are corrected through a separate return/refund receipt.

This ensures that historical receipts remain accurate even if central product prices or descriptions change later.


7. Tax Calculation Integrity

Taxes must be calculated according to the tax rules active at the time and place of sale.

Tax Rules

RuleInvariant
Store Tax JurisdictionTax rates are determined by the store’s registered tax jurisdiction.
Product Tax CategoryEach line item uses the tax category assigned to the product at sale time.
Rounding PolicyTax rounding follows the store’s configured policy (per line, per item, or per receipt).
Tax Total ReconciliationSum of tax lines must equal the total tax collected on the receipt.
Tax ExemptionTax-exempt transactions require valid exemption evidence and are audited.

8. Summary of “The Law”

InvariantViolation Consequence
No transactions without an active session and opening float.Transaction blocked; audit event recorded.
Closed shifts are sealed and immutable.Retroactive edits rejected; corrections via compensating documents.
Tender and change amounts cannot be negative.Transaction rejected until valid tender is provided.
Offline sequences must be strictly monotonic.Gaps/duplicates rejected or flagged for investigation.
Every cash movement is logged with reason and operator.Missing movement triggers drawer discrepancy and audit exception.
Completed receipt snapshots are immutable.Post-sale edits rejected; corrections via return/refund.
Tax calculation follows jurisdiction and product category rules.Incorrect tax triggers compliance exception and reconciliation adjustment.

These invariants collectively ensure that the POS domain remains the authoritative source of truth for frontline retail transactions while preserving cash accountability, auditability, and operational resilience.

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