Introducing a new way to review your PRs.

Read the announcement

frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)

View on GitHub

20 documents · Updated Nov 23, 2026

docs / accounting-and-finance

Accounting and financial operations

ERPNext’s financial domain turns company activity into controlled financial records. It defines the account and party context for posting. It tracks receivables and payables through invoices and payments. It supports reconciliation, close, taxation, and reporting.

Financial model

Accounting masters

Accounting masters define the financial language of a company. The chart of accounts groups balances under assets, liabilities, equity, income, and expense. Account types add meaning for party balances, bank activity, stock, taxes, and reports. Fiscal years define the accounting calendar.

The account tree is company-scoped. Group accounts organize reports. Ledger accounts receive entries. An account with posted history cannot be changed in ways that would change its report meaning or currency. Parent and child companies can keep account names, numbers, key controls, and explicit currencies aligned.

The model also carries business context. Cost centers, projects, finance books, and custom accounting dimensions let finance review the same account movement by business area. An accounting dimension links a business document type to a value set. Its company defaults can feed documents and budgets. Its filters can restrict or require values for selected ledger accounts. Dimensions can also be required for Profit and Loss or Balance Sheet accounts. Disabled dimensions no longer take part in active filters or ledger checks.

References: erpnext/…/account.py• L112-127 erpnext/…/account.py• L169-213 erpnext/…/account.py• L646-800 erpnext/…/accounting_dimension.py• L43-127 erpnext/…/accounting_dimension.py• L289-379 erpnext/…/accounting_dimension_filter.py• L32-135 erpnext/…/fiscal_year.py• L1-120

Parties and currencies

Customers and suppliers connect commercial activity to company-specific receivable and payable accounts. Party setup supplies the account, currency, address, tax context, price list, contact, and payment terms that a transaction needs. Account lookup follows party, party group, and company defaults while preserving the currency already used by that party. Price-list selection respects enabled lists and the user’s permitted lists.

ERPNext keeps transaction currency, party account currency, account currency, and company currency as related but distinct views. Exchange rates preserve the source amount while reports can show a chosen presentation currency. Existing party ledger currency constrains later account choices so one party balance does not split across incompatible currencies.

References: erpnext/…/party.py• L136-200 erpnext/…/party.py• L398-463 erpnext/…/party.py• L465-555 erpnext/…/party.py• L603-669 erpnext/…/address.py• L28-63 erpnext/…/utils.py• L46-131 erpnext/…/test_party.py• L13-49 erpnext/…/test_party.py• L63-179

Ledgers and balances

The General Ledger is the account view of posted activity. Each valid accounting event contributes balanced debit and credit movement with its company, date, account, party, currency, finance book, and business context. The Payment Ledger is the party view of the same lifecycle. It tracks invoices, advances, payments, allocations, and outstanding amounts.

The ledgers serve different control needs. The General Ledger supports account balances and statements. The Payment Ledger supports receivable and payable work. Closing balances carry approved period results into later periods. Ledger comparison and health checks help identify when derived ledger views no longer agree with source vouchers.

Account balance views can show a selected bank or ledger account and its child accounts over daily, weekly, monthly, quarterly, or yearly points. Balance-sheet accounts show cumulative values. Period-closing vouchers are excluded so the view represents account activity rather than the close entry itself. Finance-book selection controls which book balances are included.

References: erpnext/…/gl_entry.py• L1-120 erpnext/…/general_ledger.py• L154-228 erpnext/…/payment_ledger_entry.py• L1-120 erpnext/…/account_closing_balance.py• L47-70 erpnext/…/ledger_health.py• L28-77 erpnext/…/utils.py• L201-344 erpnext/…/utils.py• L1500-1605 erpnext/…/test_utils.py• L25-81

Transaction operations

Transaction posting

Transaction posting moves a business document from an operational record into the financial books. Sales invoices, purchase invoices, journal entries, and payment entries use account, party, tax, currency, and dimension context to create a balanced financial effect. Journal entries also support opening, inter-company, reversal, periodic, deferred, asset, and exchange adjustments. Returns and cancellation keep the business event linked to its accounting result.

The detailed voucher-to-ledger path is described in Financial transaction posting. This page keeps the wider relationship in view: source documents create ledger history, and that history drives outstanding balances, reconciliation, close, and reports.

