accounting.journal_entry.utils package

Submodules

accounting.journal_entry.utils.account_option module

The account option for the journal entry management.

class accounting.journal_entry.utils.account_option.AccountOption(account: Account)

Bases: object

An account option.

code: str

The account code.

id: str

The account ID.

is_in_use: bool

True if this account is in use, or False otherwise.

is_need_offset: bool

True if this account needs offset, or False otherwise.

query_values: list[str]

The values to be queried.

title: str

The account title.

accounting.journal_entry.utils.description_editor module

The description editor.

class accounting.journal_entry.utils.description_editor.DescriptionAccount(account: Account, freq: int)

Bases: object

An account for a description tag.

add_freq(freq: int) None

Adds the frequency of an account.

Parameters:

freq – The frequency of the tag name with the account.

Returns:

None.

code: str

The account code.

freq: int

The frequency of the tag with the account.

id: int

The account ID.

is_need_offset: bool

Whether the journal entry line items of this account need offset.

property title: str

Returns the account title.

Returns:

The account title.

class accounting.journal_entry.utils.description_editor.DescriptionDebitCredit(debit_credit: Literal['debit', 'credit'])

Bases: object

The description on debit or credit.

property accounts: list[DescriptionAccount]

Returns the suggested accounts of all tags in the description editor in debit or credit, in their frequency order.

Returns:

The suggested accounts of all tags, in their frequency order.

add_tag(tag_type: Literal['general', 'travel', 'bus'], name: str, account: Account, freq: int) None

Adds a tag.

Parameters:
  • tag_type – The tag type, either “general”, “travel”, or “bus”.

  • name – The name.

  • account – The associated account.

  • freq – The frequency of the tag name with the account.

Returns:

None.

bus: DescriptionType

The bus tags.

debit_credit: Literal['debit', 'credit']

Either debit or credit.

general: DescriptionType

The general tags.

recurring: list[DescriptionRecurring]

The recurring transactions.

travel: DescriptionType

The travel tags.

class accounting.journal_entry.utils.description_editor.DescriptionEditor

Bases: object

The description editor.

credit: DescriptionDebitCredit

The credit tags.

debit: DescriptionDebitCredit

The debit tags.

class accounting.journal_entry.utils.description_editor.DescriptionRecurring(name: str, account: Account, description_template: str)

Bases: object

A recurring transaction.

account: DescriptionAccount

The account.

property account_codes: list[str]

Returns the account codes by the order of their frequencies.

Returns:

The account codes by the order of their frequencies.

description_template: str

The description template.

name: str

The name.

class accounting.journal_entry.utils.description_editor.DescriptionTag(name: str)

Bases: object

A description tag.

property account_codes: list[str]

Returns the account codes by the order of their frequencies.

Returns:

The account codes by the order of their frequencies.

property accounts: list[DescriptionAccount]

Returns the accounts by the order of their frequencies.

Returns:

The accounts by the order of their frequencies.

add_account(account: Account, freq: int)

Adds an account.

Parameters:
  • account – The associated account.

  • freq – The frequency of the tag name with the account.

Returns:

None.

freq: int

The frequency of the tag.

name: str

The tag name.

class accounting.journal_entry.utils.description_editor.DescriptionType(type_id: Literal['general', 'travel', 'bus'])

Bases: object

A description type

add_tag(name: str, account: Account, freq: int) None

Adds a tag.

Parameters:
  • name – The tag name.

  • account – The associated account.

  • freq – The frequency of the tag name with the account.

Returns:

None.

id: Literal['general', 'travel', 'bus']

The type ID.

property tags: list[DescriptionTag]

Returns the tags by the order of their frequencies.

Returns:

The tags by the order of their frequencies.

accounting.journal_entry.utils.description_editor.get_position(string: str | Column, substring: str | Column) Function

Returns the SQL function to find the position of a substring.

Parameters:
  • string – The string.

  • substring – The substring.

Returns:

The position of the substring, starting from 1.

accounting.journal_entry.utils.description_editor.get_prefix(string: str | Column, separator: str | Column) Function

Returns the SQL function to find the prefix of a string.

Parameters:
  • string – The string.

  • separator – The separator.

Returns:

The position of the substring, starting from 1.

accounting.journal_entry.utils.operators module

The operators for different journal entry types.

class accounting.journal_entry.utils.operators.CashDisbursementJournalEntry

Bases: JournalEntryOperator

A cash disbursement journal entry.

CHECK_ORDER: int = 1

The order when checking the journal entry operator.

property form: Type[JournalEntryForm]

Returns the form class.

Returns:

The form class.

is_my_type(journal_entry: JournalEntry) bool

Checks and returns whether the journal entry belongs to the type.

Parameters:

journal_entry – The journal entry.

Returns:

True if the journal entry belongs to the type, or False otherwise.

render_create_template(form: CashDisbursementJournalEntryForm) str

Renders the template for the form to create a journal entry.

Parameters:

form – The journal entry form.

Returns:

the form to create a journal entry.

render_detail_template(journal_entry: JournalEntry) str

Renders the template for the detail page.

Parameters:

journal_entry – The journal entry.

Returns:

the detail page.

