Subcontracting operations
Subcontracting operations coordinate goods that a supplier or customer-side job worker produces. The flow links a finished good to its BOM, service charge, raw-material custody, production work, receipt, delivery, return, and operational status.
This page is a child of Manufacturing and subcontracting. Production planning and in-house execution are covered in Production planning and execution. Stock custody and warehouse behavior are covered in Inventory and warehouse, while the supplier buying handoff is covered in Purchase to pay.
Subcontracting models
ERPNext supports two related models. In the supplier model, the company buys a finished good from a job worker and supplies the raw material. In the inward model, a customer supplies material to the company for processing and receives the produced good back.
| Model | Commercial source | Material owner during processing | Main result |
|---|---|---|---|
| Supplier subcontracting | Subcontracting Purchase Order | Company | Subcontracting Receipt and optional Purchase Receipt |
| Customer inward subcontracting | Subcontracting Sales Order | Customer for marked materials | Manufacture and Subcontracting Delivery |
The two models share the same broad control idea: an order defines the quantity and material basis, stock movements record custody, and production or receipt events update the order. They use different party links and warehouse rules so company-owned and customer-owned material remain distinct.
References: erpnext/…/subcontracting.py• L18-120 erpnext/…/subcontracting.py• L14-69 erpnext/…/subcontracting_order.json• L91-125 erpnext/…/subcontracting_inward_order.json• L64-80
Supplier subcontracting lifecycle
Supplier subcontracting turns a purchase need into supplier work, controlled material transfer, and returned stock. The Purchase Order provides the commercial service line. The Subcontracting Order provides the operational work package.
The following flow shows how the main records move from demand to returned goods.
flowchart LR
D[Production Plan or purchase need] --> PO[Subcontracting Purchase Order]
PO --> SO[Subcontracting Order]
SO --> T[Send raw material to supplier]
T --> R[Subcontracting Receipt]
R --> PR[Purchase Receipt]
R --> S[Finished goods and cost]
T --> RT[Return unused material]
The order can be created from a submitted subcontracting Purchase Order. It cannot add work after the purchase quantity is fully covered. Receipt quantities update both the order and the purchase-side progress. A Subcontracting Order row also stays aligned with the state of its Purchase Order row, so a closed purchase row cannot receive new subcontracting work or be reopened behind the order.
References: erpnext/…/subcontracting.py• L92-120 erpnext/…/subcontracting_order.py• L186-211 erpnext/…/subcontracting_order.py• L276-289 erpnext/…/subcontracting_order.py• L446-490
Subcontracting BOMs
A Subcontracting BOM defines the commercial conversion between a stock finished good and the non-stock service item used to buy the supplier's work. It points to the manufacturing BOM that defines the finished good's material need.
The finished good must be an active stock item marked for subcontracting. Its BOM must belong to the item or its template and must be active and submitted when the Subcontracting BOM is active. The service item must be active and non-stock. The conversion factor expresses service quantity per finished-good quantity. Only one active Subcontracting BOM can apply to a finished good.
This record does not replace the manufacturing BOM. The manufacturing BOM explains what material the supplier needs. The Subcontracting BOM explains how much supplier service the Purchase Order needs for the planned output.
References: erpnext/…/subcontracting_bom.json• L42-124 erpnext/…/subcontracting_bom.py• L33-108 erpnext/…/test_subcontracting_bom.py• L21-120
Purchase Orders and service items
A subcontracting Purchase Order buys a service item against a finished good. The finished good and its quantity remain the business output, while the service item and its quantity represent the supplier charge. The Purchase Order validates that the finished good is subcontracted, has a usable BOM, and has a positive quantity.
When an active Subcontracting BOM matches the finished good, the system can fill the service item and calculate its quantity from the conversion factor. The Purchase Order can then create a Subcontracting Order, either by user action or by the configured automatic path. Once a Subcontracting Order exists, the Purchase Order item cannot be changed in a way that breaks the operational link.
References: erpnext/…/subcontracting.py• L18-44 erpnext/…/subcontracting.py• L68-108 erpnext/…/subcontracting_bom.py• L143-190
Subcontracting orders
A Subcontracting Order is the active supplier-work record. It links one subcontracting Purchase Order to a job worker, finished goods, required BOMs, service charges, supplied raw materials, warehouses, and optional project or accounting dimensions.
The order keeps three connected views of the work:
- Finished-good rows show the output quantity, target warehouse, BOM, cost, and received quantity.
- Service rows show the non-stock supplier charge tied to its Purchase Order item.
- Supplied-material rows show each BOM material, required quantity, reserve warehouse, supplied quantity, consumed quantity, returned quantity, and remaining company material.
The order status reflects the strongest current operational state. It moves from open work to material transferred, partially received, or completed as stock transfers and receipts post against its rows. “Material Transferred” means every required raw-material item is fully supplied. Users can close or reopen a submitted order through a permission-checked action. Closing releases unused material reservations while preserving reservations already used by transferred or consumed material.
When transferred material exceeds the BOM requirement and the selected backflush basis is the BOM, the receipt step can ask the operator which unfinished-good rows to receive. This keeps excess material from forcing an unintended receipt quantity.
References: erpnext/…/subcontracting_order.py• L130-164 erpnext/…/subcontracting_order.py• L213-289 erpnext/…/subcontracting_order.py• L446-490 erpnext/…/subcontracting_order.py• L646-675 erpnext/…/subcontracting_order.py• L852-875 erpnext/…/test_subcontracting_order.py• L63-125
Service costing
The supplier's service charge is kept with the finished-good row that caused it. This matters when rows are reordered or when one Purchase Order contains several finished goods. The system matches service rows by their Purchase Order item rather than by table position.
The finished-good rate combines raw-material cost, service cost, and additional cost. Supplier currency is converted to company currency for the cost view. This gives the receipt a cost basis that includes both company-supplied material and the supplier's work.
References: erpnext/…/subcontracting_order.py• L301-344 erpnext/…/test_subcontracting_order.py• L438-468 erpnext/…/subcontracting_order_item.json• L275-297
Material custody
Material custody tracks company-owned raw material while it is at the supplier. A Send to Subcontractor stock movement moves material from a company warehouse to the supplier warehouse and remains linked to the order and the finished good that will consume it.
The movement uses one of two bases:
- BOM basis limits the total sent quantity to the BOM requirement, with the configured transfer allowance.
- Material-transferred basis uses the quantity actually sent as the receipt consumption limit.
The order updates supplied and returned quantities after each submitted movement. A return of unused material reduces the net quantity held by the supplier. Stock reservations can move from the Production Plan to the Subcontracting Order or be created directly for the order. Repeated or partial transfers keep each order reservation tied to its own allocation. Alternative materials remain linked to the original requirement so the original requirement is closed correctly. Reserve warehouses supplied through a Job Card must belong to the order's company. When an order closes, only its unused reservation balance is released.
References: erpnext/…/subcontracting_controller.py• L1344-1467 erpnext/…/subcontracting.py• L14-85 erpnext/…/subcontracting.py• L166-211 erpnext/…/subcontracting_order.py• L531-675 erpnext/…/test_subcontracting_order.py• L748-829 erpnext/…/test_subcontracting_order.py• L1002-1079
Supplier receipts
A Subcontracting Receipt records the supplier's returned output. It separates accepted quantity, rejected quantity, process loss, secondary output, consumed raw material, warehouse placement, and additional cost. Its posting updates stock, cost, the Subcontracting Order, reservations, and linked Job Card progress.
When a receipt is submitted, the system follows this sequence:
- It validates the received quantities and the available supplied material.
- It builds the consumed-material view from the BOM or from transferred material.
- It checks that consumption meets the required material basis.
- It posts accepted output and rejected output to their warehouses.
- It reduces supplier-held raw material and updates order quantities.
- It posts the related accounting result and can create a Purchase Receipt.
An accepted quantity goes to the accepted warehouse. A rejected quantity goes to a separate rejected warehouse. A receipt return reverses the related output and sends back no more raw material than the original receipt consumed. The return must use the same job worker warehouse as the original receipt. Serial and batch links keep these movements traceable. Return rows keep the source receipt's costing and secondary-item links, so repeated partial returns can reach the full returned state without losing output or cost data.
References: erpnext/…/subcontracting_receipt.py• L181-225 erpnext/…/subcontracting_receipt.py• L264-330 erpnext/…/subcontracting_receipt.py• L1115-1225 erpnext/…/test_subcontracting_receipt.py• L360-399 erpnext/…/test_subcontracting_receipt.py• L1284-1323
Receipt costing and secondary items
Receipt cost combines consumed raw material, supplier service, additional costs, and landed cost. BOM secondary items such as scrap, by-products, or co-products remain tied to the finished-good row.
The system first deducts secondary items with their own valuation or manual cost. It then allocates a percentage share of the remaining cost to percentage-based secondary items. The finished-good amount reflects this allocation, so the returned stock and secondary output share one cost view. A return uses the source receipt's rate for the finished good and its secondary items.
Secondary-item quantities come from BOM conversion and can be fractional even when the stock UOM requires whole numbers. The whole-number check applies to user-entered finished-good rows, not to these BOM-derived secondary rows. Partial returns round secondary quantities against the running finished-good total. If a cancelled earlier return leaves a remainder, the return that removes the last finished goods takes the remainder instead of leaving secondary output on the receipt. Older receipt rows without a direct BOM-secondary link are paired by their quantity when a return rebuilds them.
References: erpnext/…/subcontracting_receipt.py• L516-645 erpnext/…/subcontracting_receipt.py• L716-805 erpnext/…/subcontracting_receipt.py• L917-1025 erpnext/…/test_subcontracting_receipt.py• L68-104 erpnext/…/test_subcontracting_receipt.py• L453-506
Receipt accounting
Receipt posting also produces the accounting view for supplier work when perpetual inventory is enabled. It credits consumed material at the supplier warehouse and separates finished-good inventory, service cost, additional cost, landed cost, and any valuation difference.
This keeps the physical result and the cost result connected. The receipt can be reviewed through stock and accounting ledger views before the optional Purchase Receipt carries the commercial receipt forward.
References: erpnext/…/gl_composer.py• L20-31 erpnext/…/gl_composer.py• L33-184 erpnext/…/gl_composer.py• L193-229 erpnext/…/subcontracting_receipt.js• L30-67
Purchase Receipt handoff
A submitted Subcontracting Receipt can create a Purchase Receipt for the service and finished-good purchase lines. The mapping preserves Purchase Order item links, accepted and rejected quantities, process-loss service quantity, warehouses, and the source Subcontracting Receipt.
One Subcontracting Receipt can map to more than one Purchase Order only when their currency, tax, and discount terms can share one Purchase Receipt. The handoff keeps the physical receipt and the supplier invoice path connected. It does not replace the Subcontracting Receipt's stock and consumption record. A receipt can create at most one non-return Purchase Receipt, and automatic creation follows the buying setting.
References: erpnext/…/mapper.py• L31-162 erpnext/…/mapper.py• L165-250 erpnext/…/subcontracting_receipt.py• L1232-1241 erpnext/…/subcontracting_receipt_item.json• L536-552
Customer inward subcontracting
Customer inward subcontracting reverses the ownership direction. A subcontracting Sales Order defines work for a customer. The Subcontracting Inward Order tracks customer-provided raw material, in-house production, finished-good delivery, and returns.
The lifecycle is coordinated through stock movements and a Work Order rather than through the supplier receipt path.
flowchart LR
SO[Subcontracting Sales Order] --> IO[Subcontracting Inward Order]
IO --> CR[Receive customer material]
CR --> WO[Work Order]
WO --> MF[Manufacture finished goods]
MF --> SD[Subcontracting Delivery]
CR --> RR[Return unused customer material]
SD --> SR[Subcontracting Return]
The inward order requires at least one customer-provided raw material for each finished good. A finished-good variant without its own BOM can use the valid BOM from its template. The order records required, received, consumed, returned, produced, delivered, process-loss, and returned-finished-good quantities. Its status moves from open to ongoing, produced, delivered, or returned as these events occur. A submitted order can be closed or reopened through a permission-checked action, but other status values remain calculated from its quantity balances.
References: erpnext/…/subcontracting.py• L14-69 erpnext/…/subcontracting_inward_order.py• L75-160 erpnext/…/subcontracting_inward_order.py• L256-331 erpnext/…/test_subcontracting_inward_order.py• L35-52
Customer material receipt
Receive from Customer moves marked customer-provided items into the customer warehouse linked to the inward order. The movement creates reservations for the received quantity, which makes the material available to the linked production work without treating it as ordinary company supply.
The customer warehouse must belong to the customer. The inward order keeps separate required, received, consumed, returned, and work-order quantities so later production and returns cannot use the same customer stock twice. Additional material can be linked to the finished-good work when the stock movement identifies that relationship. Multiple receipts use the balance on hand to keep the customer-provided material cost current.
References: erpnext/…/subcontracting_inward_order.py• L177-183 erpnext/…/subcontracting_inward_order.py• L381-445 erpnext/…/subcontracting_inward_order.py• L448-492 erpnext/…/test_subcontracting_inward_order.py• L86-165
Customer production and delivery
The inward order can create a Work Order for the remaining quantity that customer material can support. The Work Order uses the customer warehouse as its source for customer-owned material and the inward-order delivery warehouse as its finished-good destination.
Manufacture consumes customer-provided material against the Work Order or the inward order when the Work Order skips a separate transfer. Subcontracting Delivery moves produced finished goods from the delivery warehouse to the customer. Delivery normally stops at the ordered quantity. When Selling Settings allows overproduced delivery, it remains available while produced goods exceed the ordered quantity. Unused customer material and delivered finished goods can be returned through separate return movements. Delivery may include secondary items when the selling setting allows it.
References: erpnext/…/subcontracting_inward_order.py• L273-369 erpnext/…/subcontracting_inward_order.py• L494-635 erpnext/…/test_subcontracting_inward_order.py• L613-728 erpnext/…/test_subcontracting_inward_order.py• L788-833
Operational reporting
Subcontracting reports turn order balances into work queues and progress views. They show what material still needs transfer or receipt, what finished goods still need receipt or delivery, and how each order's raw material and output quantities relate.
| Report view | Operational question | Main measures |
|---|---|---|
| Subcontract Order Summary | What is the status of supplier work and material custody? | Ordered, received, required, supplied, consumed, returned |
| Raw Materials to Be Transferred | What company material is still needed by suppliers? | Required, transferred, returned, pending |
| Items to Be Received | What supplier output is still due? | Required, received, pending |
| Inward Order Summary | What customer material and output belong to each inward job? | Ordered, produced, delivered, returned, required, received, consumed |
| Items to Be Delivered | What produced customer goods still need delivery? | Ordered, produced, delivered, pending |
| Raw Materials to Be Received | What customer material is still expected? | Required, received, returned, process loss, pending |
The reports calculate pending work from linked quantities rather than from status alone. For inward work, pending customer material includes returned material and the material needed for process loss. This lets an operator act on a partial receipt or delivery even when the parent order remains open or ongoing.
The Subcontracting Order dashboard chart adds a monthly view of submitted subcontracting Purchase Orders and their value. It supports a higher-level view of subcontracting demand beside the row-level work queues.
References: erpnext/…/subcontract_order_summary.py• L17-115 erpnext/…/subcontracted_raw_materials_to_be_transferred.py• L48-85 erpnext/…/subcontracted_item_to_be_received.py• L58-96 erpnext/…/subcontracting_inward_order_summary.py• L14-121 erpnext/…/subcontracted_items_to_be_delivered.py• L15-46 erpnext/…/subcontracted_raw_materials_to_be_received.py• L15-93 erpnext/…/subcontracting_order.json• L8-32
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to Subcontracting BOM conversion or service-item rules must preserve the finished-good quantity, service quantity, Purchase Order line, and Subcontracting Order line relation.
- Changes to BOM lookup must preserve the link between an item or item template and its active, submitted manufacturing BOM. This includes variant finished goods in inward orders.
- Changes to Purchase Order subcontracting mapping must preserve the finished-good BOM, finished-good quantity, service quantity, and prevention of edits after an active Subcontracting Order exists.
- Changes to Purchase Order row status checks must preserve the rule that open work cannot use a closed purchase row and cannot reopen over one.
- Changes to supplier material transfer rules must preserve the selected backflush basis, transfer allowance, alternative-item link, serial or batch identity, and supplied-item quantity roll-up.
- Changes to Subcontracting Order service rows must keep service cost matched by Purchase Order item rather than by row position.
- Changes to order reservation and reserve-warehouse rules must preserve company ownership and the allocation of partial, repeated, and cross-source transfers. Closing must release unused balances without cancelling used reservations.
- Changes to receipt consumption or return rules must preserve the balance among required, transferred, consumed, returned, and still-available raw material. A return must not send back more raw material than its receipt consumed.
- Changes to receipt posting must keep stock ledger, accounting, reservations, order status, Job Card quantity, Purchase Receipt mapping, and the original job worker warehouse on returns aligned.
- Changes to receipt secondary-item costing or quantity validation must preserve BOM-derived quantities, own-cost deductions before percentage allocation, source receipt rates on returns, and the distinction between secondary rows and user-entered finished-good rows.
- Changes to receipt return rebuilding must preserve links to the source receipt, legacy-row pairing, running-total rounding, and application of any remaining secondary quantity to the final finished-good return.
- Changes to inward-order stock movements must preserve customer ownership, customer warehouse checks, reservations, Work Order quantity, and delivery or return balances.
- Changes to inward-order delivery controls must keep the client action available when overproduced delivery is allowed and keep the server quantity cap consistent with that setting.
- Changes to inward-order received-item quantities must preserve the distinction between required, received, consumed, work-order, returned, and billed quantities.
- Changes to subcontracting reports must preserve pending-quantity formulas and the links between finished-good rows and raw-material rows.
- Changes to the dashboard chart must preserve its submitted subcontracting Purchase Order filter and monthly value basis.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An active Subcontracting BOM uses a disabled finished good or a non-stock service item | The order cannot express a valid supplier output and service charge | BOM validation requires an active stock finished good and a non-stock service item |
| More than one active Subcontracting BOM exists for one finished good | Purchase and sales flows can select different service conversions | Active-BOM validation permits only one record per finished good |
| A Subcontracting BOM points to a BOM for an unrelated item or to a draft BOM | Supplier material requirements can come from the wrong or unapproved product definition | BOM validation checks the item or template and requires an active submitted BOM for active records |
| A subcontracting Purchase Order lacks a valid finished good, BOM, or positive finished-good quantity | The system cannot build a reliable operational order | Purchase Order validation requires all three values |
| A variant finished good has no own BOM and template fallback is not applied | An inward order cannot create the correct production basis | BOM lookup accepts the valid template BOM for the variant |
| A Subcontracting Order is linked to an unsubmitted, non-subcontracting, or closed Purchase Order row | Supplier work is detached from the commercial commitment | Order validation requires a submitted open subcontracting Purchase Order and open source rows |
| A service item is a stock item | Supplier service can be treated as physical material | Order and BOM validation require non-stock service items |
| A raw-material transfer exceeds the BOM or transferred-material allowance | Company stock can remain with the supplier without order coverage | Stock Entry validation totals submitted transfers and returns against the selected basis |
| A transfer uses a source warehouse that does not match the order's reservation allocation | A valid transfer can consume the wrong reservation or leave the intended reservation open | Transfer allocation uses the order reservation and preserves separate earlier allocations |
| A reserve warehouse filled from a Job Card belongs to another company | Stock can be reserved or moved across company boundaries | Warehouse validation requires the reserve warehouse to belong to the order company |
| A closed order cancels a reservation that already has transferred or consumed stock | Later stock actions lose the reservation history for material already used | Closing releases only unused balance and keeps used reservation rows |
| A receipt consumes more material than the supplier received or than the selected basis allows | Supplier consumption and stock value become overstated | Receipt validation compares consumed quantity with BOM or transferred availability |
| A receipt return sends back more raw material than its original receipt consumed | Supplier-held material and stock value become understated | Return validation caps raw-material return by the receipt's consumed quantity |
| Accepted and rejected quantities are both zero | The receipt has no stock result | Receipt validation requires an accepted or rejected quantity |
| A BOM secondary item produces a fractional quantity in a whole-number UOM | A valid receipt can be blocked even though the quantity comes from the BOM | Whole-number validation applies to finished-good rows and skips BOM-derived secondary rows |
| Repeated partial returns round away the last BOM secondary quantity | The source receipt can remain partly returned with secondary output left behind | The final return of all finished goods takes the remaining secondary quantity |
| A return cannot identify the source row for a legacy secondary item | Secondary output can be returned against the wrong finished-good row | Return rebuilding links current BOM rows directly and pairs older rows by quantity |
| Accepted and rejected warehouses are the same | Good and rejected stock lose their separate custody paths | Receipt validation requires distinct warehouses |
| A receipt return uses a different job worker warehouse from the original receipt | Returned raw material can be posted against the wrong custody location | Return validation requires the original receipt's job worker warehouse |
| A receipt uses a serial or batch not sent to the supplier | Traceability no longer proves material custody | Receipt material checks limit serial and batch use to transferred stock |
| A receipt combines Purchase Orders with incompatible currency, tax, or discount terms | The Purchase Receipt cannot represent one consistent commercial basis | Receipt mapping checks shared terms before combining Purchase Orders |
| Customer material is received into a warehouse that is not owned by the customer | Customer stock can be mixed with the wrong party's stock | Inward-order validation checks customer warehouse ownership |
| Customer material is consumed above received less returned quantity | The inward job consumes material that is not available | Inward manufacture checks Work Order and inward-order balances |
| Inward delivery exceeds produced or ordered quantity while overproduced delivery is disabled | The customer receives output that the job has not made or the order does not allow | Delivery validation caps delivery by produced and ordered quantities |
| Inward delivery leaves produced over-quantity unavailable while overproduced delivery is enabled | Produced goods remain undelivered even though the setting permits them | The inward order keeps the delivery action available while produced quantity exceeds delivered quantity |
| An inward-order return exceeds delivered or available customer material | The system can return more than the job holds | Return validation compares the movement with delivered or received less consumed balances |
Key files
| File | Why to read it |
|---|---|
| erpnext/…/subcontracting_bom.py | Defines the finished-good, service-item, BOM, and conversion rules. |
| erpnext/…/subcontracting_bom.json | Shows the business fields that connect output quantity to supplier service quantity. |
| erpnext/…/subcontracting.py | Connects subcontracting Purchase Orders to finished goods, service items, and Subcontracting Orders. |
| erpnext/…/subcontracting_order.py | Defines supplier work, service cost, supplied material, reservations, status, and receipt creation. |
| erpnext/…/test_subcontracting_order.py | Shows the contracts for service matching, reservation allocation, order close, and receipt creation. |
| erpnext/…/subcontracting_controller.py | Provides the shared material, BOM, serial or batch, and stock-transfer rules. |
| erpnext/…/subcontracting.py | Enforces raw-material transfer limits and updates supplier-held quantities. |
| erpnext/…/subcontracting_receipt.py | Defines supplier receipt validation, costing, stock, accounting, reservations, returns, and order updates. |
| erpnext/…/gl_composer.py | Shows how supplier receipt value becomes accounting entries. |
| erpnext/…/mapper.py | Shows the Purchase Receipt and return handoffs from a supplier receipt. |
| erpnext/…/subcontracting_receipt.js | Shows receipt actions for ledgers, Purchase Receipt creation, returns, and serial or batch custody. |
| erpnext/…/subcontracting_receipt_item.json | Shows receipt quantities, costing, secondary-item links, warehouses, and source purchase links. |
| erpnext/…/subcontracting_inward_order.py | Defines customer material, Work Order creation, inward progress, and delivery or return actions. |
| erpnext/…/test_subcontracting_inward_order.py | Shows the contracts for customer material cost, reservations, production, delivery, and returns. |
| erpnext/…/subcontract_order_summary.py | Provides the supplier order and material custody view. |
| erpnext/…/subcontracting_inward_order_summary.py | Provides the customer inward order, output, and material progress view. |
| erpnext/…/subcontracted_items_to_be_delivered.py | Provides the customer output delivery queue. |
| erpnext/…/subcontracted_raw_materials_to_be_received.py | Provides the customer material receipt queue. |
| erpnext/…/subcontracting_order.json | Defines the monthly dashboard view of submitted subcontracting Purchase Orders. |