POS

POS - Domain Events & Integration Contracts

Domain events, integration contracts, and asynchronous reactions between POS and the broader Obelaw ecosystem.

Domain Events & Integration Contracts

POS communicates with the rest of the Obelaw ecosystem exclusively through domain events and integration contracts. This event-driven architecture preserves domain boundaries, enables asynchronous downstream processing, and allows central systems to react to frontline retail facts without blocking checkout speed.


1. Domain Events Emitted

The following table lists the primary domain events emitted by the POS bounded context.

Event NameEmitted WhenPayload Highlights
PosSessionOpenedCashier opens a shift session with declared opening float.Session ID, terminal ID, store, cashier, opening float, timestamp.
PosSaleCompletedA customer sale is finalized and receipt issued.Receipt number, terminal sequence, store, line items, taxes, tenders, total, customer alias.
PosSaleRefundedA return/refund transaction is completed.Original receipt reference, return receipt number, returned items, refund tenders, reason.
PosCashDropRecordedCash is removed from drawer to safe during shift.Session ID, amount, timestamp, reason, supervisor, drop slip reference.
PosPettyExpenseRecordedCash is disbursed for operational expense.Session ID, amount, timestamp, reason, approver.
PosReceiptCancelledAn entire transaction is abandoned before payment.Receipt draft ID, terminal, timestamp, reason.
PosLineItemVoidedA line item is removed before transaction completion.Receipt ID, line item, reason, operator.
PosPaymentAuthorizedCard or digital wallet payment is authorized.Receipt ID, tender type, authorization code, amount, terminal.
PosSessionClosedShift session is closed with reconciliation totals.Session ID, sales totals, refund totals, tender totals, tax totals, discrepancy, closing float.
PosDrawerDiscrepancyRecordedClosing count differs from expected cash.Session ID, expected cash, actual cash, overage/shortage amount, reason.
PosOfflineReplayCompletedQueued offline transactions are successfully synchronized.Terminal ID, sequence range, transaction count, conflict summary.
PosCustomerLinkedA customer profile is attached to a transaction.Receipt ID, customer alias, loyalty account.

2. Integration Contracts & Asynchronous Reactions

Downstream contexts subscribe to POS events and translate them into their own internal workflows. The POS context does not know how these reactions are implemented; it only publishes facts.

Inventory / WMS Reactions

Subscribed EventWMS ActionResulting WMS Document
PosSaleCompletedDeduct sold quantities from the store’s floor stock bucket.Stock Deduction / Goods Issue Note.
PosSaleRefundedAdd returned quantities back to the store’s floor stock or designated returns location.Stock Addition / Goods Received Note.
PosOfflineReplayCompletedReconcile any optimistic local stock decrements with central stock levels.Inventory Reconciliation Adjustment.

Responsibility Boundary

  • POS reports what was sold or returned, with product codes and quantities.
  • WMS decides from which floor stock bucket, lot, or location to deduct or receive stock.
  • POS never instructs WMS on bin-level decisions; WMS never slows down checkout.

Accounting / FMS Reactions

Subscribed EventFMS ActionResulting FMS Impact
PosSessionClosedPost aggregated sales revenue by tender type and tax category.Revenue Journal Vouchers.
PosSessionClosedPost cash-on-hand movement reflecting net cash collected.Cash / Bank Deposit Journal.
PosSessionClosedPost tax liabilities collected during the session.Tax Payable Journal Entries.
PosDrawerDiscrepancyRecordedPost overage or shortage as a variance expense or income.Cash Variance Journal Voucher.
PosSaleCompletedUpdate revenue recognition sub-ledger if accounting method requires per-receipt posting.Revenue Sub-ledger Entry.
PosSaleRefundedPost refund contra-revenue and tax liability reversal.Refund Journal Vouchers.

Responsibility Boundary

  • POS emits session-level and receipt-level sales facts.
  • FMS applies chart of accounts, tax codes, revenue recognition policies, and variance rules.
  • POS does not post journal entries; FMS does not issue receipts.

Sales / OMS Reactions

Subscribed EventOMS ActionResulting OMS Document
PosSaleCompletedRecord sale in enterprise order history for reporting and customer service.Order History Record.
PosSaleRefundedLink refund to original sale and update order status.Return Record.
PosCustomerLinkedAttach transaction to customer order history.Customer Order History Update.

Responsibility Boundary

  • POS executes the frontline transaction.
  • OMS maintains enterprise order history, fulfillment exceptions, and customer service context.

CRM / Loyalty Reactions