Submitted order and quotation item changes must also preserve the accounting context that later billing uses. Quantity, rate, units, tax defaults, payment schedules, and dimensions move together with the updated commercial record.

This diagram shows how business activity becomes financial information used by later controls.

flowchart LR
    M[Accounting masters] --> D[Business documents]
    D --> V[Submitted vouchers]
    V --> GL[General Ledger]
    V --> PL[Payment Ledger]
    PL --> O[Outstanding balances]
    O --> P[Payments and reconciliation]
    GL --> C[Period close]
    GL --> R[Financial reports]

References: erpnext/…/gl_composer.py• L22-61 erpnext/…/gl_composer.py• L16-50 erpnext/…/journal_entry.py• L49-56 erpnext/…/journal_entry.py• L142-185 erpnext/…/journal_entry.py• L216-254 erpnext/…/journal_entry.js• L244-333 erpnext/…/payment_entry.py• L267-277 erpnext/…/child_item_update.py• L185-235

Invoicing

Sales and purchase invoices record what a customer owes or what the company owes a supplier. They bring together party accounts, items or services, payment terms, taxes, discounts, advances, currency, and due dates. Submission updates receivables or payables and may also update income, expense, stock, asset, tax, or clearing balances.

Invoice posting can defer income or expense across a service period. Deferred values move from a holding account to income or expense over time. The process respects service dates, partial periods, currencies, prior recognition, returns, and frozen accounting dates.

Returns and credit or debit notes use the source invoice trail to change the balance without hiding the original sale or purchase. Invoice items retain links to orders, deliveries, stock movement, assets, services, and accounting dimensions. These links let billing, stock, and financial status move together.

Purchase invoices can be held after submission when a supplier or bill needs review. A held invoice stays out of payment selection until its release date or until the hold is removed. A return invoice cannot be held, and a settled invoice cannot be placed on hold. The Billed Items to Be Received report highlights submitted stock or asset bills whose quantities are not yet fully received as of a selected date. It accounts for receipts, returns, debit notes, and invoices made from receipts.

References: erpnext/…/sales_invoice.js• L73-172 erpnext/…/sales_invoice.py• L310-409 erpnext/…/sales_invoice.py• L452-545 erpnext/…/purchase_invoice.py• L278-349 erpnext/…/purchase_invoice.py• L373-451 erpnext/…/purchase_invoice.py• L760-886 erpnext/…/purchase_invoice.py• L1001-1032 erpnext/…/purchase_invoice.json• L624-632 erpnext/…/mapper.py• L50-141 erpnext/…/billed_items_to_be_received.py• L19-84 erpnext/…/billed_items_to_be_received.py• L87-214

Pricing rules

Pricing rules control rates, discounts, margins, and product offers before an invoice or order becomes a posted financial document. They can apply to an item, item group, brand, or whole transaction. Party, price list, currency, date, quantity, amount, campaign, and coupon context narrows which rule applies.

Rules can run alone or in priority order. A matched rule is recorded on the transaction so later saves can retain a user change or remove a discount that is no longer valid. Product rules can add a free item. Transaction rules can change the payment schedule when the total changes.

References: erpnext/…/pricing_rule.py• L15-63 erpnext/…/pricing_rule.py• L180-193 erpnext/…/pricing_rule.py• L401-455 erpnext/…/utils.py• L39-81 erpnext/…/utils.py• L307-381

Payments

Payment Entries record money received, money paid, or moved between company accounts. They connect company and party accounts and can allocate an amount to invoices, orders, advances, dunnings, or other references. Payment Requests and Payment Orders support the request and approval stages before money is posted.

A payment can be fully allocated, partly allocated, or left unallocated. Deductions cover write-offs, bank charges, taxes, dunning charges, and exchange differences. Payment terms can apply an early-payment discount when the payment date qualifies. The payment checks current outstanding values before submission and updates payment schedules, Payment Ledger entries, and linked document status.

Payment entries support Receive, Pay, and Internal Transfer flows. An internal transfer must use different source and target accounts. Payments keep paid and received amounts in their account currencies and use exchange rates to produce company-currency values. A difference is not left open on submission. It is handled through a write-off, bank charge, or exchange gain or loss account. Cancellation reverses the financial effect and restores the linked balance.

