home · contact · privacy
In /balance view, sort node children by € amount. master
authorChristian Heller <c.heller@plomlompom.de>
Sun, 4 Jan 2026 00:11:07 +0000 (01:11 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 4 Jan 2026 00:11:07 +0000 (01:11 +0100)
src/ledgplom/ledger.py
src/templates/balance.tmpl

index 3a07f3513b6b6214750c5d119fe6e30f40bdf861..bc7323bac656e647744a8791ac2b2c46e8cd9808 100644 (file)
@@ -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()
index 3b2d9a943f7eba35837415469cfd6231672f1389..f9eece8d1fa360bd463d5b05f4d0c0abb2337376 100644 (file)
@@ -77,7 +77,7 @@ span.indent {
     </td>
     <td>{{account.desc}}</td>
     </tr>
-    {% 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 %}