{% import 'macros/_account_macros.html' as account_macros with context %} {% set show_other_column = (operating_currencies|sort != api.options['commodities']|list|sort) %} {% macro tree(real_account, totals=True) %}
  1. {% for currency in operating_currencies %} {{ currency }} {% endfor %} {% if show_other_column %} {{ _('Other') }} {% endif %}

  2. {% for account in ([real_account] if real_account.account else real_account.values()) recursive %} {% if account|should_show %} {% set balance = account.balance.cost() %} {% set balance_children = (account|balance_children).cost() %}
  3. {% for currency in operating_currencies %} {{ balance.get_units(currency).number|format_currency(currency) }} {{ balance_children.get_units(currency).number|format_currency(currency) }} {% endfor %} {% if show_other_column %} {% for currency in api.options['commodities'] if currency not in operating_currencies %} {% if currency in balance.currencies() %} {{ balance.get_units(currency).number|format_currency(currency) }} {{ currency }} {% endif %} {% if currency in balance_children.currencies() %} {{ balance_children.get_units(currency).number|format_currency(currency) }} {{ currency }} {% endif %} {% endfor %} {% endif %}

    {% if account|length %}
      {{ loop(account.values()|sort(attribute='account')) }}
    {% endif %}
  4. {% endif %} {% endfor %} {% if totals %} {% set balance = (real_account|balance_children).cost() %}
  5. {% for currency in operating_currencies %} {{ balance.get_units(currency).number|format_currency(currency) }} {% endfor %} {% if show_other_column %} {% for currency in api.options['commodities'] if currency not in operating_currencies%} {% if currency in balance.currencies() %} {{ balance.get_units(currency).number|format_currency(currency) }} {{ currency }}
    {% endif %} {% endfor %}
    {% endif %}

  6. {% endif %}
{% endmacro %} {% macro balance_with_budget(amount, budget) %} {% if budget %} {% if amount.currency in budget %} {% set diff = budget[amount.currency] - amount.number %} ({{ diff|format_currency(currency, show_if_zero=True) }}) {% else %} {% endif %} {% endif %} {{ amount|format_amount }} {% endmacro %} {% macro account_tree(account_name, interval_balances, dates, accumulate) %}
  1. {% for begin_date, end_date in dates %} {% if accumulate %} {% set time_filter = dates[0][0]|string + ' - ' + end_date|string %} {% else %} {% set time_filter = begin_date|string + ' - ' + end_date|string %} {% endif %} {{ interval_macros.format_date(begin_date) }} {% endfor %}

  2. {% for account in [interval_balances[0]|get_or_create(account_name)] recursive %}
  3. {% for begin_date, end_date in dates %} {% if accumulate %}{% set begin_date = dates[-1][0] %}{% endif %} {% set budget = api.calculate_budget(account.account, begin_date, end_date) %} {% set current_account = interval_balances[loop.index0]|get_or_create(account.account) %} {% set balance = current_account.balance.cost() %} {% set balance_children = (current_account|balance_children).cost() %} {% for pos in balance %} {{ balance_with_budget(pos.units, budget) }} {% endfor %} {% for pos in balance_children %} {{ balance_with_budget(pos.units, budget) }} {% endfor %} {% endfor %}

      {{ loop(account.values()|sort(attribute='account')) }}
  4. {% endfor %}
  5. {% for begin_date, end_date in dates %} {% set current_account = interval_balances[loop.index0]|get_or_create(account_name) %} {% set balance_children = (current_account|balance_children).cost() %} {% for pos in balance_children %} {{ pos.units|format_amount }}
    {% endfor %}
    {% endfor %}

{% endmacro %}