{% extends "_layout.html" %} {% set active_page = 'query' %} {% set show_filters = False %} {% macro source_link(ehash) -%} {% set context = api.context(ehash) %} {{ url_for_source(file_path=context.filename, line=context.line) }} {%- endmacro %} {% block javascript %}{% include "javascript/_editor.html" %}{% endblock %} {% import 'macros/_account_macros.html' as account_macros with context %} {% macro querycell(name, value, type_) %} {% set type = type_|string %} {% if type == "" %} {% for position in value.cost() %} {% if position.units.number != 0 %} {{ position.units|format_amount }}
{% endif %} {% endfor %} {% elif type == "" %} {% if name == "account" %} {{ account_macros.account_name(value) }} {% else %} {{value }} {% endif %} {# TODO do the same for payee(s) and tag(s) #} {% elif type == "" %} {{ value|format_currency }} {% elif type == "" %} {{ value|format_currency }} {% elif type == "" %} {{ value|upper }} {% elif type == "" %} {{ value }} {% elif type == "" %} {{ value|join(',') }} {% elif type == "" %} {{ value }} {% elif type == "" %} {{ value.units|format_amount }} {% else %} {{ value }} {% endif %} {% endmacro %} {% block content %}

Query

{% if api.queries() %}
(Source)
{% endif %}
{{ query or '' }}
{% if not error and not result %}

You can run custom querys (BQL) like with the bean-query tool. For a detailed explanation of how queries can be created see the Beancount Query Lanugage Reference, or more generally, the Beancount Documentation Overview. Sample queries can be found here (please submit your own queries if they might be useful for others).

{% if not api.queries() %}

If you add query-Directives to your Source these stored queries will be displayed as a dropdown to quickly select them.

{% endif %} {% endif %} {% if error %}

Result

{{ error }}

{% endif %} {% if result %}

Result

Download as CSV, XLS, XLSX or ODS

{% for name, type in result.0 %} {% endfor %} {% for row in result.1 %} {% for name, type in result.0 %} {{ querycell(name, row[name], type) }} {% endfor %} {% endfor %}
{{ name }}
{% endif %} {% endblock %}