Northwind ERP Operations Skill
Use this skill when a task involves the Northwind Components ERP shared REST API for warehouse, inventory, order, supplier, incident, or BOM-based operations. The tasks always produce structured JSON answers from live API data combined with a local input payload (memo, template, or request specification).
API Reference
All business data lives behind the shared ERP API. The runner supplies the base URL as <TASK_ENV_BASE_URL>. Use GET requests only; no authentication is needed.
Endpoints
| Endpoint |
Query Parameters |
Returns |
GET /health |
none |
API health status |
GET /products |
none |
All products |
GET /products/<sku> |
none |
Single product |
GET /customers |
none |
All customers |
GET /customers/<customer_id> |
none |
Single customer |
GET /warehouses |
none |
All warehouses |
GET /inventory |
?warehouse_id=&sku= |
Filtered inventory records |
GET /purchase_orders |
?supplier_id=&sku=&status= |
Filtered purchase orders |
GET /orders |
?wave=&required_date=&customer_id= |
Filtered sales orders |
GET /orders/<order_id> |
none |
Single order with lines |
GET /shipping/quote |
?warehouse_id=&destination_zip=&weight_lb=&speed= |
Shipping quote |
GET /incidents |
?start=&end=&supplier_id=&sku=&incident_type=&status= |
Filtered quality incidents |
GET /suppliers |
none |
All suppliers |
GET /boms |
none |
All bill-of-materials records |
GET /boms/<bom_id> |
none |
Single BOM with components |
Query string values follow standard URL encoding. Date filters use YYYY-MM-DD format and are inclusive on both ends.
Domain Model
Entity Relationships
- Order (
SO-*) belongs to a Customer (CUST-*), contains one or more Lines each with a SKU, quantity, and requested warehouse.
- Product (
NW-*) has a status (active or inactive), unit_weight_lb, and is sourced from a Supplier (SUP-*).
- Warehouse (
WH_NORTH, WH_CENTRAL, WH_WEST) holds Inventory with on_hand, reserved, quarantined, and buffer_stock fields.
- Effective available inventory =
on_hand - reserved - quarantined - buffer_stock.
- Purchase Order (
PO-*) has a status (open, confirmed, received, closed), supplier, warehouse, sku, and delivery_date.
- Supplier (
SUP-*) has a quality_status (approved, watch, quality_hold).
- Incident (
INC-*) has a type (RMA or WORK_ORDER), severity (low, medium, high, critical), status (open, closed), open_date, close_date, resolution_cost, and links to a supplier and sku.
- BOM (
BOM-*) has a name and components, each with a sku and quantity_per.
Key Field Meanings
| Field |
Meaning |
on_hand |
Physical units present in the warehouse |
reserved |
Units already committed to other orders |
quarantined |
Units held for quality inspection |
buffer_stock |
Minimum operating reserve that must not be consumed |
effective_available |
on_hand - reserved - quarantined - buffer_stock |
Decision Frameworks
1. Expedite Queue Decision Logic
For each order in an expedite queue memo, query its order lines, customer record, and each line's product and inventory at the requested warehouse, then apply this cascade:
Step A: Inventory Status
- Query inventory for each order-line SKU at the requested warehouse.
- If any SKU has
effective_available <= 0: classify that SKU by root cause.
- If the product
status is inactive and inventory is also at or below zero: inactive_and_shortage.
- If the product
status is inactive but inventory is positive: inactive_sku.
- If inventory is at or below zero with an active product:
shortage.
- If inventory is below the ordered quantity but above zero:
low_stock.
- If every line's
effective_available >= ordered_quantity: ready.
Step B: Customer Exception
- Check the order's customer record.
- If
account_status is blocked: account_blocked.
- If
account_status is review or flagged: review_required.
- If
fraud_alert is active: fraud_watch.
- If
credit_risk is flagged: credit_watch.
- Otherwise:
none.
Step C: Final Decision and Next Action (combined)
Apply the most restrictive outcome from these precedence rules:
- If
customer_exception is account_blocked -> reject_hold / hold_credit_or_fraud.
- If
customer_exception is fraud_watch -> reject_hold / hold_credit_or_fraud.
- If
customer_exception is review_required -> manual_review / send_account_review (even if inventory is fine).
- If
customer_exception is credit_watch -> manual_review / send_account_review (even if inventory is fine).
- If
inventory_status is inactive_and_shortage and no blocking customer exception -> manual_review / escalate_product_master.
- If
inventory_status is inactive_sku and no blocking customer exception -> manual_review / escalate_product_master.
- If
inventory_status is shortage and no blocking customer exception -> backorder / create_backorder.
- If
inventory_status is low_stock and no blocking customer exception -> delayed_release / delay_and_monitor.
- Otherwise ->
ship_now / release_to_pick.
Step D: SKU Lists
shortage_skus: SKUs with effective_available <= 0 and product status is active. Sorted ascending.
inactive_skus: SKUs whose product status is inactive. Sorted ascending.
low_stock_skus: SKUs where 0 < effective_available < ordered_quantity and product is active. Sorted ascending.
Step E: Shipping Quote
Call GET /shipping/quote for each order using the order's warehouse_id, the customer's destination_zip, the sum of unit_weight_lb * quantity across all lines, and the appropriate shipping speed. Use the operator note or order data to determine the speed; default to the speed requested on the order when unspecified.
2. Replenishment / Kit Build Planning
For a BOM-based kit build run:
Step A: Gather Requirements
- Query each BOM to get its components (SKU, quantity_per).
- Multiply by
target_build_quantity to get total_required per SKU (sum across BOMs when a SKU appears in multiple BOMs).
Step B: Check Warehouse Stock
- Query inventory for each component SKU at the target warehouse.
- Compute
effective_available using the formula above.
Step C: Check Purchase Orders
- Query POs at the target warehouse for each component SKU with
status=open or status=confirmed.
- A PO is timely if its
delivery_date is on or before the earliest target_build_date for that component.
- Sum timely PO quantities into
timely_po_qty.
Step D: Determine Action
- Compute
gap = total_required - effective_available.
- If
gap <= 0 and effective_available >= total_required: no_action_stocked.
- If
effective_available exceeds total_required by a wide margin and the SKU is not needed: overstock_excluded.
- If timely POs cover the full gap:
timely_po_covered (exclude from transfers and purchases).
- If
gap > 0 after POs, try inter-warehouse transfers from other warehouses with positive effective available.
- Any remaining gap after transfers becomes a
purchase_requisition_qty.
Step E: Transfers
- For each transfer-needed SKU, check all other warehouses for available inventory.
- Prefer warehouses with the most available stock. Record
from_warehouse_id, to_warehouse_id, quantity, and needed_by (earliest build date for that SKU).
- Sort transfer_requests by SKU ascending, then quantity descending, then from_warehouse_id ascending.
Step F: Purchase Requisitions
- For each SKU still short after transfers, create a purchase requisition.
- Use the SKU's primary supplier from the product record, the target warehouse, and the remaining gap as
quantity.
needed_by is the earliest build date for that SKU.
unit_cost comes from the product's standard_cost field. extended_cost = quantity * unit_cost, rounded to 2 decimals.
- Sort by SKU ascending.
Step G: Excluded Components
- SKUs with
final_action of timely_po_covered -> reason timely_po_covers_gap, list coverage POs.
- SKUs with
final_action of overstock_excluded -> reason target_overstock.
- SKUs with
final_action of no_action_stocked -> reason stocked_no_gap.
- Sort by SKU ascending.
Step H: Summary
component_count: number of distinct component SKUs.
total_purchase_units: sum of all purchase_requisition_qty values.
total_purchase_cost: sum of all extended_cost values, rounded to 2 decimals.
total_transfer_units: sum of all transfer quantity values.
timely_po_covered_units: sum of total_required - target_effective_available for components whose gap is fully covered by timely POs. Track the actual gap covered, not the full PO quantity.
3. Supplier Incident Scorecard
Step A: Filter Incidents
- Query
GET /incidents with start and end dates, inclusive.
- Use the full incident population for the denominator in percentage calculations.
Step B: Per-Supplier Aggregation
- Query
GET /suppliers for names and quality statuses.
- For each supplier with at least one filtered incident:
incident_count: total incidents in the window.
incident_percentage: (incident_count / total_filtered_incidents) * 100, rounded to 1 decimal.
total_resolution_cost: sum of resolution_cost across incidents, rounded to 2 decimals.
avg_duration_days: average of close_date - open_date for closed incidents or analysis_date - open_date for open ones, in calendar days, rounded to 2 decimals.
rma_count: count where incident_type is RMA.
work_order_count: count where incident_type is WORK_ORDER.
open_incident_count: count where status is open.
severe_incident_count: count where severity is high or critical.
recommendation_code: apply the policy cascade below.
Step C: Recommendation Cascade
Evaluate conditions in this exact precedence order:
ESCALATE_SUPPLIER: supplier quality_status is quality_hold AND incident_count >= 3, OR any incident has severity=critical AND incident_type=RMA, OR rma_count >= 3 AND total_resolution_cost >= 15000.00.
PROCESS_REVIEW: work_order_count >= 3 AND work_order_count > rma_count (and ESCALATE_SUPPLIER does not apply).
WATCHLIST: quality_status is watch or quality_hold, OR incident_count >= 4, OR total_resolution_cost >= 12000.00, OR severe_incident_count >= 2.
MONITOR: none of the above conditions apply.
Step D: Top-Level Summary
filtered_incident_count: total incidents matching the date filter.
supplier_count: count of suppliers with at least one filtered incident.
total_resolution_cost: sum of all resolution costs, rounded to 2 decimals.
overall_rma_count: total RMA incidents in the window.
overall_work_order_count: total WORK_ORDER incidents in the window.
highest_cost_supplier_id: supplier with maximum total_resolution_cost. Break ties with lowest supplier_id.
highest_share_supplier_id: supplier with maximum incident_count. Break ties with lowest supplier_id.
4. Allocation Desk (Mixed-Warehouse Transfer Review)
Step A: Load the Wave
- Query
GET /orders?wave=<wave_id> to get all orders in the wave.
- Each order contains lines with
sku, quantity, and warehouse_id.
Step B: Check Customer Status First
- For each order, query the customer record.
- If the customer's
account_status is blocked: every line in that order gets action=manual_review with primary_reason=account_blocked. The order joins blocked_orders.
- If
account_status is review or flagged: every line gets action=manual_review with primary_reason=account_review_required. The order joins blocked_orders.
- If
fraud_alert is active: every line gets action=manual_review with primary_reason=fraud_watch. The order joins blocked_orders.
Step C: Check Product Status
- For each non-blocked line, query the product record.
- If
status is inactive: action=manual_review, primary_reason=inactive_product. The order is not necessarily added to blocked_orders (only account/customer-risk orders go there).
Step D: Check Inventory
- Query inventory for the SKU at the requested warehouse.
- Compute
effective_available.
requested_effective_available is the value for the line's SKU at the requested warehouse.
Step E: Determine Action
- If
effective_available >= ordered_quantity and no blocking condition: action=ship, ship_quantity=ordered_quantity.
- If
effective_available < ordered_quantity and no blocking condition:
- Check other warehouses for the same SKU. Use any available inventory (positive
effective_available) from other warehouses.
- If combined available (requested warehouse + other warehouses) >= ordered_quantity:
action=transfer.
ship_quantity = amount the requested warehouse can supply (min of effective_available and ordered_quantity).
transfer_quantity = the remainder.
- Pick one source warehouse for the transfer (prefer the one with most available stock).
- If combined available is still insufficient:
action=backorder, backorder_quantity = ordered_quantity - ship_quantity.
Step F: Order Rollup
- For each order, determine the single
outcome:
- All lines
ship -> ready_to_ship.
- One or more lines
manual_review and the rest are shippable -> manual_review.
- One or more lines
transfer and no manual_review or backorder -> needs_transfer.
- One or more lines
backorder and no manual_review -> has_backorder.
- Mix of
ship, transfer, and backorder -> mixed_actions.
- Any
manual_review line overrides: the order outcome is manual_review.
5. Procurement Quality Control
Step A: Load Target Suppliers
- Query each target supplier by ID to get
supplier_name and quality_status.
Step B: Load Recent Incidents
- Query
GET /incidents?start=<start>&end=<end>&supplier_id=<id> for each target supplier.
- Count
recent_incident_count, recent_rma_count (type=RMA), severe_or_critical_count (severity=high or critical), open_incident_count (status=open).
- Collect
affected_skus (unique SKUs from incidents, sorted ascending).
- Collect up to 5
sample_incident_ids (sorted ascending).
Step C: Load Open/Confirmed POs
- Query
GET /purchase_orders?supplier_id=<id>&status=open and status=confirmed.
- These are the candidate
held_po_ids when a decision freezes or holds replenishment.
Step D: Decision Rules
Apply in precedence order:
freeze_new_replenishment: supplier quality_status is quality_hold AND recent_incident_count >= 1. Hold all open/confirmed POs for that supplier.
buyer_review_required: supplier quality_status is watch OR severe_or_critical_count >= 2 OR recent_rma_count >= 2. Hold all open/confirmed POs for that supplier.
monitor_only: none of the above apply. No POs held.
Step E: Aggregate Outputs
held_po_ids: union of all held PO IDs across suppliers, deduplicated and sorted ascending.
release_supplier_ids: supplier IDs where decision is monitor_only, sorted ascending.
- Summary:
suppliers_reviewed, counts by decision type, held_po_count, total_recent_incidents.
Output Conventions
General Rules
- Every answer is a single JSON object matching the provided answer template exactly.
- Do not include narrative text, explanations, or markdown outside the JSON.
- Sort lists as specified by each template (usually by
order_id, line_id, sku, or supplier_id ascending).
- All currency values: round to exactly 2 decimal places. Use standard rounding (half-up).
- All percentage values: round to exactly 1 decimal place when specified.
- All duration values: round to exactly 2 decimal places when specified.
- Integer fields must be whole numbers (no decimal places).
- When a template dictates an enum for a field, use only the allowed values.
- Empty lists use
[], not null.
- Include all required top-level keys even when their values are empty lists or zeros.
- Compute
effective_available as on_hand - reserved - quarantined - buffer_stock in every inventory check. Do not use raw on_hand.
- When a customer check triggers
manual_review on an order, all lines in that order receive manual_review regardless of individual line inventory status.
Common Pitfalls
- Do not treat
reserved, quarantined, or buffer_stock as available inventory.
- Do not overlook product
status when classifying SKUs; an inactive product whose inventory is also at/below zero produces inactive_and_shortage, not plain shortage.
- In allocation tasks,
blocked_orders includes only account-level and customer-risk blocks (account_blocked, account_review_required, fraud_watch), not product-level inactive_product reviews.
- In replenishment, a timely PO's quantity counts toward coverage but the gap covered by that PO is
min(po_qty, gap), not the full PO quantity, for summary totals.
- For shipping quotes, sum the weights of all lines in the order. Use the order's warehouse and the customer's destination zip.
- When an answer template specifies a
required_value for a field (e.g., wave_id), use that exact value.
- In scorecards, duration for open incidents uses the analysis date as the close date.
- The
total_shipping_cost_usd summary is the sum of all individual total_cost_usd values, rounded to 2 decimals.
- In BOM planning, when a SKU appears in multiple BOMs, sum the required quantities. The earliest build date across BOMs drives the
needed_by date for that SKU.
- In allocation,
transfer_requests ordering: sort by order_id ascending, then line_id ascending (not by SKU).
- In expedite, the
final_decision for inactive_and_shortage and inactive_sku is manual_review with next_action of escalate_product_master, unless a higher-precedence customer exception applies.
Workflow Pattern
Every Northwind ERP task follows this general sequence:
- Read the local payload (memo, request spec, or production memo) and the answer template from
input/payloads/.
- Query the ERP API for all relevant entities: orders, customers, products, inventory, warehouses, suppliers, POs, BOMs, incidents, or shipping quotes as needed.
- Cross-reference the API data against the request: match orders to customers, lines to inventory and products, suppliers to incidents and POs, BOM components to stock levels.
- Apply the decision framework appropriate to the task type (expedite, replenishment, scorecard, allocation, or procurement-quality).
- Populate the answer template with computed values, following all ordering and formatting rules.
- Return only the JSON object - no prose, no markdown wrapping, no extra commentary.
1---2name: northwind-erp-operations-43description: Solve Northwind Components ERP operations tasks using the shared REST API. Covers expedite queues, replenishment planning, supplier scorecards, allocation decisions, and procurement quality controls with structured JSON outputs.4metadata:5 source: https://skillmd.com/skills/prism-shadow/northwind-erp-operations-46---78# Northwind ERP Operations Skill910Use this skill when a task involves the Northwind Components ERP shared REST API for warehouse, inventory, order, supplier, incident, or BOM-based operations. The tasks always produce structured JSON answers from live API data combined with a local input payload (memo, template, or request specification).1112## API Reference1314All business data lives behind the shared ERP API. The runner supplies the base URL as `<TASK_ENV_BASE_URL>`. Use GET requests only; no authentication is needed.1516### Endpoints1718| Endpoint | Query Parameters | Returns |19|----------|-----------------|---------|20| `GET /health` | none | API health status |21| `GET /products` | none | All products |22| `GET /products/<sku>` | none | Single product |23| `GET /customers` | none | All customers |24| `GET /customers/<customer_id>` | none | Single customer |25| `GET /warehouses` | none | All warehouses |26| `GET /inventory` | `?warehouse_id=&sku=` | Filtered inventory records |27| `GET /purchase_orders` | `?supplier_id=&sku=&status=` | Filtered purchase orders |28| `GET /orders` | `?wave=&required_date=&customer_id=` | Filtered sales orders |29| `GET /orders/<order_id>` | none | Single order with lines |30| `GET /shipping/quote` | `?warehouse_id=&destination_zip=&weight_lb=&speed=` | Shipping quote |31| `GET /incidents` | `?start=&end=&supplier_id=&sku=&incident_type=&status=` | Filtered quality incidents |32| `GET /suppliers` | none | All suppliers |33| `GET /boms` | none | All bill-of-materials records |34| `GET /boms/<bom_id>` | none | Single BOM with components |3536Query string values follow standard URL encoding. Date filters use `YYYY-MM-DD` format and are inclusive on both ends.3738## Domain Model3940### Entity Relationships4142- **Order** (`SO-*`) belongs to a **Customer** (`CUST-*`), contains one or more **Lines** each with a **SKU**, **quantity**, and **requested warehouse**.43- **Product** (`NW-*`) has a **status** (active or inactive), **unit_weight_lb**, and is sourced from a **Supplier** (`SUP-*`).44- **Warehouse** (`WH_NORTH`, `WH_CENTRAL`, `WH_WEST`) holds **Inventory** with `on_hand`, `reserved`, `quarantined`, and `buffer_stock` fields.45- **Effective available** inventory = `on_hand - reserved - quarantined - buffer_stock`.46- **Purchase Order** (`PO-*`) has a **status** (open, confirmed, received, closed), **supplier**, **warehouse**, **sku**, and **delivery_date**.47- **Supplier** (`SUP-*`) has a **quality_status** (approved, watch, quality_hold).48- **Incident** (`INC-*`) has a **type** (RMA or WORK_ORDER), **severity** (low, medium, high, critical), **status** (open, closed), **open_date**, **close_date**, **resolution_cost**, and links to a **supplier** and **sku**.49- **BOM** (`BOM-*`) has a **name** and **components**, each with a **sku** and **quantity_per**.5051### Key Field Meanings5253| Field | Meaning |54|-------|---------|55| `on_hand` | Physical units present in the warehouse |56| `reserved` | Units already committed to other orders |57| `quarantined` | Units held for quality inspection |58| `buffer_stock` | Minimum operating reserve that must not be consumed |59| `effective_available` | `on_hand - reserved - quarantined - buffer_stock` |6061## Decision Frameworks6263### 1. Expedite Queue Decision Logic6465For each order in an expedite queue memo, query its order lines, customer record, and each line's product and inventory at the requested warehouse, then apply this cascade:6667**Step A: Inventory Status**68- Query inventory for each order-line SKU at the requested warehouse.69- If any SKU has `effective_available <= 0`: classify that SKU by root cause.70 - If the product `status` is `inactive` and inventory is also at or below zero: `inactive_and_shortage`.71 - If the product `status` is `inactive` but inventory is positive: `inactive_sku`.72 - If inventory is at or below zero with an active product: `shortage`.73 - If inventory is below the ordered quantity but above zero: `low_stock`.74- If every line's `effective_available >= ordered_quantity`: `ready`.7576**Step B: Customer Exception**77- Check the order's customer record.78- If `account_status` is `blocked`: `account_blocked`.79- If `account_status` is `review` or `flagged`: `review_required`.80- If `fraud_alert` is active: `fraud_watch`.81- If `credit_risk` is flagged: `credit_watch`.82- Otherwise: `none`.8384**Step C: Final Decision and Next Action (combined)**85Apply the most restrictive outcome from these precedence rules:86871. If `customer_exception` is `account_blocked` -> `reject_hold` / `hold_credit_or_fraud`.882. If `customer_exception` is `fraud_watch` -> `reject_hold` / `hold_credit_or_fraud`.893. If `customer_exception` is `review_required` -> `manual_review` / `send_account_review` (even if inventory is fine).904. If `customer_exception` is `credit_watch` -> `manual_review` / `send_account_review` (even if inventory is fine).915. If `inventory_status` is `inactive_and_shortage` and no blocking customer exception -> `manual_review` / `escalate_product_master`.926. If `inventory_status` is `inactive_sku` and no blocking customer exception -> `manual_review` / `escalate_product_master`.937. If `inventory_status` is `shortage` and no blocking customer exception -> `backorder` / `create_backorder`.948. If `inventory_status` is `low_stock` and no blocking customer exception -> `delayed_release` / `delay_and_monitor`.959. Otherwise -> `ship_now` / `release_to_pick`.9697**Step D: SKU Lists**98- `shortage_skus`: SKUs with `effective_available <= 0` and product status is active. Sorted ascending.99- `inactive_skus`: SKUs whose product `status` is `inactive`. Sorted ascending.100- `low_stock_skus`: SKUs where `0 < effective_available < ordered_quantity` and product is active. Sorted ascending.101102**Step E: Shipping Quote**103Call `GET /shipping/quote` for each order using the order's `warehouse_id`, the customer's `destination_zip`, the sum of `unit_weight_lb * quantity` across all lines, and the appropriate shipping `speed`. Use the operator note or order data to determine the speed; default to the speed requested on the order when unspecified.104105### 2. Replenishment / Kit Build Planning106107For a BOM-based kit build run:108109**Step A: Gather Requirements**110- Query each BOM to get its components (SKU, quantity_per).111- Multiply by `target_build_quantity` to get `total_required` per SKU (sum across BOMs when a SKU appears in multiple BOMs).112113**Step B: Check Warehouse Stock**114- Query inventory for each component SKU at the target warehouse.115- Compute `effective_available` using the formula above.116117**Step C: Check Purchase Orders**118- Query POs at the target warehouse for each component SKU with `status=open` or `status=confirmed`.119- A PO is **timely** if its `delivery_date` is on or before the earliest `target_build_date` for that component.120- Sum timely PO quantities into `timely_po_qty`.121122**Step D: Determine Action**123- Compute `gap = total_required - effective_available`.124- If `gap <= 0` and `effective_available >= total_required`: `no_action_stocked`.125- If `effective_available` exceeds `total_required` by a wide margin and the SKU is not needed: `overstock_excluded`.126- If timely POs cover the full gap: `timely_po_covered` (exclude from transfers and purchases).127- If `gap > 0` after POs, try inter-warehouse transfers from other warehouses with positive effective available.128- Any remaining gap after transfers becomes a `purchase_requisition_qty`.129130**Step E: Transfers**131- For each transfer-needed SKU, check all other warehouses for available inventory.132- Prefer warehouses with the most available stock. Record `from_warehouse_id`, `to_warehouse_id`, `quantity`, and `needed_by` (earliest build date for that SKU).133- Sort transfer_requests by SKU ascending, then quantity descending, then from_warehouse_id ascending.134135**Step F: Purchase Requisitions**136- For each SKU still short after transfers, create a purchase requisition.137- Use the SKU's primary supplier from the product record, the target warehouse, and the remaining gap as `quantity`.138- `needed_by` is the earliest build date for that SKU.139- `unit_cost` comes from the product's `standard_cost` field. `extended_cost = quantity * unit_cost`, rounded to 2 decimals.140- Sort by SKU ascending.141142**Step G: Excluded Components**143- SKUs with `final_action` of `timely_po_covered` -> reason `timely_po_covers_gap`, list coverage POs.144- SKUs with `final_action` of `overstock_excluded` -> reason `target_overstock`.145- SKUs with `final_action` of `no_action_stocked` -> reason `stocked_no_gap`.146- Sort by SKU ascending.147148**Step H: Summary**149- `component_count`: number of distinct component SKUs.150- `total_purchase_units`: sum of all `purchase_requisition_qty` values.151- `total_purchase_cost`: sum of all `extended_cost` values, rounded to 2 decimals.152- `total_transfer_units`: sum of all transfer `quantity` values.153- `timely_po_covered_units`: sum of `total_required - target_effective_available` for components whose gap is fully covered by timely POs. Track the actual gap covered, not the full PO quantity.154155### 3. Supplier Incident Scorecard156157**Step A: Filter Incidents**158- Query `GET /incidents` with `start` and `end` dates, inclusive.159- Use the full incident population for the denominator in percentage calculations.160161**Step B: Per-Supplier Aggregation**162- Query `GET /suppliers` for names and quality statuses.163- For each supplier with at least one filtered incident:164 - `incident_count`: total incidents in the window.165 - `incident_percentage`: `(incident_count / total_filtered_incidents) * 100`, rounded to 1 decimal.166 - `total_resolution_cost`: sum of `resolution_cost` across incidents, rounded to 2 decimals.167 - `avg_duration_days`: average of `close_date - open_date` for closed incidents or `analysis_date - open_date` for open ones, in calendar days, rounded to 2 decimals.168 - `rma_count`: count where `incident_type` is `RMA`.169 - `work_order_count`: count where `incident_type` is `WORK_ORDER`.170 - `open_incident_count`: count where `status` is `open`.171 - `severe_incident_count`: count where `severity` is `high` or `critical`.172 - `recommendation_code`: apply the policy cascade below.173174**Step C: Recommendation Cascade**175Evaluate conditions in this exact precedence order:1761771. `ESCALATE_SUPPLIER`: supplier `quality_status` is `quality_hold` AND `incident_count >= 3`, OR any incident has `severity=critical` AND `incident_type=RMA`, OR `rma_count >= 3` AND `total_resolution_cost >= 15000.00`.1782. `PROCESS_REVIEW`: `work_order_count >= 3` AND `work_order_count > rma_count` (and ESCALATE_SUPPLIER does not apply).1793. `WATCHLIST`: `quality_status` is `watch` or `quality_hold`, OR `incident_count >= 4`, OR `total_resolution_cost >= 12000.00`, OR `severe_incident_count >= 2`.1804. `MONITOR`: none of the above conditions apply.181182**Step D: Top-Level Summary**183- `filtered_incident_count`: total incidents matching the date filter.184- `supplier_count`: count of suppliers with at least one filtered incident.185- `total_resolution_cost`: sum of all resolution costs, rounded to 2 decimals.186- `overall_rma_count`: total RMA incidents in the window.187- `overall_work_order_count`: total WORK_ORDER incidents in the window.188- `highest_cost_supplier_id`: supplier with maximum `total_resolution_cost`. Break ties with lowest `supplier_id`.189- `highest_share_supplier_id`: supplier with maximum `incident_count`. Break ties with lowest `supplier_id`.190191### 4. Allocation Desk (Mixed-Warehouse Transfer Review)192193**Step A: Load the Wave**194- Query `GET /orders?wave=<wave_id>` to get all orders in the wave.195- Each order contains lines with `sku`, `quantity`, and `warehouse_id`.196197**Step B: Check Customer Status First**198- For each order, query the customer record.199- If the customer's `account_status` is `blocked`: every line in that order gets `action=manual_review` with `primary_reason=account_blocked`. The order joins `blocked_orders`.200- If `account_status` is `review` or `flagged`: every line gets `action=manual_review` with `primary_reason=account_review_required`. The order joins `blocked_orders`.201- If `fraud_alert` is active: every line gets `action=manual_review` with `primary_reason=fraud_watch`. The order joins `blocked_orders`.202203**Step C: Check Product Status**204- For each non-blocked line, query the product record.205- If `status` is `inactive`: `action=manual_review`, `primary_reason=inactive_product`. The order is not necessarily added to `blocked_orders` (only account/customer-risk orders go there).206207**Step D: Check Inventory**208- Query inventory for the SKU at the requested warehouse.209- Compute `effective_available`.210- `requested_effective_available` is the value for the line's SKU at the requested warehouse.211212**Step E: Determine Action**213- If `effective_available >= ordered_quantity` and no blocking condition: `action=ship`, `ship_quantity=ordered_quantity`.214- If `effective_available < ordered_quantity` and no blocking condition:215 - Check other warehouses for the same SKU. Use any available inventory (positive `effective_available`) from other warehouses.216 - If combined available (requested warehouse + other warehouses) >= ordered_quantity: `action=transfer`.217 - `ship_quantity` = amount the requested warehouse can supply (min of `effective_available` and `ordered_quantity`).218 - `transfer_quantity` = the remainder.219 - Pick one source warehouse for the transfer (prefer the one with most available stock).220 - If combined available is still insufficient: `action=backorder`, `backorder_quantity = ordered_quantity - ship_quantity`.221222**Step F: Order Rollup**223- For each order, determine the single `outcome`:224 - All lines `ship` -> `ready_to_ship`.225 - One or more lines `manual_review` and the rest are shippable -> `manual_review`.226 - One or more lines `transfer` and no `manual_review` or `backorder` -> `needs_transfer`.227 - One or more lines `backorder` and no `manual_review` -> `has_backorder`.228 - Mix of `ship`, `transfer`, and `backorder` -> `mixed_actions`.229 - Any `manual_review` line overrides: the order outcome is `manual_review`.230231### 5. Procurement Quality Control232233**Step A: Load Target Suppliers**234- Query each target supplier by ID to get `supplier_name` and `quality_status`.235236**Step B: Load Recent Incidents**237- Query `GET /incidents?start=<start>&end=<end>&supplier_id=<id>` for each target supplier.238- Count `recent_incident_count`, `recent_rma_count` (type=RMA), `severe_or_critical_count` (severity=high or critical), `open_incident_count` (status=open).239- Collect `affected_skus` (unique SKUs from incidents, sorted ascending).240- Collect up to 5 `sample_incident_ids` (sorted ascending).241242**Step C: Load Open/Confirmed POs**243- Query `GET /purchase_orders?supplier_id=<id>&status=open` and `status=confirmed`.244- These are the candidate `held_po_ids` when a decision freezes or holds replenishment.245246**Step D: Decision Rules**247Apply in precedence order:2482491. `freeze_new_replenishment`: supplier `quality_status` is `quality_hold` AND `recent_incident_count >= 1`. Hold all open/confirmed POs for that supplier.2502. `buyer_review_required`: supplier `quality_status` is `watch` OR `severe_or_critical_count >= 2` OR `recent_rma_count >= 2`. Hold all open/confirmed POs for that supplier.2513. `monitor_only`: none of the above apply. No POs held.252253**Step E: Aggregate Outputs**254- `held_po_ids`: union of all held PO IDs across suppliers, deduplicated and sorted ascending.255- `release_supplier_ids`: supplier IDs where decision is `monitor_only`, sorted ascending.256- Summary: `suppliers_reviewed`, counts by decision type, `held_po_count`, `total_recent_incidents`.257258## Output Conventions259260### General Rules261262- Every answer is a single JSON object matching the provided answer template exactly.263- Do not include narrative text, explanations, or markdown outside the JSON.264- Sort lists as specified by each template (usually by `order_id`, `line_id`, `sku`, or `supplier_id` ascending).265- All currency values: round to exactly 2 decimal places. Use standard rounding (half-up).266- All percentage values: round to exactly 1 decimal place when specified.267- All duration values: round to exactly 2 decimal places when specified.268- Integer fields must be whole numbers (no decimal places).269- When a template dictates an enum for a field, use only the allowed values.270- Empty lists use `[]`, not `null`.271- Include all required top-level keys even when their values are empty lists or zeros.272- Compute `effective_available` as `on_hand - reserved - quarantined - buffer_stock` in every inventory check. Do not use raw `on_hand`.273- When a customer check triggers `manual_review` on an order, all lines in that order receive `manual_review` regardless of individual line inventory status.274275### Common Pitfalls276277- Do not treat `reserved`, `quarantined`, or `buffer_stock` as available inventory.278- Do not overlook product `status` when classifying SKUs; an inactive product whose inventory is also at/below zero produces `inactive_and_shortage`, not plain `shortage`.279- In allocation tasks, `blocked_orders` includes only account-level and customer-risk blocks (account_blocked, account_review_required, fraud_watch), not product-level `inactive_product` reviews.280- In replenishment, a timely PO's quantity counts toward coverage but the gap covered by that PO is `min(po_qty, gap)`, not the full PO quantity, for summary totals.281- For shipping quotes, sum the weights of all lines in the order. Use the order's warehouse and the customer's destination zip.282- When an answer template specifies a `required_value` for a field (e.g., `wave_id`), use that exact value.283- In scorecards, duration for open incidents uses the analysis date as the close date.284- The `total_shipping_cost_usd` summary is the sum of all individual `total_cost_usd` values, rounded to 2 decimals.285- In BOM planning, when a SKU appears in multiple BOMs, sum the required quantities. The earliest build date across BOMs drives the `needed_by` date for that SKU.286- In allocation, `transfer_requests` ordering: sort by `order_id` ascending, then `line_id` ascending (not by SKU).287- In expedite, the `final_decision` for `inactive_and_shortage` and `inactive_sku` is `manual_review` with `next_action` of `escalate_product_master`, unless a higher-precedence customer exception applies.288289## Workflow Pattern290291Every Northwind ERP task follows this general sequence:2922931. **Read the local payload** (memo, request spec, or production memo) and the answer template from `input/payloads/`.2942. **Query the ERP API** for all relevant entities: orders, customers, products, inventory, warehouses, suppliers, POs, BOMs, incidents, or shipping quotes as needed.2953. **Cross-reference** the API data against the request: match orders to customers, lines to inventory and products, suppliers to incidents and POs, BOM components to stock levels.2964. **Apply the decision framework** appropriate to the task type (expedite, replenishment, scorecard, allocation, or procurement-quality).2975. **Populate the answer template** with computed values, following all ordering and formatting rules.2986. **Return only the JSON** object - no prose, no markdown wrapping, no extra commentary.