Build MOQ-Compliant Supplier POs, Landed Costs, OTB & Shopify PO/Transfer CSVs
build_supplier_purchase_ordersConverts SKU demand signals into vendor-grouped purchase orders, applying MOQs, case packs, landed costs, and budget limits, then exports Shopify Draft PO CSVs and vendor emails.
Instructions
Turns SKU demand signals into ready-to-send Purchase Orders grouped by vendor. Enforces carton/case-pack multiples, per-SKU MOQs, supplier-level minimum units/USD thresholds (topping up A-class SKUs first), US import tariff + freight landed unit costs with margin-erosion alerts, and optional Open-to-Buy (max_cash_budget_usd) cashflow rationing. Outputs ready-to-import Shopify Native Draft PO CSV (SKU,Supplier SKU,Quantity,Cost,Tax %), Shopify POS Inventory Transfers CSV (SKU,Barcode,Quantity), and formatted vendor PO emails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| skus | No | Structured SKU inventory + velocity rows. | |
| demo_mode | No | Generate full multi-vendor POs using the built-in Austin, TX merchant demo dataset. | |
| po_prefix | No | Prefix for generated Purchase Order numbers. | PO-2026 |
| inventory_csv | No | Raw Shopify Products/Inventory CSV text. | |
| service_level | No | Target cycle service level used for Z-score safety stock calculation (85%=1.04, 90%=1.28, 95%=1.65, 97.5%=1.96, 99%=2.33). | 95% |
| supplier_rules | No | Per-vendor MOQ, minimum USD spend, import tariff %, freight USD, lead time override, payment terms, email, and ship-to location rules. | |
| use_live_shopify | No | Pull live store SKUs and barcodes from Shopify Admin GraphQL (Pro / License). | |
| review_period_days | No | Days of forward cover to buy beyond lead time. | |
| max_cash_budget_usd | No | Optional Open-to-Buy (OTB) maximum landed cash spend ceiling in USD across all generated POs. Trims lowest-priority C/B cartons first while protecting CRITICAL A-class SKUs. | |
| min_gross_margin_pct | No | Minimum acceptable landed gross margin % before triggering `margin_erosion_warning: true` on a PO line. | |
| default_import_duty_pct | No | Fallback US import tariff / customs duty % when not specified on a vendor's supplier_rules entry. |