Transaction

Hugh Jeremy edited this page Oct 4, 2018 · 3 revisions

Documentation > Transaction

A Transaction is an exchange of value between two or more Accounts. For example, the raising of an invoice, the incrurring of a liability, or the receipt of a payment. Many Transactions together, each touching the same Account, form an Account Ledger, and the cumulative sum of the Transactions form an Account Balance.

Transactions are composed of Entries, each of which includes a debit or credit (The fundamental Sides). The sum of all debits and credits in all the Entries that compose a Transaction must always equal zero.

Transactions may be retrieved and created in arbitrary units, either a Global Units or Custom Units. Amatino will transparently handle all unit conversions. For example, a Transaction could be created in Australian Dollars, touch an Account denominated in Pounds Sterling, and be retrieved in Bitcoin.

Properties

.session - Session

The underlying credentials used to retrieve this Transaction instance


.entity - Entity

The Entity which this Transaction describes

.time - datetime

The time at which this Transaction was or is to be executed


.description - str

A human-friendly description of this Transaction

Example: 'Recognise receipt of sweet loot'


.entries - List[Entry]

A list Entry instances that comprise this Transaction


.global_unit_id - Optional[int]

The integer identifier of the GlobalUnit that denominates this Transaction, if any

Example: 5


.customer_unit_id - Optional[int]

The integer identifier of the CustomUnit that denominations this Transaction, if any

Example: None


.denomination - Denomination

The unit denominating this Transaction - Either a GlobalUnit or CustomUnit

Methods

classmethod .create() -> Transaction

Return a new Transaction, created using the supplied parameters

Parameters

  1. session: Session
  2. entity: Entity
  3. time: datetime
  4. entries: List[Entry]
  5. denomination: Denomination
  6. description: Optional[str]

Example

transaction = Transaction.create(
  session=session,
  entity=mega_corp,
  time=datetime.utcnow(),
  entries=[
    Entry(Side.debit, Decimal(10), asset_account),
    Entry(Side.credit, Decimal(5), liability_account),
    Entry(Side.credit, Decimal(5), another_account)
  ]
  denomination=USD
)

classmethod .retrieve() -> Transaction

Return an existing Transaction.

Note that a Denomination is required - A Transaction may touch Accounts with heterogenous denominations, a circumstance under which default behaviour would be non-deterministic. Therefore, you are required to explicitly provide the denomination with which you wish to view the Transaction. You can get a convenient reference to .denomination from Account and other Transaction instances.

Parameters

  1. session: Session
  2. entity: Entity
  3. id_: int
  4. denomination: Denomination

Example

transaction = Transaction.retrieve(
  session=session,
  entity=mega_corp,
  id_=458923,
  denomination=USD
)

.update() -> Transaction

Return an updated Transaction. NB: The Transaction instance is not updated in place. The updated Transaction is returned.

All parameters are optional. Those that you do not supply will be set to existing values.

Parameters

  1. time: Optional[datetime]
  2. entries: Optional[List[Entry]]
  3. denomination: Optional[Denomination]
  4. description: Optional[str]

Example

updated_transaction = existing_transaction.update(
  description='New, fancier description',
  time=datetime.utcnow()
)

.delete() -> None:

Return None after destroying this Transaction, such that it will be no longer included in any view of this Entity's accounting information.

Parameters

None

Example

existing_transaction.delete()
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.