Skip to content
Hugh Jeremy edited this page Oct 4, 2018 · 4 revisions

Documentation > Entry

Entries compose Transactions. An individual entry allocates some value to an Account as either one of the fundamental Sides: a debit or a credit. All together, those debits and credits will add up to zero, satisfying the fundamental double-entry accounting equality.

When consuming the Amatino API, operations involving Entries always occur as part of a Transaction request. For example, when creating a Transaction, you will specify a list of Entry objects under the entries key. You will never send or recieve an Entry object on its own to or from the Amatino API.

Unlike almost all other classes in Amatino Python, Entries are initialised using the native __init__ initialiser rather than through a class method.

Parameters

.side - Side

Either a debit or a credit.

Example: Side.debit


.account_id - int

The integer identifier of the Account to which this Entry records value.

Example: 42


. amount - decimal.Decimal

A Decimal absolute magnitude of the value of this Entry

Example: 125.23


.description

A string human-readable description of this Entry

Example: 'Record deposit component of customer order'


Initialiser

Unlike most other Amatino Python classes, Entries require the use of their native init initialiser.

Parameters

  1. side: Side
  2. amount: decimal.Decimal
  3. account: Account
  4. description: Optional[str]

Example

debit = Entry(
  side=Side.debit,
  amount=Decimal(42),
  account=cash_account
)

Methods

classmethod .create_balanced_pair -> List[Entry]

Return a list containing pair of Entries. The two Entries will be in balance. Useful as a shorthand when creating a Transaction to which only two Accounts are party.

Parameters

  1. debit_account: Account
  2. credit_account: Account
  3. amount: decimal.Decimal
  4. description: Optional[str]

Example

balanced_pair = Entry.create_balanced_pair(
  debit_account=cash_account,
  credit_account=revenue,
  amount=Decimal(42)
)

classmethod .plug() -> Optional[Entry]

Return an Entry that plugs the balance gap in a set of given Entries. Or, return None if the Entries are already in balance. Handy as a shorthand when you know that the final Entry in a Transaction is the remaining imbalance from already calculated Entries.

Parameters

  1. account: Account
  2. entries: List[Entry]
  3. description: Optional[str]

Example

entry_1 = Entry(Side.debit, Decimal(5), cash_account)
entry_2 = Entry(Side.credit, Decimal(10), revenue_account)

plug_entry = Entry.plug(
  account=receivables,
  entries=[entry_1, entry_2]
)

print(plug_entry.amount)
# Prints '5'

Clone this wiki locally