accounting package

Submodules

accounting.client module

class accounting.client.Client(host=None, json_encoder=None, json_decoder=None)[source]

Bases: builtins.object

get(path)[source]
get_balance()[source]
get_register()[source]
post(path, payload, **kw)[source]
simple_transaction(from_acc, to_acc, amount, symbol=None, payee=None)[source]
accounting.client.main(argv=None, prog=None)[source]
accounting.client.print_balance_accounts(accounts, level=0)[source]
accounting.client.print_transactions(transactions)[source]

accounting.config module

accounting.decorators module

accounting.decorators.allow_all_origins(origin)[source]
accounting.decorators.cors(origin_callback=None)[source]

Flask endpoint decorator.

Example:

@app.route('/cors-endpoint', methods=['GET', 'OPTIONS'])
@cors()
def cors_endpoint():
    return jsonify(message='This is accessible via a cross-origin XHR')

# Or if you want to control the domains this resource can be requested
# from via CORS:
domains = ['http://wandborg.se', 'http://sfconservancy.org']

def restrict_domains(origin):
    return ' '.join(domains)

@app.route('/restricted-cors-endpoint')
@cors(restrict_domains)
def restricted_cors_endpoint():
    return jsonify(
        message='This is accessible from %s' % ', '.join(domains))
Parameters:origin_callback (function) – A callback that takes one str() argument containing the Origin HTTP header from the request object. This can be used to filter out which domains the resource can be requested via CORS from.
accounting.decorators.jsonify_exceptions(func)[source]

Wraps a Flask endpoint and catches any AccountingException-based exceptions which are returned to the client as JSON.

accounting.exceptions module

exception accounting.exceptions.AccountingException(message, **kw)[source]

Bases: builtins.Exception

Used as a base for exceptions that are returned to the caller via the jsonify_exceptions decorator

exception accounting.exceptions.LedgerNotBalanced(message, **kw)

Bases: accounting.exceptions.AccountingException

exception accounting.exceptions.TransactionIDCollision(message, **kw)

Bases: accounting.exceptions.AccountingException

exception accounting.exceptions.TransactionNotFound(message, **kw)[source]

Bases: accounting.exceptions.AccountingException

accounting.gtkclient module

class accounting.gtkclient.AccountingApplication[source]

Bases: builtins.object

load_ui(path)[source]
on_about_dialog_response(widget, response_type)[source]
on_show_about_activate(widget)[source]
on_transaction_refresh_activate(widget)[source]
on_transaction_view_cursor_changed(widget)[source]
on_transactions_loaded(transactions)[source]
accounting.gtkclient.indicate_activity(func_or_str)[source]
accounting.gtkclient.indicate_activity_done(func)[source]
accounting.gtkclient.main(argv=None)[source]

accounting.models module

class accounting.models.Account(name=None, amounts=None, accounts=None)[source]

Bases: builtins.object

class accounting.models.Amount(amount=None, symbol=None)[source]

Bases: builtins.object

class accounting.models.Posting(account=None, amount=None, metadata=None)[source]

Bases: builtins.object

class accounting.models.Transaction(id=None, date=None, payee=None, postings=None, metadata=None, _generate_id=False)[source]

Bases: builtins.object

generate_id()[source]

accounting.transport module

class accounting.transport.AccountingDecoder[source]

Bases: flask.json.JSONDecoder

dict_to_object(d)[source]
class accounting.transport.AccountingEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: flask.json.JSONEncoder

default(o)[source]

accounting.web module

This module contains the high-level webservice logic such as the Flask setup and the Flask endpoints.

accounting.web.client()[source]
accounting.web.index()[source]

Hello World!

accounting.web.init_ledger()[source]
accounting.web.main(argv=None)[source]
accounting.web.transaction_by_id_options(transaction_id=None)[source]
accounting.web.transaction_delete(transaction_id=None)[source]
accounting.web.transaction_get(transaction_id=None)[source]
accounting.web.transaction_get_all(transaction_id=None)

Returns the JSON-serialized output of accounting.Ledger.reg()

accounting.web.transaction_options()[source]
accounting.web.transaction_post()[source]

REST/JSON endpoint for transactions.

Current state:

Takes a POST request with a transactions JSON payload and writes it to the ledger file.

Requires the transactions payload to be __type__-annotated:

{
  "transactions": [
    {
      "__type__": "Transaction",
      "date": "2013-01-01",
      "payee": "Kindly T. Donor",
      "postings": [
        {
          "__type__": "Posting",
          "account": "Income:Foo:Donation",
          "amount": {
            "__type__": "Amount",
            "amount": "-100",
            "symbol": "$"
          }
        },
        {
          "__type__": "Posting",
          "account": "Assets:Checking",
          "amount": {
            "__type__": "Amount",
            "amount": "100",
            "symbol": "$"
          }
        }
      ]
    }
}

becomes:

2013-01-01 Kindly T. Donor
  Income:Foo:Donation                                         $ -100
  Assets:Checking                                              $ 100
accounting.web.transaction_update(transaction_id=None)[source]

Module contents