render_edit_template(journal_entry: JournalEntry, form: CashDisbursementJournalEntryForm) str

Renders the template for the form to edit a journal entry.

Parameters:
  • journal_entry – The journal entry.

  • form – The form.

Returns:

the form to edit a journal entry.

class accounting.journal_entry.utils.operators.CashReceiptJournalEntry

Bases: JournalEntryOperator

A cash receipt journal entry.

CHECK_ORDER: int = 2

The order when checking the journal entry operator.

property form: Type[JournalEntryForm]

Returns the form class.

Returns:

The form class.

is_my_type(journal_entry: JournalEntry) bool

Checks and returns whether the journal entry belongs to the type.

Parameters:

journal_entry – The journal entry.

Returns:

True if the journal entry belongs to the type, or False otherwise.

render_create_template(form: CashReceiptJournalEntryForm) str

Renders the template for the form to create a journal entry.

Parameters:

form – The journal entry form.

Returns:

the form to create a journal entry.

render_detail_template(journal_entry: JournalEntry) str

Renders the template for the detail page.

Parameters:

journal_entry – The journal entry.

Returns:

the detail page.

render_edit_template(journal_entry: JournalEntry, form: CashReceiptJournalEntryForm) str

Renders the template for the form to edit a journal entry.

Parameters:
  • journal_entry – The journal entry.

  • form – The form.

Returns:

the form to edit a journal entry.

accounting.journal_entry.utils.operators.JOURNAL_ENTRY_TYPE_TO_OP: dict[JournalEntryType, JournalEntryOperator] = {JournalEntryType.CASH_DISBURSEMENT: <accounting.journal_entry.utils.operators.CashDisbursementJournalEntry object>, JournalEntryType.CASH_RECEIPT: <accounting.journal_entry.utils.operators.CashReceiptJournalEntry object>, JournalEntryType.TRANSFER: <accounting.journal_entry.utils.operators.TransferJournalEntry object>}

The map from the journal entry types to their operators.

class accounting.journal_entry.utils.operators.JournalEntryOperator

Bases: ABC

The base journal entry operator.

CHECK_ORDER: int = -1

The order when checking the journal entry operator.

abstract property form: Type[JournalEntryForm]

Returns the form class.

Returns:

The form class.

abstract is_my_type(journal_entry: JournalEntry) bool

Checks and returns whether the journal entry belongs to the type.

Parameters:

journal_entry – The journal entry.

Returns:

True if the journal entry belongs to the type, or False otherwise.

abstract render_create_template(form: FlaskForm) str

Renders the template for the form to create a journal entry.

Parameters:

form – The journal entry form.

Returns:

the form to create a journal entry.

abstract render_detail_template(journal_entry: JournalEntry) str

Renders the template for the detail page.

Parameters:

journal_entry – The journal entry.

Returns:

the detail page.

abstract render_edit_template(journal_entry: JournalEntry, form: FlaskForm) str

Renders the template for the form to edit a journal entry.

Parameters:
  • journal_entry – The journal entry.

  • form – The form.

Returns:

the form to edit a journal entry.

class accounting.journal_entry.utils.operators.TransferJournalEntry

Bases: JournalEntryOperator

A transfer journal entry.

CHECK_ORDER: int = 3

The order when checking the journal entry operator.

property form: Type[JournalEntryForm]

Returns the form class.

Returns:

The form class.

is_my_type(journal_entry: JournalEntry) bool

Checks and returns whether the journal entry belongs to the type.

Parameters:

journal_entry – The journal entry.

Returns:

True if the journal entry belongs to the type, or False otherwise.

render_create_template(form: TransferJournalEntryForm) str

Renders the template for the form to create a journal entry.

Parameters:

form – The journal entry form.

Returns:

the form to create a journal entry.

render_detail_template(journal_entry: JournalEntry) str

Renders the template for the detail page.

Parameters:

journal_entry – The journal entry.

Returns:

the detail page.

render_edit_template(journal_entry: JournalEntry, form: TransferJournalEntryForm) str

Renders the template for the form to edit a journal entry.

Parameters:
  • journal_entry – The journal entry.

  • form – The form.

Returns:

the form to edit a journal entry.

accounting.journal_entry.utils.operators.get_journal_entry_op(journal_entry: JournalEntry, is_check_as: bool = False) JournalEntryOperator

Returns the journal entry operator that may be specified in the “as” query parameter. If it is not specified, check the journal entry type from the journal entry.

Parameters:
  • journal_entry – The journal entry.

  • is_check_as – True to check the “as” parameter, or False otherwise.

Returns:

None.

accounting.journal_entry.utils.original_line_items module

The selectable original line items.

accounting.journal_entry.utils.original_line_items.get_selectable_original_line_items(line_item_id_on_form: set[int], is_payable: bool, is_receivable: bool) list[JournalEntryLineItem]

Queries and returns the selectable original line items, with their net balances. The offset amounts of the form is excluded.

Parameters:
  • line_item_id_on_form – The ID of the line items on the form.

  • is_payable – True to check the payable original line items, or False otherwise.

  • is_receivable – True to check the receivable original line items, or False otherwise.

Returns:

The selectable original line items, with their net balances.

Module contents

The utilities for the journal entry management.