{# === _adjustment_row.html — row partial for the Adjustments tab === #} {% comment %} Single table row used by BOTH the flat Adjustments view and (later) the grouped view. Context: - adj a PayrollAdjustment instance - additive_types list of type labels that are additive (used to decide whether the amount should be prefixed with + or - in the display) Row actions differ by paid status: - Paid -> single View Payslip icon button - Unpaid -> three buttons: Preview, Edit, Delete (these reuse the existing modals on the dashboard -- no new JS) {% endcomment %} {% load format_tags %} {# --- Bulk-select checkbox --- #} {# Paid rows show a disabled checkbox so the column stays aligned; #} {# only unpaid rows can be bulk-selected for deletion (feature comes in Task 6). #} {% if adj.payroll_record %} {% else %} {% endif %} {# --- Date --- #} {{ adj.date|date:"d M Y" }} {# --- Worker name (class="worker-lookup-link" opens the Worker Lookup modal) --- #} {{ adj.worker.name }} {# --- Type badge (colour comes from the .badge-type- CSS class) --- #} {{ adj.type }} {# --- Amount (sign reflects additive vs deductive) --- #} {% if adj.type in additive_types %} +R {{ adj.amount|money }} {% else %} −R {{ adj.amount|money }} {% endif %} {# --- Project (clickable if present, dash if missing) --- #} {% if adj.project %} {# Link lands on the History tab of the project detail page — the #} {# most useful landing for a user who clicked a historical #} {# adjustment. Tab activation is driven by the #history fragment #} {# via a small helper in projects/detail.html. #} {{ adj.project.name }} {% else %}{% endif %} {# --- Team (worker's first team, if any — many workers are unteamed) --- #} {# Uses `teams.all` (NOT `teams.first`) because the view's #} {# .prefetch_related('worker__teams') populates `_prefetched_objects_cache` #} {# for `.all()` calls — `.first()` would ignore the cache and fire a #} {# fresh `ORDER BY ... LIMIT 1` SQL query per row (up to ~50 per page). #} {% with teams=adj.worker.teams.all %} {% if teams %}{{ teams.0.name }}{% else %}{% endif %} {% endwith %} {# --- Description (truncated; full text shown in a hover tooltip) --- #} {% if adj.description %} {{ adj.description|truncatechars:40 }} {% else %}{% endif %} {# --- Status: Paid #N (links to the payslip) or Unpaid badge --- #} {% if adj.payroll_record %} Paid #{{ adj.payroll_record.id }} {% else %} Unpaid {% endif %} {# --- Row actions (eye + pen + x for unpaid; eye only for paid) --- #} {% if adj.payroll_record %} {# Eye icon on paid rows opens the same Payslip Preview modal used on #} {# the Pending tab (instead of navigating to the payslip detail page). #} {# The "Paid #N" badge in the Status column still links to the #} {# historical payslip for users who want to jump to the PDF view. #} {% else %} {# UNPAID row: Preview + Edit only. Single-row delete happens #} {# inside the Edit Adjustment modal; bulk delete uses the row #} {# checkboxes + floating action bar (shared entry point). #} {% endif %}