accounting package

Subpackages

Submodules

accounting.commands module

The console commands.

accounting.forms module

The forms.

accounting.forms.ACCOUNT_REQUIRED: DataRequired = <wtforms.validators.DataRequired object>

The validator to check if the account code is empty.

class accounting.forms.AccountExists

Bases: object

The validator to check if the account exists.

class accounting.forms.CurrencyExists

Bases: object

The validator to check if the account exists.

class accounting.forms.IsCreditAccount(message: str | LazyString)

Bases: object

The validator to check if the account is for credit line items.

class accounting.forms.IsDebitAccount(message: str | LazyString)

Bases: object

The validator to check if the account is for debit line items.

accounting.locale module

The localization for the accounting application.

accounting.locale.domain: Domain = <Domain([PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mia-accounting/checkouts/stable/src/accounting/translations')], ['accounting'])>

The message domain.

accounting.locale.gettext(string, **variables) str

A replacement of the Babel gettext() function..

Parameters:
  • string – The message to translate.

  • variables – The variable substitution.

Returns:

The translated message.

accounting.locale.init_app(app: Flask, bp: Blueprint) None

Initializes the application.

Parameters:
  • app – The Flask application.

  • bp – The blueprint of the accounting application.

Returns:

None.

accounting.locale.lazy_gettext(string, **variables) LazyString

A replacement of the Babel lazy_gettext() function..

Parameters:
  • string – The message to translate.

  • variables – The variable substitution.

Returns:

The translated message.

accounting.locale.pgettext(context, string, **variables) str

A replacement of the Babel gettext() function..

Parameters:
  • context – The context.

  • string – The message to translate.

  • variables – The variable substitution.

Returns:

The translated message.

accounting.locale.translation_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mia-accounting/checkouts/stable/src/accounting/translations')

The directory of the translation files.

accounting.models module

The data models.

class accounting.models.Account(**kwargs)

Bases: Model

An account.

ACCUMULATED_CHANGE_CODE: str = '3351-001'

The code of the accumulated-change account,

CASH_CODE: str = '1111-001'

The code of the cash account,

NET_CHANGE_CODE: str = '3353-001'

The code of the net-change account,

classmethod accumulated_change() Self

Returns the accumulated-change account.

Returns:

The accumulated-change account

base: Mapped[BaseAccount]

The base account.

base_code: Mapped[str]

The code of the base account.

property can_delete: bool

Returns whether the account can be deleted.

Returns:

True if the account can be deleted, or False otherwise.

classmethod cash() Self

Returns the cash account.

Returns:

The cash account

property code: str

Returns the code.

Returns:

The code.

property count: int

Returns the number of items in the account.

Returns:

The number of items in the account.

created_at: Mapped[dt.datetime]

The date and time when this record was created.

created_by: Mapped[user_cls]

The user who created the record.

created_by_id: Mapped[int]

The ID of the user who created the record.

delete() None

Deletes this account.

Returns:

None.

classmethod find_by_code(code: str) Self | None

Finds an account by its code.

Parameters:

code – The code.

Returns:

The account, or None if this account does not exist.

id: Mapped[int]

The account ID.

property is_modified: bool

Returns whether a product account was modified.

Returns:

True if modified, or False otherwise.

is_need_offset: Mapped[bool]

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

property is_nominal: bool

Returns whether the account is a nominal account.

Returns:

True if the account is a nominal account, or False otherwise.

property is_real: bool

Returns whether the account is a real account.

Returns:

True if the account is a real account, or False otherwise.

l10n: Mapped[list[AccountL10n]]

The localized titles.

line_items: Mapped[list[JournalEntryLineItem]]

The journal entry line items.

no: Mapped[int]

The account number under the base account.

property query_values: list[str]

Returns the values to be queried.

Returns:

The values to be queried.

classmethod selectable_credit() list[Self]

Returns the selectable debit accounts. Receivable line items can not start from credit.

Returns:

The selectable debit accounts.

classmethod selectable_debit() list[Self]

Returns the selectable debit accounts. Payable line items can not start from debit.

Returns:

The selectable debit accounts.

property title: str

Returns the title in the current locale.

Returns:

The title in the current locale.

title_l10n: Mapped[str]

The title.

updated_at: Mapped[dt.datetime]

The date and time when this record was last updated.

updated_by: Mapped[user_cls]

The last user who updated the record.

updated_by_id: Mapped[int]

The ID of the last user who updated the record.

class accounting.models.AccountL10n(**kwargs)

Bases: Model

A localized account title.

account: Mapped[Account]

The account.

account_id: Mapped[int]

The account ID.

locale: Mapped[str]

The locale.

title: Mapped[str]

The localized title.

class accounting.models.BaseAccount(**kwargs)

Bases: Model

A base account.

accounts: Mapped[list[Account]]

The descendant accounts under the base account.

code: Mapped[str]

The account code.

l10n: Mapped[list[BaseAccountL10n]]

The localized titles.

property query_values: list[str]

Returns the values to be queried.

Returns:

The values to be queried.

property title: str

Returns the title in the current locale.

Returns:

The title in the current locale.

title_l10n: Mapped[str]

The title.

class accounting.models.BaseAccountL10n(**kwargs)

Bases: Model

A localized base account title.

account: Mapped[BaseAccount]

The account.

account_code: Mapped[str]

The account code.

locale: Mapped[str]

The locale.

title: Mapped[str]

The localized title.

class accounting.models.Currency(**kwargs)

Bases: Model

A currency.

property can_delete: bool

Returns whether the currency can be deleted.

Returns:

True if the currency can be deleted, or False otherwise.

code: Mapped[str]

The currency code.

created_at: Mapped[dt.datetime]

The date and time when this record was created.

created_by: Mapped[user_cls]

The user who created the record.

created_by_id: Mapped[int]

The ID of the user who created the record.

delete() None

Deletes the currency.

Returns:

None.

property is_modified: bool

Returns whether a product account was modified.

Returns:

True if modified, or False otherwise.

l10n: Mapped[list[CurrencyL10n]]

The localized names.

line_items: Mapped[list[JournalEntryLineItem]]

The journal entry line items.

property name: str

Returns the name in the current locale.

Returns:

The name in the current locale.

name_l10n: Mapped[str]

The currency name.

updated_at: Mapped[dt.datetime]

The date and time when this record was last updated.

updated_by: Mapped[user_cls]

The last user who updated the record.

updated_by_id: Mapped[int]

The ID of the last user who updated the record.

class accounting.models.CurrencyL10n(**kwargs)

Bases: Model

A localized currency name.

currency: Mapped[Currency]

The currency.

currency_code: Mapped[str]

The currency code.

locale: Mapped[str]

The locale.

name: Mapped[str]

The localized name.

class accounting.models.JournalEntry(**kwargs)

Bases: Model

A journal entry.

property can_delete: bool

Returns whether the journal entry can be deleted.

Returns:

True if the journal entry can be deleted, or False otherwise.

created_at: Mapped[dt.datetime]

The date and time when this record was created.

created_by: Mapped[user_cls]

The user who created the record.

created_by_id: Mapped[int]

The ID of the user who created the record.

property currencies: list[JournalEntryCurrency]

Returns the line items categorized by their currencies.

Returns:

The currency categories.

date: Mapped[dt.date]

The date.

delete() None

Deletes the journal entry.

Returns:

None.

id: Mapped[int]

The journal entry ID.

property is_cash_disbursement: bool

Returns whether this is a cash disbursement journal entry.

Returns:

True if this is a cash disbursement journal entry, or False otherwise.

property is_cash_receipt: bool

Returns whether this is a cash receipt journal entry.

Returns:

True if this is a cash receipt journal entry, or False otherwise.

line_items: Mapped[list[JournalEntryLineItem]]

The line items.

no: Mapped[int]

The journal entry number under the date.

note: Mapped[str | None]

The note.

updated_at: Mapped[dt.datetime]

The date and time when this record was last updated.

updated_by: Mapped[user_cls]

The last user who updated the record.

updated_by_id: Mapped[int]

The ID of the last user who updated the record.

class accounting.models.JournalEntryCurrency(code: str, debit: list[JournalEntryLineItem], credit: list[JournalEntryLineItem])

Bases: object

A currency in a journal entry.

code: str

The currency code.

credit: list[JournalEntryLineItem]

The credit line items.

property credit_total: str

Returns the total amount of the credit line items.

Returns:

The total amount of the credit line items.

debit: list[JournalEntryLineItem]

The debit line items.

property debit_total: Decimal

Returns the total amount of the debit line items.

Returns:

The total amount of the debit line items.

property name: str

Returns the currency name.

Returns:

The currency name.

class accounting.models.JournalEntryLineItem(**kwargs)

Bases: Model

A line item in the journal entry.

account: Mapped[Account]

The account.

property account_code: str

Returns the account code.

Returns:

The account code.

account_id: Mapped[int]

The account ID.

amount: Mapped[Decimal]

The amount.

property balance: Decimal

Returns the balance.

Returns:

The balance.

property credit: Decimal | None

Returns the credit amount.

Returns:

The credit amount, or None if this is not a credit line item.

currency: Mapped[Currency]

The currency.

currency_code: Mapped[str]

The currency code.

property debit: Decimal | None

Returns the debit amount.

Returns:

The debit amount, or None if this is not a debit line item.

description: Mapped[str | None]

The description.

id: Mapped[int]

The line item ID.

is_debit: Mapped[bool]

True for a debit line item, or False for a credit line item.

property is_need_offset: bool

Returns whether the line item needs offset.

Returns:

True if the line item needs offset, or False otherwise.

property is_offset: bool

Returns whether the line item is an offset.

Returns:

True if the line item is an offset, or False otherwise.

journal_entry: Mapped[JournalEntry]

The journal entry.

journal_entry_id: Mapped[int]

The journal entry ID.

property match: Self | None

Returns the match of the line item.

Returns:

The match of the line item.

property net_balance: Decimal

Returns the net balance.

Returns:

The net balance.

no: Mapped[int]

The line item number under the journal entry and debit or credit.

property offsets: list[Self]

Returns the offset items.

Returns:

The offset items.

original_line_item: Mapped[JournalEntryLineItem | None]

The original line item.

original_line_item_id: Mapped[int | None]

The ID of the original line item.

property query_values: list[str]

Returns the values to be queried.

Returns:

The values to be queried.

class accounting.models.Option(**kwargs)

Bases: Model

An option.

created_at: Mapped[dt.datetime]

The date and time when this record was created.

created_by: Mapped[user_cls]

The user who created the record.

created_by_id: Mapped[int]

The ID of the user who created the record.

name: Mapped[str]

The name.

updated_at: Mapped[dt.datetime]

The date and time when this record was last updated.

updated_by: Mapped[user_cls]

The last user who updated the record.

updated_by_id: Mapped[int]

The ID of the last user who updated the record.

value: Mapped[str]

The option value.

accounting.template_filters module

The template filters.

accounting.template_filters.default(value: Any, default_value: Any = '') Any

Returns the default value if the given value is None.

Parameters:
  • value – The value.

  • default_value – The default value when the given value is None.

Returns:

The value, or the default value if the given value is None.

accounting.template_filters.format_amount(value: Decimal | None) str | None

Formats an amount for readability.

Parameters:

value – The amount.

Returns:

The formatted amount text.

accounting.template_filters.format_date(value: date) str

Formats a date to be human-friendly.

Parameters:

value – The date.

Returns:

The human-friendly date text.

accounting.template_globals module

The template globals.

accounting.template_globals.currency_options() list[Currency]

Returns the currency options.

Returns:

The currency options.

accounting.template_globals.default_currency_code() str

Returns the default currency code.

Returns:

The default currency code.

Module contents

The accounting application.

accounting.VERSION: str = '1.5.11'

The package version.

accounting.data_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mia-accounting/checkouts/stable/src/accounting/data')

The data directory.

accounting.db: SQLAlchemy = <SQLAlchemy>

The database instance.

accounting.init_app(app: Flask, user_utils: UserUtilityInterface, url_prefix: str = '/accounting') None

Initialize the application.

Parameters:
  • app – The Flask application.

  • user_utils – The user utilities.

  • url_prefix – The URL prefix of the accounting application.

Returns:

None.