---
id: c4f9b2e7-3d1a-4a8f-b6c2-9e5d7a1f4c83
name: Monitor inventory levels and low stock alerts
kind: InventoryMonitoring
cron: 0 */15 * * * *
analysis_window: 90d
comparison_periods: [7d, 28d]
---

Monitor **ingredient inventory levels** and generate **low stock alerts** to prevent shortages and ensure continuous menu availability.

The process should analyze recent consumption patterns and compare forecasted ingredient usage with available stock to detect **ingredients at risk of running out before the next replenishment cycle**.

The output must contain **low-stock alerts and reorder recommendations only**, without explanations or descriptions of methodology.

## Known Tables & Columns

### `GNDITEM`
- item (integer) - menu item identifier — references itm.id  
- bohname (varchar) - menu item name — join itm on gnditem.item = itm.id and use itm.longname  
- price (decimal) - current selling price  
- revid (integer) - revenue center identifier  

### `ITM`
- id (integer) - menu item identifier  
- longname (varchar) - menu item name  
- recipe relationships - mapping of menu items to ingredient usage quantities  

### `QTYPRICE`
- quantity tiers - thresholds for bulk purchasing  
- supplier pricing - price per unit depending on ordered quantity  

### `GNDSALE`
- historical sales forecasts  
- waste indicators  
- shortage indicators  

## Analysis Approach

### Stage 1 — Historical Consumption Analysis
Extract historical sales data from the last **90 days** using `GNDITEM`.

Aggregate sales by:
- menu item
- day of week
- service period or time window if available.

Convert menu item demand into **ingredient consumption** using recipe relationships from `ITM`.

Identify high-usage ingredients and recurring demand patterns.

### Stage 2 — Consumption Forecast
Estimate **near-term ingredient consumption** based on recent demand patterns.

Adjust forecasts using contextual signals such as:
- seasonal variations
- promotions
- scheduled events or traffic spikes.

### Stage 3 — Inventory Level Evaluation
Compare forecasted ingredient consumption with **current or expected stock levels**.

Use signals from `GNDSALE` to identify:
- ingredients that frequently run out
- ingredients associated with shortage events.

### Stage 4 — Low Stock Risk Detection
Determine whether ingredient inventory will fall below **safe operating levels** by evaluating:
- forecasted consumption
- remaining stock
- safety stock thresholds.

Identify ingredients at risk of **running out before the next delivery cycle**.

### Stage 5 — Procurement Context Evaluation
Use `QTYPRICE` to determine available supplier options and quantity tiers.

Evaluate whether:
- restocking should occur immediately
- restocking can be combined with upcoming orders
- bulk tiers justify larger replenishment quantities.

### Stage 6 — Alert Generation
Generate structured alerts for ingredients approaching **low stock conditions**.

Alerts should include:
- estimated time until stockout
- recommended reorder quantity
- urgency level.

## Output Constraints

- Use historical data from the **last 90 days** only.
- Prefer aggregated summaries.
- Avoid requesting more than **3 database queries** unless necessary.
- Return **low-stock alerts and reorder recommendations only**.
- **Do not include explanations, reasoning, or methodology**.

## Output Format

Return structured inventory alerts.

