From: Christian Heller Date: Tue, 28 Jan 2025 18:51:44 +0000 (+0100) Subject: Improve ledger layout. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Byoutube_prefix%7D%7D%7B%7Bvideo_id%7D%7D?a=commitdiff_plain;p=plomledger Improve ledger layout. --- diff --git a/ledger.py b/ledger.py index d7ebad6..098c6f6 100755 --- a/ledger.py +++ b/ledger.py @@ -136,6 +136,7 @@ class BookingLine: def __init__(self, booking: 'Booking') -> None: self.errors: list[str] = [] self.booking = booking + self.idx = 0 class IntroLine(BookingLine): @@ -170,8 +171,9 @@ class IntroLine(BookingLine): class TransferLine(BookingLine): """Non-first Booking line, expected to carry value movement.""" - def __init__(self, booking: 'Booking', code: str) -> None: + def __init__(self, booking: 'Booking', code: str, idx: int) -> None: super().__init__(booking) + self.idx = idx self.currency = '' self.amount: Optional[Decimal] = None if not code[0].isspace(): @@ -211,8 +213,8 @@ class Booking: self.intro_line = IntroLine(self, dat_lines[0].code) dat_lines[0].booking_line = self.intro_line self._transfer_lines = [] - for dat_line in dat_lines[1:]: - dat_line.booking_line = TransferLine(self, dat_line.code) + for i, dat_line in enumerate(dat_lines[1:]): + dat_line.booking_line = TransferLine(self, dat_line.code, i + 1) self._transfer_lines += [dat_line.booking_line] changes = Wealth() sink_account = None diff --git a/templates/_macros.tmpl b/templates/_macros.tmpl index a899699..c88bce6 100644 --- a/templates/_macros.tmpl +++ b/templates/_macros.tmpl @@ -7,15 +7,21 @@ td.amt, td.curr { font-family: monospace; font-size: 1.3em; } td.invalid, tr.warning td.invalid { background-color: #ff0000; } {% endmacro %} +{% macro css_ledger_index_col() %} +table.ledger tr > td:first-child { background-color: white; } +{% endmacro %} + {% macro table_dat_lines(dat_lines, raw) %} - +
{% for dat_line in dat_lines %} {% if (not raw) and dat_line.is_intro and loop.index > 1 %} - + {% endif %} {% if dat_line.is_intro %} - + + {% elif dat_line.booking_line.idx == 1 %} + {% else %} {% endif %} @@ -29,8 +35,8 @@ td.invalid, tr.warning td.invalid { background-color: #ff0000; } {% else %} {% if dat_line.is_intro %} - {{dat_line.booking_line.date}} - {{dat_line.booking_line.target}} + + {{dat_line.booking_line.target}} {% elif not dat_line.error %} diff --git a/templates/ledger_raw.tmpl b/templates/ledger_raw.tmpl index d09e722..d11e192 100644 --- a/templates/ledger_raw.tmpl +++ b/templates/ledger_raw.tmpl @@ -4,6 +4,7 @@ {% block css %} table { font-family: monospace; } {{ macros.css_errors() }} +{{ macros.css_ledger_index_col() }} {% endblock %} {% block content %} diff --git a/templates/ledger_structured.tmpl b/templates/ledger_structured.tmpl index 1669ce9..654cf80 100644 --- a/templates/ledger_structured.tmpl +++ b/templates/ledger_structured.tmpl @@ -4,6 +4,9 @@ {% block css %} {{ macros.css_td_money() }} {{ macros.css_errors() }} +{{ macros.css_ledger_index_col() }} +table.ledger > tbody > tr > td.date, table.ledger > tbody > tr > td:first-child { font-family: monospace; font-size: 1.3em; text-align: center; } +table.ledger > tbody > tr > td { vertical-align: middle; } {% endblock %} {% block content %}
 
 
#/b[#][b]{{dat_line.booking_line.date}}{{dat_line.booking_line.amount_short}} {{dat_line.booking_line.currency|truncate(4,true,"…")}}