{% extends "_layout.html" %} {% set active_page = 'query' %} {% 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', '') %} {% set result_only = request.args.get('result_only', False) %} {% block content %} {% if not result_only %} {% if api.queries %} {{ _('Load stored query:') }} {% for query in api.queries %} {{ query.name }} {% endfor %} {{ _('(Source)') }} {% endif %} {{ query or '' }} Submit Query {% endif %} {% if not error and not result_types %} Sample Queries balances from year = 2014 SELECT last(date) as last_date, cost(sum(position)) as cost; SELECT date, account, position, balance WHERE account ~ 'Travel'; {{ _('More 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 %} {{ name }} {% endfor %} {% for row in result_rows %} {% for name, type in result_types %} {{ querycell(name, row[name], type) }} {% endfor %} {% endfor %} {% endif %} {% if not result_only %} {% endif %} {% endblock %}
balances from year = 2014
SELECT last(date) as last_date, cost(sum(position)) as cost;
SELECT date, account, position, balance WHERE account ~ 'Travel';
{{ error }}
{{ _('Download as') }} CSV{% if config['HAVE_EXCEL'] %}, XLS, XLSX or ODS {% endif %}