models.assignment

Represents an matching between Transactions that have an opposite effect on an Account.

Module Contents

Classes

Assignment

Represents an assigment of a clearable type to an assignable Transaction.

class models.assignment.Assignment

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

Represents an assigment of a clearable type to an assignable Transaction.

clearables

A list of Transaction Types that can be cleared by assignable Transactions.

Type:

(list of Transaction.TransactionType)

assignables

A list of Transaction Types that can have cleareable Transactions assigned to them.

Type:

(list of Transaction.TransactionType)

assignment_date: sqlalchemy.orm.Mapped[datetime.datetime]

The date of the Assignment.

Type:

(datetime)

transaction_id: sqlalchemy.orm.Mapped[int]

The id of the assignable Transaction in the Assignment.

Type:

(int)

assigned_id: sqlalchemy.orm.Mapped[int]

The id of the clearable Transaction|Balance in the Assignment.

Type:

(int)

assigned_type: sqlalchemy.orm.Mapped[str]

The class name of the clearable Transaction|Balance in the Assignment.

Type:

(str)

assigned_no: sqlalchemy.orm.Mapped[str]

The Transaction number of the clearable Transaction|Balance in the Assignment.

Type:

(str)

amount: sqlalchemy.orm.Mapped[decimal.Decimal]

The amount of the Assignment.

Type:

(Decimal)

transaction: sqlalchemy.orm.Mapped[python_accounting.models.Transaction]

The assignable Transaction in the Assignment.

Type:

(Transaction)

__repr__() str
assigned(session) python_accounting.models.Transaction

Get the clearable Transaction|Balance assigned to this assigment’s transaction.

Parameters:

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

Returns:

The model cleared by this assignment.

Return type:

Transaction|Balance

validate(session) None

Validates the Assignment properties.

Parameters:

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

Raises:
  • ValueError – If the assignable Transaction or clearable Transaction|Balance could not be found.

  • UnassignableTransactionError – If the assignable Transaction type is not one of the assignable types.

  • UnclearableTransactionError – If the clearable Transaction type is not one of the clearable types.

  • UnpostedAssignmentError – If either the assignable or clearable Transaction is not posted.

  • InsufficientBalanceError – If the remaining balance in the assignable Transaction is less than the Assignment amount.

  • OverclearanceError – If the Assignment amount is greater than the clearable Transaction|Balance uncleared amount.

  • CompoundTransactionAssignmentError – If either the assignable or clearable Journal Entry is a compound Transaction.

  • SelfClearanceError – If the assignable and clearable Transaction of the Assignment is the same.

  • InvalidAssignmentAccountError – If the assignable Transaction and clearable Transaction|Balance main Accounts are not the same.

  • MixedAssignmentError – If either an already Transaction is being cleared or an already cleared Transaction is being assigned.

Returns:

None