References: erpnext/…/payment_entry.py• L178-207 erpnext/…/payment_entry.py• L267-282 erpnext/…/payment_entry.py• L438-601 erpnext/…/payment_entry.py• L736-742 erpnext/…/payment_entry.py• L1169-1410 erpnext/…/test_payment_entry.py• L1259-1390 erpnext/…/payment_request.js• L44-95 erpnext/…/test_mode_of_payment.py• L30-112

Point of sale

Point of sale accounting links a cashier session to paid invoices and the company’s cash or bank accounts. An open POS session controls which invoices belong to a cashier and profile. A POS Closing Entry gathers the session’s invoices, payments, and taxes, then consolidates them for the period.

POS invoices require an approved payment setup and keep paid, outstanding, change, write-off, and return amounts in step with the payment rows. The flow also checks the company and profile, allowed payment modes, available stock, serial or batch data, and payment requests for phone payments.

The close checks for duplicate, missing, unpaid, or mismatched invoices. It groups invoices by customer and accounting context. Returns remain linked to the consolidated sale that they reverse. Failed closes can be retried. Cancellation reverses the consolidation only when the session state permits it.

References: erpnext/…/pos_invoice.py• L210-317 erpnext/…/pos_invoice.py• L555-625 erpnext/…/pos_invoice.py• L800-969 erpnext/…/pos_invoice.py• L1159-1191 erpnext/…/pos_invoice_merge_log.py• L48-169 erpnext/…/pos_invoice_merge_log.py• L235-398 erpnext/…/pos_invoice_merge_log.py• L566-748 erpnext/…/test_pos_invoice_merge_log.py• L649-689

Party reconciliation

Party reconciliation matches open invoices with payments, advances, journal entries, and return documents. It changes the allocation links used to calculate outstanding balances. The work is scoped by company, party, account, dates, amounts, dimensions, and user access.

The process fetches eligible entries, allocates a payment to one or more open items, and confirms the result. It checks both sides of the allocation against current balances. Foreign-currency differences can create a separate gain or loss effect. Reconciliation updates the source voucher and its ledger view rather than creating a second payment.

For the detailed matching flow, see Banking and reconciliation. That page also covers bank-side matching and statement work, which is separate from party-level invoice allocation.

References: erpnext/…/payment_reconciliation.py• L136-184 erpnext/…/payment_reconciliation.py• L192-235 erpnext/…/payment_reconciliation.py• L386-426 erpnext/…/payment_reconciliation.py• L493-638 erpnext/…/payment_reconciliation.py• L780-815 erpnext/…/test_payment_reconciliation.py• L424-447

Bank reconciliation

Bank reconciliation compares bank statement activity with posted ERPNext activity. A bank account joins a company bank ledger account to the bank identity. A bank transaction records the statement date, direction, amount, currency, reference, party clues, and the amount still without a match.

Statements can be brought in as bank transactions. Matching then links a statement line to a payment, journal entry, invoice, or another bank transaction. Clearance dates and statement balances let finance separate what is posted in ERPNext from what has cleared at the bank.

Bank transaction rules add a controlled classification layer before matching. Rules can select transactions by direction, amount range, and description text. A match can classify the line as a bank entry, payment entry, or transfer. Multiple-account bank entries can use safe amount formulas based on the transaction amount. Rules run in priority order and can run automatically for unreconciled transactions.

The full ingestion, matching, clearance, and statement-report flow is described in Banking and reconciliation.

References: erpnext/…/bank_account.py• L62-93 erpnext/…/bank_transaction.py• L54-119 erpnext/…/bank_reconciliation_tool.py• L60-138 erpnext/…/bank_reconciliation_tool.py• L417-447 erpnext/…/bank_transaction_rule.py• L20-55 erpnext/…/bank_transaction_rule.py• L89-156 erpnext/…/bank_transaction_rule.py• L178-314 erpnext/…/test_bank_transaction_rule.py• L76-173 erpnext/…/bank_reconciliation_statement.py• L16-60

Collections and financing

Dunning manages follow-up for overdue customer invoices. A Dunning Type defines the message, fee, interest rate, income account, and cost center. A Dunning record applies that policy to overdue payments and keeps the reminder tied to the outstanding balance.

