diff --git a/core/tests.py b/core/tests.py index d2006f0..4aeabc8 100644 --- a/core/tests.py +++ b/core/tests.py @@ -589,3 +589,8 @@ class CurrentOutstandingInScopeTests(TestCase): # With team filter, only self.w's logs appear — R 400 total result = _current_outstanding_in_scope(team_ids=[self.t1.id]) self.assertEqual(result['total'], Decimal('400.00')) + # The R500 bonus on other_worker must NOT appear in by_project because + # that worker isn't in t1 — the team scope excludes them entirely. + self.assertEqual(len(result['by_project']), 2) + amounts = [row['amount'] for row in result['by_project']] + self.assertNotIn(Decimal('500.00'), amounts) diff --git a/core/views.py b/core/views.py index 565c0d5..7fbc9e8 100644 --- a/core/views.py +++ b/core/views.py @@ -270,7 +270,8 @@ def _current_outstanding_in_scope(project_ids=None, team_ids=None): raw = _compute_outstanding(project_ids=project_ids, team_ids=team_ids) by_project_list = sorted( [{'name': name, 'amount': amt} for name, amt in raw['outstanding_by_project'].items()], - key=lambda r: -r['amount'], + key=lambda r: r['amount'], + reverse=True, ) return { 'total': raw['outstanding_payments'],