mixins

Provides accounting functionality mixins.

Submodules

Package Contents

Classes

AssigningMixin

This class provides assignable Transactions functionality for

BuyingMixin

This class provides validation for Transaction that buy goods and services for an Entity.

ClearingMixin

This class provides clearable Transactions functionality for assigning them to

IsolatingMixin

This class enables isolating by Entity for accounting objects.

SellingMixin

This class provides validation for Transaction that sell goods and services for an Entity.

class mixins.AssigningMixin

This class provides assignable Transactions functionality for clearing clearable Transactions.

balance(session) decimal.Decimal
Gets how much of the Transaction amount is remaining available for assigning

to clearable Transactions.

Parameters:

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

Returns:

The difference between the Transaction amount and the total amount of assignments made to it.

Return type:

Decimal

assignments(session) list

Gets the assignments made on the Transaction.

Parameters:

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

Returns:

A List of assignments made for the Transaction.

unassign(session) None

Removes all assignments made to this Transaction.

Parameters:

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

Returns:

None

bulk_assign(session) None

Assigns the Transaction’s amount to all outstanding clearable Transactions for the main account on a FIFO basis.

Parameters:

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

Returns:

None

class mixins.BuyingMixin(**kw: Any)

Bases: python_accounting.mixins.trading.TradingMixin

This class provides validation for Transaction that buy goods and services for an Entity.

line_item_types: list

A list of Account Types that are allowed as Line Item accounts for buying Transactions.

Type:

(list of Account.AccountType)

main_account_types: list

A list of Account Types that are allowed as main accounts for buying Transactions.

Type:

(list of Account.AccountType)

account_type_map: dict

A mapping of Transactions to the Account Types that apply to their validation.

Type:

(dict of Account.AccountType)

class mixins.ClearingMixin

This class provides clearable Transactions functionality for assigning them to assignable Transactions.

cleared(session) decimal.Decimal

Gets how much of the Transaction amount has been cleared by assignable Transactions.

Parameters:

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

Returns:

The total amount of assignments made against Transaction.

Return type:

Decimal

clearances(session) list

Gets the assignments made to clear the Transaction.

Parameters:

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

Returns:

A List of assignments made to clear the Transaction.

unclear(session) None

Removes all assignments made to clear this Transaction.

Parameters:

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

Returns:

None

class mixins.IsolatingMixin

This class enables isolating by Entity for accounting objects.

entity_id

The id of the Entity to which the model belongs.

Type:

int

entity_id: sqlalchemy.orm.Mapped[int]
entity() sqlalchemy.orm.Mapped[Entity]

Returns the Entity of the instance.

class mixins.SellingMixin(**kw: Any)

Bases: python_accounting.mixins.trading.TradingMixin

This class provides validation for Transaction that sell goods and services for an Entity.

line_item_types: list

A list of Account Types that are allowed as Line Item accounts for selling Transactions.

Type:

(list of Account.AccountType)

main_account_types: list

A list of Account Types that are allowed as main accounts for selling Transactions.

Type:

(list of Account.AccountType)

account_type_map: dict

A mapping of Transactions to the Account Types that apply to their validation.

Type:

(dict of`Account.AccountType`)