Invoice discounting moves selected unpaid receivables into a short-term financing arrangement without replacing the invoice as the business source. Opening invoices and opening journal entries bring an existing party or account position into ERPNext. Later payments and reports treat those entries as part of the normal balance flow.

References: erpnext/…/dunning.js• L4-80 erpnext/…/dunning.js• L203-275 erpnext/…/payment_entry.py• L209-262 erpnext/…/invoice_discounting.js• L4-23 erpnext/…/invoice_discounting.js• L53-83 erpnext/…/opening_invoice_creation_tool.py• L1-180

Financial controls

Budget controls

Budgets set planned spending for a company, account, and business area such as a cost center, project, or custom dimension. They compare planned amounts with requests, orders, and booked expenses. Each budget can stop an excess, warn the user, or ignore it.

Budget periods follow fiscal years and cannot overlap for the same account and business area. This keeps one planned amount from being counted twice and gives reports a clear time boundary.

References: erpnext/…/budget.py• L28-80 erpnext/…/budget.py• L82-149 erpnext/…/budget.py• L151-192 erpnext/…/accounting_dimension.py• L178-207

Taxation

Tax templates define tax accounts, rates, and charge order for sales and purchases. Tax rules select a suitable template from company, party, item, address, tax category, date, and priority context. Withholding records tax held from a party payment or invoice for later review.

Item tax templates add item-level tax context. Tax processing supports inclusive and exclusive charges, deductions, discounts, currency conversion, and tax effects on invoices and payments. Validation keeps tax accounts inside the company and keeps dependent tax rows in a valid order.

References: erpnext/…/taxes.py• L22-140 erpnext/…/taxes.py• L185-243 erpnext/…/taxes.py• L290-394 erpnext/…/taxes.py• L423-475 erpnext/…/purchase_invoice.json• L1642-1673 erpnext/…/test_sales_invoice.py• L382-515 erpnext/…/gl_composer.py• L754-849

Period closing

Period closing creates a controlled boundary for financial review. An Accounting Period can restrict selected document types. A Period Closing Voucher closes a continuous part of a fiscal year and transfers income and expense activity to a valid closing account.

Large closes can run as a managed background process. The process records queued, running, paused, completed, and cancelled work. It creates closing balances by account and business dimension so later reports can distinguish current activity from balances brought forward.

References: erpnext/…/period_closing_voucher.py• L62-116 erpnext/…/period_closing_voucher.py• L145-194 erpnext/…/process_period_closing_voucher.py• L44-121 erpnext/…/account_closing_balance.py• L47-70

Financial reporting

Standard reports

Financial reports turn posted activity into views for control and decision work. The General Ledger explains account movement with opening, period, closing, and running balances. Trial Balance checks opening, period, and closing debit and credit values. Balance Sheet, Profit and Loss, Cash Flow, sales and purchase registers, tax reports, bank reports, and budget views serve related review needs.

Receivable and payable reports explain party balances, payment terms, future payments, and ageing. Reports can filter by company, finance book, currency, account, party, and business dimensions. They distinguish independent period activity from accumulated values. Presentation-currency views use an exchange rate for the report date when a stored account value cannot be used directly.

References: erpnext/…/general_ledger.py• L34-59 erpnext/…/general_ledger.py• L154-240 erpnext/…/trial_balance.py• L43-167 erpnext/…/trial_balance.py• L630-854 erpnext/…/financial_statements.py• L33-221 erpnext/…/financial_statements.py• L368-426 erpnext/…/utils.py• L96-131

Cash flow analysis

Cash Flow explains how posted activity changes cash and bank balances. It presents operating, investing, and financing movement, then combines those sections into net change in cash. It can show opening and closing cash balances when the report is not grouped by dimension.

The report can use normal account rules or a financial report template. Its period mode can show separate activity or accumulated values. Dimension grouping places movement in the period column for the matching cost center, project, or accounting dimension. This keeps the report useful for both cash control and business-area review.

References: erpnext/…/cash_flow.py• L38-174 erpnext/…/cash_flow.py• L177-239 erpnext/…/cash_flow.py• L250-365 erpnext/…/cash_flow.py• L428-493

Sales and purchase analysis

