refactor: improve month by month and year by year value display

This commit is contained in:
Herculino Trotta
2025-12-30 21:58:12 -03:00
parent 39f66b620a
commit 6c90e1bb7f
2 changed files with 20 additions and 28 deletions
@@ -88,9 +88,9 @@
{% trans 'Entity' %} {% trans 'Entity' %}
{% endif %} {% endif %}
</th> </th>
<th scope="col" class="text-center font-bold">{% trans 'Total' %}</th> <th scope="col" class="font-bold">{% trans 'Total' %}</th>
{% for month in data.months %} {% for month in data.months %}
<th scope="col" class="text-center"> <th scope="col">
{% if month == 1 %}{% trans 'Jan' %} {% if month == 1 %}{% trans 'Jan' %}
{% elif month == 2 %}{% trans 'Feb' %} {% elif month == 2 %}{% trans 'Feb' %}
{% elif month == 3 %}{% trans 'Mar' %} {% elif month == 3 %}{% trans 'Mar' %}
@@ -125,7 +125,7 @@
{% endif %} {% endif %}
</th> </th>
{# Total column for this item #} {# Total column for this item #}
<td class="text-nowrap text-center font-semibold bg-base-200"> <td class="text-nowrap font-semibold bg-base-200">
{% for currency_id, currency_data in item.total.currencies.items %} {% for currency_id, currency_data in item.total.currencies.items %}
<c-amount.display <c-amount.display
:amount="currency_data.final_total" :amount="currency_data.final_total"
@@ -139,8 +139,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -149,7 +148,7 @@
</td> </td>
{# Month columns #} {# Month columns #}
{% for month in data.months %} {% for month in data.months %}
<td class="text-nowrap text-center"> <td class="text-nowrap">
{% with month_data=item.month_totals %} {% with month_data=item.month_totals %}
{% for m, m_data in month_data.items %} {% for m, m_data in month_data.items %}
{% if m == month %} {% if m == month %}
@@ -166,8 +165,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -187,7 +185,7 @@
<tr class="font-bold bg-base-200"> <tr class="font-bold bg-base-200">
<th class="sticky left-0 bg-base-200 z-10">{% trans 'Total' %}</th> <th class="sticky left-0 bg-base-200 z-10">{% trans 'Total' %}</th>
{# Grand total #} {# Grand total #}
<td class="text-nowrap text-center bg-base-300"> <td class="text-nowrap bg-base-300">
{% for currency_id, currency_data in data.grand_total.currencies.items %} {% for currency_id, currency_data in data.grand_total.currencies.items %}
<c-amount.display <c-amount.display
:amount="currency_data.final_total" :amount="currency_data.final_total"
@@ -201,8 +199,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -211,7 +208,7 @@
</td> </td>
{# Month totals #} {# Month totals #}
{% for month in data.months %} {% for month in data.months %}
<td class="text-nowrap text-center"> <td class="text-nowrap">
{% with month_total=data.month_totals %} {% with month_total=data.month_totals %}
{% for m, m_data in month_total.items %} {% for m, m_data in month_total.items %}
{% if m == month %} {% if m == month %}
@@ -228,8 +225,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -56,9 +56,9 @@
{% trans 'Entity' %} {% trans 'Entity' %}
{% endif %} {% endif %}
</th> </th>
<th scope="col" class="text-center font-bold">{% trans 'Total' %}</th> <th scope="col" class="font-bold">{% trans 'Total' %}</th>
{% for year in data.years %} {% for year in data.years %}
<th scope="col" class="text-center">{{ year }}</th> <th scope="col">{{ year }}</th>
{% endfor %} {% endfor %}
</tr> </tr>
</thead> </thead>
@@ -79,7 +79,7 @@
{% endif %} {% endif %}
</th> </th>
{# Total column for this item #} {# Total column for this item #}
<td class="text-nowrap text-center font-semibold bg-base-200"> <td class="text-nowrap font-semibold bg-base-200">
{% for currency_id, currency_data in item.total.currencies.items %} {% for currency_id, currency_data in item.total.currencies.items %}
<c-amount.display <c-amount.display
:amount="currency_data.final_total" :amount="currency_data.final_total"
@@ -93,8 +93,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -103,7 +102,7 @@
</td> </td>
{# Year columns #} {# Year columns #}
{% for year in data.years %} {% for year in data.years %}
<td class="text-nowrap text-center"> <td class="text-nowrap">
{% with year_data=item.year_totals %} {% with year_data=item.year_totals %}
{% for y, y_data in year_data.items %} {% for y, y_data in year_data.items %}
{% if y == year %} {% if y == year %}
@@ -120,8 +119,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -141,7 +139,7 @@
<tr class="font-bold bg-base-200"> <tr class="font-bold bg-base-200">
<th class="sticky left-0 bg-base-200 z-10">{% trans 'Total' %}</th> <th class="sticky left-0 bg-base-200 z-10">{% trans 'Total' %}</th>
{# Grand total #} {# Grand total #}
<td class="text-nowrap text-center bg-base-300"> <td class="text-nowrap bg-base-300">
{% for currency_id, currency_data in data.grand_total.currencies.items %} {% for currency_id, currency_data in data.grand_total.currencies.items %}
<c-amount.display <c-amount.display
:amount="currency_data.final_total" :amount="currency_data.final_total"
@@ -155,8 +153,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}
@@ -165,7 +162,7 @@
</td> </td>
{# Year totals #} {# Year totals #}
{% for year in data.years %} {% for year in data.years %}
<td class="text-nowrap text-center"> <td class="text-nowrap">
{% with year_total=data.year_totals %} {% with year_total=data.year_totals %}
{% for y, y_data in year_total.items %} {% for y, y_data in year_total.items %}
{% if y == year %} {% if y == year %}
@@ -182,8 +179,7 @@
:amount="currency_data.exchanged.final_total" :amount="currency_data.exchanged.final_total"
:prefix="currency_data.exchanged.currency.prefix" :prefix="currency_data.exchanged.currency.prefix"
:suffix="currency_data.exchanged.currency.suffix" :suffix="currency_data.exchanged.currency.suffix"
:decimal_places="currency_data.exchanged.currency.decimal_places" :decimal_places="currency_data.exchanged.currency.decimal_places"></c-amount.display>
color="{% if currency_data.exchanged.final_total < 0 %}red{% elif currency_data.exchanged.final_total > 0 %}green{% endif %}"></c-amount.display>
</div> </div>
{% endif %} {% endif %}
{% empty %} {% empty %}