accounting.report.utils package

Submodules

accounting.report.utils.base_page_params module

The page parameters of a report.

class accounting.report.utils.base_page_params.BasePageParams

Bases: ABC

The base HTML page parameters class.

property csv_uri: str
abstract property has_data: bool

Returns whether there is any data on the page.

Returns:

True if there is any data, or False otherwise.

property journal_entry_types: Type[JournalEntryType]

Returns the journal entry types.

Returns:

The journal entry types.

abstract property report_chooser: ReportChooser

Returns the report chooser.

Returns:

The report chooser.

accounting.report.utils.base_report module

The base report.

class accounting.report.utils.base_report.BaseReport

Bases: ABC

The base report class.

abstract csv() Response

Returns the report as CSV for download.

Returns:

The response of the report for download.

abstract html() str

Composes and returns the report as HTML.

Returns:

The report as HTML.

accounting.report.utils.csv_export module

The utilities to export the report as CSV for download.

class accounting.report.utils.csv_export.BaseCSVRow

Bases: ABC

The base CSV row.

abstract property values: list[str | Decimal | None]

Returns the values of the row.

Returns:

The values of the row.

accounting.report.utils.csv_export.csv_download(filename: str, rows: list[BaseCSVRow]) Response

Exports the data rows as a CSV file for download.

Parameters:
  • filename – The download file name.

  • rows – The data rows.

Returns:

The response for download the CSV file.

accounting.report.utils.csv_export.period_spec(period: Period) str

Constructs the period specification to be used in the filename.

Parameters:

period – The period.

Returns:

The period specification to be used in the filename.

accounting.report.utils.offset_matcher module

The forms for the unmatched offset management.

class accounting.report.utils.offset_matcher.OffsetMatcher(currency: Currency, account: Account)

Bases: object

The offset matcher.

line_items: list[JournalEntryLineItem]

The unapplied debits or credits and unmatched offsets.

match() None

Matches the original line items with offsets.

Returns:

None.

matched_pairs: list[OffsetPair]

A list of matched pairs.

property status: str | LazyString

Returns the match status message.

Returns:

The match status message.

unapplied: list[JournalEntryLineItem]

The unapplied debits or credits.

unmatched: list[JournalEntryLineItem]

The unmatched offsets.

class accounting.report.utils.offset_matcher.OffsetPair(original_line_item: JournalEntryLineItem, offset: JournalEntryLineItem)

Bases: object

A pair of an original line item and its offset.

offset: JournalEntryLineItem

The offset.

original_line_item: JournalEntryLineItem

The original line item.

accounting.report.utils.report_chooser module

The report chooser.

This file is largely taken from the NanoParma ERP project, first written in 2021/9/16 by imacat (imacat@nanoparma.com).

class accounting.report.utils.report_chooser.ReportChooser(active_report: ReportType, period: Period | None = None, currency: Currency | None = None, account: Account | None = None)

Bases: object

The report chooser.

current_report: str | LazyString

The title of the current report.

Whether the current report is the search page.

accounting.report.utils.report_type module

The report types.

class accounting.report.utils.report_type.ReportType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

The report types.

BALANCE_SHEET: str = 'balance-sheet'

The balance sheet.

INCOME_EXPENSES: str = 'income-expenses'

The income and expenses log.

INCOME_STATEMENT: str = 'income-statement'

The income statement.

JOURNAL: str = 'journal'

The journal.

LEDGER: str = 'ledger'

The ledger.

SEARCH: str = 'search'

The search.

TRIAL_BALANCE: str = 'trial-balance'

The trial balance.

UNAPPLIED: str = 'unapplied'

The unapplied original line items.

UNMATCHED: str = 'unmatched'

The unmatched offsets.

accounting.report.utils.unapplied module

The unapplied original line item utilities.

accounting.report.utils.unapplied.get_accounts_with_unapplied(currency: Currency) list[Account]

Returns the accounts with unapplied original line items.

Parameters:

currency – The currency.

Returns:

The accounts with unapplied original line items.

accounting.report.utils.unapplied.get_net_balances(currency: Currency, account: Account) dict[int, Decimal | None]

Returns the net balances of the unapplied line items of the account.

Parameters:
  • currency – The currency.

  • account – The account.

Returns:

The net balances of the unapplied line items of the account.

accounting.report.utils.unmatched module

The unmatched offset utilities.

accounting.report.utils.unmatched.get_accounts_with_unmatched(currency: Currency) list[Account]

Returns the accounts with unmatched offsets.

Parameters:

currency – The currency.

Returns:

The accounts with unmatched offsets, with the “count” property set to the number of unmatched offsets.

accounting.report.utils.urls module

The utilities to get the ledger URL.

accounting.report.utils.urls.balance_sheet_url(currency: Currency, period: Period) str

Returns the URL of a balance sheet.

Parameters:
  • currency – The currency.

  • period – The period.

Returns:

The URL of the balance sheet.

accounting.report.utils.urls.income_expenses_url(currency: Currency, account: CurrentAccount, period: Period) str

Returns the URL of an income and expenses log.

Parameters:
  • currency – The currency.

  • account – The account.

  • period – The period.

Returns:

The URL of the income and expenses log.

accounting.report.utils.urls.income_statement_url(currency: Currency, period: Period) str

Returns the URL of an income statement.

Parameters:
  • currency – The currency.

  • period – The period.

Returns:

The URL of the income statement.

accounting.report.utils.urls.journal_url(period: Period) str

Returns the URL of a journal.

Parameters:

period – The period.

Returns:

The URL of the journal.

accounting.report.utils.urls.ledger_url(currency: Currency, account: Account, period: Period) str

Returns the URL of a ledger.

Parameters:
  • currency – The currency.

  • account – The account.

  • period – The period.

Returns:

The URL of the ledger.

accounting.report.utils.urls.trial_balance_url(currency: Currency, period: Period) str

Returns the URL of a trial balance.

Parameters:
  • currency – The currency.

  • period – The period.

Returns:

The URL of the trial balance.

accounting.report.utils.urls.unapplied_url(currency: Currency, account: Account | None) str

Returns the URL of the unapplied original line items.

Parameters:
  • currency – The currency.

  • account – The account, or None to list the accounts with unapplied original line items.

Returns:

The URL of the unapplied original line items.

accounting.report.utils.urls.unmatched_url(currency: Currency, account: Account | None) str

Returns the URL of the unmatched offset line items.

Parameters:
  • currency – The currency.

  • account – The account, or None to list the accounts with unmatched offset line items.

Returns:

The URL of the unmatched offset line items.

Module contents

The utilities for the reports.