Sales and purchase registers present invoice totals with their party, tax, account, payment, and source-document context. They can include payments for a selected party and show a running balance. Gross Profit compares sales value with the buying value supplied by stock movement, delivery, purchase, or service context.

These reports connect commercial review to accounting without replacing the ledger. Their totals respect returns, internal transfers, taxes, outstanding amounts, cost centers, projects, warehouses, and invoice links. Gross Profit also handles product bundles, drop-ship buying values, and returns linked to the source invoice item.

References: erpnext/…/sales_register.py• L34-210 erpnext/…/purchase_register.py• L36-206 erpnext/…/gross_profit.py• L23-176 erpnext/…/gross_profit.py• L518-649 erpnext/…/gross_profit.py• L1093-1280

Custom financial reports

Financial Report Templates let a finance team define a report shape over account data. A template can arrange rows into sections, use opening, closing, or period movement values, and calculate derived rows. The report engine applies company, period, fiscal year, account, cost center, project, finance book, and dimension context before it formats the result.

The engine collects account balances, resolves row dependencies, calculates formulas, formats sections, and can provide a growth view and chart data. Validation keeps account filters, formulas, dependencies, and custom data sources within an approved reporting contract.

References: erpnext/…/financial_report_engine.py• L211-227 erpnext/…/financial_report_engine.py• L280-352 erpnext/…/financial_report_engine.py• L366-442 erpnext/…/financial_report_validation.py• L161-239

Change checklist

When these files or sections are changed, remember to consider these:

  • Account changes must preserve company ownership, account-tree meaning, currency history, child-company synchronization, freeze controls, and rename or merge safety.
  • Voucher changes must preserve the link between the source document, General Ledger movement, Payment Ledger entries, payment schedules, deferred recognition, and cancellation effects.
  • Invoice and tax changes must keep party balances, payment terms, return links, tax accounts, tax order, currency conversion, and stock or asset effects aligned.
  • Submitted order-item changes must keep item tax defaults, dimensions, payment schedules, delivery or receipt quantities, reservations, and later invoice links consistent.
  • Dimension changes must preserve generated document fields, company defaults, mandatory Profit and Loss or Balance Sheet checks, tree-child filters, blank-value filters, and POS consolidation groups.
  • Payment and reconciliation changes must validate live outstanding values, prevent over-allocation, preserve payment-term balances, and post foreign-currency differences to the intended account.
  • Bank rule changes must keep priority order, description matching, company account scope, safe formula limits, and the classification handoff to bank, payment, or transfer entries aligned.
  • Period close changes must preserve continuous period boundaries, prior-close order, closing-account rules, opening balances, dimension scope, and background-job status.
  • Report changes must keep normal and synchronized ledger-report paths aligned for filters, opening balances, fiscal-year resets, presentation currency, dimension grouping, permissions, and totals.
  • POS consolidation changes must preserve customer or customer-group scope, invoice return links, payment and tax totals, accounting dimensions, and cancellation of linked consolidated documents.
  • Purchase-billing changes must preserve the difference between billed quantity and received quantity across receipts, receipt returns, debit notes, and replacement invoices.

Important failure modes

