home · contact · privacy
Warn for _all_ lines of Booking with invalid lines.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 22 Jan 2025 11:22:06 +0000 (12:22 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 22 Jan 2025 11:22:06 +0000 (12:22 +0100)
ledger.py
templates/_base.tmpl
templates/_macros.tmpl

index f82cc41e10481d4aaf53d5d38ad13024ae360fda..2a13d4badc563d4095af28da02e7a1dfd2f68b08 100755 (executable)
--- a/ledger.py
+++ b/ledger.py
@@ -57,6 +57,7 @@ class DatLine:
         self.comment = halves[1] if len(halves) > 1 else ''
         self.code = halves[0]
         self.booking_line: Optional[BookingLine] = None
+        self.questionable = False
 
     @property
     def is_intro(self) -> bool:
@@ -156,8 +157,6 @@ class Booking:
             dat_line.booking_line = TransferLine(self.id_, dat_line.code)
         self.account_changes: dict[str, Wealth] = {}
         self.sink_account = None
-        for dat_line in [dl for dl in self.dat_lines if dl.error]:
-            return
         changes = Wealth()
         for transfer_line in [dl.booking_line for dl in self.dat_lines[1:]]:
             assert isinstance(transfer_line, TransferLine)
@@ -175,9 +174,11 @@ class Booking:
         if self.sink_account:
             self.account_changes[self.sink_account] += changes.as_sink
         elif not changes.sink_empty:
-            last_line = self.dat_lines[-1]
-            assert isinstance(last_line.booking_line, BookingLine)
-            last_line.booking_line.error = 'needed sink missing'
+            assert self.dat_lines[-1].booking_line is not None
+            self.dat_lines[-1].booking_line.error = 'needed sink missing'
+        for dat_line in [dl for dl in self.dat_lines if dl.error]:
+            for dl in self.dat_lines:
+                dl.questionable = True
 
 
 class Handler(PlomHttpHandler):
index 2206d5199770e544ce900fbd955d3f9df609bf05..217af12c512a91200b6e3880b7be93833498064e 100644 (file)
@@ -6,7 +6,6 @@
 <style>
 body { background-color: white; font-family: sans-serif; }
 tr:nth-child(odd) { background-color: #dcdcdc; }
-td.invalid { background-color: red; }
 {% block css %}{% endblock %}
 </style>
 </head>
index b3cb64a5b683aa94c2a7e0de77b41373b547c441..2989bd6afe021d50707f43bbe51088dfe03e28a6 100644 (file)
@@ -1,4 +1,6 @@
 {% macro css_value_line() %}
+tr.warning td { background-color: #ff8888; }
+td.invalid, tr.warning td.invalid { background-color: #ff0000; }
 td.amt { text-align: right }
 td.amt, td.curr { font-family: monospace; font-size: 1.3em; }
 td.curr { text-align: center; }
@@ -10,7 +12,7 @@ td.curr { text-align: center; }
   {% if (not (raw or single)) and dat_line.is_intro and loop.index > 1 %}
     <tr><td colspan=5>&nbsp;</td></tr>
   {% endif %}
-  <tr>
+  <tr{% if dat_line.questionable %} class="warning"{% endif %}>
   {% if not single %}
     {% if dat_line.is_intro %}
       <td id="{{dat_line.booking_id}}"><a href="#{{dat_line.booking_id}}">#</a></td>
@@ -38,7 +40,7 @@ td.curr { text-align: center; }
   {% endif %}
   </tr>
   {% if dat_line.error and not raw %}
-    <tr><td class="invalid" colspan={% if single %}4{% else %}5{% endif %}>{{dat_line.error}}</td></tr>
+    <tr class="warning">{% if not single %}<td></td>{% endif %}<td class="invalid" colspan=3>{{dat_line.error}}</td><td></td></tr>
   {% endif %}
 {% endfor %}
 </table>