Domain Invariants & Business Rules
Invariants governing negative stock prohibition, immutable ledger requirements, serial lifecycle integrity, and picking strategies.
Domain Invariants & Business Rules (“The Law”)
Domain invariants represent absolute truths that the system enforces. Any transaction violating these invariants is aborted.
1. Negative Stock Prohibition
Physical inventory represents physical mass. Physical mass cannot be negative. Therefore:
$$\forall \text{ SKU } x \text{ and Location } l, \quad \text{Quantity}(x, l) \ge 0$$
- The Law: Under no circumstance can the physical count of stock in any addressable Bin fall below zero.
- Exception Rule: Any attempt to deduct quantity that results in a value $< 0$ triggers a
CriticalInventoryAnomalyExceptionand rolls back the transaction. This prevents virtual sales exceeding physical existence.
Valuation & Reconciliation Mismatch Proof
If the system allowed a negative inventory balance (e.g. $-10$ units), it would create structural errors in cost valuation and physical auditing:
- Asset Valuation Distortion: If the standard cost of SKU $x$ is $$15.00$ and quantity is $-10$, the inventory asset ledger records a value of $-$150.00$. A negative asset is a liability, which violates financial accounting principles.
- Broken Average Cost Calculation (MAC): If a new shipment of 20 units arrives at $$20.00$ each when stock is at $-10$, the Moving Average Cost calculation would divide by the net balance ($20 - 10 = 10$), artificially inflating the unit cost.
- Audit Impossibility: A physical audit cannot verify the existence of negative items. Audits rely on counting physical mass from 0 upward. Allowing negative states breaks physical-to-virtual verification cycles.
2. Immutable Movement Ledger
Inventory balances are never modified using in-place updates.
- The Law: A stock balance at any coordinate is the mathematical sum of historical, immutable double-entry movement ledger entries.
- Transaction Rule: To shift 5 units of SKU $x$ from Bin $A$ to Bin $B$, the system writes a single transaction recording:
- Debit: Location $A$, Quantity $-5$
- Credit: Location $B$, Quantity $+5$
- Once written, these ledger rows are read-only. Corrections require compensating entries, not row edits or deletions.
3. Unique Serial Lifecycle Invariant
A serialized item represents a distinct physical item.
- The Law: A unique Serial Number ($S/N$) for a specific SKU can occupy exactly one bin location and hold exactly one state in the system at any given timestamp:
$$\text{Location}(S/N, t) = 1 \quad \text{and} \quad \text{State}(S/N, t) = 1$$
- Duplicate serial entries inside active inventory are blocked.
4. Picking & Dispatch Policies
When compiling a picking list, the system enforces the following strategies to determine which batches or lots are picked first:
- First-In, First-Out (FIFO): The system prioritizes picking items from the batch with the oldest receiving timestamp. This prevents stock obsolescence.
- First-Expired, First-Out (FEFO): For expiration-sensitive inventory (perishables, pharmaceuticals), the system prioritizes picking lots closest to their expiry date, overriding FIFO.