Acquire.Accounting._transactionrecord module¶
-
class
TransactionRecord(uid=None, bucket=None)[source]¶ Bases:
objectThis 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_refund(refund)[source]¶ Assert that the passed refund matches this transaction
Parameters: refund (Refund) – Refund to check
-
credit_account_uid()[source]¶ Return the UID of the account to which value has been credited
Returns: Account UID to which value has been credited Return type: str
-
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
Returns: CreditNote for this transaction Return type: CreditNote
-
datetime()[source]¶ Return the datetime when this transaction was applied
Returns: Datetime at which transaction was applied Return type: datetime
-
debit_account_uid()[source]¶ Return the UID of the account from which value has been debited
Returns: Account UID from which value debited Return type: str
-
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
Returns: DebitNote for this transaction Return type: DebitNote
-
description()[source]¶ Return the description of this transaction
Returns: Description of this transaction Return type: str
-
static
from_data(data)[source]¶ Construct and return a new Transaction from the passed JSON-decoded dictionary
Parameters: data (dict) – Dictionary from JSON Returns: Created from JSON Return type: TransactionRecord
-
get_receipt_info()[source]¶ Return the receipt underlying this transaction
Returns: Receipt for this transaction Return type: Receipt
-
get_refund_info()[source]¶ Return the reason for the refund
Returns: Refund for this transaction Return type: Refund
-
is_direct()[source]¶ Return whether or not this transaction was direct (so was not provisional and so didn’t need a receipt)
Returns: True if direct transaction, else False Return type: bool
-
is_null()[source]¶ Return whether or not this is a null record
Returns: True if this record is null, else False Return type: bool
-
is_provisional()[source]¶ Return whether or not this transaction is provisional
Returns: True if transaction is provisional, else False Return type: bool
-
is_receipt()[source]¶ Return whether or not this transaction is a receipt
Returns: True if transaction is a receipt, else False Return type: bool
-
is_receipted()[source]¶ Return whether or not this transaction has been receipted
Returns: True if transaction receipted, else False Return type: bool
-
is_refund()[source]¶ Return whether or not this transaction is a refund
Returns: True if transaction is a refund, else False Return type: bool
-
is_refunded()[source]¶ Return whether or not this transaction has been refunded
Returns: True if transaction refunded, else False Return type: bool
-
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
Parameters: - expected_state (TransactionState) – State of transaction
- new_state (TransactionState) – State to update transaction to
- bucket (dict) – Bucket to load data from
Returns: Updated transaction
Return type:
-
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
Returns: TransactionRecord
-
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
Returns: 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
Returns: None
-
to_data()[source]¶ Return this transaction as a dictionary that can be encoded to JSON
Returns: Dictionary serialisable to JSON Return type: dict
-
transaction()[source]¶ Return the transaction underlying this record
Returns: Transaction underlying this TransactionRecord Return type: Transaction
-
transaction_state()[source]¶ Return the current state of this transaction
Returns: State of transaction Return type: Enum
-