diff --git a/core/templates/core/payroll_dashboard.html b/core/templates/core/payroll_dashboard.html index f224fae..1240d9c 100644 --- a/core/templates/core/payroll_dashboard.html +++ b/core/templates/core/payroll_dashboard.html @@ -585,12 +585,12 @@
- {% for t in adj_type_choices %} + {% for value, label in adj_type_choices %} {% endfor %}
@@ -915,7 +915,7 @@ {% for group in adj_groups %} diff --git a/core/views.py b/core/views.py index 19b87c0..a1b0b5f 100644 --- a/core/views.py +++ b/core/views.py @@ -2565,10 +2565,17 @@ def _group_adjustments(adjustments, group_by): groups = [] for key, rows in buckets.items(): if group_by == 'type': - label = key + # Visible header text uses the short display label (e.g. "Loan", + # "Advance", "Advance Repaid") from the model's TYPE_CHOICES. + label = rows[0].get_type_display() + # type_key holds the raw DB value so the template can emit it as + # data-type="..." for the [data-type="X"] CSS border-left accent + # selectors that still key on the canonical DB value. + type_key = key slug = key.lower().replace(' ', '-') else: # worker label = rows[0].worker.name + type_key = None slug = f'worker-{key}' net_sum = sum( (r.amount if r.type in ADDITIVE_TYPES else -r.amount) @@ -2576,6 +2583,7 @@ def _group_adjustments(adjustments, group_by): ) groups.append({ 'label': label, + 'type_key': type_key, 'slug': slug, 'rows': rows, 'count': len(rows), @@ -3232,11 +3240,14 @@ def payroll_dashboard(request): 'order': sort_order, 'group_by': group_by, }, - # Flat list of type labels for the Adjustments tab filter dropdown. - # Stored under a separate key so we don't clobber the existing - # 'adjustment_types' context var (which is TYPE_CHOICES tuples - # used by the Add/Edit adjustment modals). - 'adj_type_choices': list(ADDITIVE_TYPES) + list(DEDUCTIVE_TYPES), + # (db_value, display_label) pairs for the Type filter popover on the + # Adjustments tab. Uses TYPE_CHOICES directly so the checkbox labels + # show the short display labels (Loan / Advance / Advance Repaid) + # while checkbox values stay on the DB value (which the view filters + # by). Stored under a separate key so we don't clobber the existing + # 'adjustment_types' context var (also TYPE_CHOICES tuples, used by + # the Add/Edit adjustment modals). + 'adj_type_choices': PayrollAdjustment.TYPE_CHOICES, # PERF: reuse `all_workers`/`all_teams` (already cached above for # the Add-Adjustment modal) — same row-set, same ordering, so no # need to re-query the database for the filter popovers.