models.account
Represents an Account, the basic unit of accounting that groups the transactions of an Entity.
Module Contents
Classes
Represents an account which groups related Transactions. |
Attributes
- models.account.account_type_enum
- class models.account.Account
Bases:
python_accounting.mixins.IsolatingMixin,python_accounting.models.recyclable.RecyclableRepresents an account which groups related Transactions.
- AccountType
Account Types as defined by IFRS and GAAP.
- Type:
(StrEnum)
- purchasables
A list of Account Types that can be used in purchasing Transactions.
- Type:
(list of Account.AccountType)
- __mapper_args__
- id: sqlalchemy.orm.Mapped[int]
The primary key of the Account database record.
- Type:
(int)
- name: sqlalchemy.orm.Mapped[str]
The label of the Account.
- Type:
(str)
- description: sqlalchemy.orm.Mapped[str]
A narration of the purpose of the Account.
- Type:
(str, optional)
- account_code: sqlalchemy.orm.Mapped[int]
A serially generated code based on the type of the Account.
- Type:
(int)
- account_type: sqlalchemy.orm.Mapped[strenum.StrEnum]
The type of the Account.
- Type:
(AccountType)
- currency_id: sqlalchemy.orm.Mapped[int]
The id of the Currency model associated with the Account.
- Type:
(int)
- category_id: sqlalchemy.orm.Mapped[int]
The id of the Category model to which the Account belongs.
- Type:
(int, optional)
- currency: sqlalchemy.orm.Mapped[Currency]
The Currency associated with the Account.
- Type:
(Currency)
- category: sqlalchemy.orm.Mapped[Category]
The Category to which the Account belongs.
- Type:
(Category, optional)
- _get_account_code(session) int
- __repr__() str
- balance_movement(session, start_date: datetime.datetime, end_date: datetime.datetime) decimal.Decimal
Get the change in the account balance between the given dates.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
start_date (datetime) – The earliest transaction date for Transaction amounts to be included in the balance.
end_date (datetime) – The latest transaction date for Transaction amounts to be included in the balance.
- Returns:
The difference between the balance of the Account at the start date and end date.
- Return type:
Decimal
- static section_balances(session, account_types: list, start_date: datetime.datetime = None, end_date: datetime.datetime = None, full_balance: bool = True) dict
Gets the opening, movement and closing balances of the accounts of the given section (account types), organized by category.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
account_types (list of Account.AccountType) – The Account types belonging to the section.
start_date (datetime) – The earliest transaction date for Transaction amounts to be included in the balance.
end_date (datetime) – The latest transaction date for Transaction amounts to be included in the balance.
full_balance (bool) – Whether to include opening balance amounts in the balance.
- Returns:
A summary of the total opening, balance movement and closing balance, which details of totals by Category and the Accounts contained in each Category.
opening (Decimal): The sum of opening balances of Accounts in the section.
movement (Decimal): The movememt of the balances of Accounts in the section.
closing (Decimal): The sum of opening closing of Accounts in the section.
categories (dict): The Accounts belonging to the section separated by Category.
- Return type:
dict
- opening_balance(session, year: int = None) decimal.Decimal
Gets the the opening balance for the account for the given year.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
year (int) – The calendar year for which to retrieve the opening balance.
- Returns:
The total opening balance of the Account for the year.
- Return type:
Decimal
- closing_balance(session, end_date: datetime.datetime = None) decimal.Decimal
Gets the the closing balance of the Account as at the given date.
- 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 balance.
- Returns:
The total opening balance of the Account for the year.
- Return type:
Decimal
- statement(session, start_date: datetime.datetime = None, end_date: datetime.datetime = None, schedule: bool = False) dict
- Gets a chronological listing of the Transactions posted to the Account between
the dates given.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
start_date (datetime) – The earliest transaction date for Transaction amounts to be included in the statement.
end_date (datetime) – The latest transaction date for Transaction amounts to be included in the statement.
schedule (bool) – Whether to exclude assignable Transactions and only list clearable Transactions with outstanding amounts.
- Raises:
InvalidAccountTypeError – If the Account type is not Receivable or Payable.
- Returns:
With a A summary of the opening and closing balance in the case of a statement, the total, cleared and uncleared amounts if its a schedule together with a list of Transactions.
- Statements.
opening_balance (Decimal): The balance of the Account at the beginning of the statement period.
transactions (list): Transactions posted to the Account during the period.
closing_balance (Decimal): The balance of the Account at the end of the statement period.
- Schedule.
transactions (list): Outstanding clearable Transactions posted to the Account as at the end date.
total_amount (Decimal): The total amount of the Transactions in the Schdeule.
cleared_amount (Decimal): The amount of the Transactions in the Schdeule that has been cleared.
uncleared_amount (Decimal): The amount of the Transactions in the Schdeule that is still outstanding.
- Return type:
dict
- validate(session) None
Validates the Account properties.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
- Raises:
InvalidCategoryAccountTypeError – If the account type of the Account does not match that of its assigned Category.
- Returns:
None
- validate_delete(session) None
Validates if the account can be deleted.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
- Raises:
HangingTransactionsError – If the Account has had Transactions during the current Reporting period.
- Returns:
None