TriggerConsequenceGuard
An account is renamed or merged while ledger updates are activeThe change can race with new entries or move history into an incompatible accountRequire an idle accounting system and matching account properties. erpnext/…/account.py• L668-800
A party is assigned an account currency that differs from its existing ledger currencyOne party balance can split across incompatible currenciesKeep the party account currency aligned with existing ledger currency. erpnext/…/party.py• L651-669
A payment is allocated against an old outstanding amountThe payment can over-allocate an invoice or payment termRe-fetch current references and reject allocations above the live balance. erpnext/…/payment_entry.py• L504-601
A payment has a non-zero difference at submissionThe voucher cannot post a balanced financial resultRequire a zero difference or a valid deduction, write-off, or exchange gain or loss entry. erpnext/…/payment_entry.py• L267-277
A mode of payment points to a disabled or invalid accountInvoices, requests, or payments can use an unavailable cash or bank routeRequire an enabled mode with one company-scoped ledger account. erpnext/…/test_mode_of_payment.py• L30-112
A bank rule uses an invalid or unsafe amount formulaAutomatic classification can fail or execute an unintended expressionAllow only numeric formulas based on transaction amount and reject unsafe operators. erpnext/…/bank_transaction_rule.py• L13-55
A bank rule points to an account from another companyA bank transaction can post outside its companyValidate every rule account against the rule company. erpnext/…/bank_transaction_rule.py• L147-156
An accounting dimension is disabled or has no required business valueLedger review can lose a required business split or apply stale filtersRefresh active dimension checks and require values only for enabled dimensions. erpnext/…/accounting_dimension.py• L272-317, erpnext/…/pos_invoice_merge_log.py• L355-378
A purchase invoice is held while payment selection still includes itA supplier payment can be made before bill review endsExclude active holds from outstanding invoice selection. erpnext/…/utils.py• L1340-1355, erpnext/…/utils.py• L1384-1427
A purchase invoice mixes stock update with an existing purchase receiptStock can be recorded twicePrevent stock update when an item already links to a receipt. erpnext/…/purchase_invoice.py• L759-768
A report ignores receipts or returns when measuring billed quantityBilled Items to Be Received can show a false pending quantityCalculate receipt, receipt-return, debit-note, and replacement-invoice effects as of the report date. erpnext/…/billed_items_to_be_received.py• L19-84
POS invoices with different dimensions are consolidated togetherConsolidated ledger values can lose their business contextSplit consolidation groups by active accounting dimensions, cost center, and project. erpnext/…/pos_invoice_merge_log.py• L544-563
A report mixes accumulated periods with the wrong total ruleTotals can double-count running balances or omit a dimension groupSelect total keys from the period mode and dimension grouping. erpnext/…/financial_statements.py• L192-221, erpnext/…/cash_flow.py• L271-285
General Ledger and Payment Ledger entries divergeReceivable and payable reports can disagree with voucher historyUse ledger comparison and health checks to identify the affected voucher. erpnext/…/general_and_payment_ledger_comparison.py• L149-184, erpnext/…/ledger_health.py• L28-59

Key files

FileWhy to read it
erpnext/…/account.pyDefines company-scoped account structure, currency, ledger controls, synchronization, rename, and merge rules.
erpnext/…/party.pyShows how customers and suppliers receive accounts, currencies, addresses, tax context, price lists, and payment terms.
erpnext/…/journal_entry.pyShows the balanced voucher used for manual, opening, inter-company, deferred, periodic, and system-generated accounting.
erpnext/…/journal_entry.jsShows journal-entry setup, currency behavior, references, reversal, and inter-company actions.
erpnext/…/sales_invoice.pyShows customer billing, returns, stock, assets, taxes, deferred revenue, POS links, and ledger effects.
erpnext/…/purchase_invoice.pyShows supplier billing, holds, stock effects, returns, outstanding values, exchange rates, and cancellation.
erpnext/…/mapper.pyShows how supplier invoices create receipts and debit notes while preserving pending quantities.
erpnext/…/billed_items_to_be_received.pyShows the report view for billed stock or asset items that are not fully received.
erpnext/…/payment_entry.pyShows payment direction, allocation, deductions, currencies, and ledger updates.
erpnext/…/payment_reconciliation.pyShows party-level fetching, allocation, validation, permissions, and reconciliation.
erpnext/…/bank_transaction_rule.pyShows rule-based classification of unreconciled bank transactions.
erpnext/…/pos_invoice.pyShows POS payment, stock, return, and customer-session accounting.
erpnext/…/pos_invoice_merge_log.pyShows POS consolidation, dimension-aware grouping, returns, and reversal.
erpnext/…/accounting_dimension.pyShows active dimensions, defaults, mandatory account checks, tree filters, and generated document fields.
erpnext/…/child_item_update.pyShows how submitted order item changes preserve quantities, rates, taxes, schedules, dimensions, and downstream status.
erpnext/…/general_ledger.pyShows ledger filters, opening and closing balances, grouping, currencies, dimensions, permissions, and reporting paths.
erpnext/…/financial_statements.pyShows period construction, account-tree reporting, dimension grouping, closing balances, and report totals.
erpnext/…/cash_flow.pyShows operating, investing, and financing cash movement and opening or closing cash behavior.
erpnext/…/period_closing_voucher.pyShows period order, closing-account checks, and close boundaries.