home · contact · privacy
Fix balance showing not-yet-used accounts. master
authorChristian Heller <c.heller@plomlompom.de>
Thu, 20 Mar 2025 02:43:01 +0000 (03:43 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 20 Mar 2025 02:43:01 +0000 (03:43 +0100)
src/templates/balance.tmpl

index cfd46f70595c8235eff5459a9a888cdf2f03bea4..35f0faecab364d983401adcd536e421d95d76d3b 100644 (file)
@@ -2,41 +2,43 @@
 
 
 {% macro account_with_children(booking_id, account, indent) %}
 
 
 {% macro account_with_children(booking_id, account, indent) %}
-  <tr class="alternating">
-  <td class="money">
-  {% if account.get_wealth(booking_id).moneys|length == 1 %}
-    <table>
-    {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
-      {{ macros.tr_money_balance(amt, curr) }}
-    {% endfor %}
-    </table>
-  {% else %}
-    <details>
-    <summary>
-    <table>
-    {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
-      {% if 1 == loop.index %}
-        {{ macros.tr_money_balance(amt, curr) }}
-      {% endif %}
-    {% endfor %}
-    </table>
-    </summary>
-    <table>
-    {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
-      {% if 1 < loop.index %}
+  {% if account.get_wealth(booking_id).moneys|length > 0 %}
+    <tr class="alternating">
+    <td class="money">
+    {% if account.get_wealth(booking_id).moneys|length == 1 %}
+      <table>
+      {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
         {{ macros.tr_money_balance(amt, curr) }}
         {{ macros.tr_money_balance(amt, curr) }}
-      {% endif %}
+      {% endfor %}
+      </table>
+    {% else %}
+      <details>
+      <summary>
+      <table>
+      {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
+        {% if 1 == loop.index %}
+          {{ macros.tr_money_balance(amt, curr) }}
+        {% endif %}
+      {% endfor %}
+      </table>
+      </summary>
+      <table>
+      {% for curr, amt in account.get_wealth(booking_id).moneys.items() %}
+        {% if 1 < loop.index %}
+          {{ macros.tr_money_balance(amt, curr) }}
+        {% endif %}
+      {% endfor %}
+      </table>
+      </details>
+    {% endif %}
+    </td>
+    <td class="acc"><span class="indent">{% for i in range(indent) %}&nbsp;{% endfor %}</span>{% if account.parent %}:{% endif %}{{account.basename}}{% if account.children %}:{% endif %}</td>
+    <td>{{account.desc}}</td>
+    </tr>
+    {% for child in account.children %}
+      {{ account_with_children(booking_id, child, indent=indent+1) }}
     {% endfor %}
     {% endfor %}
-    </table>
-    </details>
   {% endif %}
   {% endif %}
-  </td>
-  <td class="acc"><span class="indent">{% for i in range(indent) %}&nbsp;{% endfor %}</span>{% if account.parent %}:{% endif %}{{account.basename}}{% if account.children %}:{% endif %}</td>
-  <td>{{account.desc}}</td>
-  </tr>
-  {% for child in account.children %}
-    {{ account_with_children(booking_id, child, indent=indent+1) }}
-  {% endfor %}
 {% endmacro %}
 
 
 {% endmacro %}