National Commerce Docs
Database

Inventory

Per-SKU stock levels and reorder-point settings for each Base SKU at each Warehouse.

The inventory tables track how much stock exists for each product at each location and the settings that drive reordering. The main Inventory table holds one row per Base SKU per Warehouse, while inventory_formula_inputs stores the global defaults for the reorder formula.

Inventory

One row represents the stock of a single Base SKU at one Warehouse. Each row also carries the five reorder-point levers used to decide when and how much to reorder. These levers match the "Reorder Point Settings" feature screen.

ColumnTypeNotes
idintegerPrimary key.
Inventory_NametextHuman-readable name for the inventory row.
Warehouses_idinteger→ references Warehouses. The location holding the stock.
base_sku_idinteger→ references Base SKUs. The product being stocked.
brandinteger→ references Brands. Must be greater than 0.
Units_Remaining_in_StockbigintCurrent on-hand units.
Current_Inbound_InventorybigintUnits on inbound purchase orders. Default 0. Maintained by trigger (see below).
Shipped_in_last_14daysbigintRolling shipped-units count used to estimate daily demand. Default 0.
safety_stock_to_hold_in_daysbigintReorder lever: days of buffer stock to hold. Default 3.
trailing_days_to_measure_daily_demandbigintReorder lever: window used to measure daily demand. Default 14.
replen_order_lead_timebigintReorder lever: expected lead time for a replenishment order, in days. Default 10.
order_intervalbigintReorder lever: days between reorders. Default 7.
base_sku_order_multipleintegerReorder lever: order quantities are rounded to this multiple. Synced with the Base SKU (see below).
created_at, updated_at, created_by, updated_bytimestamp / varcharStandard audit columns. created_at defaults to now().

Automation. Current_Inbound_Inventory is denormalized. The trigger_update_inventory_sum trigger on Inventory Purchase Order Line Items recomputes this value for the affected Inventory row whenever PO line items change. See Automation.

Two-way order_multiple sync

base_sku_order_multiple is kept in sync between Inventory and its linked Base SKU. On the Inventory side, update_base_sku_order_multiple_for_inventory (AFTER UPDATE) and update_base_sku_order_multiple_for_inventory_2 (AFTER INSERT) push the multiple back to the Base SKU. On the Base SKU side, the sync_base_sku_order_multiple_with_inventory trigger pushes changes the other direction. Update the value in either place and both stay aligned.

External notifications

The inventory_update_trigger (AFTER INSERT/UPDATE) calls notify_n8n_inventory_update(), which notifies an external n8n workflow whenever inventory changes. See the full trigger catalog in Automation.

An Inventory row links to a Warehouse, a Base SKU, and a Brand. Together the Warehouse and Base SKU identify what stock this row represents; the Brand records which brand owns it.

inventory_formula_inputs

Standalone configuration that holds the global default values for the reorder formula. It has no foreign keys and is not tied to any single SKU or warehouse. These defaults back the per-SKU levers stored on the Inventory table.

ColumnTypeNotes
idintegerPrimary key.
Trailing_Days_to_Measure_Daily_DemandbigintDefault trailing window for measuring daily demand.
Safety_Stock_to_Hold____of_Days_bigintDefault days of safety stock to hold.
Order_IntervalbigintDefault days between reorders.
created_at, updated_at, created_by, updated_bytimestamp / varcharStandard audit columns.

This table stands alone. It has no relationships to other tables; it simply supplies default values that are copied onto the reorder levers of each Inventory row.

On this page