Acquire.Accounting._ledger module¶
-
class
Ledger[source]¶ Bases:
objectThis is a static class which manages the global ledger for the entire accounting service
-
static
get_key(uid)[source]¶ Return the object store key for the transaction record with UID=uid
Parameters: uid (str) – UID to get key ofr Returns: Object store key for UID Return type: str
-
static
load_transaction(uid, bucket=None)[source]¶ Load the transactionrecord with UID=uid from the ledger
Parameters: - uid (str) – UID of transaction to load
- bucket (dict, default=None) – Bucket to load data from
Returns: Transaction with that UID
Return type:
-
static
perform(transaction=None, transactions=None, debit_account=None, credit_account=None, authorisation=None, authorisation_resource=None, is_provisional=False, receipt_by=None, bucket=None)[source]¶ Perform the passed transaction(s) between ‘debit_account’ and ‘credit_account’, recording the ‘authorisation’ for this transaction. If ‘is_provisional’ then record this as a provisional transaction (liability for the debit_account, future unspendable income for the ‘credit_account’). Payment won’t actually be taken until the transaction is ‘receipted’ (which may be for less than (but not more than) then provisional value, and which must take place before ‘receipt_by’ (which will default to one week in the future if not supplied - the actual time is encoded in the returned TransactionRecords). Returns the (already recorded) TransactionRecord.
Note that if several transactions are passed, then they must all succeed. If one of them fails then they are immediately refunded.
Parameters: - transactions (the) – List of Transactions to process
- debit_account (Account) – Account to debit
- credit_account (Account) – Account to credit
- authorisation (Authorisation) – Authorisation for
- transactions –
- is_provisional (bool, default=False) – Whether the transactions
- provisional (are) –
- receipt_by (datetime, default=None) – Date by which transactions
- be receipted (must) –
- bucket – Bucket to load data from
-
static
receipt(receipt, bucket=None)[source]¶ Create and record a new transaction from the passed receipt. This applies the receipt, thereby actually transferring value from the debit account to the credit account of the corresponding transaction. Note that you can only receipt a transaction once! This returns the (already recorded) TransactionRecord for the receipt
Parameters: - receipt (Receipt) – Receipt to use for transaction
- bucket (default=None) – Bucket to load data from
Returns: List of TransactionRecords
Return type: list
-
static
refund(refund, bucket=None)[source]¶ Create and record a new transaction from the passed refund. This applies the refund, thereby transferring value from the credit account to the debit account of the corresponding transaction. Note that you can only refund a transaction once! This returns the (already recorded) TransactionRecord for the refund
-
static
save_transaction(record, bucket=None)[source]¶ Save the passed transaction record to the object store
Parameters: - record (TransactionRecord) – To save
- bucket (dict, default=None) – Bucket to save data from
Returns: None
-
static