Subscribed EventCRM / Loyalty ActionResulting Output
PosSaleCompletedAccrue loyalty points based on sale value and customer tier.Loyalty Points Accrual.
PosSaleRefundedReverse or adjust loyalty points previously accrued.Loyalty Points Reversal.
PosCustomerLinkedLink transaction to customer profile and touchpoint history.Customer Activity Record.
PosSaleCompletedTrigger post-purchase engagement (feedback, warranty, cross-sell).Campaign Trigger.

Responsibility Boundary

  • POS identifies the customer where possible and emits sale facts.
  • CRM / Loyalty manages points, profiles, and engagement asynchronously without blocking checkout.

PIM / Catalog Reactions

Subscribed EventPIM ActionResulting Output
PosSaleCompleted (aggregated)Update product velocity and sales analytics.Sales Velocity Report.
PosOfflineReplayCompletedRefresh product cache availability indicators on terminals.Cache Update.

Responsibility Boundary

  • PIM owns product master data and analytics.
  • POS consumes product snapshots and contributes sales velocity facts.

Payments / Card Acquirer Reactions

Subscribed EventAcquirer ActionResulting Output
PosPaymentAuthorizedCapture authorized funds for settlement.Settlement Batch.
PosSaleRefundedProcess refund to original card or wallet.Refund Settlement.

Responsibility Boundary

  • POS initiates authorization and captures payment events.
  • Acquirer owns fund settlement, chargebacks, and reconciliation.

3. Event Flow Architecture

POS events flow from edge terminals through an ACL to central event consumers:

┌─────────────────────┐      ┌─────────────────────────────┐      ┌─────────────────────┐
│  POS Terminal       │      │  Anti-Corruption Layer      │      │  Central Domain     │
│  (Edge Publisher)   │ ───► │  (Validate / Translate /    │ ───► │  (Event Subscriber) │
│                     │      │   Sequence / Replay)        │      │                     │
└─────────────────────┘      └─────────────────────────────┘      └─────────────────────┘

ACL Responsibilities

ResponsibilityDescription
Sequence ValidationEnsures terminal sequences are monotonic and gap-free.
Duplicate DetectionRejects or idempotently accepts duplicate transaction events.
Payload TranslationConverts terminal-specific receipt formats into canonical event payloads.
Store MappingMaps terminal IDs to store, tax jurisdiction, and business calendar.
Downstream RoutingRoutes events to WMS, FMS, OMS, CRM, and PIM subscribers.

4. Offline Replay Contracts

When a terminal reconnects, queued transactions are replayed under strict contracts:

Contract RuleDescription
Sequential ReplayTransactions are replayed in monotonic sequence order.
IdempotencyCentral systems accept duplicate events with the same sequence and payload without double processing.
Conflict DetectionConflicting events (e.g., gift card spent elsewhere) are flagged for manual resolution.
Partial ReplayIf replay fails mid-batch, the terminal retries from the first unaccepted sequence.
AcknowledgmentCentral systems acknowledge the highest contiguous accepted sequence.

Conflict Resolution Examples

Conflict ScenarioResolution
Gift card balance exhausted during offline periodRefund or alternative tender requested from customer; shortfall logged as variance.
Product price changed while offlineOriginal snapshot price honored; variance between old and new price logged for review.
Product discontinued while offlineSale honored if local cache was valid; inventory disposition handled by WMS.
Duplicate sequence with different payloadManual investigation; terminal state reconciliation required.

5. Event Sourcing & Replay Considerations

Because POS state is reconstructed from immutable event history, downstream contexts can replay events for recovery, audit, or reprocessing:

Replay ScenarioRule
WMS replayRe-apply stock deductions using receipt sequence as idempotency key.
FMS replayRe-post session aggregates using session ID and sequence range as idempotency keys.
CRM replayRe-accrue loyalty points only if not already processed for the receipt.

All events carry a unique event identifier, terminal sequence, store reference, session reference, timestamp, and correlation identifier to support idempotent processing and end-to-end traceability.


6. Anti-Corruption Layer Translation Examples

POS EventACL Translation for WMSACL Translation for FMS
PosSaleCompletedConvert product codes to WMS SKU strings; map store to floor stock location.Aggregate session sales into revenue, tax, and cash journal lines by tender type.
PosSaleRefundedMap returned items to store returns location; restore stock.Post contra-revenue and tax reversal entries.
PosSessionClosedConfirm no pending stock adjustments from offline replay.Post final cash deposit, revenue, tax, and variance journal vouchers.

This event-driven, ACL-protected integration model ensures that POS remains an autonomous, high-performance edge domain while participating fully in the broader ERP ecosystem.

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