Skip to content

Commit

Permalink
Fixed budgeting on_track (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
WattsUp authored Jan 18, 2025
1 parent ca2698a commit 77b2186
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion nummus/controllers/budgeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions tests/controllers/test_budgeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_,
}
Expand Down

0 comments on commit 77b2186

Please sign in to comment.