if self.pagename.startswith('edit_'):
ctx['id'] = id_
if self.pagename == 'balance':
- valid, balance_roots = self.server.balance_roots(
- int(self.params.first('cutoff') or '0'))
+ id_ = int(self.params.first('up_incl') or '-1')
+ valid, balance_roots = self.server.balance_roots(id_)
self.send_rendered(Path('balance.tmpl'),
- ctx | {'roots': balance_roots, 'valid': valid})
+ ctx | {'roots': balance_roots,
+ 'valid': valid,
+ 'booking': self.server.bookings[id_]})
elif self.pagename == 'booking':
self.redirect(
Path('/').joinpath('edit_structured').joinpath(str(id_)))
"""Return only those .data_lines with .code or .comment."""
return [dl for dl in self.dat_lines if not dl.is_empty]
- def balance_roots(self, cutoff: int) -> tuple[bool, list[Account]]:
- """Return tree of calculated Accounts over .bookings[:cutoff]."""
+ def balance_roots(self, up_incl: int) -> tuple[bool, list[Account]]:
+ """Return tree of calculated Accounts over .bookings[:up_incl+1]."""
account_names = set()
valid = True
- to_balance = self.bookings[:cutoff] if cutoff else self.bookings
+ to_balance = (self.bookings[:up_incl + 1] if up_incl >= 0
+ else self.bookings)
for booking in to_balance:
valid = valid if not booking.is_questionable else False
for account_name in booking.account_changes:
{% endif %}
<tr class="alternating{% if dat_line.is_questionable %} warning{% endif %}">
{% if dat_line.is_intro %}
- <td id="{{dat_line.booking_id}}"><a href="#{{dat_line.booking_id}}">#</a>/<a href="/balance?cutoff={{dat_line.booking_id+1}}">b</a></td>
+ <td id="{{dat_line.booking_id}}"><a href="#{{dat_line.booking_id}}">#</a>/<a href="/balance?up_incl={{dat_line.booking_id}}">b</a></td>
{% else %}
<td></td>
{% endif %}