ctx['id'] = int(self.path_toks[2])
ctx['dat_lines'] = self.server.bookings[ctx['id']].dat_lines
if self.pagename == 'balance':
- valid, balance_roots = self.server.balance_roots
+ valid, balance_roots = self.server.balance_roots(
+ int(self.params.first('cutoff') or '0'))
self.send_rendered(Path('balance.tmpl'),
ctx | {'roots': balance_roots, 'valid': valid})
elif self.pagename == 'booking':
"""Return only those .data_lines with .code or .comment."""
return [dl for dl in self.dat_lines if not dl.is_empty]
- @property
- def balance_roots(self) -> tuple[bool, list[Account]]:
- """Return tree of calculated Accounts over all .bookings."""
+ def balance_roots(self, cutoff: int) -> tuple[bool, list[Account]]:
+ """Return tree of calculated Accounts over .bookings[:cutoff]."""
account_names = set()
valid = True
- for booking in self.bookings:
+ to_balance = self.bookings[:cutoff] if cutoff else self.bookings
+ for booking in to_balance:
valid = valid if not booking.is_questionable else False
for account_name in booking.account_changes:
account_names.add(account_name)
full_names_to_accounts[parent_name] if parent_name
else None,
step_name)
- for booking in self.bookings:
+ for booking in to_balance:
for account_name in booking.account_changes:
full_names_to_accounts[account_name].local_wealth +=\
booking.account_changes[account_name]