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:
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:
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[:]
<form action="/ledger_{% if raw %}raw{% else %}structured{% endif %}" method="POST">
<table class="ledger">
{% 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 %}
<tr ><td> </td></tr>
<a href="/bookings/{{dat_line.booking_id}}">{{dat_line.booking.date}}</a>
</td>
<td{% if dat_line.error %} class="invalid"{% endif %}>{{dat_line.booking.target}}</td>
- <td>{{dat_line.comment}}</td>
+ <td>{{dat_line.comment_in_ledger}}</td>
{% elif dat_line.error %}
<td class="invalid" colspan=3>{{dat_line.code}}</td>
- <td>{{dat_line.comment}}</td>
+ <td>{{dat_line.comment_in_ledger}}</td>
{% elif dat_line.booking_line %}
<td class="amt">{{dat_line.booking_line.amount_short}}</td>
<td class="curr">{{dat_line.booking_line.currency|truncate(4,true,"…")}}</td>
<td>{{dat_line.booking_line.account}}</td>
- <td>{{dat_line.comment}}</td>
+ <td>{{dat_line.comment_in_ledger}}</td>
{% else %}
<td colspan=2></td>
- <td colspan=2>{{dat_line.comment}} </td>
+ <td colspan=2>{{dat_line.comment_in_ledger}} </td>
{% endif %}
{% endif %}
</tr>