accounting.storage package

Submodules

accounting.storage.ledgercli module

class accounting.storage.ledgercli.Ledger(app=None, ledger_file=None, ledger_bin=None)[source]

Bases: accounting.storage.Storage

add_transaction(transaction)[source]

Writes a transaction to the ledger file by opening it in ‘ab’ mode and writing a ledger transaction based on the Transaction instance in transaction.

assemble_arguments(command=None)[source]

Returns a list of arguments suitable for subprocess.Popen based on self.ledger_bin and self.ledger_file.

bal()[source]
commit_changes(message)

Commits any changes to self.ledger_file to the git repository

delete_transaction(transaction_id)[source]

Delete a transaction from the ledger file.

This method opens the ledger file, loads all lines into memory and looks for the transaction_id, then looks for the bounds of that transaction in the ledger file, removes all lines within the bounds of the transaction and removes them, then writes the lines back to the ledger file.

Exceptions:

  • RuntimeError: If all boundaries to the transaction are not found
  • TransactionNotFound: If no such transaction_id can be found in self.ledger_file
get_transaction(transaction_id)[source]
get_transactions()[source]
reg()[source]
send_command(command)[source]

Creates a new ledger process with the specified command and returns the output.

Raises an AccountingException-based Exception based on the ledger-cli stderr.

update_transaction(transaction)[source]

Update a transaction in the ledger file.

Takes a Transaction object and removes the old transaction using transaction.id from the passed Transaction instance and adds transaction to the database.

accounting.storage.ledgercli.main(argv=None)[source]

Module contents

class accounting.storage.Storage(*args, **kw)[source]

Bases: builtins.object

ABC for accounting storage

add_transaction(transaction)[source]
delete_transaction(transaction_id)[source]
get_account(*args, **kw)[source]
get_accounts(*args, **kw)[source]
get_transaction(*args, **kw)[source]
get_transactions(*args, **kw)[source]
reverse_transaction(transaction_id)[source]
update_transaction(transaction)[source]

Table Of Contents

Related Topics

This Page