home · contact · privacy
Fix dat file bugs not properly marked in ledger views. master
authorChristian Heller <c.heller@plomlompom.de>
Thu, 15 Jan 2026 21:04:11 +0000 (22:04 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 15 Jan 2026 21:04:11 +0000 (22:04 +0100)
src/ledgplom/ledger.py
src/templates/_macros.tmpl
src/templates/ledger_raw.tmpl
src/templates/ledger_structured.tmpl
src/tests/full.balance
src/tests/full.dat
src/tests/full.ledger_raw
src/tests/full.ledger_structured

index a286640de29047deed5cf6b6a1d4f233cec0ecd8..6550f798522ce460c31b018ea7865c54340d21bf 100644 (file)
@@ -158,11 +158,6 @@ class _DatLine:
         code = halves[0]
         return cls(code, comment)
 
-    @classmethod
-    def from_subclass(cls, line: '_DatLine') -> Self:
-        'Devolve from subclassed line into cls.'
-        return cls(line.code, line.comment)
-
     @property
     def comment_instructions(self) -> dict[str, str]:
         'Parse .comment into _Account modification instructions.'
@@ -474,12 +469,12 @@ class _DatBlock:
         return ''
 
     @property
-    def lines(self) -> list[_DatLine]:
+    def lines(self) -> list[_BookingLine | _GapLine]:
         'Return .lines of .booking and .gap as list[_DatLine].'
         lines = (self.booking.lines if self.booking else []) + self.gap.lines
         if self.booking and not self.gap.lines:
             lines += [_GapLine()]
-        return [_DatLine.from_subclass(line) for line in lines]
+        return lines
 
     def _set_neighbor(
             self,
@@ -625,7 +620,7 @@ class Ledger:
         lines = []
         for block in self._blocks:
             lines += block.lines
-        return lines
+        return [_DatLine(line.code, line.comment) for line in lines]
 
     def _calc_accounts(self) -> dict[str, _Account]:
         'Build mapping of account names to _Accounts.'
index a98aa1b4ef64958289f40475e34fd84a957f2162..c2495c5b29beda12e28bc6abb923b72e6d80704a 100644 (file)
@@ -106,8 +106,8 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
                    />
         </td>
         <td rowspan={{ block.lines | length + 1 }} {# -#}
-            class="block_column{{ 'critical' if block.booking
-                                             and block.booking.sink_error }}">
+            class="block_column{{ ' critical' if block.booking
+                                              and block.booking.sink_error }}">
             [<a href="#block_{{ block.id_ }}">#</a>]<br />
             [<a href="/balance?up_incl={{ block.id_ }}">b</a>]<br />
             [<a href="/edit_{{ mode }}/{{ block.id_ }}">e</a>]
index 76f3a3f7c0eae06aa87d2755ad16fc1447d34d51..d421cc213f2602d45a5a493d83a336e50539f9f2 100644 (file)
@@ -19,8 +19,8 @@ table {
 {{ macros.ledger_block_columns('raw', block) -}}
 {##}{% for line in block.lines %}
     <tr>{# -#}
-        <td{{ ' class="critical"' if line.errors }}>
-            {{-line.raw}}&nbsp;{# -#}
+        <td{{ ' class="critical"'|safe if line.errors }}>
+            {{- line.raw }}&nbsp;{# -#}
         </td>{# -#}
     </tr>
 {##}{% endfor %}
index 9ec839e4fd754be174275cb52e9db54c4f4ff085..b045164d718e08d82a610bfb0cbc584998cea824 100644 (file)
@@ -31,7 +31,7 @@
         <td class="currency{{ ' critical' if line.errors }}">
             {{- macros.currency_short(line.currency) -}}
         </td>
-        <td{{ ' class="critical"' if line.errors }}>
+        <td{{ ' class="critical"'|safe if line.errors }}>
             {{- line.account -}}
         </td>
         <td>{{ line.comment }}</td>
index f96e1a74f710ac040ed49b12a967837b220a980a..3422bb3934b39b76d3b7e4d1aa9b966412f120e1 100644 (file)
@@ -87,14 +87,14 @@ span.indent {
     |
     balance after <a href="/blocks/4">booking 4 (2001-01-01: test)</a>
 </p>
-<table class="alternating ">
+<table class="alternating critical">
     <tr>
         <td class="money">
             <details>
                 <summary>
                     <table>
                         <tr>
-                            <td class="balance amount">-10</td>
+                            <td class="balance amount">-9</td>
                             <td class="balance currency">€</td>
                         </tr>
                     </table>
index fffe6f506d222b130c75e208c313fa40d2967e6d..28b6b04743439c2692801cfa7cc47dd64ef79317 100644 (file)
@@ -7,10 +7,12 @@
 2001-01-02 test
     bar   -10 €  ; bar
     baz    10 €
+    baz     x €
 
 
 2001-01-02 test
     bar    20 €
+    bar     1 €
     baz   -20 €  ; baz
 
 2001-01-01 test
index 45eda317d67b8b55af6d1035ee2c2e34ef10af43..b7ed479a8c8c25c1cb51ad640ef580692275cc54 100644 (file)
@@ -112,7 +112,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
     <tr><td>&nbsp;</td></tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
     <tr id="block_2">
-        <td rowspan=6 class="block_column">
+        <td rowspan=7 class="block_column">
             <input type="submit"
                    name="ledger_moveup_2"
                    value="^"
@@ -126,7 +126,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
             <br />
             <input type="submit" name="ledger_copy_2" value="C"/>
         </td>
-        <td rowspan=6 class="block_column">
+        <td rowspan=7 class="block_column">
             [<a href="#block_2">#</a>]<br />
             [<a href="/balance?up_incl=2">b</a>]<br />
             [<a href="/edit_raw/2">e</a>]
@@ -135,11 +135,12 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
     <tr><td>2001-01-02 test&nbsp;</td></tr>
     <tr><td>  bar  -10 € ; bar&nbsp;</td></tr>
     <tr><td>  baz  10 €&nbsp;</td></tr>
+    <tr><td class="critical">  baz  x €&nbsp;</td></tr>
     <tr><td>&nbsp;</td></tr>
     <tr><td>&nbsp;</td></tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
     <tr id="block_3">
-        <td rowspan=5 class="block_column">
+        <td rowspan=6 class="block_column">
             <input type="submit"
                    name="ledger_moveup_3"
                    value="^"
@@ -153,7 +154,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
             <br />
             <input type="submit" name="ledger_copy_3" value="C"/>
         </td>
-        <td rowspan=5 class="block_column">
+        <td rowspan=6 class="block_column critical">
             [<a href="#block_3">#</a>]<br />
             [<a href="/balance?up_incl=3">b</a>]<br />
             [<a href="/edit_raw/3">e</a>]
@@ -161,6 +162,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
     </tr>
     <tr><td>2001-01-02 test&nbsp;</td></tr>
     <tr><td>  bar  20 €&nbsp;</td></tr>
+    <tr><td>  bar  1 €&nbsp;</td></tr>
     <tr><td>  baz  -20 € ; baz&nbsp;</td></tr>
     <tr><td>&nbsp;</td></tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
index 2054d570243ecf5db0860db275a4d44088213547..b7681534e29daf7bc19eaa15cd43155cdb1c54b2 100644 (file)
@@ -136,7 +136,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
     </tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
     <tr id="block_2">
-        <td rowspan=6 class="block_column">
+        <td rowspan=7 class="block_column">
             <input type="submit"
                    name="ledger_moveup_2"
                    value="^"
@@ -150,7 +150,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
             <br />
             <input type="submit" name="ledger_copy_2" value="C"/>
         </td>
-        <td rowspan=6 class="block_column">
+        <td rowspan=7 class="block_column">
             [<a href="#block_2">#</a>]<br />
             [<a href="/balance?up_incl=2">b</a>]<br />
             [<a href="/edit_structured/2">e</a>]
@@ -172,6 +172,12 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
         <td>baz</td>
         <td></td>
     </tr>
+    <tr>
+        <td class="amount critical">x</td>
+        <td class="currency critical">€</td>
+        <td class="critical">baz</td>
+        <td></td>
+    </tr>
     <tr>
         <td colspan=4>&nbsp;</td>
     </tr>
@@ -180,7 +186,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
     </tr>
     <tr></tr><!-- keep the background-color alternation in proper order -->
     <tr id="block_3">
-        <td rowspan=5 class="block_column">
+        <td rowspan=6 class="block_column">
             <input type="submit"
                    name="ledger_moveup_3"
                    value="^"
@@ -194,7 +200,7 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
             <br />
             <input type="submit" name="ledger_copy_3" value="C"/>
         </td>
-        <td rowspan=5 class="block_column">
+        <td rowspan=6 class="block_column critical">
             [<a href="#block_3">#</a>]<br />
             [<a href="/balance?up_incl=3">b</a>]<br />
             [<a href="/edit_structured/3">e</a>]
@@ -210,6 +216,12 @@ Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
         <td>bar</td>
         <td></td>
     </tr>
+    <tr>
+        <td class="amount">1.00</td>
+        <td class="currency">€</td>
+        <td>bar</td>
+        <td></td>
+    </tr>
     <tr>
         <td class="amount">-20.00</td>
         <td class="currency">€</td>