{% extends "_layout.html" %} {% set active_page = 'query' %} {% set show_filters = False %} {% 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 %} {% set name = request.args.get('name', None) %} {% set query = request.args.get('query_string', '') %} {% block content %} {% if api.queries %}
{{ _('(Source)') }}
{% endif %}
{{ query or '' }}
{% if not error and not result_types %}

{{ _('You can run querys like with the bean-query tool. For a detailed explanation of how queries can be created see the Beancount Query Lanugage Reference.') }}

{% 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.', url=url_for('source')) }}

{% endif %}

Sample Queries

{% endif %} {% if error %}

{{ _('Result') }}

{{ error }}

{% endif %} {% if result_types %}

{{ _('Download as') }} CSV{% if config['HAVE_EXCEL'] %}, XLS, XLSX or ODS {% endif %}

{{ _('Result') }}

{% for name, type in result_types %} {% endfor %} {% for row in result_rows %} {% for name, type in result_types %} {{ querycell(name, row[name], type) }} {% endfor %} {% endfor %}
{{ name }}
{% endif %} {% endblock %}