From: Christian Heller Date: Sun, 11 Jan 2026 17:29:18 +0000 (+0100) Subject: Improve ledger templates and their testing files. X-Git-Url: https://plomlompom.com/repos/booking/%7B%7Bdb.prefix%7D%7D/edit?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=ledgplom Improve ledger templates and their testing files. --- diff --git a/src/ledgplom/ledger.py b/src/ledgplom/ledger.py index bc7323b..5e6b00b 100644 --- a/src/ledgplom/ledger.py +++ b/src/ledgplom/ledger.py @@ -593,8 +593,8 @@ class Ledger: if (not dat_lines) or dat_lines[-1].code: # ensure final gap line so dat_lines += [_DatLine()] # last booking gets finished booking_lines: list[_BookingLine] = [] - new_block = DatBlock(None, _Gap()) - self._blocks_start = new_block + i_block = DatBlock(None, _Gap()) + self._blocks_start = i_block for dat_line in dat_lines: if bool(dat_line.code): if not booking_lines: @@ -603,10 +603,12 @@ class Ledger: booking_lines += [_TransferLine.from_dat(dat_line)] else: # enter new gap -> ready to start next block if booking_lines: - new_block.next = DatBlock(_Booking(booking_lines)) - new_block = new_block.next - booking_lines = [] - new_block.gap.add([_GapLine.from_dat(dat_line)]) + ### i_block = i_block.next = DatBlock(_Booking(booking_lines)) + i_block.next = DatBlock(_Booking(booking_lines)) + i_block = i_block.next + ### booking_lines.clear() + booking_lines = [] # .clear() + i_block.gap.add([_GapLine.from_dat(dat_line)]) self.last_save_hash = self._hash_dat_lines() @property @@ -700,7 +702,7 @@ class Ledger: lines_gap_post_booking: list[_GapLine] = [] for dat_line in [_DatLine.from_raw(line) for line in new_lines]: if dat_line.code: - if lines_gap_post_booking: + if lines_gap_post_booking: # .code belongs to _next_ Booking lines_gap_post_booking += [_GapLine.from_dat(dat_line)] elif not lines_booking: lines_booking += [_IntroLine.from_dat(dat_line)] diff --git a/src/templates/_base.tmpl b/src/templates/_base.tmpl index d91f5d8..afecacc 100644 --- a/src/templates/_base.tmpl +++ b/src/templates/_base.tmpl @@ -30,13 +30,13 @@ table.alternating > tbody > tr:nth-child(odd) { background-color: #dcdcdc; } table.alternating > tbody > tr:nth-child(even) { - {{macros.css_bg_white()}}; + {{macros.css_bg_white()}} } td { vertical-align: top; } -div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical { - {{macros.css_bg_red()}} +.critical { + background: {{macros.css_red()}} !important; } {% block css %} {% endblock %} diff --git a/src/templates/_macros.tmpl b/src/templates/_macros.tmpl index 46a55a3..e6b9268 100644 --- a/src/templates/_macros.tmpl +++ b/src/templates/_macros.tmpl @@ -1,7 +1,14 @@ {# =====================[ general css ]========================== #} -{% macro css_bg_white() %}background: #ffffff;{% endmacro %} -{% macro css_bg_red() %}background: #ff6666;{% endmacro %} +{% macro css_red() %}#ff6666{% endmacro %} +{% macro css_red_lighter() %}#ff8a8a{% endmacro %} +{% macro css_white() %}#ffffff{% endmacro %} + + + +{% macro css_bg_white() -%} +{##}background: {{ css_white() }}; +{%- endmacro %} @@ -11,32 +18,30 @@ {% endmacro %} + {% macro css_tabular_money() %} td.amount { text-align: right; } -td.amount, td.currency { -{{ css_noninput_monospace() -}}}{% endmacro %} -{# endmacro #} +td.amount, +td.currency { +{{ css_noninput_monospace() -}} +} +{%- endmacro %} {% macro css_balance() %} -table.alternating.critical > tbody > tr:nth-child(odd) { - {{ css_bg_red() }} -} table.alternating.critical > tbody > tr:nth-child(even) { - background-color: #ff8a8a; + background-color: {{ css_red_lighter() }}; } td.balance.amount { width: 10em; } td.balance.currency { width: 3em; -}{% -endmacro %} -{# endmacro #} +} +{%- endmacro %} @@ -63,10 +68,7 @@ endmacro %} td.block_column { {{css_bg_white()}} } -td.block_column.critical { - {{css_bg_red()}} -}{% endmacro %} -{# endmacro #} +{%- endmacro %} @@ -80,20 +82,38 @@ td.block_column.critical { {% macro ledger_block_columns(mode, block) %} - - - -
-
- + + + + +
+ +
+ - + [#]
[b]
[e] - {% endmacro %} -{# endmacro #} + +{% endmacro %} {# =====================[ for edit pages ]======================= #} diff --git a/src/templates/ledger_raw.tmpl b/src/templates/ledger_raw.tmpl index 8779504..5f129fb 100644 --- a/src/templates/ledger_raw.tmpl +++ b/src/templates/ledger_raw.tmpl @@ -3,7 +3,7 @@ {% block css %} -{{macros.css_ledger()}} +{{ macros.css_ledger() }} table { font-family: monospace; } @@ -13,15 +13,15 @@ table { {% block content %}
-{{macros.ledger_empty_lines_fix(has_redundant_empty_lines)}} +{{ macros.ledger_empty_lines_fix(has_redundant_empty_lines) -}} {% for block in blocks %} - {{macros.ledger_block_columns('raw', block)}} - {% for line in block.lines %} + {{ macros.ledger_block_columns('raw', block) }} +{##}{% for line in block.lines %} - + - {% endfor %} +{##}{% endfor %} {% endfor %}
{{line.raw}} {{line.raw}} 
diff --git a/src/templates/ledger_structured.tmpl b/src/templates/ledger_structured.tmpl index fd1c120..aeae2ba 100644 --- a/src/templates/ledger_structured.tmpl +++ b/src/templates/ledger_structured.tmpl @@ -3,31 +3,40 @@ {% block css %} -{{macros.css_ledger()}} -{{macros.css_tabular_money()}} +{{ macros.css_ledger() }} +{{ macros.css_tabular_money() }} {% endblock %} {% block content %}
-{{ macros.ledger_empty_lines_fix(has_redundant_empty_lines) -}} +{{ macros.ledger_empty_lines_fix(has_redundant_empty_lines) -}} +
{% for block in blocks %} -{##}{{ macros.ledger_block_columns('structured', block) }} +{{ macros.ledger_block_columns('structured', block) -}} {##}{% if block.booking %} - - + + -{######}{% for line in block.booking.transfer_lines %} +{####}{% for line in block.booking.transfer_lines %} - - - - + + + + -{######}{% endfor %} +{####}{% endfor %} {##}{% endif %} {##}{% for line in block.gap.lines %} diff --git a/src/tests/empty.html b/src/tests/empty.html index 15c4cde..b173595 100644 --- a/src/tests/empty.html +++ b/src/tests/empty.html @@ -27,24 +27,22 @@ table.alternating > tbody > tr:nth-child(odd) { background-color: #dcdcdc; } table.alternating > tbody > tr:nth-child(even) { - background: #ffffff;; + background: #ffffff; } td { vertical-align: top; } -div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical { - background: #ff6666; +.critical { + background: #ff6666 !important; } td.block_column { background: #ffffff; } -td.block_column.critical { - background: #ff6666; -} td.amount { text-align: right; } -td.amount, td.currency { +td.amount, +td.currency { font-family: monospace; font-size: 1.25em; } @@ -63,19 +61,29 @@ td.amount, td.currency {
{{block.booking.date}} {{block.booking.target}}{{block.booking.intro_line.comment}} + {{- block.booking.date }} {{ block.booking.target -}} + {{ block.booking.intro_line.comment }}
{{line.amount_short}}{{ macros.currency_short(line.currency) }}{{line.account}}{{line.comment}} + {{- line.amount_short -}} + + {{- macros.currency_short(line.currency) -}} + + {{- line.account -}} + {{ line.comment }}
- + - - - + diff --git a/src/tests/full.dat b/src/tests/full.dat index 3cf3339..2866ede 100644 --- a/src/tests/full.dat +++ b/src/tests/full.dat @@ -1,7 +1,17 @@ -2001-01-01 test - foo 10 € +2001-01-01 test ; foo + foo 10 € bar -10 € 2001-01-02 test - bar 20 € - baz -20 € + bar -10 € ; bar + baz 10 € + + +2001-01-02 test + bar 20 € + baz -20 € ; baz + +2001-01-01 test + foo 10 € + bar -10 € + diff --git a/src/tests/full.html b/src/tests/full.html index 41c0ed6..8f3b3b2 100644 --- a/src/tests/full.html +++ b/src/tests/full.html @@ -27,24 +27,22 @@ table.alternating > tbody > tr:nth-child(odd) { background-color: #dcdcdc; } table.alternating > tbody > tr:nth-child(even) { - background: #ffffff;; + background: #ffffff; } td { vertical-align: top; } -div.critical, td.critical, tr.critical, span.critical, input[type="submit"].critical { - background: #ff6666; +.critical { + background: #ff6666 !important; } td.block_column { background: #ffffff; } -td.block_column.critical { - background: #ff6666; -} td.amount { text-align: right; } -td.amount, td.currency { +td.amount, +td.currency { font-family: monospace; font-size: 1.25em; } @@ -63,78 +61,193 @@ td.amount, td.currency {
-
-
- +
+ +
+ +
+
+ [#]
[b]
[e]
 
- + - - - - + + - - - + - - + + - - - + + + - - - + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - + + +
-
-
- +
+ +
+ +
+
+ [#]
[b]
[e]
-
-
- +
+ +
+ +
+
+ [#]
[b]
[e]
2001-01-01 test2001-01-01 testfoo
10.00€foo10.00€foo
-10.00€bar-10.00€bar
 
-
-
- +
+ +
+ +
+
+ [#]
[b]
[e]
2001-01-02 test
-10.00€barbar
10.00€baz
 
 
+ +
+ +
+ +
+ [#]
+ [b]
+ [e] +
2001-01-02 test
20.00€bar
-20.00€bazbaz
 
+ +
+ +
+ +
+ [#]
+ [b]
+ [e] +
2001-01-02 test2001-01-01 test
20.00€bar10.00€foo
-20.00€baz-10.00€bar