Domain Events & Integration Contracts

Mappings of emitted events and asynchronous downstream domain interactions.

Domain Events & Integration Contracts

The Inventory & WMS domain communicates changes in state asynchronously by publishing Domain Events. Downstream systems consume these events without direct database dependencies.


1. Emitted Domain Events Table

Event NameTriggering ConditionPayload ParametersDownstream Impact
ItemStockReceivedGRN ApprovedSKU, Quantity, Batch, Warehouse, ValueTreasury / FMS: Updates Inventory Asset value.
Procurement: Reconciles Purchase Order.
ItemStockExhaustedATP reaches 0SKU, WarehouseProcurement: Triggers auto-reorder workflow.
Sales: Hides product from storefront.
StockTransferredGIN ClosedSKU, Qty, Source, TargetLogistics: Validates route optimization stats.
SerialAllocatedReservation MadeSKU, Serial Number, Sales Order IDSales: Confirms item matches picking order.
StockQuarantinedQuarantine Note PostedSKU, Qty, Lot, ReasonQA Context: Triggers inspection review workflows.

2. Downstream Domain Interactions

Financial Management (FMS) / Treasury Integration

  • Mechanism: The WMS context does not execute general ledger double-entry bookkeeping. Instead, it emits ItemStockReceived and StockQuarantined (with valuation metrics in the payload).
  • FMS Reaction: The FMS system consumes these events asynchronously to adjust asset accounting sheets (e.g. debiting inventory assets and crediting liabilities upon receiving).

Procurement Integration (Auto-Reordering)

  • Mechanism: The WMS context calculates stock levels against thresholds and emits ItemStockExhausted or StockLevelFellBelowMinimum.

  • The Reorder Invariant: The event StockLevelFellBelowMinimum is dispatched when:

    $$\text{ATP} + \text{Inbound Pending POs} < \text{Minimum Reorder Threshold}$$

  • Procurement Reaction: The Procurement system automatically triggers reorder pipelines, generating purchase order drafts without WMS intervention.


3. Integration Contract Guarantees

  • At-Least-Once Delivery: The message queue guarantees that every inventory change event is delivered to the broker at least once. Downstream consumers must implement idempotent processing to prevent duplicate ledger updates.
  • Payload Immutability: Domain event payloads are structured, read-only structures representing a historical fact that cannot be rewritten.

4. Event Payload Structures (Interface Contracts)

Downstream consumers rely on strict, versioned schemas representing the domain events.

Payload: ItemStockReceived

  • EventID: Unique UUID tracking the event transmission.
  • Timestamp: ISO 8601 timestamp of GRN approval.
  • SKU: Product identifier code.
  • BatchNumber: The lot identifier matching quality records.
  • Quantity: Integer representing total count received.
  • UnitValue: Monetary acquisition value per item (used by FMS for MAC calculations).
  • WarehouseID: Destination storage facility identification code.

Payload: ItemStockExhausted

  • EventID: Unique UUID tracking the event transmission.
  • Timestamp: ISO 8601 timestamp of stock depletion.
  • SKU: Product identifier code.
  • WarehouseID: Facility where stock has been exhausted.
  • SafetyStockRemaining: Boolean indicating if safety stock buffers are still intact.