From: Christian Heller Date: Thu, 15 Jan 2026 21:04:11 +0000 (+0100) Subject: Fix dat file bugs not properly marked in ledger views. X-Git-Url: https://plomlompom.com/repos/booking/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/new_day?a=commitdiff_plain;ds=sidebyside;p=ledgplom Fix dat file bugs not properly marked in ledger views. --- diff --git a/src/ledgplom/ledger.py b/src/ledgplom/ledger.py index a286640..6550f79 100644 --- a/src/ledgplom/ledger.py +++ b/src/ledgplom/ledger.py @@ -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.' diff --git a/src/templates/_macros.tmpl b/src/templates/_macros.tmpl index a98aa1b..c2495c5 100644 --- a/src/templates/_macros.tmpl +++ b/src/templates/_macros.tmpl @@ -106,8 +106,8 @@ Detected redundant empty lines in gaps, + class="block_column{{ ' critical' if block.booking + and block.booking.sink_error }}"> [#]
[b]
[e] diff --git a/src/templates/ledger_raw.tmpl b/src/templates/ledger_raw.tmpl index 76f3a3f..d421cc2 100644 --- a/src/templates/ledger_raw.tmpl +++ b/src/templates/ledger_raw.tmpl @@ -19,8 +19,8 @@ table { {{ macros.ledger_block_columns('raw', block) -}} {##}{% for line in block.lines %} {# -#} - - {{-line.raw}} {# -#} + + {{- line.raw }} {# -#} {# -#} {##}{% endfor %} diff --git a/src/templates/ledger_structured.tmpl b/src/templates/ledger_structured.tmpl index 9ec839e..b045164 100644 --- a/src/templates/ledger_structured.tmpl +++ b/src/templates/ledger_structured.tmpl @@ -31,7 +31,7 @@ {{- macros.currency_short(line.currency) -}} - + {{- line.account -}} {{ line.comment }} diff --git a/src/tests/full.balance b/src/tests/full.balance index f96e1a7..3422bb3 100644 --- a/src/tests/full.balance +++ b/src/tests/full.balance @@ -87,14 +87,14 @@ span.indent { | balance after booking 4 (2001-01-01: test)

- +
- - - - + + + + @@ -180,7 +186,7 @@ Detected redundant empty lines in gaps, - - + + + +
- +
-10-9 €
diff --git a/src/tests/full.dat b/src/tests/full.dat index fffe6f5..28b6b04 100644 --- a/src/tests/full.dat +++ b/src/tests/full.dat @@ -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 diff --git a/src/tests/full.ledger_raw b/src/tests/full.ledger_raw index 45eda31..b7ed479 100644 --- a/src/tests/full.ledger_raw +++ b/src/tests/full.ledger_raw @@ -112,7 +112,7 @@ Detected redundant empty lines in gaps, -
+ + [#]
[b]
[e] @@ -135,11 +135,12 @@ Detected redundant empty lines in gaps, baz x € 
 
 
+ + [#]
[b]
[e] @@ -161,6 +162,7 @@ Detected redundant empty lines in gaps, -
+ + [#]
[b]
[e] @@ -172,6 +172,12 @@ Detected redundant empty lines in gaps, x
€baz
 
+ + [#]
[b]
[e] @@ -210,6 +216,12 @@ Detected redundant empty lines in gaps, 1.00
€bar
-20.00 €