From: Jacob Lifshay Date: Mon, 20 Jun 2022 04:32:13 +0000 (-0700) Subject: fix budget excluding subtasks getting "fixed" to be negative X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16ad3ec56fc34b6e256248881c69f6277848061f;p=utils.git fix budget excluding subtasks getting "fixed" to be negative --- 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,