MRP Calculations
The core of the MRP Tools is a background process that calculates the material plan. This process runs asynchronously and populates the MRP Entry table, which serves as the data source for the MRP Workbench. The calculation is designed to be idempotent, meaning it clears all previous data before generating the new plan to ensure accuracy.
1. MRP Settings
The MRP Settings doctype allows you to configure various parameters for the MRP calculation:
- Custom Item Lead Time Field: This setting allows you to select an Item DocField to be used as the primary lead time (in days) for procurement or manufacturing. By default, this is
lead_time_days. - Item Additional Lead Time Field: Optionally, you can select another Item DocField to add to the primary lead time. This is useful for incorporating custom lead time factors.
- Custom Purchase Order Item Delivery Date Field: This setting allows you to select a mandatory Date DocField from the
Purchase Order Itemdoctype. This field will be used as the delivery date for calculatingOrdered Qtyin the MRP run. By default,schedule_dateis used. - Custom Re-order Qty Item Field: Here you can select another
ItemDocField to be used as the Re-order Quantity. Defaults to the 'Minimum Order Qty' field. - Assume Remaining Quantity: When calculating scheduled receipts from open Purchase Orders, this setting determines whether to include partially received order items. If enabled, the remaining unreceived quantity is considered as expected supply. If disabled, partially received items are ignored.
Variables/Measures Display Settings
The Variables/Measures Display Settings tab controls which planning metrics are visible as detail rows when you expand an item in the MRP Workbench. Each of the 13 available measures has a checkbox. Unchecking a measure hides its detail row from the workbench and removes it from the "Select a field" dropdown.
The following measures are enabled by default:
| Measure | Description |
|---|---|
| Projected On Hand (without Suggested Orders) | Projected inventory assuming no new orders are placed |
| Scheduled Receipts | Supply already confirmed via open Work Orders and Purchase Orders |
| Suggested Receipts | Quantity the MRP suggests should be received in each period |
| Projected On Hand (with Suggested Orders, excl Safety Stock) | Projected inventory including suggested orders, before safety stock buffer |
| Projected On Hand (with Suggested Orders, incl Safety Stock) | Projected inventory including suggested orders and safety stock |
| Open Sales/Work Orders | Firm demand from open Sales Orders and Work Orders |
| Total Forecast Demand | Demand from forecasts, including BOM-exploded upstream demand |
| Suggested Orders | Quantity to order, offset by lead time — the primary action field |
| Suggested Orders Value | Estimated cost of suggested orders |
| Suggested Orders Payable | Projected cash outflow for suggested (not-yet-placed) orders, based on supplier payment terms |
| Scheduled Receipts Value | Estimated value of open Purchase Order lines due in each period (base currency) |
| Scheduled Receipts Payable | Projected cash outflow for open Purchase Orders, distributed by supplier payment terms |
| Total Payable | Combined cash outflow: Scheduled Receipts Payable + Suggested Orders Payable |
The following measures are disabled by default (enable them for additional detail):
| Measure | Description |
|---|---|
| On Hand (without Suggested Orders) | Beginning-of-period stock, assuming no suggested orders |
| On Hand (with Suggested Orders, excl Safety Stock) | Beginning-of-period stock including the effect of suggested orders, excluding safety stock |
| On Hand (with Suggested Orders, incl Safety Stock) | Beginning-of-period stock including the effect of suggested orders and safety stock |
The calculation is executed in several distinct stages:
2. Item and Period Scaffolding
First, the system creates a planning scaffold for all relevant items over the defined time horizon.
- BOM Level Calculation: The process starts by calculating the Bill of Materials (BOM) level for every stock item. It uses a recursive SQL query to determine the deepest level an item appears in any default, active BOM. Top-level items are at level 0.
- Time Horizon Generation: Based on the "Look Ahead" setting in
MRP Settings, the system generates a series of weekly periods (e.g.,2026-W40,2026-W41, etc.). - MRP Entry Creation: An
MRP Entryrecord is created for each item for each week in the look-ahead period. This creates the grid of data that will be populated in the subsequent steps.
3. Raw Signal Population
Next, the system populates the raw input signals for every item and period in a series of set-based SQL passes. No calculations are performed yet — these are just data loads:
- Reserved Qty: Demand from open Sales Orders, grouped by delivery week.
- Reserved Qty for Production: Material requirements from open Work Orders, grouped by planned start week.
- Forecast Demand: Demand from the
MRP Forecastdoctype, grouped by forecast week. - Planned Qty: Expected supply from open Work Orders (manufactured items), grouped by planned start week.
- Ordered Qty and Scheduled Receipts Value: Expected supply and committed spend from open Purchase Orders, grouped by delivery week. The delivery date field and partial-receipt handling are controlled by the
Purchase Order Item Delivery Date FieldandAssume Remaining Quantitysettings inMRP Settings.
4. Level-by-Level Net Explosion
This is the core of the calculation. The system iterates through each BOM level in order (level 0 first, then 1, 2, and so on). At each level, three steps run in sequence:
Step 1 — Roll up totals
The raw signals are summed into planning totals for all items at the current level:
Open Orders= Reserved Qty + Reserved Qty for Production + Upstream Net DemandTotal Forecast Demand= Forecast DemandScheduled Receipts= Planned Qty + Ordered Qty
Step 2 — Calculate Suggested Receipts
For each item at this level, the system calculates how much needs to be produced or purchased, period by period, in chronological order:
- Beginning Inventory:
On Hand Inventoryfor the first period is the current actual stock level. For subsequent periods it is theProjected On Hand Inventoryfrom the previous period. - Net Requirements: Total demand is determined by the "Requirement based on" setting (e.g., Forecast only, Open Orders + Forecast, etc.).
- Shortage:
shortage = on_hand_inventory + scheduled_receipts − demand − safety_stock - Suggested Receipts: If shortage < 0, the system orders enough to cover it, rounded up to the item's
Min Order Qty. If stock and scheduled receipts are sufficient,Suggested Receipts = 0— no production is needed. - Projected Inventory:
on_hand_inventory − demand + scheduled_receipts + suggested_receipts
Step 3 — Net demand explosion (all levels except the last)
Once Suggested Receipts is known for the current level, that quantity is exploded down to child components:
- For each manufactured item at this level where
suggested_receipts > 0, the system multiplies by each BOM component's quantity ratio and writes the result into the child item'sUpstream Net Demandfield. - The demand is dated by shifting the parent's
target_datebackward by the parent's combined lead time (primary + additional). If this shifted date falls before today, it snaps forward to the current week. - Demand from multiple parents is accumulated (additive), not overwritten.
- Because the explosion is anchored on
suggested_receipts— not on raw demand — children only receive upstream demand when the parent genuinely needs to be produced. If the parent's stock already covers its demand,suggested_receipts = 0and no demand propagates to children.
"Forecast only" mode note: Under this mode,
Upstream Net Demandstill flows intoOpen Orders(step 1), butOpen Ordersis ignored when computing demand in step 2 (onlyTotal Forecast Demandis used). A child component with no direct forecast therefore receives zeroSuggested Receipts, even if its parent has a production need. Use "Open Orders + Forecast" if you want upstream production demand to drive component ordering.
5. Finalisation
After all levels have been processed, the system computes the output and action fields:
- Suggested Orders: Each
Suggested Receiptis offset backward by the item's lead time to place aSuggested Orderin the correct earlier period. For example, a suggested receipt in Week 42 for an item with a 2-week lead time generates a suggested order in Week 40. - Days to Reorder: Calculated for the header period (week 0) only. The system finds the first period with a suggested receipt, works backward by the item's lead time, and computes how many days remain. A positive value means there is still time to act; a negative value means the order is already late. If no shortage is projected across the entire horizon, this field shows
—to clearly distinguish "no action needed" from0(order today). Two variants are calculated: one including the safety stock floor and one excluding it. - Cash Requirements: Finally, the system projects the financial impact of the plan across three fields.
- Suggested Orders Value: Calculates the estimated cost of the
Suggested Ordersusing the item's buying price list or valuation rate. - Suggested Orders Payable: Projects the cash outflow for not-yet-placed orders based on the default Supplier's Payment Terms. The due date is calculated relative to the week in which the order would be placed.
- Scheduled Orders Value: Calculates the base-currency value of open Purchase Order lines due in each period, using
(remaining qty × base_rate)from each PO line. This reflects committed spend already on order. - Scheduled Orders Payable: Projects the cash outflow for open Purchase Orders using the same supplier payment terms logic. The due date is calculated relative to the PO delivery week. When a payment term is configured as Order date, the delivery week is used as an approximation since the original PO order date is not tracked per-period.
- Total Payable: The sum of
Scheduled Orders PayableandSuggested Orders Payable— the complete projected cash requirement for the period. - Custom Due Dates: For more precise cash planning, the system supports dynamic due dates on the
Payment Termdoctype. This allows you to split payments based on milestones:- Order date: The payment is calculated relative to when the order is placed (or the delivery week for open POs).
- Shipment date: The payment is calculated relative to the shipment date (order/delivery date + Item's primary lead time).
- Arrival date: The payment is calculated relative to the arrival date (order/delivery date + Item's total lead time).
- If no custom due date is set, the system defaults to the Arrival date.
- If no supplier or payment terms are configured for an item, all payable amounts default to the same period as the order or delivery.
- Suggested Orders Value: Calculates the estimated cost of the
MRP Entry Fields
The following are the key fields calculated for each item in each period:
| Field | Description |
|---|---|
| Item Details | |
item_code | The item being planned. |
bom_level | The calculated BOM level of the item. |
target_date | The target date for the planning period (week). |
reorder_level | The minimum stock level for the item, from the Safety Stock field on the Item master. |
reorder_quantity | The minimum order quantity (MOQ) for the item, from the Min Order Qty field on the Item master. |
lead_time | The lead time (in days) for procuring or manufacturing the item, derived from the 'Item Lead Time Field' and 'Item Additional Lead Time Field' in MRP Settings. |
| Inventory & Demand | |
on_hand_inventory | The stock on hand at the beginning of the period. |
open_orders | Total firm demand for the period: Reserved Qty (Sales Orders) + Reserved Qty for Production (Work Orders) + Upstream Net Demand. |
upstream_net_demand | Net demand exploded from parent items at the level above. Written when a parent's suggested_receipts > 0 and this item appears in the parent's BOM. Accumulated additively from all parents. |
total_forecast_demand | Total demand from MRP Forecasts for this item and period. |
| Supply | |
scheduled_receipts | Total expected supply from open Work Orders and Purchase Orders. |
| Calculations & Projections | |
suggested_receipts | The quantity the MRP calculation suggests should be received in this period to avoid a shortage. |
suggested_orders | The quantity that should be ordered, offset by lead time. This is the primary action field. |
projected_on_hand_inventory | The projected stock on hand at the end of the period after considering all demand, supply, and suggested receipts. |
suggested_orders_value | The estimated value of the suggested orders. |
suggested_orders_value_payable | Projected cash outflow for not-yet-placed orders, distributed by the supplier's payment terms. |
scheduled_receipts_value | Base-currency value of open Purchase Order lines due in this period: SUM((qty − received_qty) × base_rate). |
scheduled_receipts_value_payable | Projected cash outflow for open Purchase Orders, distributed by the supplier's payment terms relative to the PO delivery week. |
total_payable | Combined projected cash outflow: scheduled_receipts_value_payable + suggested_orders_value_payable. |
| Urgency Indicators (header period only) | |
days_to_reorder | Days until the order must be placed, accounting for lead time and safety stock. Negative = already late. Blank (—) when no shortage is projected across the entire horizon. |
days_to_reorder_excl_reorder_level | Same as above, but calculated without the safety stock floor. Blank (—) when no true shortage (excluding safety stock) is projected. |
needs_reorder | Internal flag (1/0) set to 1 when a genuine shortage including safety stock was found. Used by the workbench to distinguish "order today" (0 days) from "no action needed" (—). |
needs_reorder_excl_reorder_level | Same as above, but for the safety-stock-excluded calculation. |