models.category

Represents the Base class for accounting models.

Module Contents

Classes

Category

Represents a grouping of Accounts of the same type.

class models.category.Category

Bases: python_accounting.mixins.IsolatingMixin, python_accounting.models.Recyclable

Represents a grouping of Accounts of the same type.

__mapper_args__
id: sqlalchemy.orm.Mapped[int]

The primary key of the Category database record.

Type:

(int)

name: sqlalchemy.orm.Mapped[str]

The label of the Category.

Type:

(str)

category_account_type: sqlalchemy.orm.Mapped[strenum.StrEnum]

The Account type of the members of the Category.

Type:

(list of Account.AccountType)

accounts: sqlalchemy.orm.Mapped[List[python_accounting.models.Account]]

Accounts that belong to the Category.

Type:

(list)

__repr__() str
validate(_) None

Validates the Category properties.

Parameters:

session (Session) – The accounting session to which the Category belongs.

Raises:

InvalidAccountTypeError – If the category account type is not one of Account.AccountType.

Returns:

None

account_balances(session, end_date: datetime.datetime = None) dict

Returns the Accounts belonging to the Category and their balances.

Parameters:
  • session (Session) – The accounting session to which the Account belongs.

  • end_date (datetime) – The latest transaction date for Transaction amounts to be included in the Account balances.

Returns:

With a A summary of the total of the Account balances of the together with a list of the Accounts themselves.

  • total (Decimal): The total of the closing balances of the Category accounts as at the end date.

  • accounts (list): The Accounts belonging to the Category.

Return type:

dict