Glossary & Data Model
Terms
Stock Count — a physical inventory session: a snapshot of expected stock for one or more storages, counted against by staff, and closed by confirming (optionally updating live stock) or cancelling.
Stock Count Item (line) — one item/storage combination within a count; the unit of counting. Corresponds 1:1 with an InventoryLocation that had stock when the count opened.
Open / Confirmed / Cancelled — the three states a count can be in (StockCountStatus). Only an OPEN count can be counted, edited, confirmed, cancelled, or deleted.
All-storages count — a count opened with no specific inventoryStorage, which locks every storage in the company for its duration. Flagged in the UI as "All storages will be counted and blocked."
Locking / locked storage — an InventoryStorage currently held by an open count (lockedByStockCountId set). While locked, no other inventory-moving transaction can touch it.
Expected amount/value — the frozen snapshot a count started with: what the system believed was in a location when the count opened, computed once and never recalculated even if live stock or pricing changes afterward.
Counted amount/value — what a counter actually recorded for a line. null until counted; distinguishing "counted as zero" from "not yet looked at."
Variance — counted − expected, stored (not derived on read) on each line and rolled up onto the count, so lists can sort/filter on it directly.
Adjustment order — a normal InventoryOrder of type ADJUSTMENT, optionally created when a count is confirmed with "update stock," carrying one line per line that varied. Booked through the same code path as any other inventory order type.
Confirm without changing stock / Confirm and update stock — the two explicit outcomes of confirming a count. The former just records the count; the latter also books the adjustment order described above.
View Created Stock Count — a permission that scopes a user's visibility to only the counts they personally created, as opposed to View Stock Count which shows every count in the company.
Data model
StockCount (packages/prisma/schema.prisma:4421)
| Field | Notes | ||
|---|---|---|---|
number | Sequential per company (#1, #2…), separate from the UUID id | ||
status | OPEN \ | CONFIRMED \ | CANCELED |
inventoryStorage / inventoryStorageId | null means "all storages" | ||
isMaster | Passed through from creation; not derived | ||
totalItems, countedItems | Line counts, kept in sync by recalculateStockCountTotals | ||
expectedAmount, expectedAmountBox, expectedValue | Frozen at open time, never recomputed | ||
countedAmount, countedAmountBox, countedValue | Rolled up from counted lines only | ||
varianceAmount, varianceValue | Rolled up from counted lines; stored, not derived on read | ||
stockUpdated | true once an adjustment order has been booked for this count | ||
inventoryOrder / inventoryOrderId | The ADJUSTMENT order this count produced, if any (unique — one order per count) | ||
confirmedAt, confirmedBy | Set on confirm or cancel (shared fields for "when this count stopped being open") | ||
lockedStorages | Reverse relation: storages currently pointing their lock at this count |
StockCountItem (packages/prisma/schema.prisma:4474)
| Field | Notes |
|---|---|
code | e.g. 12-003 — survives Excel export/re-import; what upload rows match against first |
box, price, due | Frozen from the InventorySubItem at count-open time |
expectedAmount, expectedAmountBox, expectedValue | The snapshot for this one line |
countedAmount, countedAmountBox, countedValue | null until counted |
varianceAmount, varianceValue | null until counted (not zero — no answer yet, not "no difference") |
countedAt, countedBy | Who counted this line and when; null = not yet counted |
| Unique constraints | [stockCountId, inventoryStorageId, inventorySubItemId] (one line per variation per storage per count) and [stockCountId, code] (codes unique within a count) |
InventoryStorage additions
| Field | Notes |
|---|---|
lockedByStockCount / lockedByStockCountId | Set while a count holds this storage; cleared on confirm/cancel/delete |
Related reading
- Opening a Count & Locking Storages — how the snapshot and lock are created
- Counting & Recording — the four ways to record a count
- Closing a Count & Stock Adjustments — confirm/cancel/delete and the adjustment order
- Permissions & Visibility — the new permissions and how scoping is enforced