Sales and Purchase Cycle in ERPNext: Technical Flow from Order to Accounting
Introduction
ERPNext handles Sales and Purchase not as isolated transactions but as a tightly connected business lifecycle. Each document created by users triggers validations, stock movements, tax calculations, and accounting entries behind the scenes.
A clear understanding of this flow is mandatory for ERPNext consultants, finance teams, and implementation engineers to avoid stock mismatches, incorrect profit calculation, and audit failures.
Business Transaction → Operational Document → Stock Ledger → General Ledger
1. ERPNext Sales & Purchase Architecture Overview
ERPNext follows a document-driven ERP architecture. Every business event is recorded as a DocType, and each DocType is responsible for a specific operational or accounting role.
Sales and Purchase cycles span across multiple modules, but all converge at the Stock and Accounts engines.
| Layer | Role |
|---|---|
| Selling / Buying | Commercial transactions |
| Stock | Inventory movement & valuation |
| Accounts | GL posting & financial impact |
DocType Controller → validate() → on_submit() → Ledger Update
2. Lead and Opportunity – Pre-Sales Layer
Leads and Opportunities are pre-sales tracking documents. They help in forecasting revenue but do not impact inventory or accounting.
Lead → Opportunity → Quotation
| Document | Stock Impact | Accounting Impact |
|---|---|---|
| Lead | No | No |
| Opportunity | No | No |
3. Quotation – Commercial Proposal Logic
Quotation defines pricing, discounts, and taxes offered to a customer. ERPNext applies price list rules and validates item master data.
net_rate = price_list_rate - discount
amount = net_rate * qty
| Field | Description |
|---|---|
| Price List | Base selling rate |
| Discount % | Commercial concession |
4. Sales Order – Contractual Control Document
Sales Order is the legally and operationally binding document. It controls delivery, stock reservation, credit exposure, and production planning.
Quotation → Sales Order → Delivery Note → Sales Invoice
| Setting | Effect |
|---|---|
| Reserve Stock | Blocks available quantity |
| Delivery Date | MRP dependency |
5. Customer Credit Limit Validation
ERPNext prevents over-selling by validating customer credit limit at Sales Order stage.
if outstanding_amount + order_total > credit_limit:
frappe.throw("Credit limit exceeded")
| Component | Included |
|---|---|
| Outstanding Invoices | Yes |
| Draft Orders | Optional |
6. Pick List – Warehouse Execution Layer
Pick List translates Sales Orders into warehouse-level execution instructions. It helps identify exact bins and warehouses.
Sales Order → Pick List → Delivery Note
| Warehouse | Allocated Qty |
|---|---|
| Main Store | 8 |
| Reserve Store | 2 |
7. Delivery Note – Physical Stock Movement
Delivery Note is the point where inventory actually moves out of the warehouse. Submitting it creates Stock Ledger Entries.
| Field | Value |
|---|---|
| Actual Qty | -10 |
| Warehouse | Finished Goods |
SLE.actual_qty = -qty
SLE.valuation_rate = calculated_rate
8. Stock Valuation and Cost of Goods Sold
ERPNext calculates valuation using FIFO or Moving Average based on item settings. COGS is derived automatically during delivery.
COGS = outgoing_qty × valuation_rate
| Method | Usage |
|---|---|
| FIFO | Batch-wise costing |
| Moving Average | Weighted costing |
9. Sales Invoice – Revenue Recognition
Sales Invoice records revenue and customer receivable. It is the primary accounting document in the sales cycle.
| Account | Debit | Credit |
|---|---|---|
| Debtors | Yes | No |
| Income | No | Yes |
10. Sales Tax Calculation Logic
ERPNext supports multiple tax components, inclusive pricing, and item-wise tax rules.
tax_amount = net_total × tax_rate / 100
grand_total = net_total + total_tax
11. Accounts Receivable Lifecycle
Once invoiced, the amount remains outstanding until cleared via Payment Entry.
Invoice → Outstanding → Payment Entry
| Status | Meaning |
|---|---|
| Unpaid | Open AR |
| Paid | Cleared |
12. Sales Payment Entry
Payment Entry records cash or bank receipts and clears receivable balances.
| Account | Effect |
|---|---|
| Bank | Debit |
| Debtors | Credit |
13. Material Request – Demand Generation
Material Requests initiate procurement based on stock shortage or production demand.
| Type | Purpose |
|---|---|
| Purchase | External buying |
| Transfer | Internal movement |
14. Request for Quotation (RFQ)
RFQ helps compare supplier pricing and lead time before finalizing a purchase.
| Supplier | Rate | Lead Time |
|---|---|---|
| A | 100 | 7 days |
| B | 95 | 10 days |
15. Purchase Order – Procurement Commitment
Purchase Order is a legal commitment to the supplier and controls quantity and price.
RFQ → Supplier Quotation → Purchase Order
16. Purchase Receipt – Stock Inflow
Purchase Receipt updates stock and creates incoming Stock Ledger Entries.
| Qty | Incoming Rate |
|---|---|
| 20 | 120 |
17. Landed Cost Voucher
Landed Cost Voucher distributes freight, customs, and insurance into item valuation.
allocated_cost = item_value / total_value × charges
18. Purchase Invoice – Liability Recognition
Purchase Invoice records supplier payable and accounting impact.
| Account | Debit | Credit |
|---|---|---|
| Expense / Stock | Yes | No |
| Creditors | No | Yes |
19. Stock vs Expense Purchase Accounting
ERPNext posts accounting based on item type configuration.
| Item Type | Posting |
|---|---|
| Stock | Inventory |
| Service | Expense |
20. Purchase Tax Handling
Supports input tax credit, reverse charge, and multiple tax templates.
input_tax_credit = tax_amount
21. Accounts Payable Lifecycle
Supplier invoices remain outstanding until Payment Entry is made.
Purchase Invoice → Outstanding → Payment Entry
22. Supplier Payment Entry
Payment Entry clears payable and credits bank or cash.
| Account | Effect |
|---|---|
| Creditors | Debit |
| Bank | Credit |
23. Document Traceability and Audit Trail
ERPNext maintains full document linkage for audits and troubleshooting.
SO → DN → SI → Payment
PO → PR → PI → Payment
24. Period Closing and Reconciliation
Period Closing Voucher locks accounting periods and prevents backdated entries.
| Purpose | Result |
|---|---|
| Lock Period | Audit safety |
25. Common Issues and Best Practices
Most implementation issues arise from skipping standard document flow.
- Always use Delivery Note for stock sales
- Avoid direct Sales Invoice for inventory
- Reconcile stock monthly
- Validate item and account mapping
Conclusion
The Sales and Purchase cycle in ERPNext is a deeply integrated operational and accounting framework. Every document influences inventory valuation, taxation, receivables, payables, and profit.
A strong technical understanding of this flow ensures clean audits, accurate reporting, and scalable ERP implementations.

No comments yet. Login to start a new discussion Start a new discussion