fava

Fava – A web interface for Beancount.

fava.application

Fava’s main WSGI application.

when using Fava’s WSGI app, make sure to set app.config['BEANCOUNT_FILES']. To start a simple server:

from fava.application import app
app.config['BEANCOUNT_FILES'] = ['/path/to/file.beancount']
app.run('localhost', 5000)
fava.application.app

An instance of flask.Flask, this is Fava’s WSGI application.

fava.application.account(name, subreport='journal')

The account report.

fava.application.context()

Entry context.

fava.application.document()

Download a document.

fava.application.download_journal()

Download a Journal file.

fava.application.download_query(result_format)

Download a query result.

fava.application.extension_report(report_name)

Endpoint for extension reports.

fava.application.fava_api_exception(error)

Handle API errors.

fava.application.get_locale()

Get locale.

Returns

The locale that should be used for Babel. If not given as an option to Fava, guess from browser.

fava.application.help_page(page_slug='_index')

Fava’s included documentation.

fava.application.holdings_by(aggregation_key)

The holdings report.

fava.application.index()

Redirect to the Income Statement (of the given or first file).

fava.application.jump()

Redirect back to the referer, replacing some parameters.

This is useful for sidebar links, e.g. a link /jump?time=year would set the time filter to year on the current page.

When accessing /jump?param1=abc from /example/page?param1=123&param2=456, this view should redirect to /example/page?param1=abc&param2=456.

fava.application.report(report_name)

Endpoint for most reports.

fava.application.statement()

Download a statement file.

fava.application.static_url(**values)

Return a static url with an mtime query string for cache busting.

fava.application.template_context()

Inject variables into the template context.

fava.application.url_for(endpoint, **values)

A wrapper around flask.url_for that uses a cache.

fava.application.url_for_current(**kwargs)

URL for current page with updated request args.

fava.application.url_for_source(**kwargs)

URL to source file (possibly link to external editor).

fava.cli

The command-line interface for Fava.

fava.json_api

JSON API.

This module contains the url endpoints of the JSON API that is used by the web interface for asynchronous functionality.

fava.json_api.add_document()

Upload a document.

fava.json_api.add_entries(request_data)

Add multiple entries.

fava.json_api.api_endpoint(func)

Register an endpoint.

fava.json_api.changed()

Check for file changes.

fava.json_api.errors()

Number of errors.

fava.json_api.extract()

Extract entries using the ingest framework.

fava.json_api.filepath_in_document_folder(documents_folder, account, filename)

File path for a document in the folder for an account.

Parameters
  • documents_folder – The documents folder.

  • account – The account to choose the subfolder for.

  • filename – The filename of the document.

Returns

The path that the document should be saved at.

fava.json_api.format_source(request_data)

Format beancount file.

fava.json_api.json_request(func)

Check existence and load the JSON payload of the request.

fava.json_api.json_response(func)

Jsonify the response.

fava.json_api.move()

Move a file.

fava.json_api.payee_accounts()

Rank accounts for the given payee.

fava.json_api.payee_transaction()

Last transaction for the given payee.

fava.json_api.source(request_data)

Write one of the source files.

fava.serialisation

(De)serialisation of entries.

When adding entries, these are saved via the JSON API - using the functionality of this module to obtain the appropriate data structures from beancount.core.data. Similarly, for the full entry completion, a JSON representation of the entry is provided.

This is not intended to work well enough for full roundtrips yet.

fava.serialisation.deserialise(json_entry)

Parse JSON to a Beancount entry.

Parameters

json_entry – The entry.

Raises
  • KeyError – if one of the required entry fields is missing.

  • FavaAPIException – if the type of the given entry is not supported.

fava.serialisation.deserialise_posting(posting)

Parse JSON to a Beancount Posting.

Extract tags and links from a narration string.

Parameters
  • string – A string, possibly containing tags (#tag) and links

  • (^link)

Returns

A triple (new_string, tags, links) where new_string is string stripped of tags and links.

fava.serialisation.parse_number(num)

Parse a number as entered in an entry form, supporting division.

fava.serialisation.serialise(entry)

Serialise an entry.

fava.template_filters

Template filters for Fava.

All functions in this module will be automatically added as template filters.

fava.template_filters.balance_children(account)

Compute the total balance of an account.

fava.template_filters.basename(file_path)

Return the basename of a filepath.

fava.template_filters.collapse_account_at_level(account_name, level)

Return true if account should be collapsed at the given tree depth.

fava.template_filters.cost(inventory)

Get the cost of an inventory.

fava.template_filters.cost_or_value(inventory, date=None)

Get the cost or value of an inventory.

fava.template_filters.flag_to_type(flag)

Names for entry flags.

fava.template_filters.format_amount(amount)

Format an amount to string using the DisplayContext.

fava.template_filters.format_currency(value, currency=None, show_if_zero=False)

Format a value using the derived precision for a specified currency.

fava.template_filters.format_date(date)

Format a date according to the current interval.

fava.template_filters.format_errormsg(message)

Match account names in error messages and insert HTML links for them.

fava.template_filters.get_market_value(pos, price_map, date=None)

Get the market value of a Position.

This differs from the convert.get_value function in Beancount by returning the cost value if no price can be found.

Parameters
  • pos – A Position.

  • price_map – A dict of prices, as built by prices.build_price_map().

  • date – A datetime.date instance to evaluate the value at, or None.

Returns

An Amount, with value converted or if the conversion failed just the cost value (or the units if the position has no cost).

fava.template_filters.get_or_create(account, account_name)

Get or create a child account.

fava.template_filters.hash_entry(entry)

Hash an entry.

fava.template_filters.remove_keys(_dict, keys)

Remove keys from a dictionary.

fava.template_filters.should_show(account)

Determine whether the account should be shown.

fava.template_filters.units(inventory)

Get the units of an inventory.