From: Christian Heller Date: Mon, 24 Feb 2025 12:38:46 +0000 (+0100) Subject: Hide ;def comments in /ledger_structured. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7Bdb.prefix%7D%7D/booking/%7B%7Bitem_name%7D%7D?a=commitdiff_plain;ds=sidebyside;p=ledgplom Hide ;def comments in /ledger_structured. --- diff --git a/src/run.py b/src/run.py index db54b77..8c26685 100755 --- a/src/run.py +++ b/src/run.py @@ -138,6 +138,12 @@ class DatLine(Dictable): self.comment = halves[1] if len(halves) > 1 else '' self.code = halves[0] self.booking_line: Optional[BookingLine] = None + self.hide_comment_in_ledger = False + + @property + def comment_in_ledger(self) -> str: + """What to show in structured ledger view (as per .hide_comment…).""" + return '' if self.hide_comment_in_ledger else self.comment @property def is_intro(self) -> bool: @@ -548,15 +554,16 @@ class Server(PlomHttpServer): booked_lines.clear() gap_lines += [dat_line] self.paths_to_descs = {} - for comment in [dl.comment for dl in self.dat_lines if dl.comment]: - if comment.startswith(PREFIX_DEF): - parts = [part.strip() for part - in comment[len(PREFIX_DEF):].split(';')] - first_part_parts = parts[0].split(maxsplit=1) - account_name = first_part_parts[0] - desc = first_part_parts[1] if len(first_part_parts) > 1 else '' - if desc: - self.paths_to_descs[account_name] = desc + for dat_line in [dl for dl in self.dat_lines + if dl.comment.startswith(PREFIX_DEF)]: + parts = [part.strip() for part + in dat_line.comment[len(PREFIX_DEF):].split(';')] + first_part_parts = parts[0].split(maxsplit=1) + account_name = first_part_parts[0] + desc = first_part_parts[1] if len(first_part_parts) > 1 else '' + if desc: + self.paths_to_descs[account_name] = desc + dat_line.hide_comment_in_ledger = True for booking in self.bookings: booking.recalc_prev_next(self.bookings) if booking: @@ -604,8 +611,10 @@ class Server(PlomHttpServer): for line in self.dat_lines: line.prev_line_empty = False if prev_line: - line.prev_line_empty = not prev_line.code + prev_line.comment - prev_line = line + line.prev_line_empty = not (prev_line.code + + prev_line.comment_in_ledger) + if prev_line or line.code + line.comment_in_ledger: # jump over + prev_line = line # empty start def _recalc_dat_lines(self) -> None: self.dat_lines = self.initial_gap_lines[:] diff --git a/src/templates/_macros.tmpl b/src/templates/_macros.tmpl index 614a7fa..a3187c9 100644 --- a/src/templates/_macros.tmpl +++ b/src/templates/_macros.tmpl @@ -32,7 +32,7 @@ table.ledger tr > td:first-child { background-color: white; }
{% for dat_line in dat_lines %} - {% if raw or dat_line.code or dat_line.comment %} + {% if raw or dat_line.code or dat_line.comment_in_ledger %} {% if (not raw) and dat_line.prev_line_empty %} @@ -66,18 +66,18 @@ table.ledger tr > td:first-child { background-color: white; } {{dat_line.booking.date}}{{dat_line.booking.target}} - + {% elif dat_line.error %} - + {% elif dat_line.booking_line %} - + {% else %} - + {% endif %} {% endif %}
 
{{dat_line.comment}}{{dat_line.comment_in_ledger}}{{dat_line.code}}{{dat_line.comment}}{{dat_line.comment_in_ledger}}{{dat_line.booking_line.amount_short}} {{dat_line.booking_line.currency|truncate(4,true,"…")}} {{dat_line.booking_line.account}}{{dat_line.comment}}{{dat_line.comment_in_ledger}}{{dat_line.comment}} {{dat_line.comment_in_ledger}}