Calculate order quantity
calculate_order_quantityUse this when someone asks how many units to order, given demand, lead time, stock on hand and on order, and supplier rules such as MOQ, case pack or a minimum order value. Sizes the line the way Forthcast sizes a purchase-order line and lists every rule that changed the quantity. Works without a connected store.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| moq | No | Supplier minimum order quantity for this item. | |
| on_hand | Yes | Units available now. | |
| on_order | No | Units already on open purchase orders. | |
| case_pack | No | Units per case; quantity is rounded up to whole cases. | |
| unit_cost | No | Purchase cost per unit. | |
| daily_demand | No | Daily units sold, oldest first, 14 to 365 values. | |
| service_level | No | Target in-stock probability, 0.50 to 0.99. | |
| lead_time_days | Yes | Supplier lead time in days. | |
| min_order_value | No | Supplier minimum order value in currency; needs unit_cost. | |
| demand_std_daily | No | Standard deviation of daily demand, if known. | |
| cover_days_target | No | Optional explicit days of cover to buy instead of the default weeks-of-supply target. | |
| average_daily_demand | No | Average units sold per day, if no daily history. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| position | Yes | ||
| shortfall | Yes | ||
| assumptions | Yes | ||
| connect_hint | No | How to get this done automatically on live store data. | Forthcast does this automatically for Shopify stores: https://apps.shopify.com/forthcast |
| raw_quantity | Yes | ||
| safety_stock | Yes | ||
| reorder_point | Yes | ||
| rules_applied | Yes | ||
| estimated_cost | No | ||
| value_category | Yes | ||
| demand_category | Yes | ||
| lead_time_category | Yes | ||
| suggested_quantity | Yes | ||
| weeks_of_supply_target | Yes | ||
| days_of_cover_after_delivery | No |