From 16ad3ec56fc34b6e256248881c69f6277848061f Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 19 Jun 2022 21:32:13 -0700 Subject: [PATCH] fix budget excluding subtasks getting "fixed" to be negative --- src/budget_sync/budget_graph.py | 6 ++++-- src/budget_sync/test/test_budget_graph.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/budget_sync/budget_graph.py b/src/budget_sync/budget_graph.py index de1bed8..1577a4b 100644 --- a/src/budget_sync/budget_graph.py +++ b/src/budget_sync/budget_graph.py @@ -750,8 +750,10 @@ class BudgetGraph: node.fixed_budget_including_subtasks)) def set_excluding_from_including_and_error(): - node.fixed_budget_excluding_subtasks = \ - node.budget_including_subtasks - subtasks_total + v = node.budget_including_subtasks - subtasks_total + if v < 0: + return set_including_from_excluding_and_error() + node.fixed_budget_excluding_subtasks = v errors.append( BudgetGraphMoneyMismatchForBudgetExcludingSubtasks( node.bug.id, root.bug.id, diff --git a/src/budget_sync/test/test_budget_graph.py b/src/budget_sync/test/test_budget_graph.py index bd3a9cb..7aaadf5 100644 --- a/src/budget_sync/test/test_budget_graph.py +++ b/src/budget_sync/test/test_budget_graph.py @@ -893,12 +893,12 @@ alias2 = {paid=2020-03-16,amount=23} errors = bg.get_errors() self.assertErrorTypesMatches(errors, [ BudgetGraphNegativeMoney, - BudgetGraphMoneyMismatchForBudgetExcludingSubtasks]) + BudgetGraphMoneyMismatchForBudgetIncludingSubtasks]) self.assertEqual(errors[0].bug_id, 1) self.assertEqual(errors[0].root_bug_id, 1) self.assertEqual(errors[1].bug_id, 1) self.assertEqual(errors[1].root_bug_id, 1) - self.assertEqual(errors[1].expected_budget_excluding_subtasks, -10) + self.assertEqual(errors[1].expected_budget_including_subtasks, 0) bg = BudgetGraph([ MockBug(bug_id=1, cf_budget_parent=None, -- 2.30.2