def do_GET(self) -> None:
# pylint: disable=invalid-name,missing-function-docstring
if self.pagename == 'balance':
- self.send_rendered(Path('balance.tmpl'),
- {'roots': self.server.balance_roots})
+ valid, balance_roots = self.server.balance_roots
+ self.send_rendered(Path('balance.tmpl'), {'roots': balance_roots,
+ 'valid': valid})
elif self.pagename == 'booking':
self.send_rendered(
Path('booking.tmpl'),
return [dl for dl in self.dat_lines if not dl.is_empty]
@property
- def balance_roots(self) -> list[Account]:
+ def balance_roots(self) -> tuple[bool, list[Account]]:
"""Return tree of calculated Accounts over all .bookings."""
account_names = set()
+ valid = True
for booking in self.bookings:
+ 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: dict[str, Account] = {}
for account_name in booking.account_changes:
full_names_to_accounts[account_name].local_wealth +=\
booking.account_changes[account_name]
- return [ac for ac in full_names_to_accounts.values() if not ac.parent]
+ return valid, [ac for ac in full_names_to_accounts.values()
+ if not ac.parent]
if __name__ == "__main__":
<style>
body { background-color: white; font-family: sans-serif; }
tr:nth-child(odd) { background-color: #dcdcdc; }
+td { text-align: left; vertical-align: top; }
+table.warning tbody tr td, tr.warning td { background-color: #ff8888; }
{% block css %}{% endblock %}
</style>
</head>
{% macro css_td_money() %}
td.amt { text-align: right }
td.amt, td.curr { font-family: monospace; font-size: 1.3em; }
-td.curr { text-align: left; }
{% endmacro %}
{% macro css_errors() %}
-tr.warning td { background-color: #ff8888; }
td.invalid, tr.warning td.invalid { background-color: #ff0000; }
{% endmacro %}
<td class="curr">{{curr|truncate(4,true,"…")}}</td>
{% endif %}
{% endfor %}
-<td>{% for _ in range(indent) %} {% endfor %}{{account.basename}}</td>
+<td rowspan={{ account.wealth.moneys|length }}>{% for _ in range(indent) %} {% endfor %}{{account.basename}}</td>
</tr>
{% for curr, amt in account.wealth.moneys.items() %}
{% if 1 < loop.index %}
{% endblock css %}
{% block content %}
-<table>
+<table{% if not valid %} class="warning"{% endif %}>
{% for root in roots %}
{{ account_with_children(root, indent=0) }}
{% endfor %}