models.line_item

Represents the individual entries in a Transaction that will eventually be posted to the Ledger.

Module Contents

Classes

LineItem

Represents the other side of the double entry from the main account of a Transaction.

class models.line_item.LineItem(**kw: Any)

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

Represents the other side of the double entry from the main account of a Transaction.

__tablename__ = 'line_item'
__mapper_args__
id: sqlalchemy.orm.Mapped[int]

The primary key of the Line Item database record.

Type:

(int)

narration: sqlalchemy.orm.Mapped[str]

A short description of the Line Item’s contribution to the Transaction.

Type:

(str)

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

The multiple of the Line Item amount to be posted to the Ledger.

Type:

(Decimal)

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

The amount to be posted to the Line Item Account.

Type:

(Decimal)

credited: sqlalchemy.orm.Mapped[bool]

Determines whether the Line Item amount will be posted to the credit side of the Line Item Account. Defaults to False.

Type:

(bool, optional)

tax_inclusive: sqlalchemy.orm.Mapped[bool]

Determines whether the Tax amount of the Line Item is included in the Line Item amount. Defaults to False.

Type:

(bool, optional)

account_id: sqlalchemy.orm.Mapped[int]

The id of the Account model associated with the Line Item.

Type:

(int)

transaction_id: sqlalchemy.orm.Mapped[int]

The id of the Transaction model associated with the Line Item.

Type:

(int, optional)

tax_id: sqlalchemy.orm.Mapped[int]

The id of the Tax model associated with the Line Item.

Type:

(int, optional)

account: sqlalchemy.orm.Mapped[Account]

The the Account model associated with the Line Item.

Type:

(Account)

tax: sqlalchemy.orm.Mapped[Tax]

The Tax model associated with the Line Item.

Type:

(Tax, optional)

transaction: sqlalchemy.orm.Mapped[Transaction]

The Transaction model associated with the Line Item.

Type:

(Transaction, optional)

ledgers: sqlalchemy.orm.Mapped[List[Ledger]]

The Ledger models associated with the Line Item.

Type:

(list)

validate_ledgers(key, ledger, is_remove)

Validates adding or removing of Line Item Ledgers.

Raises:

ValueError – If the Line Item Ledgers are manually added or removed.

__repr__() str
validate(_) None

Validates the Line Item properties.

Parameters:

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

Raises:

NegativeValueError – If the Line Item amount or quantity is less than 0.

Returns:

None

validate_delete(session) None

Validates if the line item can be deleted.