Files
HRM-System/docs/PLAN-statutory-components-display.md

3.6 KiB
Raw Blame History

PLAN: Fix Statutory Deductions Not Showing in Components Column

Problem

On the Employee Salaries index page, the Components column shows "Basic only" for employees whose SSS / PhilHealth / Pag-IBIG fields are left blank (null).

Leaving them blank means "use standard bracket logic" — and the payroll engine does auto-calculate them via StatutoryBracket. However the UI has no awareness of this, so it looks like nothing is deducted.

Screenshot Evidence

  • Von Jalipa (₱30,000 monthly) → shows "Basic only" → SSS/PH/HDMF should show as Auto
  • Donna Marie Moreno (₱695 daily) → shows "Basic only" + fixed badges → correct (has fixed values)

Root Cause

Frontend — index.tsx line 335

// Only shows badges IF fixed values exist
{(row.sss_fixed || row.philhealth_fixed || row.pagibig_fixed) && (
  <div>
    {row.sss_fixed && <span>SSS: {row.sss_fixed}</span>}
    ...
  </div>
)}

When sss_fixed is null → entire block is skipped → no indicator shown.

Backend — EmployeeSalaryController@index

The controller transform (lines 158175) only attaches component_names/component_types for salary components. It does not compute or attach the bracket-based statutory amounts.


Proposed Fix

Phase 1 — Backend: Compute & Pass Bracket Amounts

File: app/Http/Controllers/EmployeeSalaryController.php Location: index() transform closure (after line 167)

Add on-the-fly bracket lookup per salary record and attach as:

  • sss_computed → monthly employee share from SSS bracket (null if fixed is set)
  • philhealth_computed → monthly employee share from PhilHealth bracket (null if fixed is set)
  • pagibig_computed → monthly employee share from Pag-IBIG bracket (null if fixed is set)

Logic mirrors PayrollService::calculateStatutoryContribution() exactly (same MSC formula for SSS).

No DB migration needed — computed values are calculated at query time, not stored.


Phase 2 — Frontend: Show Auto Badges

File: resources/js/pages/hr/employee-salaries/index.tsx Location: Components column render (lines 334341)

Replace the fixed-only badge block with a unified render for both modes:

State Badge Style
Fixed override set Solid badge — bg-amber-100 text-amber-800
Auto (bracket-based) Light ring badge — bg-amber-50 ring-amber-300 + (auto) label
No bracket / no value Hidden

The "Basic only" text remains visible only when there are truly no salary components AND no statutory badges (fixed or auto) to display.


Files to Modify

File Change
app/Http/Controllers/EmployeeSalaryController.php Add sss_computed, philhealth_computed, pagibig_computed in transform closure
resources/js/pages/hr/employee-salaries/index.tsx Update Components column to render auto badges when computed values exist

Verification Checklist

  • Von Jalipa (₱30,000 monthly, all blank) → shows 3 light "(auto)" badges with correct amounts
  • Donna Marie Moreno (₱695 daily, fixed set) → shows 3 solid badges (no "(auto)")
  • Employee with no matching bracket → shows nothing (graceful)
  • "Basic only" text only shows when no components AND no statutory badges at all
  • Amounts shown are monthly (not halved per cutoff — halving happens at payroll run time)

Agent Assignments

  • Backend: backend-specialist → Phase 1 transform logic
  • Frontend: frontend-specialist → Phase 2 badge UI

Estimated Effort: ~30 min · 2 files · no DB changes · no migration