From 77b2186411d61beba8bd913836b8b9507ed76621 Mon Sep 17 00:00:00 2001 From: Bradley Davis Date: Sat, 18 Jan 2025 12:49:53 -0800 Subject: [PATCH] Fixed budgeting on_track (#252) --- nummus/controllers/budgeting.py | 2 +- tests/controllers/test_budgeting.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nummus/controllers/budgeting.py b/nummus/controllers/budgeting.py index 8741b8f..6a4d344 100644 --- a/nummus/controllers/budgeting.py +++ b/nummus/controllers/budgeting.py @@ -176,7 +176,7 @@ def ctx_target( "target_assigned": target_assigned, "total_assigned": total_assigned, "to_go": target_assigned - assigned, - "on_track": total_assigned >= target_assigned, + "on_track": assigned >= target_assigned, "next_due_date": due_date, "progress_bars": progress_bars, "target": tar.amount, diff --git a/tests/controllers/test_budgeting.py b/tests/controllers/test_budgeting.py index a6b921e..fa24492 100644 --- a/tests/controllers/test_budgeting.py +++ b/tests/controllers/test_budgeting.py @@ -1259,7 +1259,7 @@ def test_ctx_target(self) -> None: tar.period = TargetPeriod.MONTH tar.type_ = TargetType.REFILL tar.due_date_ord = today.toordinal() - tar.repeat_every = 2 + tar.repeat_every = 6 s.flush() # Underfunded @@ -1288,21 +1288,21 @@ def test_ctx_target(self) -> None: # Underfunded ctx = budgeting.ctx_target( tar, - utils.date_add_months(month, 1), - assigned=Decimal(20), - available=Decimal(0), # Spent it all - leftover=Decimal(10), + utils.date_add_months(month, 3), + assigned=Decimal(0), + available=Decimal(20), + leftover=Decimal(20), ) target: budgeting.TargetContext = { - "target_assigned": Decimal(45), - "total_assigned": Decimal(30), - "to_go": Decimal(25), + "target_assigned": Decimal(20), + "total_assigned": Decimal(20), + "to_go": Decimal(20), "on_track": False, - "next_due_date": utils.date_add_months(today, 2), + "next_due_date": utils.date_add_months(today, 6), "progress_bars": [Decimal(100)], "target": Decimal(100), "total_target": Decimal(100), - "total_to_go": Decimal(70), + "total_to_go": Decimal(80), "period": tar.period, "type": tar.type_, }