How does stock automatically deduct when I sell a coffee?
- Cashier rings a Latte 12oz. The system writes a sale_items row.
- A Postgres trigger fires: it reads the product's recipe (18g beans + 240ml milk + 1× cup).
- It writes negative stock_movements rows for each ingredient and decrements ingredients.current_stock atomically.
- If any ingredient drops below the reorder threshold, the dashboard low-stock alert turns on automatically.
You'll see
Inventory → Ingredients shows live decrementing counts after every sale.