home · contact · privacy
Improve balance table layout, color warning if bad Bookings. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 22 Jan 2025 19:00:58 +0000 (20:00 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 22 Jan 2025 19:00:58 +0000 (20:00 +0100)
ledger.py
templates/_base.tmpl
templates/_macros.tmpl
templates/balance.tmpl

index 89cf94fca69ad0bebfdcffc5a091951adb2819e9..89d5ca2e8eb8a6143b3ae93b38af7e562554b2b6 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -226,8 +226,9 @@ class Handler(PlomHttpHandler):
     def do_GET(self) -> None:
         # pylint: disable=invalid-name,missing-function-docstring
         if self.pagename == 'balance':
-            self.send_rendered(Path('balance.tmpl'),
-                               {'roots': self.server.balance_roots})
+            valid, balance_roots = self.server.balance_roots
+            self.send_rendered(Path('balance.tmpl'), {'roots': balance_roots,
+                                                      'valid': valid})
         elif self.pagename == 'booking':
             self.send_rendered(
                     Path('booking.tmpl'),
@@ -270,10 +271,12 @@ class Server(PlomHttpServer):
         return [dl for dl in self.dat_lines if not dl.is_empty]
 
     @property
-    def balance_roots(self) -> list[Account]:
+    def balance_roots(self) -> tuple[bool, list[Account]]:
         """Return tree of calculated Accounts over all .bookings."""
         account_names = set()
+        valid = True
         for booking in self.bookings:
+            valid = valid if not booking.is_questionable else False
             for account_name in booking.account_changes:
                 account_names.add(account_name)
         full_names_to_accounts: dict[str, Account] = {}
@@ -292,7 +295,8 @@ class Server(PlomHttpServer):
             for account_name in booking.account_changes:
                 full_names_to_accounts[account_name].local_wealth +=\
                         booking.account_changes[account_name]
-        return [ac for ac in full_names_to_accounts.values() if not ac.parent]
+        return valid, [ac for ac in full_names_to_accounts.values()
+                       if not ac.parent]
 
 
 if __name__ == "__main__":
index 8b8dccfbd3fae3da50ac1969208357877c9c71ad..268fb643542b2226bcf0e8a4f7cae5170c56ff9f 100644 (file)
@@ -6,6 +6,8 @@
 <style>
 body { background-color: white; font-family: sans-serif; }
 tr:nth-child(odd) { background-color: #dcdcdc; }
+td { text-align: left; vertical-align: top; }
+table.warning tbody tr td, tr.warning td { background-color: #ff8888; }
 {% block css %}{% endblock %}
 </style>
 </head>
index 2342215132e71832fc29cd56edde915db5109920..85c032ee5c1e6c00491577c8040b7b42b2c006ef 100644 (file)
@@ -1,11 +1,9 @@
 {% macro css_td_money() %}
 td.amt { text-align: right }
 td.amt, td.curr { font-family: monospace; font-size: 1.3em; }
-td.curr { text-align: left; }
 {% endmacro %}
 
 {% macro css_errors() %}
-tr.warning td { background-color: #ff8888; }
 td.invalid, tr.warning td.invalid { background-color: #ff0000; }
 {% endmacro %}
 
index 856b55533fd1eb3843b8918c127e5c0ed8c24969..783e74854797436955e6f216158be2ac4e84efd4 100644 (file)
@@ -8,7 +8,7 @@
 <td class="curr">{{curr|truncate(4,true,"…")}}</td>
 {% endif %}
 {% endfor %}
-<td>{% for _ in range(indent) %}&nbsp; &nbsp; &nbsp;{% endfor %}{{account.basename}}</td>
+<td rowspan={{ account.wealth.moneys|length }}>{% for _ in range(indent) %}&nbsp; &nbsp; &nbsp;{% endfor %}{{account.basename}}</td>
 </tr>
 {% for curr, amt in account.wealth.moneys.items() %}
 {% if 1 < loop.index %}
@@ -29,7 +29,7 @@
 {% endblock css %}
 
 {% block content %}
-<table>
+<table{% if not valid %} class="warning"{% endif %}>
 {% for root in roots %}
 {{ account_with_children(root, indent=0) }}
 {% endfor %}