Sales and commerce
Sales and commerce coordinates the customer-facing path from an identified lead to a priced commitment, delivery, payment, and repeat billing. It keeps the customer record as the shared commercial identity while connected sales, stock, accounts, point-of-sale, and portal flows move the transaction toward completion.
Commercial lifecycle
The commercial lifecycle turns sales interest into linked business records. A lead, prospect, or CRM deal can provide the party context for a quotation or order. A submitted quotation can become a sales order, and the order can drive a proforma document, delivery, invoicing, and operational planning. The same customer and item context follows the path so that price, tax, payment, stock, and progress data remain connected.
References: erpnext/…/lead.json• L141-175 erpnext/…/mapper.py• L15-30 erpnext/…/mapper.py• L204-235 erpnext/…/mapper.py• L607-665 erpnext/…/proforma_invoice.py• L47-60
The diagram shows the main path and the two common entry points for a sale.
flowchart LR
Lead[Lead] --> Customer[Customer]
Customer --> Quotation[Quotation]
Lead --> Quotation
Quotation -->|accepted| SalesOrder[Sales Order]
SalesOrder --> Proforma[Proforma invoice]
SalesOrder --> Delivery[Delivery Note]
SalesOrder --> Invoice[Sales Invoice]
Delivery --> Invoice
Invoice --> Payment[Payment and receivable status]
Customer --> POS[Point of Sale]
POS --> Invoice
Leads and customers
The lead is the early sales record for a person or organization. It stores contact and qualification data and can progress through enquiry and quotation stages. The customer is the buyer record used by later commercial documents. During quotation or order creation, the system can reuse an existing customer or create one from a lead or prospect. A CRM deal can also identify the customer context. See Customer relationship management for the wider lead and opportunity lifecycle.
The customer record also supplies the defaults and limits that shape later transactions. It can define the billing currency, selling price list, payment terms, tax context, credit and overdue limits, and the companies in which the customer may transact. When a customer leaves these values empty, the customer group can provide shared payment and credit defaults. A customer default price list must be a selling list, so buying terms cannot enter a sales transaction by mistake. Customer-level rules can require a sales order or delivery note before invoicing. A disabled, frozen, or held customer cannot continue normal new commercial activity until its state allows it. Credit warnings use server-side, company-scoped receivable data and permitted credit contacts. This makes the customer more than a name on a document: it is the shared commercial identity and policy boundary for the sale.
Selling Settings also supplies customer naming, group, territory, and overview defaults through the Customer settings map. This keeps customer creation and customer review aligned with the site's selling policy.
Customer-created quotations use the customer's currency and commercial defaults. The quotation receives the current exchange rate for that currency, so the offer remains usable for cross-currency sales without losing the customer-level billing choice.
Customer records can also represent an internal customer for an inter-company sale. The system allows only one such customer for each represented company, which keeps the internal party identity clear across transactions. The record also carries company-specific credit limits and overdue billing thresholds. An unset customer overdue threshold can inherit the customer group's value, while a customer value takes precedence. These controls can stop a sale or require an approved credit role when the customer has too much open or overdue debt. Overdue amounts use the payment ledger and due-date terms in the company currency, so the limit reflects the receivable state used by invoice views.
The customer page provides direct entry points for opportunities, quotations, sales orders, payment entries, and customer-specific pricing rules. It also presents frequently ordered items and optional item limits, so the customer record can guide both what can be sold and what is likely to be sold next. Customer records may link to supplier records when one party serves both roles.
References: erpnext/…/lead.json• L61-83 erpnext/…/customer.js• L15-50 erpnext/…/customer.js• L256-274 erpnext/…/customer.js• L290-337 erpnext/…/customer.json• L227-277 erpnext/…/customer.json• L580-605 erpnext/…/customer.py• L194-210 erpnext/…/customer.py• L617-798 erpnext/…/mapper.py• L10-33 erpnext/…/test_customer.py• L27-55 erpnext/…/test_customer.py• L72-124 erpnext/…/test_customer.py• L241-331 erpnext/…/test_customer.py• L362-607 erpnext/…/test_customer.py• L663-689 erpnext/…/test_customer.py• L749-779
Customer overview
The customer overview brings the main commercial and receivable signals into the customer record. It presents sales position, sales trend, open pipeline, outstanding invoices, overdue value, advances, ageing, collection days, and credit position for a selected company and time period. Access checks apply to both the customer and company, and accounting values appear only when the viewer has the required accounts access.
The overview is a decision view rather than a new transaction path. It uses the same sales, order, invoice, payment, and permission boundaries as the underlying records, so a restricted user does not see whole-company credit usage or hidden invoice totals. Selling Settings controls whether this dashboard loads when the customer opens; when the setting is off, the customer can load the overview on demand.
References: erpnext/…/customer_overview.py• L15-49 erpnext/…/customer_overview.py• L52-112 erpnext/…/customer_overview.py• L121-151 erpnext/…/customer.py• L117-124 erpnext/…/selling_settings.json• L452-462 erpnext/…/customer.json• L9-25 erpnext/…/test_customer_overview.py• L20-67 erpnext/…/test_customer_overview.py• L79-107
Quotations and sales orders
A quotation presents a time-bound offer with items, prices, discounts, taxes, terms, addresses, and payment terms. Its status records whether the offer is open, partly ordered, ordered, lost, cancelled, or expired. When accepted, the system maps the submitted quotation into a sales order and carries only still-available item quantities. This supports partial acceptance, alternative items, unit-price items, and unit-of-measure conversion without losing the source relationship.
The quotation can represent different commercial parties while it is still part of the sales pipeline. It keeps the party, company, validity date, price list, currency, tax, payment, and campaign context needed to make the offer meaningful to the recipient. The selling settings can allow an expired quotation to become a sales order when the business chooses to keep that path open. When a quotation uses a blanket order, the system checks that the blanket order is an open selling commitment for the same customer and currency before the quotation proceeds. Its item and rate terms remain part of that commitment.
Marking a quotation as lost requires write access and is not allowed after the quotation is fully or partly ordered. This keeps the offer outcome aligned with the sales order already created from it.
References: erpnext/…/quotation.js• L9-21 erpnext/…/quotation.js• L113-149 erpnext/…/quotation.json• L11-31 erpnext/…/quotation.py• L108-128 erpnext/…/quotation.py• L171-192 erpnext/…/quotation.py• L368-406 erpnext/…/mapper.py• L15-178 erpnext/…/quotation_item.json• L175-231 erpnext/…/selling_settings.json• L229-236 erpnext/…/blanket_order.py• L150-197 erpnext/…/blanket_order.py• L421-439 erpnext/…/test_quotation.py• L360-390 erpnext/…/test_quotation.py• L668-682
The sales order is the committed request to supply goods or services. It records the customer, delivery dates, warehouse context, commercial totals, payment schedule, and progress toward picking, delivery, and billing. It can reserve stock and can branch into the work needed to meet the commitment, such as material requests, purchase orders, work orders, production plans, projects, maintenance work, or subcontracting.
The order keeps its source quotation and item links while later teams act on the commitment. These links let the system create only the remaining quantity for a delivery or invoice. They also preserve the context for returns, supplier delivery, product bundles, subcontracting, and different units of measure. A stock-bearing product bundle uses one active, submitted, enabled version for its parent item. Its component rows determine whether the order needs warehouse delivery and stock reservation. Reservation covers direct order items and packed bundle components, then changes as delivery, closure, or cancellation changes the remaining commitment. The order can reserve stock automatically or through an explicit reservation action. A stock-bearing item or bundle must have a source warehouse. Picking uses the remaining quantity of each bundle component in its stock unit, while material requests keep the planned unit for downstream supply work. The order checks customer credit at submission.
Service rows can skip delivery when the selling setting allows it, while bundles with stock-bearing components still require delivery. Drop-shipped rows use supplier receipt progress instead of warehouse delivery. A subcontracted order ties each service row to a valid finished good and bill of materials, then can create inward work for that finished good. Once submitted inward work exists, the related order items cannot be changed freely.
Purchase orders made from an overdue sales order use the current date as their required date, so an old sales commitment does not create an already-due procurement request. A sales-order row already linked to a purchase order cannot be removed because that would break the supply trace.
A submitted order can also produce a proforma invoice. A proforma invoice is a customer-facing statement of selected order items before the final receivable invoice. It supports quantity-based or amount-based values, keeps the source order link, and creates a private PDF when issued. It does not change delivery or billing progress on the source order. Issued quantities and amounts remain tied to the order so later proforma documents do not repeat the same value.
Customer-facing documents can use the standard Classic layouts for quotations and sales orders. These layouts present the party, dates, item rows, and commercial totals in a consistent form for external communication.
References: erpnext/…/sales_order.js• L8-23 erpnext/…/sales_order.js• L80-176 erpnext/…/sales_order.js• L970-1221 erpnext/…/sales_order.js• L1552-1633 erpnext/…/sales_order.py• L59-220 erpnext/…/sales_order.py• L268-305 erpnext/…/sales_order.py• L382-435 erpnext/…/sales_order.py• L487-505 erpnext/…/sales_order.py• L580-727 erpnext/…/sales_order.py• L826-915 erpnext/…/reservation.py• L23-61 erpnext/…/status.py• L21-104 erpnext/…/status.py• L114-171 erpnext/…/subcontracting.py• L16-69 erpnext/…/mapper.py• L62-159 erpnext/…/mapper.py• L421-665 erpnext/…/mapper.py• L789-918 erpnext/…/mapper.py• L985-1095 erpnext/…/product_bundle.py• L50-91 erpnext/…/product_bundle.py• L129-207 erpnext/…/proforma_invoice.py• L47-151 erpnext/…/proforma_invoice.py• L207-280 erpnext/…/quotation_classic.json• L12 erpnext/…/sales_order_classic.json• L12 erpnext/…/sales_order.json• L1-12 erpnext/…/test_sales_order.py• L340-469 erpnext/…/test_sales_order.py• L597-721 erpnext/…/test_sales_order.py• L969-1113 erpnext/…/test_sales_order.py• L1502-1530 erpnext/…/test_sales_order.py• L2020-2455 erpnext/…/test_sales_order.py• L2548-2672 erpnext/…/test_sales_order.py• L3862-3984 erpnext/…/test_sales_order.py• L4649-4673
Fulfillment and invoicing
Fulfillment turns an accepted order into a stock movement or service delivery. A Delivery Note records what leaves the warehouse and links each delivered row to its source order or invoice. A Sales Invoice records the amount due and updates billing progress. Businesses can deliver before billing, bill before delivery when allowed, or use a sales invoice that also updates stock. Returns reverse the commercial and stock effect through linked return documents. Invoice creation also checks access to linked addresses and items, so an order does not grant access to unrelated data. See Sales fulfillment for the detailed delivery flow and Accounting and finance for the receivable side.
References: erpnext/…/delivery_note.py• L282-319 erpnext/…/sales_invoice.py• L306-400 erpnext/…/sales_invoice.py• L443-499 erpnext/…/mapper.py• L515-520 erpnext/…/test_sales_order.py• L615-795 erpnext/…/test_sales_order.py• L931-967 erpnext/…/test_sales_order.py• L1458-1474 erpnext/…/test_sales_order.py• L3037-3094
For delivered goods that need customer installation or service completion, an Installation Note can be created from an eligible Delivery Note. It carries the customer, address, contact, and delivered item context so the commercial delivery can lead into a recorded service outcome. The installation record checks that its source delivery is submitted, that the item and serial or batch context match, and that installation does not predate delivery.
References: erpnext/…/installation_note.py• L49-91 erpnext/…/installation_note.py• L94-190
The order keeps separate picking, delivery, and billing progress so an order can be partly prepared, delivered, or billed. These measures drive statuses such as To Deliver and Bill, To Deliver, To Bill, and Completed. Hold and close states pause or end further work, while item-level closure removes a row from expected delivery and billing. Closing the order requires reserved stock to be released first. Reopening a closed order rechecks customer credit and the related blanket commitment. Delivery schedules can divide an order row across dates without exceeding the ordered quantity. For drop shipping and subcontracting, progress can also depend on the related purchase or inward work.
The order calendar exposes scheduled delivery events only through the user's permitted sales-order view. The links let later documents validate the customer, company, currency, item, and unit context against the source order. The invoice selection path offers only open order rows with remaining billable quantity or amount after billing and returns, while allowing configured over-billing and unit-price rules. It lists eligible orders from oldest to newest so pending billing work is handled in a stable order. Sales orders also carry commission context into delivery notes and sales invoices, which lets sales partner reporting follow the commercial value across order, delivery, invoice, and POS transactions.
References: erpnext/…/status.py• L30-75 erpnext/…/status.py• L77-171 erpnext/…/sales_order.py• L657-689 erpnext/…/sales_order.py• L866-902 erpnext/…/delivery_note.py• L296-319 erpnext/…/sales_invoice.py• L271-288 erpnext/…/mapper.py• L239-247 erpnext/…/mapper.py• L607-665 erpnext/…/sales_order_analysis.py• L54-130 erpnext/…/sales_orders_outstanding.json• L4-32 erpnext/…/test_sales_order.py• L80-186 erpnext/…/test_sales_order.py• L368-489 erpnext/…/test_sales_order.py• L2020-2247 erpnext/…/test_sales_order.py• L2441-2466 erpnext/…/test_sales_order.py• L3013-3094 erpnext/…/test_sales_order.py• L3986-4055
Sales analytics
Sales Analytics gives teams a time-based view of submitted commercial activity. It can show value or quantity by customer, item, customer group, item group, territory, order type, or project. The report also supports a combined view across quotations, orders, deliveries, invoices, due invoices, and payments.
The report groups results into weekly, monthly, quarterly, half-yearly, or fiscal-year periods. Users can restrict the result to selected entities, and the report keeps those rows aligned with the chart. Company permissions limit the source records, while a parent company can include its subsidiary companies when aggregation is enabled. Sales Order Analysis adds order-level delivery, billing, pending value, and delay measures, while the Sales Orders Outstanding format turns its pending quantities into a printable operational view.
References: erpnext/…/sales_analytics.py• L14-36 erpnext/…/sales_analytics.py• L55-123 erpnext/…/sales_analytics.py• L204-230 erpnext/…/sales_order_analysis.py• L18-54 erpnext/…/sales_order_analysis.py• L54-130 erpnext/…/sales_orders_outstanding.json• L4-32
Quotation trends
Quotation Trends gives an earlier view of commercial demand before orders exist. It groups submitted quotation quantity and amount into fiscal or calendar periods, and it can base rows on an item, customer, or another sales dimension while grouping them by a second dimension. Its chart uses the same detail values as the table, so period totals support both review and comparison.
The report resolves party details for leads, prospects, and customers. This keeps a quotation tied to the right party name and territory even when the quotation has not yet created a customer.
References: erpnext/…/quotation_trends.py• L9-18 erpnext/…/quotation_trends.py• L21-69 erpnext/…/test_quotation_trends.py• L15-36 erpnext/…/test_quotation_trends.py• L44-120
Sales funnel and pipeline views
The Sales Funnel page gives teams a simple view of movement from lead creation through opportunity, quotation, and conversion to customer. It uses a date range and company as the reporting scope, and its counts show how many records reached each stage during that period.
References: erpnext/…/sales_funnel.py• L12-102
The same page shows opportunity value by sales stage. It converts amounts to the default currency and weights them by probability, so pipeline values represent expected rather than only raw opportunity value. Users can group the view by UTM source, campaign, or medium to relate pipeline value to its marketing origin.
References: erpnext/…/sales_funnel.py• L105-215
Customer sales signals
The customer record also exposes focused sales and receivable signals for one customer and company. This view complements aggregate sales reports by showing the customer’s current position, trend, pipeline, and payment exposure within the viewer’s permission scope.
References: erpnext/…/customer_overview.py• L15-112 erpnext/…/customer_overview.py• L154-211
Sales partner commissions
Sales partner commission reporting connects submitted sales activity to the partner who sourced it. The report accepts Sales Orders, Sales Invoices, Delivery Notes, and POS Invoices. It uses order date for sales orders and posting date for the other transaction types. It excludes documents without a sales partner, and company permissions restrict which rows a user can see.
The report shows transaction amount, commission rate, and total commission. It includes submitted returns as negative commercial activity when the source document supports returns, while cancelled and draft documents remain outside the result. An item can keep its commission rate even when commission is no longer granted, so the report can show the recorded rate with zero earned commission.
References: erpnext/…/sales_partner_commission_summary.py• L16-18 erpnext/…/sales_partner_commission_summary.py• L50-68 erpnext/…/sales_partner_commission_summary.py• L92-124 erpnext/…/sales_partner_commission_summary.py• L156-180 erpnext/…/test_sales_partner_commission_summary.py• L59-96 erpnext/…/test_sales_partner_commission_summary.py• L290-320 erpnext/…/test_sales_partner_commission_summary.py• L350-456
Pricing and commercial terms
Pricing gives the sales flow a shared way to select a base rate and then apply approved commercial rules. The customer can have a default price list and currency. Selling Settings supplies system defaults and can fall back to the default price list when the transaction list has no item price. The transaction can use item prices that are valid for a date, unit, customer, or batch. Pricing rules then adjust price or provide a product discount when item, quantity, amount, customer, territory, sales partner, campaign, or other conditions match.
References: erpnext/…/customer.json• L289-318 erpnext/…/selling_settings.json• L99-120 erpnext/…/selling_settings.json• L312-319 erpnext/…/price_list.json• L1-20 erpnext/…/item_price.json• L97-199 erpnext/…/pricing_rule.json• L114-188 erpnext/…/pricing_rule.json• L229-289 erpnext/…/test_sales_order.py• L56-85 erpnext/…/test_sales_order.py• L1862-2015 erpnext/…/test_sales_order.py• L3779-3811
The same pricing context appears on quotations, orders, invoices, and POS. This keeps the customer-facing rate aligned with currency, tax, discount, and unit choices. Selling Settings can allow price-list rates to be edited or can require the same rate through the sales cycle, with a warning or a controlled stop when the rate changes. It also controls shared sales and POS fields for tax identity, bundle rates, discount accounts, commissions, and campaign tracking. A transaction can ignore pricing rules when a controlled manual price is needed. POS can also apply a coupon by running the pricing-rule path before checkout.
Customer-specific item rules can further restrict the items shown for a customer or customer group. The same rules support frequently ordered item suggestions, so the commercial view can reflect both entitlement and prior buying behavior.
References: erpnext/…/quotation.json• L25-32 erpnext/…/selling_settings.json• L138-194 erpnext/…/selling_settings.py• L77-247 erpnext/…/test_selling_settings.py• L12-77 erpnext/…/sales_order.py• L519-520 erpnext/…/sales_invoice.py• L306-400 erpnext/…/point_of_sale.py• L65-117 erpnext/…/pos_payment.js• L325-345 erpnext/…/party_specific_item.py• L48-67 erpnext/…/party_specific_item.py• L83-158
Point-of-sale operations
Point of Sale is the fast path for an in-person sale. A POS Profile sets the company, warehouse, currency, selling price list, payment methods, tax choices, item and customer limits, and cashier controls. The profile also scopes access to the items and stock data shown by the POS screen. The screen finds sellable items by search or barcode and shows price and available quantity. It then creates a paid or partly paid sales invoice according to the profile. See Point of sale and subscriptions for the detailed POS flow.
The POS screen uses the selected customer and profile to carry price, stock, contact, loyalty, and payment context into the invoice. Checkout applies configured payment modes and can collect required invoice information. A coupon can trigger the normal pricing-rule path, while available loyalty points can be used as a payment method. The past-order view supports receipt printing and email, opens the invoice for review, and starts a return when the invoice still has returnable quantity. The Selling workspace exposes POS, POS Profile, POS Invoice, and POS Settings as the main entry points for this path.
References: erpnext/…/pos_profile.json• L1-89 erpnext/…/pos_profile.json• L134-176 erpnext/…/point_of_sale.py• L120-175 erpnext/…/point_of_sale.py• L203-230 erpnext/…/point_of_sale.py• L445-599 erpnext/…/pos_controller.js• L1-23 erpnext/…/pos_controller.js• L121-180 erpnext/…/pos_payment.js• L273-345 erpnext/…/pos_payment.js• L583-660 erpnext/…/selling.json• L286-344
POS work is grouped into a cashier session. A POS Opening Entry assigns the current user to an active profile and records the opening balances. The related POS Closing Entry checks the invoices for that profile and cashier, consolidates them when the session closes, and links the closing record back to the opening entry. A user cannot inspect another user's open session without the required opening-entry permission. The POS Profile is also the access boundary for item, stock, and profile data. This gives the account flow a clear boundary for cash and sales totals.
References: erpnext/…/pos_opening_entry.py• L38-95 erpnext/…/pos_closing_entry.py• L62-144 erpnext/…/pos_closing_entry.py• L161-239 erpnext/…/point_of_sale.py• L167-175 erpnext/…/point_of_sale.py• L445-482 erpnext/…/pos_controller.js• L305-317
Subscription billing
A subscription represents a repeating service commitment for a customer. It combines one or more subscription plans with a billing interval, billing dates, trial dates, invoice timing, tax, discount, and payment terms. Each plan links an item to a price method and a day, week, month, or year interval. Plans in one subscription must use the same billing interval.
References: erpnext/…/subscription.json• L12-48 erpnext/…/subscription.json• L155-193 erpnext/…/subscription_plan.json• L52-112 erpnext/…/subscription.py• L224-231
The subscription process checks each billing period and creates a Sales Invoice for a customer. It can bill at the start, at the end, or a set number of days before the period. Payment state then moves the subscription between active, grace, unpaid, cancelled, completed, and refunded states. An outstanding invoice can stop the next invoice unless the subscription allows billing while past due.
References: erpnext/…/subscription.py• L40-50 erpnext/…/subscription.py• L451-488 erpnext/…/subscription.py• L650-709
Customer portal access
The customer portal gives an approved customer contact a web view of permitted commercial documents. Customer records link portal users to contacts and assign the customer portal role. A portal document page checks website permission before it shows the document, its status, lines, terms, attachments, and any available payment action. This keeps customer visibility tied to the customer relationship instead of to a public document link.
References: erpnext/…/portal_user.json• L8-23 erpnext/…/customer.py• L286-305 erpnext/…/order.py• L15-54 erpnext/…/order.html• L60-119
The portal can expose a payment action when the payments app and payment-request settings allow it. The action creates a payment request for an eligible document and can submit the document as part of the order flow. The portal therefore connects document visibility with a controlled path to payment rather than changing the underlying sales, invoice, or permission model.
References: erpnext/…/order.py• L54-82 erpnext/…/order.html• L40-53 erpnext/…/payment_request.py• L61-89
Change checklist
When these files or sections are changed, remember to consider these:
- When changing quotation-to-order mapping, preserve source-row links, alternative-item selection, unit-price rows, unit conversion, and partial quantity rules so quotation progress stays correct.
- When changing quotation validity or outcome actions, keep expired-quotation conversion, write permission checks, and the rule that ordered quotations cannot become lost aligned with Selling Settings.
- When changing quotation blanket-order validation, keep the selling order type, customer identity, currency, open state, item state, quantity allowance, and agreed rate aligned with the blanket order.
- When changing order, delivery, invoice, or proforma links, keep customer, company, currency, item, unit, return, and closed-row checks aligned across all source documents.
- When changing delivery schedules, keep schedule quantities, dates, units, warehouses, source order rows, and item quantity edits aligned.
- When changing delivery-to-installation mapping, keep the eligible delivery status, remaining installation quantity, customer, address, contact, and serial or batch context aligned.
- When changing proforma creation or printing, keep the submitted-order requirement, quantity or amount basis, cumulative issued totals, private PDF attachment, source-order non-impact, and email permission checks aligned.
- When changing order item fields, keep the item schema, mapped document fields, stock reservation, delivery schedule, picking, billing, and operational planning flows aligned.
- When changing product bundle versions or active-bundle lookup, keep the single active version, child-item rules, stock-bearing delivery decision, packed-item mapping, and reservation consumers aligned.
- When changing bundle picking or raw-material mapping, keep component quantities, stock units, source-row links, and remaining-order calculations aligned with each downstream document.
- When changing subcontracting order links, keep finished-good validation, BOM selection, inward-order creation, received quantity, billing, and sales-order status changes aligned.
- When changing order status or item closure, keep picking, delivery, billing, reservation release, hold, close, reopen, credit checks, and subcontracting inward-order state consistent.
- When changing sales-order billing eligibility or the invoice picker, keep ordered, delivered, returned, billed, closed, unit-price, and over-billing rules aligned with the invoice mapper and the order sort used for pending work.
- When changing invoice mapping permissions, keep caller permission checks and the explicit override path aligned with address, item, and customer access rules.
- When changing customer defaults or restrictions, keep currency, exchange-rate selection, selling-only price lists, customer-group fallbacks, price list, payment terms, tax, company scope, invoice prerequisites, disabled, frozen, held, credit limits, and portal links aligned with downstream transactions.
- When changing customer actions or customer-specific item rules, keep opportunity, quotation, sales-order, payment, pricing-rule, allowed-item, and frequent-item entry points aligned with customer permissions and order behavior.
- When changing customer credit or overdue checks, keep customer limits, customer-group fallbacks, company currency, payment-ledger amounts, payment schedules, server-side message values, and bypass roles aligned.
- When changing customer overview data or its load setting, keep customer and company permission checks aligned with sales totals, receivables, credit usage, pipeline data, period ranges, accounts access, and the Customer settings map.
- When changing price selection, review price-list currency, default-list fallback, item-price validity, unit conversion, rate edit controls, party-specific item rules, and pricing-rule application together.
- When changing Selling Settings defaults, keep boolean values, site defaults, cache behavior, and dependent property setters aligned.
- When changing POS profile or session rules, keep profile access, item scope, opening-entry ownership, invoice ownership, receipt access, return behavior, and closing-entry consolidation in sync.
- When changing POS payment or customer actions, keep partial-payment rules, required invoice fields, loyalty redemption, coupon pricing, and customer contact updates aligned with the invoice model.
- When changing quotation trend filters or chart grouping, keep quantity and amount period buckets, party resolution for leads and prospects, detail-row selection, and table-to-chart totals aligned.
- When changing sales order analysis or outstanding-order output, keep pending quantity, delivered quantity, billed quantity, delay, closed-row handling, company permission scope, grouping, and print filters aligned.
- When changing classic quotation or order print formats, keep customer-facing labels and field mappings aligned with the source document fields.
- When changing subscription timing or status, review invoice dates, payment state, grace-period behavior, and period-end cancellation as one lifecycle.
- When changing customer portal access, keep customer-to-contact links, portal roles, website permission checks, and payment-request eligibility aligned.
- When changing sales analytics filters or period grouping, keep the report rows, chart series, entity selection, and permission-aware source query consistent.
- When changing Sales Funnel filters, stages, or value calculations, keep the lead-origin checks, customer conversion count, probability weighting, currency conversion, and company permission scope aligned.
- When changing sales partner commission sources or date filters, keep the allowed transaction types, order-versus-posting date labels, submitted and returned document handling, commission eligibility, and company permission condition aligned.
- When changing Sales Order behavior, keep the coverage for partial billing, returns, advance payment state, stock reservation, item updates, drop shipping, purchasing, workflow permissions, permissions on mapped target rows, overdue purchase dates, draft purchase-order links, calendar access, subcontracting, and downstream document creation aligned in erpnext/…/test_sales_order.py.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A quotation expires before order creation | The accepted offer cannot become a sales order unless the selling setting permits expired quotations. | Keep quotation validity checks and the setting that allows expired quotation conversion aligned. |
| A quotation uses a blanket order for another party, currency, order type, or closed item | The quotation is rejected or uses commercial terms that do not match the blanket commitment. | Validate the selling blanket order, customer, currency, open items, quantity, and agreed rates before saving the quotation. |
| A quotation row is mapped again after its ordered quantity is complete | The new sales order omits that row or its remaining quantity. | Use source-row links and compare ordered quantity with stock quantity before mapping. |
| A submitted sales order changes a row below its delivered quantity | The update is rejected because later delivery records would no longer match the order. | Keep delivered, returned, and pending quantities aligned before editing submitted rows. |
| A delivery schedule exceeds its order-row quantity or uses stale client row data | The schedule cannot be saved and the order dates do not represent a valid split. | Validate schedules from the saved server-side order row and retain its item, unit, date, and quantity context. |
| A stock item or stock-bearing product bundle has no source warehouse | The sales order cannot validate or reserve the stock. | Require a warehouse for every stock-bearing order row. |
| A product bundle consumer uses a disabled or old bundle version | Orders, delivery decisions, or reservations can use components that are not the active commercial definition. | Resolve bundles through the submitted, active, enabled version and deactivate older active versions when a new version is submitted. |
| A bundle component is picked with the bundle-row unit or a stale remaining quantity | Picking can request the wrong stock amount or repeat a component already picked. | Calculate each component's remaining stock-unit quantity from picked and delivered progress. |
| A delivery row has only one side of its source link | Delivery validation fails because the source document and source row do not identify the same item. | Set both the parent reference and the row reference for each linked delivery item. |
| An installation note is created from a stopped, closed, or fully installed delivery | The service record cannot be created for the delivered items. | Select only submitted deliveries with remaining installation quantity and preserve the customer and item links. |
| A closed order or row still has reserved stock | The order or row cannot close, or stock remains tied to work that is no longer expected. | Unreserve the stock before closing and refresh order progress after the change. |
| A closed order is reopened while credit or blanket-order rules fail | The order remains closed and cannot resume downstream work. | Recheck customer credit and the related blanket commitment when reopening. |
| A service row, subcontracted row, or drop-shipped row uses the wrong delivery source | Order progress can show delivery or billing work that does not match the way the item is supplied. | Keep skip-delivery, finished-good and BOM, supplier receipt, and downstream status rules aligned. |
| A subcontracted row has no valid finished good, quantity, or BOM | The sales order cannot be submitted or cannot create valid inward work. | Require a subcontracted finished good with positive quantity and an active subcontracting or default BOM. |
| A fully billed, returned, or closed order row is treated as billable | The invoice picker can offer work that has no remaining billable quantity or amount. | Apply the shared billable-row rules for billed quantity, delivered quantity, returns, closed rows, unit-price rows, and over-billing allowance. |
| A sales invoice mapper trusts a client-supplied address or item outside the caller's permissions | The invoice cannot be created or could expose unrelated party data. | Preserve target-document permission checks and use the explicit permission bypass only for trusted callers. |
| A raw-material request drops the planned unit | The requested quantity can be read in the wrong unit and lead to an incorrect supply amount. | Carry the planned unit from production planning into the material request. |
| A purchase order is mapped from an overdue sales order without resetting its required date | Procurement receives a date in the past and can appear overdue as soon as it is created. | Use today or a later valid date for the purchase-order schedule and header. |
| A sales-order row linked to a draft purchase order is removed | The purchase order loses its source row and the supply trace becomes invalid. | Keep linked rows in the sales order until the purchase-order link is removed. |
| A proforma invoice is created from a draft order, repeats an issued quantity or amount, or uses a disabled feature | Creation is rejected or the customer-facing pre-invoice value can exceed the selected order value. | Require the feature setting and a submitted source order. Compare issued proforma totals by source row. |
| A customer is disabled, frozen, held, outside the allowed company scope, or fails an invoice prerequisite | New commercial activity or a later invoice is blocked. | Apply customer state, release date, company restrictions, and sales-order or delivery-note requirements before creating the transaction. |
| A customer uses a buying price list as its default | Customer creation is rejected, or purchase rates could enter the sales path if the rule is bypassed. | Accept only selling price lists for customer defaults and keep the check on the customer boundary. |
| A customer exceeds the credit limit or overdue billing threshold | Order submission or later billing is blocked unless an allowed credit role bypasses the check. | Keep company-specific limits, customer-group fallback, overdue calculations from the payment ledger and due terms, server-side notification values, and bypass roles aligned. |
| A transaction has no item price in its selected price list and fallback is disabled | Price selection fails or requires a controlled manual rate. | Keep the active price list, default-list fallback, currency, and rate-edit policy aligned. |
| A customer has no allowed item under its party-specific item rules | Item search and frequently ordered item views do not offer the expected product. | Keep customer and customer-group rules aligned with item, item-group, and brand membership. |
| A Selling Settings boolean default is stored as text that does not parse as enabled | New transactions can use the wrong sales default even though the setting appears enabled. | Store boolean defaults as 1 or 0 and preserve unchanged site cache values. |
| The Customer settings map or overview field name is stale after a setting change | Customer naming, defaults, or dashboard loading can ignore the site's Selling Settings. | Keep the Customer settings map, Selling Settings field, and Customer onload behavior aligned. |
| A return and replacement delivery cause a negative stock reservation adjustment to affect another order | Stock reservation for unrelated sales orders can be reduced incorrectly. | Apply the configured sales-return reservation policy to the returned order and keep reservation quantities non-negative. |
| The pending stock quantity is compared without the order's precision | The sales-order item indicator can show the wrong stock availability near a rounding boundary. | Round the pending quantity to the field precision before comparing it with available stock. |
| A close, reopen, or calendar request ignores document-level permission | A user can change or view an order outside the permitted company or order scope. | Check the submitted order's permission before status changes and require Sales Order read access for calendar events. |
| A POS request names a profile or opening session outside the caller's permission scope | Item, stock, or cashier data is not returned and the session action is rejected. | Treat the POS Profile as the access boundary and require opening-entry permission for another user's session. |
| A POS cashier opens a second session for the same profile or user | The new opening entry is rejected and the cashier cannot start that session. | Close or cancel the existing open entry before creating another one. |
| A POS closing entry includes an invoice from another profile, user, or prior close | Session close validation fails and the invoice is not consolidated into the session. | Build the closing set from submitted invoices that match the opening profile and cashier. |
| POS checkout has no item, no payment when partial payment is not allowed, or missing required invoice data | The invoice is not submitted. | Require an item, apply the profile's partial-payment rule, and validate required invoice fields before submit. |
| A quotation trends chart includes total or group-header rows | The chart total differs from the table total and misstates quoted value. | Aggregate only detail rows and exclude blank group rows and the final total row. |
| A customer overview request lacks customer or company access | The overview is refused instead of exposing sales or receivable data. | Check Customer read access and permitted Company scope before loading the overview. |
| A restricted viewer is shown whole-company credit usage | The customer may see a credit balance that includes records outside the viewer's permitted scope. | Return credit used only when the viewer has unrestricted access to the source order, delivery, and ledger data. |
| Subscription plans use different billing intervals or currencies | The subscription cannot validate or generate a consistent invoice period. | Use plans with one interval and currency matching the party or company billing currency. |
| A customer portal user is not linked to the customer contact | The user fails website permission checks and cannot view the commercial document. | Link the portal user through the customer record and keep the contact relationship current. |
| A report filter selects unsupported value or entity combinations | The report returns no data or rejects the request instead of showing a valid comparison. | Use value for payment entries and select entities that belong to the active report tree. |
| A funnel request has no company or has a date range where the end is not after the start | The funnel request is rejected instead of returning stage counts or pipeline values. | Require a permitted company and validate the date range before loading funnel data. |
| A commission report uses an unsupported document type or ignores company restrictions | The report rejects the filter or exposes transactions from a company outside the user's scope. | Limit the report to Sales Order, Sales Invoice, Delivery Note, and POS Invoice, and apply the allowed-company condition to the selected document type. |
| A commission report uses the wrong date field or includes draft, cancelled, or partner-less documents | Commission totals and period comparisons do not match the transaction lifecycle. | Use transaction date for sales orders, posting date for other supported types, and require submitted documents with a sales partner. |
| A sales-order change breaks source links, progress totals, permissions, or reservation updates | Later delivery, invoice, purchase, work, or payment documents use the wrong remaining quantity or cannot be created. | Preserve the sales-order test guarantees for source mapping, partial billing, returns, stock reservation, item updates, access checks, status transitions, and downstream document creation. |
Key files
| File | Why to read it |
|---|---|
| erpnext/…/customer.py | Shows how the buyer record connects leads, contacts, addresses, internal parties, sales ownership, credit controls, overdue receivables, and portal users. |
| erpnext/…/customer.json | Shows the customer defaults, transaction restrictions, credit controls, and portal links that anchor later sales records. |
| erpnext/…/customer.js | Shows the customer-facing actions for creating opportunities, quotations, orders, payments, pricing rules, and customer-specific item views. |
| erpnext/…/test_customer.py | Demonstrates customer safeguards for currency and price-list defaults, inherited group terms, customer state, credit and overdue exposure, payment reconciliation, and portal contact links. |
| erpnext/…/customer_overview.py | Shows how a customer view combines sales, pipeline, receivables, ageing, advances, credit, periods, and permissions. |
| erpnext/…/test_customer_overview.py | Demonstrates overview period handling, accounts access, company and customer permissions, restricted totals, and receivable figures. |
| erpnext/…/mapper.py | Shows how customer defaults and party contacts move into quotations, opportunities, and payment entries. |
| erpnext/…/customer.json | Shows which Selling Settings defaults are applied to Customer records and how overview loading is controlled. |
| erpnext/…/quotation.py | Explains quotation state, blanket-order checks, access to outcome changes, and the point at which an offer becomes ordered or lost. |
| erpnext/…/quotation.js | Shows the customer and CRM entry points, expiry gate, lost action, and quotation-to-order handoff. |
| erpnext/…/quotation.json | Defines the party, validity, commercial terms, pricing, status, and customer-facing context of an offer. |
| erpnext/…/mapper.py | Shows the high-level handoff from quotation to customer, sales order, or invoice. |
| erpnext/…/test_quotation.py | Demonstrates quotation-to-order quantity rules, expiry behavior, revisions, lost outcomes, rates, and blanket-order-related safeguards. |
| erpnext/…/blanket_order.py | Defines the selling commitment checks that a quotation must satisfy when it uses a blanket order. |
| erpnext/…/selling_settings.py | Shows how selling defaults, boolean values, cache behavior, and dependent field rules affect the sales surface. |
| erpnext/…/selling_settings.json | Defines the cross-document defaults and controls for prices, quotation expiry, invoice prerequisites, rate checks, customer overview, and proforma invoices. |
| erpnext/…/test_selling_settings.py | Demonstrates the guarantees around defaults, cache preservation, and dependent property setters. |
| erpnext/…/sales_order.py | Defines the committed sale and its delivery, billing, payment, stock, customer, credit, permission, calendar, and related-document context. |
| erpnext/…/sales_order.js | Shows the order actions for quotation handoff, reservation, scheduling, delivery, invoicing, purchasing, production, projects, maintenance, and subcontracting. |
| erpnext/…/sales_order.json | Defines the sales-order contract, progress fields, source context, and workflow-facing document shape. |
| erpnext/…/delivery_schedule.py | Explains how one order row can be split into dated delivery quantities. |
| erpnext/…/reservation.py | Explains how order rows and packed bundle components reserve and release stock. |
| erpnext/…/status.py | Explains how picking, delivery, billing, drop-shipping, closure, and reopening become order status. |
| erpnext/…/subcontracting.py | Explains the sales-order boundary for subcontracted finished goods, BOMs, inward work, and item updates. |
| erpnext/…/mapper.py | Shows how the order branches into delivery, invoice, material, purchasing, production, project, and service work. |
| erpnext/…/product_bundle.py | Defines bundle versions, active-bundle resolution, component rules, and the link between a parent item and stock-bearing components. |
| erpnext/…/proforma_invoice.py | Explains the order-linked pre-invoice document, its quantity or amount basis, issued totals, PDF, and email boundary. |
| erpnext/…/delivery_note.py | Shows how fulfillment validates source links and updates stock and order progress. |
| erpnext/…/installation_note.py | Shows how a delivered item moves into customer installation or service tracking. |
| erpnext/…/sales_invoice.py | Shows how invoicing updates receivables, billing links, stock when enabled, returns, and POS behavior. |
| erpnext/…/sales_analytics.py | Explains how commercial records become period-based value or quantity views with entity and company filters. |
| erpnext/…/sales_order_analysis.py | Explains how order lines become pending, delivery, billing, and delay measures. |
| erpnext/…/sales_orders_outstanding.json | Shows how outstanding order rows become a printable pending-fulfillment view. |
| erpnext/…/quotation_trends.py | Explains how submitted quotations become period-based quantity and amount views with matching chart totals. |
| erpnext/…/sales_funnel.py | Explains how lead conversion counts and probability-weighted opportunity values become funnel and pipeline views. |
| erpnext/…/sales_partner_commission_summary.py | Explains how submitted sales, delivery, invoice, and POS records become partner commission values under date and company filters. |
| erpnext/…/test_sales_partner_commission_summary.py | Demonstrates the guarantees around supported transaction types, date labels, returns, commission eligibility, totals, and company restrictions. |
| erpnext/…/pricing_rule.json | Defines the business conditions that can change a selling price or add a product discount. |
| erpnext/…/party_specific_item.py | Explains customer and customer-group item restrictions and item suggestions based on order history. |
| erpnext/…/point_of_sale.py | Shows how POS access, item search, price selection, warehouse availability, customer updates, invoice history, and opening sessions work. |
| erpnext/…/pos_controller.js | Shows how the POS session starts, loads profile context, creates invoices, and moves between cart, payment, and past orders. |
| erpnext/…/pos_payment.js | Shows how payment modes, partial payment, loyalty redemption, coupons, required fields, and checkout shape the POS invoice. |
| erpnext/…/pos_opening_entry.py | Defines the start of a controlled cashier session. |
| erpnext/…/pos_closing_entry.py | Defines invoice checks and consolidation at session close. |
| erpnext/…/selling.json | Shows the customer-facing Selling workspace entry points, including POS Settings. |
| erpnext/…/subscription.py | Explains repeating invoice creation and subscription status changes. |
| erpnext/…/subscription_plan.json | Defines plan price methods and billing intervals. |
| erpnext/…/order.py | Shows the permission and payment boundary for customer-facing document pages. |
| erpnext/…/order.html | Shows the customer-facing document and payment actions exposed by the portal. |
| erpnext/…/quotation_classic.json | Shows the customer-facing layout used to present a quotation. |
| erpnext/…/sales_order_classic.json | Shows the customer-facing layout used to present a sales order. |
| erpnext/…/test_sales_order.py | Demonstrates the guarantees around partial billing, returns, stock reservation, order updates, credit limits, advance payment state, drop shipping, purchasing, workflows, permissions, unit handling, overdue purchase dates, draft purchase-order links, subcontracting, and downstream document creation. |
| erpnext/…/test_quotation_trends.py | Demonstrates the guarantees around period buckets, party resolution, grouped rows, and chart-to-table totals. |