Purchase-to-pay lifecycle
The purchase-to-pay lifecycle turns an internal need into a supplier payment. It keeps the demand, supplier offer, purchase commitment, delivery, bill, and settlement connected so the business can track what it ordered, received, billed, and paid.
Lifecycle overview
The usual path starts with a Purchase-type Material Request. It can continue through an RFQ and Supplier Quotation, then a Purchase Order, one or more Purchase Receipts, a Purchase Invoice, and a Payment Entry. Buyers can also create an order directly from demand, and they can pay an advance before the supplier bill exists.
The diagram shows the main handoffs and the two common alternatives.
flowchart LR
MR[Material Request] --> RFQ[Request for Quotation]
RFQ --> SQ[Supplier Quotation]
MR --> PO[Purchase Order]
SQ --> PO
PO --> PR[Purchase Receipt]
PO --> PI[Purchase Invoice]
PR --> PI
PO --> ADV[Payment Entry<br/>advance]
PI --> PAY[Payment Entry<br/>settlement]
Each handoff keeps a parent link and an item-row link. These links let the system measure remaining demand and prevent a later document from consuming more quantity than its source allows. A submitted Purchase Order also exposes the next valid actions for receipt, invoice, payment, or related subcontracting work. [erpnext/…/purchase_order.js• L285-431]
Demand and sourcing
Material requests
The Material Request is the internal statement of what the company needs to buy. It sets the item, quantity, unit, warehouse, required date, company, and other demand context. It is not a supplier commitment.
Submission makes the demand available for sourcing. The request can be split across suppliers or orders, while its item rows track ordered and received progress. A buyer can use the pending rows to create supplier-specific draft Purchase Orders when no quotation round is needed.
The request can also provide the starting price basis for buying. Its pending quantity remains the limit for direct ordering even when later receipt rules allow a separate over-delivery tolerance. Demand planning can continue through inventory replenishment and traceability, while this lifecycle records the supplier-side commitment.
References: erpnext/…/material_request.json• L79-105 erpnext/…/material_request.py• L171-227 erpnext/…/mapper.py• L188-289
Requests for quotation
The Request for Quotation (RFQ) turns selected purchase demand into a supplier offer request. It carries the requested rows and the suppliers invited to respond. A buyer can source only part of a Material Request when the need or supplier group differs.
An RFQ keeps each response tied to the original request row. It supports supplier contact, quotation creation, and offer comparison without losing that source trail. A supplier response is controlled so the same supplier and RFQ do not produce conflicting open offers.
References: erpnext/…/mapper.py• L16-55 erpnext/…/mapper.py• L58-179 erpnext/…/request_for_quotation.py• L70-89
Supplier quotations
The Supplier Quotation records one supplier's offer for an RFQ. It gives the buyer the commercial terms used to choose a supplier and create a Purchase Order.
Only an active submitted offer can create a new order. The mapping uses the quantity still left on each quotation row in that row's unit. This keeps partial orders accurate when the quotation unit differs from the stock unit. The source quotation and its Material Request links remain on the order. [erpnext/…/mapper.py• L18-78]
Quotation status shows whether the offer is still usable. A submitted offer can become Partially Ordered or Ordered as orders consume it. A past-validity submitted offer becomes Expired only when it is not already used by a submitted order. Draft offers are not marked Expired, and an expired offer is rejected even if an old form still shows an order action. [erpnext/…/test_supplier_quotation.py• L76-122]
References: erpnext/…/mapper.py• L18-78 erpnext/…/test_supplier_quotation.py• L76-122 erpnext/…/test_supplier_quotation.py• L141-199
Order and receipt
Purchase orders
The Purchase Order is the company's commercial commitment to a supplier. It records the supplier, items, quantities, rates, dates, warehouses, taxes, payment terms, and company. It can come from a Supplier Quotation or from pending Purchase demand. [erpnext/…/purchase_order.json• L198-250, erpnext/…/purchase_order.json• L895-966]
The order carries the source item links that control later progress. A buyer can combine rows from more than one source, but the remaining quantity for each source row must stay distinct. A row that has been received or returned cannot be removed because that would erase the link needed to explain the downstream transaction. [erpnext/…/test_purchase_order.py• L694-740]
The order supports partial work. Its status and progress fields show whether it is on hold, waiting for receipt, waiting for billing, complete, closed, or delivered. Receiving progress and billing progress use the rows that remain open, so closing a row removes its unfinished quantity from later progress checks. Closing an item row also keeps it out of new receipt or invoice mappings. [erpnext/…/purchase_order.js• L291-352, erpnext/…/purchase_order.js• L700-708, erpnext/…/status.py• L43-78]
Receipt quantity has a different rule from order quantity. A Material Request limits how much can be committed. An item-level over-delivery allowance can later leave a valid quantity to receive even after the ordered quantity is reached. The mapper keeps that remaining quantity and rounds it for whole-number units. [erpnext/…/test_purchase_order.py• L126-212]
Some orders use a different downstream path. Drop-ship rows record delivery to the customer on the order instead of creating a warehouse receipt. Subcontracted rows require a valid finished-good definition and can create a Subcontracting Order when the buying setting enables automatic creation. An open, incomplete Subcontracting Order prevents its Purchase Order row from closing. Closing the Purchase Order closes its submitted Subcontracting Orders, but reopening the Purchase Order does not reopen them. [erpnext/…/purchase_order.py• L461-485, erpnext/…/status.py• L24-41, erpnext/…/subcontracting.py• L18-44, erpnext/…/subcontracting.py• L92-153]
References: erpnext/…/purchase_order.js• L285-431 erpnext/…/purchase_order.js• L700-735 erpnext/…/purchase_order.json• L895-966 erpnext/…/status.py• L24-78 erpnext/…/subcontracting.py• L18-153 erpnext/…/test_purchase_order.py• L126-212 erpnext/…/test_purchase_order.py• L694-740
Purchase receipts
The Purchase Receipt records the physical delivery accepted from the supplier. It normally comes from a submitted Purchase Order and can be created in stages. Each row points to the Purchase Order row and can retain its Material Request link.
Before submission, the receipt checks its source, supplier, company, currency, item, unit, quantity, posting date, and any required quality inspection. It also respects the Purchase Order hold and close states. When the company requires a Purchase Order, every non-return item must carry its order link; returns remain allowed against prior receipts. Accepted and rejected quantities stay in the receipt record so the delivery trail remains clear. [erpnext/…/purchase_receipt.py• L270-350]
Submission updates received quantities on the Purchase Order and Material Request. It also updates linked invoice receipt progress, then posts inventory and receipt accounting when those features apply. A Purchase Invoice with stock update can supply the same received progress, so the order does not count that stock receipt twice. A return is a linked negative receipt that reduces usable received quantity without deleting the original delivery. [erpnext/…/purchase_receipt.py• L154-261, erpnext/…/purchase_receipt.py• L369-417, erpnext/…/test_purchase_receipt.py• L843-877]
Receipts and invoices can arrive in either order. A Purchase Invoice can be made from an order before receipt. When that invoice later needs to cover several receipts, the billed amount is assigned from the oldest receipt forward. The same allocation handles mixed order and receipt invoices, invoice-created receipts, returns, and rate-based billing without counting the invoice twice. [erpnext/…/test_purchase_receipt.py• L878-1027, erpnext/…/test_purchase_receipt.py• L1029-1174, erpnext/…/test_purchase_receipt.py• L1193-1230, erpnext/…/test_purchase_receipt.py• L1296-1503]
For the warehouse effects of receiving and returning goods, see Inventory and warehouse.
References: erpnext/…/purchase_receipt.py• L154-261 erpnext/…/purchase_receipt.py• L270-397 erpnext/…/test_purchase_receipt.py• L458-628 erpnext/…/test_purchase_receipt.py• L843-877 erpnext/…/test_purchase_receipt.py• L878-1174 erpnext/…/test_purchase_receipt.py• L1193-1230 erpnext/…/test_purchase_receipt.py• L1296-1503
Billing and payment
Purchase invoices
The Purchase Invoice records the supplier bill and creates the payable amount. It can be made from a Purchase Order or Purchase Receipt when the buying rules allow that path. Its rows retain the order and receipt row links so partial billing can follow partial delivery.
An invoice made from a receipt uses the quantity that is received and still unbilled. An order-based invoice can use the remaining order quantity when the business rules permit it. Submission updates upstream billed progress and creates the supplier liability. When a receipt already recorded stock, the invoice clears the received-but-not-billed balance instead of recording the stock movement again.
References: erpnext/…/test_purchase_order.py• L1091-1129 erpnext/…/test_purchase_receipt.py• L157-213 erpnext/…/test_purchase_receipt.py• L878-1027
Payment entries
The Payment Entry records money paid to a supplier. It can settle one or more Purchase Invoices, or it can record an advance against a Purchase Order before an invoice exists. Its reference rows state which document and amount the payment covers.
Payment validation checks the supplier, accounts, currency, payment type, references, and allocated amounts. The allocation cannot exceed the latest outstanding amount. Submission reduces the linked payable, while cancellation reverses that settlement. The wider accounting effect is described in Accounting and finance.
References: erpnext/…/payment_entry.py• L121-138 erpnext/…/payment_entry.py• L173-212 erpnext/…/payment_entry.py• L667-731
Link and status model
Document links
The lifecycle uses parent links and item-row links. A parent link identifies the earlier business document. An item-row link identifies the exact demand, offer, order, or receipt row being fulfilled. The row link matters when one request is split across suppliers or when delivery and billing happen in parts.
| Handoff | Link carried forward | Progress represented |
|---|---|---|
| Material Request to RFQ | Request and request item | Demand sent for sourcing |
| RFQ to Supplier Quotation | RFQ and RFQ item | Supplier response received |
| Supplier Quotation to Purchase Order | Quotation and quotation item | Quantity committed |
| Purchase Order to Purchase Receipt | Order and order item | Quantity received |
| Purchase Order or Receipt to Purchase Invoice | Order and receipt items | Quantity and value billed |
| Purchase Order or Invoice to Payment Entry | Order or invoice reference | Amount advanced or paid |
References: erpnext/…/mapper.py• L97-139 erpnext/…/mapper.py• L40-49 erpnext/…/mapper.py• L47-71 erpnext/…/purchase_receipt.py• L156-203
Quantity and status flow
Submitted downstream documents update progress on their linked upstream rows. Orders increase ordered quantity on demand or quotations. Receipts increase received quantity on orders and demand. Invoices increase billed quantity. Payments reduce the invoice balance.
The model allows partial completion at every stage. Cancellation and returns reverse linked progress through explicit documents. Closed rows stop being expected in later mappings, while a returned row remains in the history needed to explain the changed quantity.
References: erpnext/…/test_supplier_quotation.py• L141-199 erpnext/…/status.py• L43-78 erpnext/…/test_purchase_order.py• L1051-1129 erpnext/…/purchase_receipt.py• L154-260
Accounting and inventory boundaries
The Purchase Receipt is the inventory boundary. Its submission records stock or asset value and places the corresponding amount in a received-but-not-billed clearing account. The Purchase Invoice creates the supplier liability and clears that temporary balance when it refers to the receipt.
The receipt accounting also covers non-stock provisional expense, rejected material, landed cost, subcontracting cost, and value differences. For Standard Cost items, the difference between receipt value and standard stock value goes to Purchase Price Variance. When a receipt is made from a foreign-currency invoice at a different rate, the exchange difference is rounded and the gain or loss rows keep matching company-currency amounts. [erpnext/…/gl_composer.py• L15-38, erpnext/…/gl_composer.py• L81-191, erpnext/…/gl_composer.py• L403-443, erpnext/…/test_purchase_receipt.py• L391-428, erpnext/…/test_purchase_receipt.py• L1193-1221]
Rejected material that stays in the in-transit warehouse is part of the row's existing stock movement. It does not create a second rejected-material stock entry. This keeps the receipt value aligned with the stock ledger for internal receipt paths. [erpnext/…/purchase_receipt.py• L508-523, erpnext/…/gl_composer.py• L380-419]
For the wider procurement context, see Procurement and supplier operations. For related stock and accounting views, see Inventory and warehouse and Accounting and finance.
References: erpnext/…/gl_composer.py• L15-38 erpnext/…/gl_composer.py• L81-191 erpnext/…/gl_composer.py• L227-443 erpnext/…/test_purchase_receipt.py• L391-428 erpnext/…/test_purchase_receipt.py• L1193-1221
Change checklist
When these files or sections are changed, remember to consider these:
- Keep source parent links and item-row links aligned across every mapper. Quantity and status updates depend on the exact row identity.
- Keep Supplier Quotation remaining-quantity rules in the quotation unit. Do not select rows using stock quantity and then map a different unit basis.
- Keep quotation expiry checks in both the order action and server-side mapping. A hidden form action must not be the only guard.
- Keep Purchase Order row updates aligned with receipt, invoice, return, and item-close behavior. A received or returned row must remain explainable.
- Keep Purchase Order status calculations aligned with closed rows and with the linked Subcontracting Order state. Closing or reopening one document must not silently reopen another.
- Keep Purchase Order submit and close behavior aligned with automatic Subcontracting Order creation and closure settings.
- Keep Material Request over-order limits separate from Purchase Order over-delivery limits. They protect different lifecycle stages.
- Keep the Purchase Order interface and mapper aligned for pending receipt quantity, whole-number units, drop-ship rows, and closed rows.
- Keep receipt source checks aligned with stock and invoice paths, including posting dates, quality checks, Purchase Order requirements, and returns against closed orders. An invoice that updates stock must not create a second stock receipt path.
- Keep receipt billing allocation aligned with direct receipt invoices, order invoices, invoice-created receipts, returns, mixed billing, and rate changes. Amount and quantity must be consumed together.
- Keep receipt stock valuation aligned with the stock ledger when a rejected quantity stays in transit. Do not add a second movement for the same row.
- Keep exchange difference rounding and account-currency amounts aligned between receipt GL entries and foreign-currency invoice receipts.
- Keep Standard Cost variance account selection aligned with the value difference booked at receipt.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An order maps an expired or already consumed quotation | A new commitment uses an offer that is no longer available | Check computed quotation status and map only remaining row quantity |
| A quotation row is selected in stock units but mapped in its purchase unit | Partial orders over- or under-consume the supplier offer | Use one remaining-quantity basis in the quotation row unit |
| A received or returned Purchase Order row is removed | Later documents lose the source needed to explain receipt or return progress | Keep rows with downstream activity and reject their removal |
| Receipt mapping drops a fully received row with allowed over-delivery | A permitted delivery cannot be recorded | Map the remaining item allowance and apply whole-number unit limits |
| A receipt uses a held, closed, invalid, or future-dated source | Physical stock or progress is recorded against an invalid commitment | Validate source state, links, quality, posting date, and quantity before submission |
| A normal receipt is submitted without a Purchase Order when the setting requires one | Receipt progress bypasses the approved order path | Require an order link for non-return items and allow the exception only for returns |
| A Purchase Order row is closed while an open incomplete Subcontracting Order still uses it | Supplier work remains active but the source row no longer expects fulfillment | Block row closure until the Subcontracting Order is complete or closed |
| An order invoice is assigned in full to every related receipt | Receipt billing and completion are overstated | Allocate the invoice amount once from the oldest eligible receipt forward |
| Billing status repair strips or overwrites an invoice-created receipt | Receipt links no longer explain the invoice and later progress is wrong | Preserve invoice-created receipts and recalculate only affected order-linked rows |
| A receipt and invoice both record the same stock movement | Inventory and received-but-not-billed balances are wrong | Let one path own stock movement and let the other clear its balance |
| Rejected material stays in transit but receives a second stock entry | Stock value is duplicated | Treat the existing in-transit row movement as the value source |
| Foreign-currency exchange difference rows use mismatched company-currency amounts | The receipt GL does not balance as expected | Round the difference and use matching debit and credit account-currency amounts |
Key files
| File | Why to read it |
|---|---|
| erpnext/…/mapper.py | Shows how purchase demand becomes sourcing documents or direct orders. |
| erpnext/…/mapper.py | Shows how demand becomes supplier responses while keeping source links. |
| erpnext/…/mapper.py | Shows quotation expiry checks and remaining-quantity order mapping. |
| erpnext/…/test_supplier_quotation.py | States the expected partial-order and expiry behavior for supplier offers. |
| erpnext/…/purchase_order.js | Shows the order actions and the visible fulfillment paths. |
| erpnext/…/purchase_order.json | Defines the order's supplier commitment and progress fields. |
| erpnext/…/purchase_order.py | Connects Purchase Order submission and cancellation to upstream progress and downstream subcontracting work. |
| erpnext/…/status.py | Defines Purchase Order progress, status changes, and closed-row handling. |
| erpnext/…/subcontracting.py | Defines the Purchase Order boundary with subcontracting work. |
| erpnext/…/test_purchase_order.py | States the expected order, receipt, return, row, and partial-quantity behavior. |
| erpnext/…/purchase_receipt.py | Defines receipt validation, linked progress, returns, and stock effects. |
| erpnext/…/gl_composer.py | Explains the receipt boundary between stock value, clearing, variance, and exchange effects. |
| erpnext/…/test_purchase_receipt.py | States the expected receipt billing, return, valuation, mixed-billing, and foreign-currency behavior. |
| erpnext/…/purchase_invoice.py | Defines payable validation and invoice-side lifecycle effects. |
| erpnext/…/mapper.py | Shows how invoice and receipt links are carried into later documents. |
| erpnext/…/payment_entry.py | Defines supplier payment references, allocation checks, and settlement effects. |