From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 27 Jan 2025 06:46:45 +0000 (+0100)
Subject: Further refine balance layout.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bprefix%7D%7D/all?a=commitdiff_plain;h=4f3a2dcc97c61209922bfe201601173538d8f483;p=plomledger

Further refine balance layout.
---

diff --git a/ledger.py b/ledger.py
index 8968a4d..7a62924 100755
--- a/ledger.py
+++ b/ledger.py
@@ -68,13 +68,6 @@ class Account:
         if self.parent:
             self.parent.children += [self]
 
-    @property
-    def full_name(self) -> str:
-        """Return full account path."""
-        if self.parent:
-            return f'{self.parent.full_name}:{self.basename}'
-        return self.basename
-
     @property
     def wealth(self) -> Wealth:
         """Total of .local_wealth with that of .children."""
diff --git a/templates/_base.tmpl b/templates/_base.tmpl
index 034c58d..0ec782d 100644
--- a/templates/_base.tmpl
+++ b/templates/_base.tmpl
@@ -8,8 +8,8 @@
 </script>
 <style>
 body { background-color: white; font-family: sans-serif; }
-tr:nth-child(odd) { background-color: #dcdcdc; }
-tr:nth-child(even) { background-color: #ffffff; }
+tr.alternating:nth-child(odd) { background-color: #dcdcdc; }
+tr.alternating:nth-child(even) { background-color: #ffffff; }
 td { text-align: left; vertical-align: top; }
 span.warning, table.warning tbody tr td, tr.warning td { background-color: #ff8888; }
 {% block css %}{% endblock %}
diff --git a/templates/_macros.tmpl b/templates/_macros.tmpl
index d09643b..0dfd2fc 100644
--- a/templates/_macros.tmpl
+++ b/templates/_macros.tmpl
@@ -11,9 +11,9 @@ td.invalid, tr.warning td.invalid { background-color: #ff0000; }
 <table>
 {% for dat_line in dat_lines %}
   {% if (not raw) and dat_line.is_intro and loop.index > 1 %}
-    <tr><td colspan=5>&nbsp;</td></tr>
+    <tr class="alternating"><td colspan=5>&nbsp;</td></tr>
   {% endif %}
-  <tr{% if dat_line.is_questionable %} class="warning"{% endif %}>
+  <tr class="alternating{% if dat_line.is_questionable %} warning{% endif %}">
   {% if dat_line.is_intro %}
     <td id="{{dat_line.booking_id}}"><a href="#{{dat_line.booking_id}}">#</a>/<a href="/balance?cutoff={{dat_line.booking_id+1}}">b</a></td>
   {% else %}
@@ -42,7 +42,7 @@ td.invalid, tr.warning td.invalid { background-color: #ff0000; }
   {% endif %}
   </tr>
   {% if dat_line.error and not raw %}
-    <tr class="warning">
+    <tr class="alternating warning">
     <td></td>
     <td class="invalid" colspan=3>{{dat_line.error}}</td>
     <td></td>
diff --git a/templates/balance.tmpl b/templates/balance.tmpl
index bcb5951..8bf74fb 100644
--- a/templates/balance.tmpl
+++ b/templates/balance.tmpl
@@ -1,33 +1,47 @@
 {% extends '_base.tmpl' %}
 
+
 {% macro account_with_children(account, indent) %}
-  <tr>
-  {% for curr, amt in account.wealth.moneys.items() %}
-    {% if 1 == loop.index %}
-      <td class="amt">{{amt}}</td>
-      <td class="curr">{{curr|truncate(4,true,"…")}}</td>
-    {% endif %}
-  {% endfor %}
-  <td>{{account.full_name}}{% if account.children %}:…{% endif %}</td>
-  </tr>
-  {% if account.wealth.moneys|length > 1 %}
-  <tr>
-  <td colspan=2>
-  <details><summary>other currencies</summary>
-  <table>
-  {% for curr, amt in account.wealth.moneys.items() %}
-    {% if 1 < loop.index %}
+  <tr class="alternating">
+  <td class="money">
+  {% if account.wealth.moneys|length == 1 %}
+    <table>
+    {% for curr, amt in account.wealth.moneys.items() %}
       <tr>
       <td class="amt">{{amt}}</td>
       <td class="curr">{{curr|truncate(4,true,"…")}}</td>
       </tr>
-    {% endif %}
-  {% endfor %}
-  </table>
-  </details>
-  <td>
-  </tr>
+    {% endfor %}
+    </table>
+  {% else %}
+    <details>
+    <summary>
+    <table class="summary">
+    {% for curr, amt in account.wealth.moneys.items() %}
+      {% if 1 == loop.index %}
+        <tr>
+        <td class="amt">{{amt}}</td>
+        <td class="curr">{{curr|truncate(4,true,"…")}}</td>
+        </tr>
+      {% endif %}
+    {% endfor %}
+    </table>
+    </summary>
+    <table>
+    {% for curr, amt in account.wealth.moneys.items() %}
+      {% if 1 < loop.index %}
+        <tr>
+        <td class="amt">{{amt}}</td>
+        <td class="curr">{{curr|truncate(4,true,"…")}}</td>
+        </tr>
+      {% endif %}
+    {% endfor %}
+    </table>
+    </details>
   {% endif %}
+  </td>
+  <td class="acc">{% for i in range(indent) %}&nbsp; &nbsp; {% endfor %}{% if account.parent %}:{% endif %}{{account.basename}}{% if account.children %}:{% endif %}</td>
+  </tr>
   {% for child in account.children %}
     {{ account_with_children(child, indent=indent+1) }}
   {% endfor %}
@@ -36,6 +50,10 @@
 
 {% block css %}
 {{ macros.css_td_money() }}
+td.amt { width: 10em; }
+td.curr { width: 3em; }
+table.summary { float: left; }
+td.money { padding-right: 1em; }
 {% endblock css %}
 
 {% block content %}