From 3fe3e5aa0122a5497c8f73c2f1b2b2e76cd52639 Mon Sep 17 00:00:00 2001 From: Konrad du Plessis Date: Thu, 23 Apr 2026 19:37:57 +0200 Subject: [PATCH] fix(adjustments): group-by uses full filtered queryset + Apply keeps group mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two final-review follow-ups from the whole-feature code review: 1. Important: group-by was bucketing adj_page.object_list (the paginated 50-row slice), making 'By Type' group headers show misleading per-page totals once filters returned >50 rows. Konrad's current data is under the threshold, but the UI promised whole-filter totals. Fix: group_by runs on the full filtered queryset (list(adjustments)) BEFORE pagination. Template already branches on adj_groups, so we now additionally hide the pagination nav when grouped — the group headers act as their own navigation and their counts/sums reflect the whole filter not just one page. 2. Minor: Apply after picking 'By Worker' silently reset to Flat view because the filter form had hidden inputs for sort/order but not group_by. Added the missing so the toggle round-trips across Apply. 65/65 tests still pass (no test changes — the previous tests' fixtures are all <50 rows so neither the bug nor the fix shows up there, but both behaviours are now correct). --- core/templates/core/payroll_dashboard.html | 9 ++++++--- core/views.py | 17 ++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/core/templates/core/payroll_dashboard.html b/core/templates/core/payroll_dashboard.html index 378a33a..e02efb8 100644 --- a/core/templates/core/payroll_dashboard.html +++ b/core/templates/core/payroll_dashboard.html @@ -744,9 +744,11 @@ - {# --- Sort state (column-header clicks will set these via JS in Task 9) --- #} + {# --- Sort state (column-header clicks set these via JS) --- #} + {# --- Group-by state (keeps Flat/By Type/By Worker across Apply) --- #} + {# --- Apply / Clear buttons --- #}
@@ -875,8 +877,9 @@
- {# --- Pagination (hrefs go through `url_replace` so `page=` doesn't stack) --- #} - {% if adj_page.has_other_pages %} + {# --- Pagination: flat view only. When grouped, group headers act as --- #} + {# --- their own navigation and totals cover the whole filtered set. --- #} + {% if adj_page.has_other_pages and not adj_groups %}