From 472bb09fbac4e41667cedbb9c14869e0b106d9f1 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 19 Jun 2022 21:34:23 -0700 Subject: [PATCH] display submitted/paid totals in tree output --- src/budget_sync/budget_graph.py | 14 ++++++++++++++ src/budget_sync/main.py | 11 +++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/budget_sync/budget_graph.py b/src/budget_sync/budget_graph.py index 1577a4b..d0ce97e 100644 --- a/src/budget_sync/budget_graph.py +++ b/src/budget_sync/budget_graph.py @@ -407,6 +407,20 @@ class Node: retval += payment.amount return retval + @cached_property + def submitted_including_subtasks(self) -> Money: + retval = self.submitted_excluding_subtasks + for i in self.immediate_children: + retval += i.submitted_including_subtasks + return retval + + @cached_property + def paid_including_subtasks(self) -> Money: + retval = self.paid_excluding_subtasks + for i in self.immediate_children: + retval += i.paid_including_subtasks + return retval + @property def parent(self) -> Optional["Node"]: if self.parent_id is not None: diff --git a/src/budget_sync/main.py b/src/budget_sync/main.py index e2e39d7..f34a22b 100644 --- a/src/budget_sync/main.py +++ b/src/budget_sync/main.py @@ -53,11 +53,14 @@ def print_budget_then_children(indent, nodes, bug_id): """ bug = nodes[bug_id] - print("bug #%5d %s budget %7s excltasks %7s" % + print("bug #%5d %sbudget %5s excltasks %5s sub_tot %s paid_tot %s" % (bug.bug.id, ' ' * (indent*4), - str(bug.budget_including_subtasks), - str(bug.budget_excluding_subtasks))) - #print (repr(bug)) + str(bug.fixed_budget_including_subtasks), + str(bug.fixed_budget_excluding_subtasks), + str(bug.submitted_including_subtasks), + str(bug.paid_including_subtasks))) + + # print(repr(bug)) for child in bug.immediate_children: if (str(child.budget_including_subtasks) == "0" and str(child.budget_excluding_subtasks) == "0"): -- 2.30.2