Acquire.Accounting._transactionrecord module

class TransactionRecord(uid=None, bucket=None)[source]

Bases: object

This class holds a record of a transaction that has already been written to the accounting ledger. This records a unique ID, the datetime of the entry, the value, the two accounts involved in the transaction (debit account to credit account), a description of what the transaction refers to, and who/how the transaction was authorised. If ‘is_provisional’ then this is a provisional transaction that is recorded as a liability for the debtor and a future income for the creditor. This is confirmed by creating a receipt via “receipt_for” by passing the UID for the transaction this receipts, and the actual ‘value’ of the receipt. Note that the actual value CANNOT exceed the original provisional value that was agreed by the debtor

assert_matching_receipt(receipt)[source]

Assert that the passed receipt matches this transaction

assert_matching_refund(refund)[source]

Assert that the passed refund matches this transaction

credit_account_uid()[source]

Return the UID of the account to which value has been credited

credit_note()[source]

Return the credit note for this transaction. This is the note recording that value has been credited to an account. A TransactionRecord is the pairing of a DebitNote with a CreditNote

datetime()[source]

Return the datetime when this transaction was applied

debit_account_uid()[source]

Return the UID of the account from which value has been debited

debit_note()[source]

Return the debit note for this transaction. This is the note recording that value has been debited to an account. A TransactionRecord is the pairing of a DebitNote with a CreditNote

description()[source]

Return the description of this transaction

static from_data(data)[source]

Construct and return a new Transaction from the passed json-decoded dictionary

get_receipt_info()[source]

Return the receipt underlying this transaction

get_refund_info()[source]

Return the reason for the refund

is_direct()[source]

Return whether or not this transaction was direct (so was not provisional and so didn’t need a receipt)

is_null()[source]

Return whether or not this is a null record

is_provisional()[source]

Return whether or not this transaction is provisional

is_receipt()[source]

Return whether or not this transaction is a receipt

is_receipted()[source]

Return whether or not this transaction has been receipted

is_refund()[source]

Return whether or not this transaction is a refund

is_refunded()[source]

Return whether or not this transaction has been refunded

static load_test_and_set(uid, expected_state, new_state, bucket=None)[source]

Static method to load up the Transaction record associated with the passed UID, check that the transaction state matches ‘expected_state’, and if it does, to update the transaction state to ‘new_state’. This returns the loaded (and updated) transaction

original_transaction()[source]

If this is a receipt or refund transaction then return the original transaction that this is receipting or refunding. Otherwise returns a null Transaction

original_transaction_record()[source]

If this is a receipt or refund transaction then return the original transaction record that this is receipting or refunding. Otherwise returns a null TransactionRecord

reload()[source]

Reload this transaction record from the object store. This is necessary if, e.g., the state of the record has been updated

to_data()[source]

Return this transaction as a dictionary that can be encoded to json

transaction()[source]

Return the transaction underlying this record

transaction_state()[source]

Return the current state of this transaction

uid()[source]

Return the UID for this transaction record

value()[source]

Return the value of this transaction

class TransactionState[source]

Bases: enum.Enum

This class holds an enum of the current state of a transaction

DIRECT = 'DR'
PROVISIONAL = 'PR'
RECEIPTED = 'RD'
RECEIPTING = 'RC'
REFUNDED = 'RR'
REFUNDING = 'RF'