Skip to content

reporting_service

ReportingService — pure computation of financial statements from a Ledger.

The balance sheet is produced "as if closed" on the reporting date: a deep copy of the ledger is closed so that income and expenses are transferred to Retained Earnings. The original ledger is never modified.

Classes:

  • ReportingService

    Generate structured financial statement data from a Ledger.

ReportingService

Generate structured financial statement data from a Ledger.

All methods are pure computations — no HTML, no UI concerns.

Methods:

  • balance_sheet

    Return a structured balance sheet, closed as of date.

  • income_statement

    Return a structured income statement (before closing).

  • trial_balance

    Return a trial balance for all accounts in the ledger.

balance_sheet

balance_sheet(
    ledger: Ledger, date: date | None = None
) -> dict[str, Any]

Return a structured balance sheet, closed as of date.

A deep copy of the ledger is closed so that all income and expense balances are transferred to Retained Earnings. The result is a clean balance sheet with only permanent accounts (Assets, Liabilities, Equity). The original ledger is not modified.

income_statement

income_statement(ledger: Ledger) -> dict[str, Any]

Return a structured income statement (before closing).

Shows income and expense account balances and net income.

trial_balance

trial_balance(ledger: Ledger) -> list[dict[str, Any]]

Return a trial balance for all accounts in the ledger.

Each row is a dict with keys: account, debit, credit, balance.