From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 20 Mar 2025 02:43:01 +0000 (+0100)
Subject: Fix balance showing not-yet-used accounts.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/static/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/add_task?a=commitdiff_plain;h=HEAD;p=ledgplom

Fix balance showing not-yet-used accounts.
---

diff --git a/src/templates/balance.tmpl b/src/templates/balance.tmpl
index cfd46f7..35f0fae 100644
--- a/src/templates/balance.tmpl
+++ b/src/templates/balance.tmpl
@@ -2,41 +2,43 @@
 
 
 {% 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) }}
-      {% 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 %}
-    </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 %}
 {% endmacro %}