home
·
contact
·
privacy
projects
/
ledgplom
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e9574d6
)
Fix dat file bugs not properly marked in ledger views.
master
author
Christian Heller
<c.heller@plomlompom.de>
Thu, 15 Jan 2026 21:04:11 +0000
(22:04 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Thu, 15 Jan 2026 21:04:11 +0000
(22:04 +0100)
src/ledgplom/ledger.py
patch
|
blob
|
history
src/templates/_macros.tmpl
patch
|
blob
|
history
src/templates/ledger_raw.tmpl
patch
|
blob
|
history
src/templates/ledger_structured.tmpl
patch
|
blob
|
history
src/tests/full.balance
patch
|
blob
|
history
src/tests/full.dat
patch
|
blob
|
history
src/tests/full.ledger_raw
patch
|
blob
|
history
src/tests/full.ledger_structured
patch
|
blob
|
history
diff --git
a/src/ledgplom/ledger.py
b/src/ledgplom/ledger.py
index a286640de29047deed5cf6b6a1d4f233cec0ecd8..6550f798522ce460c31b018ea7865c54340d21bf 100644
(file)
--- a/
src/ledgplom/ledger.py
+++ b/
src/ledgplom/ledger.py
@@
-158,11
+158,6
@@
class _DatLine:
code = halves[0]
return cls(code, comment)
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.'
@property
def comment_instructions(self) -> dict[str, str]:
'Parse .comment into _Account modification instructions.'
@@
-474,12
+469,12
@@
class _DatBlock:
return ''
@property
return ''
@property
- def lines(self) -> list[_
Dat
Line]:
+ def lines(self) -> list[_
BookingLine | _Gap
Line]:
'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 .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,
def _set_neighbor(
self,
@@
-625,7
+620,7
@@
class Ledger:
lines = []
for block in self._blocks:
lines += block.lines
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.'
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 a98aa1b4ef64958289f40475e34fd84a957f2162..c2495c5b29beda12e28bc6abb923b72e6d80704a 100644
(file)
--- a/
src/templates/_macros.tmpl
+++ b/
src/templates/_macros.tmpl
@@
-106,8
+106,8
@@
Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
/>
</td>
<td rowspan={{ block.lines | length + 1 }} {# -#}
/>
</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>]
[<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>]
diff --git
a/src/templates/ledger_raw.tmpl
b/src/templates/ledger_raw.tmpl
index 76f3a3f7c0eae06aa87d2755ad16fc1447d34d51..d421cc213f2602d45a5a493d83a336e50539f9f2 100644
(file)
--- 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 %}
<tr>{# -#}
{{ macros.ledger_block_columns('raw', block) -}}
{##}{% for line in block.lines %}
<tr>{# -#}
- <td{{ ' class="critical"' if line.errors }}>
- {{-
line.raw
}} {# -#}
+ <td{{ ' class="critical"'
|safe
if line.errors }}>
+ {{-
line.raw
}} {# -#}
</td>{# -#}
</tr>
{##}{% endfor %}
</td>{# -#}
</tr>
{##}{% endfor %}
diff --git
a/src/templates/ledger_structured.tmpl
b/src/templates/ledger_structured.tmpl
index 9ec839e4fd754be174275cb52e9db54c4f4ff085..b045164d718e08d82a610bfb0cbc584998cea824 100644
(file)
--- a/
src/templates/ledger_structured.tmpl
+++ b/
src/templates/ledger_structured.tmpl
@@
-31,7
+31,7
@@
<td class="currency{{ ' critical' if line.errors }}">
{{- macros.currency_short(line.currency) -}}
</td>
<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>
{{- line.account -}}
</td>
<td>{{ line.comment }}</td>
diff --git
a/src/tests/full.balance
b/src/tests/full.balance
index f96e1a74f710ac040ed49b12a967837b220a980a..3422bb3934b39b76d3b7e4d1aa9b966412f120e1 100644
(file)
--- a/
src/tests/full.balance
+++ b/
src/tests/full.balance
@@
-87,14
+87,14
@@
span.indent {
|
balance after <a href="/blocks/4">booking 4 (2001-01-01: test)</a>
</p>
|
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>
<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>
<td class="balance currency">€</td>
</tr>
</table>
diff --git
a/src/tests/full.dat
b/src/tests/full.dat
index fffe6f506d222b130c75e208c313fa40d2967e6d..28b6b04743439c2692801cfa7cc47dd64ef79317 100644
(file)
--- a/
src/tests/full.dat
+++ b/
src/tests/full.dat
@@
-7,10
+7,12
@@
2001-01-02 test
bar -10 € ; bar
baz 10 €
2001-01-02 test
bar -10 € ; bar
baz 10 €
+ baz x €
2001-01-02 test
bar 20 €
2001-01-02 test
bar 20 €
+ bar 1 €
baz -20 € ; baz
2001-01-01 test
baz -20 € ; baz
2001-01-01 test
diff --git
a/src/tests/full.ledger_raw
b/src/tests/full.ledger_raw
index 45eda317d67b8b55af6d1035ee2c2e34ef10af43..b7ed479a8c8c25c1cb51ad640ef580692275cc54 100644
(file)
--- a/
src/tests/full.ledger_raw
+++ b/
src/tests/full.ledger_raw
@@
-112,7
+112,7
@@
Detected redundant empty lines in gaps, <input type="submit" name="remove_redund
<tr><td> </td></tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_2">
<tr><td> </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="^"
<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>
<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>]
[<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 </td></tr>
<tr><td> bar -10 € ; bar </td></tr>
<tr><td> baz 10 € </td></tr>
<tr><td>2001-01-02 test </td></tr>
<tr><td> bar -10 € ; bar </td></tr>
<tr><td> baz 10 € </td></tr>
+ <tr><td class="critical"> baz x € </td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr id="block_3">
<tr><td> </td></tr>
<tr><td> </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="^"
<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>
<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>]
[<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 </td></tr>
<tr><td> bar 20 € </td></tr>
</tr>
<tr><td>2001-01-02 test </td></tr>
<tr><td> bar 20 € </td></tr>
+ <tr><td> bar 1 € </td></tr>
<tr><td> baz -20 € ; baz </td></tr>
<tr><td> </td></tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
<tr><td> baz -20 € ; baz </td></tr>
<tr><td> </td></tr>
<tr></tr><!-- keep the background-color alternation in proper order -->
diff --git
a/src/tests/full.ledger_structured
b/src/tests/full.ledger_structured
index 2054d570243ecf5db0860db275a4d44088213547..b7681534e29daf7bc19eaa15cd43155cdb1c54b2 100644
(file)
--- a/
src/tests/full.ledger_structured
+++ b/
src/tests/full.ledger_structured
@@
-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">
</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="^"
<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>
<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>]
[<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>
<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> </td>
</tr>
<tr>
<td colspan=4> </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">
</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="^"
<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>
<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>]
[<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>
<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>
<tr>
<td class="amount">-20.00</td>
<td class="currency">€</td>