Skip to content

Inventory & Retail

Stock management, retail sales, purchase orders, suppliers, and product catalogue.

4 min read

Overview

The inventory module tracks physical products: retail items sold to clients and back-bar consumables used in services. It manages stock levels per location, records every change as a stock movement, handles supplier purchase orders, and is called from checkout so stock is decremented when products are sold or kits are used.

Kagami salon inventory management showing retail products, professional consumables, and low-stock alerts

Products

Product type Description
retail Sold to clients at checkout (shampoo, serum, accessories)
back_bar Consumed during services, never sold directly (/dashboard/inventory/back-bar)

Product Fields (products table)

  • name, sku, description, category (free text), brand_name
  • unit: piece, ml, g, l or kg
  • cost_minor and price_minor (paise), vat_pct
  • reorder_qty: the low-stock threshold
  • supplier_id, is_active
  • allowed_tenders: optional restriction on which payment methods can pay for the product (see Checkout)

There is no separate category table and no barcode column.

Back-bar kits

service_back_bar links a service to back-bar products with qty_used and a unit. When a bill containing that service is finalised, each kit product is debited as a back_bar_use movement (quantity times the service line quantity).

Stock Management

Stock Levels

stock_levels holds qty_on_hand per product and location (location_id may be null for stock recorded without a store). It is updated in the same code path that writes the movement.

Stock Movements

Every change is a row in stock_movements with a signed qty_delta, unit_cost_minor, reference_id and note. The only valid type values (database CHECK, migration 0020) are:

Movement type Written by
sale Checkout, for each product line (negative)
back_bar_use Checkout, for each service kit item (negative)
purchase_receipt Receiving a purchase order (positive)
adjustment Manual correction on the Stock page (needs a reason note)
return_to_supplier Defined; no screen or action in the code writes it
opening_stock Defined; no screen or action in the code writes it

There are no movement types for client returns, transfers between locations, wastage or "service usage". A client product return (return-items) does not touch stock; adjust it manually. Stock changes need the inventory.adjust_stock permission (default owner and managers).

Physical counts

The Stock page offers adjustments with a reason; there is no dedicated stock-take workflow that computes variances from counted quantities. Completing an adjustment can auto-complete the weekly "stock count submitted" playbook task for the active store.

Low Stock Alerts

getLowStockProducts lists products whose qty_on_hand is at or below reorder_qty (stock with no store counts in every store view). It is a list on the Inventory pages; there is no automatic purchase-order suggestion.

Purchase Orders

Purchase orders (purchase_orders, purchase_order_lines) live at /dashboard/inventory/purchase-orders. Creating, receiving and changing status need the inventory.purchase_orders permission.

Purchase Order States

The enum is draft, sent, partial, received, cancelled. There is no approval step and no emailed PDF.

State How it is reached
draft Created in the UI with a supplier and lines (PO- number is generated)
sent "Mark Sent" on a draft
partial After a receipt where at least one line is received but not all lines are fully received
received After a receipt where every line is received in full
cancelled "Cancel" on a draft

Receiving (receivePurchaseOrderAction) writes qty_received per line and a purchase_receipt movement per line with the unit cost. I found no button in the UI that calls it, so receiving is available as a server action only (unverified whether another entry point such as the external API uses it). A receipt does not create a vendor bill; vendor bills are entered separately in finance.

Suppliers

suppliers store name, contact name, email, phone, notes and is_active (/dashboard/inventory/suppliers). There are no payment terms, product lists or outstanding-bill views on the supplier record.

Retail Sales at Checkout

When a product line is on a finalised invoice:

  • Stock is decremented by adjustStock(..., "sale") with the invoice id as reference
  • If the stock update fails, the invoice stays paid and the operator sees a warning to adjust inventory manually

COGS

There are two COGS calculations:

  • The P&L statement (lib/accounting/pl-statement.ts) sums qty_delta times unit_cost_minor over sale and back_bar_use movements
  • computeCOGS in lib/finance/reconciliation.ts does the same by month

Cost is recorded on purchase_receipt movements. COGS figures are derived from stock-movement unit costs.

Known limitations

Edge-case behaviour of the inventory actions is not exhaustively documented here; check the code before relying on it.

Key Data Entities

  • products: item definition
  • stock_levels: quantity on hand per product and location
  • stock_movements: every stock change
  • service_back_bar: kit items consumed per service
  • suppliers
  • purchase_orders and purchase_order_lines

Permissions

Defaults from lib/auth/permissions.ts; owners can change them in Settings, Roles and Permissions.

Action Permission key Default roles
Add / edit products products.manage owner, brand manager, location manager
Delete a product products.delete owner, brand manager, location manager
Adjust stock inventory.adjust_stock owner, brand manager, location manager
Create / receive / update purchase orders inventory.purchase_orders owner, brand manager, location manager