---
id: 6e3f1c94-8a27-4b6d-9f52-1d8c7e3b5a41
name: Track waste and adjust forecasts
kind: WasteOptimization
cron: 0 55 6 * * *
analysis_window: 90d
comparison_periods: [7d, 28d]
---

Track **ingredient and inventory waste** and adjust demand forecasts to improve ordering accuracy, reduce overstock, and minimize future waste.

The process should analyze historical waste patterns and incorporate them into **forecast and ordering adjustments** so that inventory levels better reflect actual consumption.

The output must contain **forecast adjustments, waste alerts, and ordering adjustments 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  
- forecast deviation signals  

## Analysis Approach

### Stage 1 — Historical Waste Extraction
Extract waste-related signals from the last **90 days** using `GNDSALE`.

Identify ingredients or menu items frequently associated with:
- spoilage
- unused stock
- overproduction.

### Stage 2 — Waste Pattern Analysis
Aggregate waste occurrences by:
- ingredient
- menu item
- day of week
- service period if available.

Identify recurring patterns such as:
- over-preparation during specific days
- ingredients consistently overstocked
- waste spikes after certain delivery cycles.

### Stage 3 — Demand vs Waste Correlation
Compare:
- historical demand from `GNDITEM`
- waste indicators from `GNDSALE`
- ingredient usage derived from recipes in `ITM`.

Detect discrepancies where predicted consumption significantly exceeds actual usage.

### Stage 4 — Forecast Adjustment
Adjust demand forecasts by incorporating detected waste patterns.

Reduce projected usage for ingredients or menu items that consistently generate excess inventory while preserving sufficient stock for high-demand periods.

### Stage 5 — Ordering Strategy Adjustment
Modify purchasing recommendations based on waste insights by:
- reducing order quantities for ingredients with repeated waste
- adjusting safety stock thresholds
- modifying delivery schedules where waste occurs after deliveries.

Consider pricing tiers and supplier options using `QTYPRICE`.

### Stage 6 — Continuous Waste Monitoring
Generate structured insights highlighting:
- ingredients with persistent waste patterns
- menu items contributing to overproduction
- opportunities to improve ordering or preparation practices.

## Output Constraints

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

## Output Format

Return structured waste insights and forecast adjustments.
