models.balance
Represents the amount outstanding on a Transaction from a previous Reporting Period.
Module Contents
Classes
Represents a Balance brought down from previous Reporting Periods. |
- class models.balance.Balance
Bases:
python_accounting.mixins.IsolatingMixin,python_accounting.mixins.ClearingMixin,python_accounting.models.RecyclableRepresents a Balance brought down from previous Reporting Periods.
- property is_posted: bool
is_posted analog for the assignment model.
- property credited: bool
credited analog for the assignment model.
- property compound: bool
compound analog for the assignment model.
- BalanceType
The double entry types of Balances.
- Type:
(StrEnum)
- BalanceTransactions
A list of Transaction Types that can have Balances.
- Type:
(StrEnum)
- __mapper_args__
- id: sqlalchemy.orm.Mapped[int]
The primary key of the Account database record.
- Type:
(int)
- transaction_date: sqlalchemy.orm.Mapped[datetime.datetime]
The date of the Balance Transaction.
- Type:
(datetime)
- reference: sqlalchemy.orm.Mapped[str]
Identifying information about the Balance Transaction.
- Type:
(str, optional)
- transaction_no: sqlalchemy.orm.Mapped[str]
The Transaction number of the Balance Transaction.
- Type:
(str)
- transaction_type: sqlalchemy.orm.Mapped[strenum.StrEnum]
The Transaction type of the Balance Transaction.
- Type:
(TransactionType)
- amount: sqlalchemy.orm.Mapped[decimal.Decimal]
The amount outstanding on the Balance Transaction.
- Type:
(Decimal)
- balance_type: sqlalchemy.orm.Mapped[strenum.StrEnum]
The side of the double entry to post the Balance amount.
- Type:
(BalanceType)
- currency_id: sqlalchemy.orm.Mapped[int]
The id of the Currency model associated with the Balance.
- Type:
(int)
- account_id: sqlalchemy.orm.Mapped[int]
The id of the Account model to which the Balance belongs.
- Type:
(int)
- reporting_period_id: sqlalchemy.orm.Mapped[int]
The id of the Reporting Period model to which the Balance belongs.
- Type:
(int)
- currency: sqlalchemy.orm.Mapped[python_accounting.models.Currency]
The Currency model associated with the Balance.
- Type:
(Currency)
- account: sqlalchemy.orm.Mapped[python_accounting.models.Account]
The Account model to which the Balance belongs.
- Type:
(Account)
- reporting_period: sqlalchemy.orm.Mapped[python_accounting.models.ReportingPeriod]
The Reporting Period model to which the Balance belongs.
- Type:
- __repr__() str
- static opening_trial_balance(session, year: int = None) dict
Gets the total opening balances for the Entity’s accounts for the given year.
- Parameters:
session (Session) – The accounting session to which the Account belongs.
year (int, optional) – The calendar year to retrieve the opening trial balance for. Defaults to the Balance’s Entity current Reporting Period’s calendar year.
- Returns:
With a A summary of the debit and credit balances of the Accounts together with a list of the Accounts themselves.
debits (Decimal): The total debit balance.
credits (Decimal): The total credit balance.
accounts (Decimal): Accounts constituting the opening trial balance.
- Return type:
dict
- validate(session) None
Validates the Balance properties.
- Parameters:
session (Session) – The accounting session to which the Balance belongs.
- Raises:
NegativeValueError – If the Balance amount is less than 0.
InvalidBalanceAccountError – If the Balance main Account is an Income Statement Account.
InvalidBalanceTransactionError – If the Balance Transaction type is not one of the Balance Transaction types.
InvalidBalanceDateError – If the Balance Transaction date is within the current reporting period and the Entity does not allow mid year balances.
- Returns:
None