Skip to content

URD: Inventory

ModuleCORE-06Versionv0.4
StatusIn-progressDate2026-05-30

1. Purpose

Define user-facing requirements for Inventory management — stock tracking, warehouse locations, purchase orders, vendors, materials (BOM), inventory tickets, and a complete, immutable audit trail of every stock movement. The outcome is that a merchant always knows what they have, where it is, and how it got there.

2. Scope

IncludedExcluded
Inventory locations (warehouses) with hierarchySale quotation / quota-based reservation
Inventory items (variant/material linked to location)Multi-level BOM / sub-assemblies
Stock quantities (on-hand, reserved, available)Recipe yield and scrap percentage
Immutable tracking audit logMulti-currency stock valuation
Tracking type catalog (19 pre-seeded)Full barcode scanning integration
Vendor (supplier) managementNegative-stock enforcement at POS
Purchase orders with goods receiptTechnical API specifications
Inventory tickets (transfer, adjustment, count, return, scrap)
Material catalog with identifiers
Material recipes (BOM) with versioning
BOM runtime explosion on kitchen ticket
Production orders, inventory rules, unit of measure

3. Definitions

TermDefinition
Inventory LocationA warehouse or storage area within a merchant. Supports hierarchy. One default per merchant.
Inventory ItemA record linking a product variant or material to a merchant for stock tracking.
Inventory StockThe quantity record — on-hand, reserved, available. One per (item, location, lot, serial).
Inventory TrackingAn immutable audit entry for every stock movement with before/after quantities.
Inventory Tracking TypeCategorizes movement direction (IN/OUT/NEUTRAL) and reason. 19 pre-seeded + 1 custom.
Inventory TicketA document for stock operations: transfer, adjustment, cycle count, returns, scrap. Has line items.
VendorA supplier from whom the merchant purchases goods.
Purchase OrderA goods-receipt document from a vendor, containing line items with quantities and pricing.
MaterialA raw ingredient or semi-finished good tracked separately from sellable products.
Material Recipe (BOM)A versioned recipe declaring which materials are consumed to produce a product variant.
BOM ExplosionAutomatic material decrement triggered by kitchen ticket item status changes.
Production OrderA manufacturing document tracking planned/actual/scrap quantities for produced goods.
Inventory RuleA configurable threshold rule that can trigger alerts, PO creation, or webhooks.
Unit of MeasureMeasurement unit with 3-level scope: system defaults → merchant → product/material.

4. Conceptual Model

Conceptual only — the full schema lives in the developer domain model.

5. Functional Requirements

