From a6a91b28b8933039e9bca4a6ef5f5ba558523704 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 4 Jan 2026 01:11:07 +0100 Subject: [PATCH] =?utf8?q?In=20/balance=20view,=20sort=20node=20children?= =?utf8?q?=20by=20=E2=82=AC=20amount.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/ledgplom/ledger.py | 6 ++++++ src/templates/balance.tmpl | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ledgplom/ledger.py b/src/ledgplom/ledger.py index 3a07f35..bc7323b 100644 --- a/src/ledgplom/ledger.py +++ b/src/ledgplom/ledger.py @@ -79,6 +79,12 @@ class Account: if self.parent: self.parent.children += [self] + def children_euro_sorted_at(self, up_incl: int) -> list[Self]: + 'Sorted .children, by .get_wealth_at(up_incl).' + return sorted(self.children, + key=lambda c: + c.get_wealth_at(up_incl).moneys.get('€', Decimal(0))) + def get_wealth_at_excl_incl(self, up_incl: int) -> tuple[_Wealth, _Wealth]: 'Total, with .children wealths, of wealth until Bookings of up_incl.' total_excl = _Wealth() diff --git a/src/templates/balance.tmpl b/src/templates/balance.tmpl index 3b2d9a9..f9eece8 100644 --- a/src/templates/balance.tmpl +++ b/src/templates/balance.tmpl @@ -77,7 +77,7 @@ span.indent { {{account.desc}} - {% for child in account.children %} + {% for child in account.children_euro_sorted_at(block_id) %} {{account_with_children(block_id, child, indent=indent+1)}} {% endfor %} {% endif %} -- 2.30.2