{% load humanize %} {# HINT: keep line breaks after tags #}

Cost report by {{ group_by }}


{% if group_by == 'month' %} {% for year, customer_data in global_data.items %} {% endfor %}

{{ year }}

{{ global_partial_sums.next|floatformat:2|intcomma }} {{ currency }}

{% for customer_name, amount in customer_data.items %} {% endfor %}
{{ forloop.counter }} {{ customer_name }} {{ amount|floatformat:2|intcomma }} {{ currency }}

Total: {{ total_sum|floatformat:2|intcomma }} {{ currency }}


Detailed report

{% for month, customers in formatted_data.items %} {% endfor %}

{{ month | date:"Y F" }}

{{ partial_sums.next|floatformat:2|intcomma }} {{ currency }}

{% for customer_name, amount in customers %} {% endfor %}
{{ forloop.counter }} {{ customer_name }} {{ amount|floatformat:2|intcomma }} {{ currency }}
{% elif group_by == 'customer' %} {% for customer_name, year_data in global_data.items %} {% endfor %}

{{ customer_name }}

{{ global_partial_sums.next|floatformat:2|intcomma }} {{ currency }}

{% for year, amount in year_data %} {% endfor %}
{{ forloop.counter }} {{ year }} {{ amount|floatformat:2|intcomma }} {{ currency }}

Total: {{ total_sum|floatformat:2|intcomma }} {{ currency }}


Detailed report

{% for customer_name, month_data in formatted_data.items %} {% endfor %}

{{ customer_name }}

{{ partial_sums.next|floatformat:2|intcomma }} {{ currency }}

{% for month, amount in month_data %} {% endfor %}
{{ forloop.counter }} {{ month | date:"Y F" }} {{ amount|floatformat:2|intcomma }} {{ currency }}
{% endif %}