One table per functional area. <AREA> codes match the test-case IDs. Priority = MoSCoW (Must / Should / Could / Won't).

5.1 Inventory Location (LOC)

IDPRequirement
URD-LOC-001MOwner can create an inventory location with an i18n name.
URD-LOC-002MA default location is auto-created for each merchant on commerce init.
URD-LOC-003MExactly one default location exists per merchant; setting a new default clears the previous.
URD-LOC-004SLocations support parent-child hierarchy.
URD-LOC-005SA location can store address and geographic (GPS) data.
URD-LOC-006MLocation lifecycle: NEW → ACTIVATED → DEACTIVATED → ARCHIVED (ARCHIVED terminal).
URD-LOC-007MEach location has a system-generated identifier (LOC_YYYYMMDD_id), not user-editable.
URD-LOC-008MLocations use soft-delete; data is preserved and admin-retrievable.
URD-LOC-009SOwner can list and filter locations by status.
URD-LOC-010MLocations are isolated per merchant.

5.2 Inventory Item (ITM)

IDPRequirement
URD-ITM-001MAn inventory item is auto-created when a product variant is created.
URD-ITM-002MOne item per (variant, location, unit) combination.
URD-ITM-003SItem supports min/max stock-level thresholds; min ≤ max.
URD-ITM-004MEach item has a system-generated identifier (SKU_YYYYMMDD_id), not user-editable.
URD-ITM-005MItem lifecycle: ACTIVATED → DEACTIVATED → ARCHIVED (ARCHIVED terminal).
URD-ITM-006MItem is linked to the merchant's default location on creation.

5.3 Inventory Stock (STK)

IDPRequirement
URD-STK-001MOne stock record per (item, location, lot, serial).
URD-STK-002MAvailable = on-hand − reserved.
URD-STK-003MAll quantities stored with decimal precision (4 places).
URD-STK-004MOwner can view current stock levels; first movement auto-creates the stock record.
URD-STK-005SLast-stocked / last-counted timestamps update automatically.
URD-STK-006MStock updates are atomic — partial failure rolls back fully.
URD-STK-007CHistorical stock-level changes are viewable.

5.4 Inventory Tracking (TRK)

IDPRequirement
URD-TRK-001MEvery stock movement creates an immutable tracking entry.
URD-TRK-002MRecords before, change, and after quantities.
URD-TRK-003MEntries from business documents store reference type and ID.
URD-TRK-004MIdempotent: same (referenceType, referenceId) produces one entry only.
URD-TRK-005MEach entry typed by tracking type (IN/OUT/NEUTRAL); 19 pre-seeded + custom.
URD-TRK-006SEntries record the acting user (createdBy / modifiedBy).
URD-TRK-007MOwner can view full tracking history.
URD-TRK-008SEntries can record effective price and multiplier.
URD-TRK-009SManual entries can include a note/reason.
URD-TRK-010CFilter history by date, type, or reference document.

5.5 Inventory Ticket (TKT)

IDPRequirement
URD-TKT-001MTickets support 6 operation types: Transfer, Adjustment, Cycle Count, Return to Vendor, Return from Customer, Scrap/Disposal.
URD-TKT-002MLifecycle: DRAFT → SUBMITTED → APPROVED → IN_PROGRESS → COMPLETED / CANCELLED.
URD-TKT-003MEach ticket has line items with planned vs. actual quantities.
URD-TKT-004MCompleting a ticket creates tracking entries and updates stock.
URD-TKT-005SLine items support lot/serial numbers.
URD-TKT-006SLine items support per-item location override.

5.6 Vendor (VEN)

IDPRequirement
URD-VEN-001MOwner can create vendors within a merchant.
URD-VEN-002MVendor has name, contact info (emails, phones), address, and a system identifier (VEN_YYYYMMDD_id).
URD-VEN-003SVendor can store a tax registration number.
URD-VEN-004MVendor uses soft-delete; historical PO references are preserved.
URD-VEN-005MVendors are isolated per merchant.

5.7 Purchase Order (PO)

IDPRequirement
URD-PO-001MOwner can create a PO selecting vendor + items in one operation; vendor required.
URD-PO-002MLifecycle: DRAFT → PROCESSING → RECEIVED → COMPLETED → CLOSED (with valid transitions only).
URD-PO-003MOwner can cancel a PO from any non-terminal status; received stock is not auto-reversed.
URD-PO-004MOwner can revert PROCESSING → DRAFT.
URD-PO-005MPO items are editable only in DRAFT status.
URD-PO-006MA PO must have ≥1 item before it can be confirmed.
URD-PO-007MGoods receipt increments stock and creates tracking entries.
URD-PO-008MReceipt supports OVERRIDE and ACCUMULATIVE modes.
URD-PO-009MPO defaults to the merchant's default location unless one is specified.
URD-PO-010MPO total = subtotal − discount + tax.
URD-PO-011SManual vs. system discount/tax are flagged distinctly.
URD-PO-012MEach PO has a system-generated purchase-order number.

5.8 Purchase Order Item (POI)

IDPRequirement
URD-POI-001MAdding the same (itemType, itemId, uom) accumulates quantity; different uom creates a new line.
URD-POI-002MItem total = (unitPrice × quantity × multiplier) + tax − discount.
URD-POI-003MSetting an item quantity ≤ 0 soft-deletes the line and recalculates the PO total.
URD-POI-004SUnit price defaults to the variant's active cost price.
URD-POI-005SUOM defaults to the inventory item's base unit.

5.9 Material (MAT)

IDPRequirement
URD-MAT-001MOwner can create materials within a merchant.
URD-MAT-002MMaterial has a system identifier (MAT_YYYYMMDD_id) and an i18n name.
URD-MAT-003MMaterial name supports multiple locales.
URD-MAT-004MMaterial description is editable.
URD-MAT-005MMaterial can be deactivated.
URD-MAT-006MMaterial can be archived (terminal, read-only).
URD-MAT-007MMaterial identifier is unique.
URD-MAT-101MOwner can attach a BARCODE identifier to a material.
URD-MAT-102MMaterial supports identifier schemes: SYSTEM, SLUG, SKU, BARCODE, QRCODE.
URD-MAT-103MA (scheme, code) pair is unique across materials.
URD-MAT-104MIdentifier scheme defaults to SYSTEM when unspecified.
URD-MAT-105SMultiple identifiers of different schemes can coexist on one material.
URD-MAT-106SMaterial is searchable by registered barcode.

5.10 Material Recipe / BOM (REC)

IDPRequirement
URD-REC-001MOwner can create a recipe attached to a product variant.
URD-REC-002MRecipe has a version (default 1.0).
URD-REC-003M(principal, version) is unique per recipe.
URD-REC-004MRecipe items specify a material, quantity, and unit.
URD-REC-005MRecipe items can be added to a recipe.
URD-REC-006MSame material appears at most once per recipe.
URD-REC-007MOwner can activate a recipe.
URD-REC-008MOwner can deactivate a recipe.
URD-REC-009SEditing an activated recipe creates a new version; the original is preserved.
URD-REC-010SMultiple recipe versions can be listed per principal.
URD-REC-011MOnly the activated recipe version is used at runtime.
URD-REC-101MRecipe item references a valid material.
URD-REC-102MRecipe item quantity stored at decimal precision (4 places).
URD-REC-103MRecipe item stores a unit.
URD-REC-104MRecipe item quantity is editable.
URD-REC-105MRecipe item soft-delete allows re-adding the same material.
URD-REC-201MA kitchen-ticket-item status change triggers recipe lookup and decrement prep at the default location.
URD-REC-202MEach recipe component is decremented; a tracking entry (Used as Material) is created.
URD-REC-203MComponent decrement updates stock at the default location.
URD-REC-204MThe activated recipe for the variant is the one exploded.
URD-REC-205MA material.stock-changed event is emitted after explosion.
URD-REC-206SNo default location → log warning, skip (no hard failure).
URD-REC-207SNo activated recipe → silent no-op.
URD-REC-208CNon-default kitchen location is respected (pending — current code uses the merchant default).

5.11 Constraints & Cross-Cutting (CON)

IDPRequirement
URD-CON-001MAll inventory endpoints require authentication (JWT or basic auth).
URD-CON-002MAll records use soft-delete; soft-deleted records are excluded from standard listings.
URD-CON-003MNegative available quantity is currently tolerated (documented business constraint, not a bug).
URD-CON-004MStock deductions are idempotent per (referenceType, referenceId).

6. Acceptance Criteria

AC-LOC-01: Default Location
GivenWhenThen
New merchantCommerce initializationDefault location auto-created
Set a new defaultPrevious default cleared
AC-STK-01: Stock Tracking
GivenWhenThen
Item with inventoryViewOn-hand, reserved, available displayed
Available drops below thresholdLow-stock indicator shown
AC-PO-01: Purchase Order Receipt
GivenWhenThen
PO in PROCESSINGGoods receivedStock incremented, tracking created
OVERRIDE modeReplaces received quantity
ACCUMULATIVE modeAdds to received quantity
AC-BOM-01: Kitchen BOM
GivenWhenThen
Variant with activated recipeKitchen item status changesMaterials decremented per recipe item
No activated recipeSilent no-op
No default locationWarning logged, skipped
AC-TKT-01: Inventory Ticket
GivenWhenThen
Transfer ticketCOMPLETEDSource decreased, destination increased
Cycle count ticketCOMPLETEDVariance calculated and applied
Adjustment ticketCOMPLETEDStock corrected with reason code

7. Constraints & Non-Goals

Constraints

IDConstraint
C-01One default location per merchant at all times.
C-02One stock record per (item, location, lot, serial).
C-03Available = on-hand − reserved (negative currently tolerated).
C-04Tracking records are immutable.
C-05Stock movements are idempotent via (referenceType, referenceId).
C-06PO items editable only in DRAFT.
C-0719 pre-seeded tracking types (+ 1 custom) at startup.
C-08All records use soft-delete.
C-09All quantities use decimal precision (4 places).

Non-Goals

  • Multi-level BOM (material as principal for sub-assemblies)
  • Recipe yield and scrap percentage
  • Explode-at-sale BOM for non-F&B retail
  • Negative-stock enforcement at POS
  • Full barcode scanning for stock takes
  • Multi-currency stock valuation

8. Version History

DateAuthorDescriptionVer
2026-02-28Q. Do - QEInitial from code analysisv0.1
2026-04-15Claude (AI pair)Add Material and MaterialRecipe (BOM) requirementsv0.2
2026-04-16Q. Do - QEConsolidated requirement areasv0.3
2026-05-30Claude (AI pair)Reformat to module template; reconcile tracking types to 19 (dev docs)v0.4

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.