fava¶
Fava - A web interface for Beancount.
fava._ctx_globals_class¶
Specify types for the flask application context.
- class fava._ctx_globals_class.Context¶
The context values - this is used for flask.g.
- beancount_file_slug: str | None¶
Slug for the active Beancount file.
- property conv: Conversion¶
Conversion to apply (parsed).
- extension: FavaExtensionBase | None¶
The current extension, if this is an extension endpoint
- property filtered: FilteredLedger¶
The filtered ledger.
- ledger: FavaLedger¶
The ledger
fava.application¶
Fava’s main WSGI application.
you can use create_app to create a Fava WSGI app for a given list of files. To start a simple server:
from fava.application import create_app
app = create_app(['/path/to/file.beancount'])
app.run('localhost', 5000)
- fava.application.app(environ, start_response) = <Flask 'fava'>¶
This is still provided for compatibility but will be removed at some point.
- fava.application.create_app(files, *, load=False, incognito=False, read_only=False, poll_watcher=False)¶
Create a Fava Flask application.
- Parameters:
- Return type:
Flask
- fava.application.static_url(filename)¶
Return a static url with an mtime query string for cache busting.
- Return type:
fava.cli¶
The command-line interface for Fava.
- exception fava.cli.AddressInUse(port)¶
- exception fava.cli.NoFileSpecifiedError¶
- exception fava.cli.NonAbsolutePathError(path)¶
fava.context¶
Specify types for the flask application context.
fava.helpers¶
Exceptions and module base class.
- class fava.helpers.BeancountError(source: Meta | None, message: str, entry: Directive | None)¶
NamedTuple base for a Beancount-style error.
- exception fava.helpers.FavaAPIError(message)¶
Fava’s base exception class.
fava.internal_api¶
Internal API.
This is used to pre-process some data that is used in the templates, allowing this part of the functionality to be tested and allowing some end-to-end tests for the frontend data validation.
- class fava.internal_api.BalancesChart(label, data, type='balances')¶
Data for a balances chart.
-
data:
Sequence
[DateAndBalance
]¶
-
data:
- class fava.internal_api.BarChart(label, data, type='bar')¶
Data for a bar chart.
- class fava.internal_api.ChartApi¶
Functions to generate chart data.
- static account_balance(account_name)¶
Generate data for an account balances chart.
- Return type:
- static hierarchy(account_name, begin_date=None, end_date=None, label=None)¶
Generate data for an account hierarchy chart.
- Return type:
- static interval_totals(interval, account_name, label=None, *, invert=False)¶
Generate data for an account per interval chart.
- Return type:
- static net_worth()¶
Generate data for net worth chart.
- Return type:
- class fava.internal_api.HierarchyChart(label, data, type='hierarchy')¶
Data for a hierarchy chart.
-
data:
SerialisedTreeNode
¶
-
data:
- class fava.internal_api.LedgerData(accounts, account_details, base_url, currencies, currency_names, errors, fava_options, incognito, have_excel, links, options, payees, precisions, tags, years, user_queries, upcoming_events_count, extensions, sidebar_links, other_ledgers)¶
This is used as report-independent data in the frontend.
-
account_details:
AccountDict
¶
-
errors:
Sequence
[SerialisedError
]¶
-
extensions:
Sequence
[ExtensionDetails
]¶
-
fava_options:
FavaOptions
¶
-
account_details:
- class fava.internal_api.SerialisedError(type, source, message)¶
A Beancount error, as passed to the frontend.
- static from_beancount_error(err)¶
Get a serialisable error from a Beancount error.
- Return type:
- fava.internal_api.get_errors()¶
Serialise errors (do not pass entry as that might fail serialisation.
- Return type:
- fava.internal_api.get_ledger_data()¶
Get the report-independent ledger data.
- Return type:
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.
- class fava.json_api.AccountBudget(budget, budget_children)¶
Budgets for an account.
- class fava.json_api.AccountReportJournal(charts, journal)¶
Data for the journal account report.
-
charts:
Sequence
[BalancesChart
|BarChart
|HierarchyChart
]¶
-
charts:
- class fava.json_api.AccountReportTree(charts, interval_balances, budgets, dates)¶
Data for the tree account reports.
-
budgets:
Mapping
[str
,Sequence
[AccountBudget
]]¶
-
charts:
Sequence
[BalancesChart
|BarChart
|HierarchyChart
]¶
-
interval_balances:
Sequence
[SerialisedTreeNode
]¶
-
budgets:
- class fava.json_api.CommodityPairWithPrices(base, quote, prices)¶
A pair of commodities and prices for them.
- class fava.json_api.Context(entry, balances_before, balances_after, sha256sum, slice)¶
Context for an entry.
- exception fava.json_api.DocumentDirectoryMissingError¶
No document directory was specified.
- status = 422¶
- exception fava.json_api.FavaJSONAPIError(message)¶
An error with a HTTPStatus.
- abstract property status: HTTPStatus¶
HTTP status that should be used for the response.
- exception fava.json_api.FileDoesNotExistError(filename)¶
The given file does not exist.
- exception fava.json_api.IncorrectTypeValidationError(param, expected)¶
Validation failed due to incorrect type of parameter.
- exception fava.json_api.MissingParameterValidationError(param)¶
Validation failed due to missing parameter.
- exception fava.json_api.NotAValidDocumentOrImportFileError(filename)¶
Not valid document or import file.
- status = 400¶
- exception fava.json_api.TargetPathAlreadyExistsError(path)¶
The given path already exists.
- status = 409¶
- class fava.json_api.TreeReport(date_range, charts, trees)¶
Data for the tree reports.
-
charts:
Sequence
[BalancesChart
|BarChart
|HierarchyChart
]¶
-
trees:
Sequence
[SerialisedTreeNode
]¶
-
charts:
- exception fava.json_api.UploadedFileIsMissingFilenameError¶
Uploaded file is missing filename.
- status = 400¶
- exception fava.json_api.ValidationError¶
Validation of data failed.
- fava.json_api.api_endpoint(func)¶
Register an API endpoint.
The part of the function name up to the first underscore determines the accepted HTTP method. For GET and DELETE endpoints, the function parameters are extracted from the URL query string and passed to the decorated endpoint handler.
- Return type:
Callable
[[],Response
]
- fava.json_api.delete_source_slice(entry_hash, sha256sum)¶
Delete an entry source slice.
- Return type:
- fava.json_api.get_account_report()¶
Get the data for the account report.
- Return type:
- fava.json_api.get_balance_sheet()¶
Get the data for the balance sheet.
- Return type:
- fava.json_api.get_commodities()¶
Get the prices for all commodity pairs.
- Return type:
- fava.json_api.get_extract(filename, importer)¶
Extract entries using the ingest framework.
- fava.json_api.get_imports()¶
Get a list of the importable files.
- Return type:
- fava.json_api.get_income_statement()¶
Get the data for the income statement.
- Return type:
- fava.json_api.get_payee_accounts(payee)¶
Rank accounts for the given payee.
- fava.json_api.get_query(query_string)¶
Run a Beancount query.
- Return type:
- fava.json_api.get_trial_balance()¶
Get the data for the trial balance.
- Return type:
- fava.json_api.json_err(msg, status)¶
Jsonify the error message.
- Return type:
Response
- fava.json_api.json_success(data)¶
Jsonify the response.
- Return type:
Response
- fava.json_api.put_attach_document(filename, entry_hash)¶
Attach a document to an entry.
- Return type:
- fava.json_api.put_source(file_path, source, sha256sum)¶
Write one of the source files and return the updated sha256sum.
- Return type:
- fava.json_api.put_source_slice(entry_hash, source, sha256sum)¶
Write an entry source slice and return the updated sha256sum.
- Return type:
- fava.json_api.validate_func_arguments(func)¶
Validate arguments for a function.
This currently only works for strings and lists (but only does a shallow validation for lists).
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.
- exception fava.serialisation.InvalidAmountError(amount)¶
Invalid amount.
- fava.serialisation.deserialise(json_entry)¶
Parse JSON to a Beancount entry.
- Parameters:
json_entry (
Any
) – The entry.- Raises:
KeyError – if one of the required entry fields is missing.
FavaAPIError – if the type of the given entry is not supported.
- Return type:
- fava.serialisation.deserialise_posting(posting)¶
Parse JSON to a Beancount Posting.
- Return type:
fava.template_filters¶
Template filters for Fava.
All functions in this module will be automatically added as template filters.
- fava.template_filters.format_currency(value, currency=None, *, show_if_zero=False)¶
Format a value using the derived precision for a specified currency.
- Return type:
- fava.template_filters.meta_items(meta)¶
Remove keys from a dictionary.