cardinal
Accounting

Financial report templates

Define the lines of a financial statement as account filters and formulas, and render them in the statement reports.

A Financial Report Template lists the lines of a statement. Each line sums accounts picked by a filter, or computes a value from other lines with a formula. The Custom Financial Statement report renders a template, and Profit and Loss Statement, Balance Sheet and Cash Flow render one when you set their Report Template filter.

Template fields

FieldMeaning
Template NameThe record's name
Report TypeProfit and Loss Statement, Balance Sheet, Cash Flow or Custom Financial Statement
DisabledA disabled template cannot be used in a report
Report Line ItemsThe Financial Report Row table, one row per line

Each row in the Report Line Items table:

FieldMeaning
Line ReferenceA code other rows' formulas use, such as IS_REVENUE
Display NameThe text on the statement
Data SourceAccount Data, Calculated Amount, Blank Line, Column Break or Section Break
Balance TypeFor Account Data: Opening Balance, Closing Balance or Period Movement (Debits - Credits)
Formula or Account FilterThe Account filter for Account Data, or the formula for Calculated Amount
Indent Level0 for a heading, 1 for a sub-category, and so on
Reverse SignShow credits as positive, as for income
Hidden Line (Internal Use Only)Compute the line for formulas but leave it off the statement
Hide If Zero, Bold Text, Italic Text, Color, Value TypeDisplay options
Include in ChartsPlot the line on the report's chart

Account filters and Account Category

An Account Data row's filter uses ERPNext's JSON filter format on Account fields: ["field", "operator", value], or {"and": [...]} and {"or": [...]} to combine them. Supported operators are =, !=, <, >, <=, >=, in, not in, like, not like and is. The row sums the company's enabled ledger accounts that match.

Most standard rows filter on Account Category. Set it in an Account's Account Category field. ERP ships ERPNext's 29 categories, such as Cash and Cash Equivalents, Trade Receivables and Revenue from Operations, each with a Root Type, and the Standard chart's accounts already name them. Renaming a category updates the template filters that use it.

Formulas

A Calculated Amount formula is a cardinal_expr expression over earlier rows' Line References, evaluated per period. A division by zero or another error gives 0. ERPNext's Python a if c else b becomes if c then a else b.

This row from the Financial Ratios Analysis template in fixtures/financial_report_template.yaml:

fixtures/financial_report_template.yaml
- {reference_code: "RATIO_CURRENT", display_name: "Current Ratio (Target: 1.5 - 2.0)", indentation_level: 1, data_source: "Calculated Amount", calculation_formula: "if BS_CURRENT_LIAB != 0 then BS_CURRENT_ASSETS / BS_CURRENT_LIAB else 0", include_in_charts: true, fieldtype: "Float"}

BS_CURRENT_ASSETS and BS_CURRENT_LIAB are hidden Account Data rows in the same template, for example:

- {reference_code: "BS_CASH", display_name: "Cash and Cash Equivalents", data_source: "Account Data", balance_type: "Closing Balance", hidden_calculation: true, calculation_formula: "[\"account_category\", \"=\", \"Cash and Cash Equivalents\"]"}

Standard templates

ERP installs ERPNext v16's six templates:

Template NameReport Type
Financial Ratios AnalysisCustom Financial Statement
Horizontal Balance Sheet (Columnar)Balance Sheet
Horizontal Profit and Loss (Columnar)Profit and Loss Statement
Standard Balance Sheet (IFRS)Balance Sheet
Standard Cash Flow Statement (IFRS)Cash Flow
Standard Profit and Loss (IFRS)Profit and Loss Statement

Running a template

Open Custom Financial Statement, or Profit and Loss Statement, Balance Sheet or Cash Flow.

Pick the Report Template, the Company and the periods, by Fiscal Year or Date Range.

ERP computes each Account Data row per period from the GL, then each Calculated Amount row in order. Opening balances start from the last Period Closing Voucher before the first period.

The Finance Book, Cost Center, Project and accounting dimension filters narrow every sum.

Rules on save

  • A Line Reference starts with a letter and holds only letters, numbers and underscores. It must be unique in the template.
  • An Account Data row needs a Balance Type.
  • Every row except Blank Line, Column Break and Section Break needs a formula or filter.
  • A formula must compile to a number, may not reference its own line and may not form a circular reference.
  • A filter must name real Account fields and supported operators.
  • Custom API rows are refused. ERP has no registry of read-only methods for them yet.

See Chart of accounts for setting Account Category, and Fiscal years and closing for Period Closing Vouchers.

On this page