diff --git a/app/Http/Controllers/AttendanceRecordController.php b/app/Http/Controllers/AttendanceRecordController.php index 24044b031..f0db7c172 100644 --- a/app/Http/Controllers/AttendanceRecordController.php +++ b/app/Http/Controllers/AttendanceRecordController.php @@ -41,7 +41,7 @@ class AttendanceRecordController extends Controller } if (Auth::user()->can('manage-attendance-records')) { - $query = AttendanceRecord::with(['employee.employee.branch', 'shift', 'attendancePolicy', 'creator']) + $query = AttendanceRecord::with(['employee.employee.branch', 'shift', 'creator']) ->where(function ($q) { if (Auth::user()->can('manage-any-attendance-records')) { $q->whereIn('created_by', getCompanyAndUsersId()); @@ -442,7 +442,7 @@ class AttendanceRecordController extends Controller $attendanceRecord->update($validated); // Reload necessary relationships if not already fresh - $attendanceRecord->loadMissing(['shift', 'attendancePolicy']); + $attendanceRecord->loadMissing(['shift']); $attendanceRecord->processAttendance(false); return redirect()->back()->with('success', __('Attendance record updated successfully')); @@ -735,7 +735,7 @@ class AttendanceRecordController extends Controller { if (Auth::user()->can('export-attendance-record')) { try { - $attendanceRecords = AttendanceRecord::with(['employee', 'shift', 'attendancePolicy']) + $attendanceRecords = AttendanceRecord::with(['employee', 'shift']) ->where(function ($q) { if (Auth::user()->can('manage-any-attendance-records')) { $q->whereIn('created_by', getCompanyAndUsersId()); @@ -758,7 +758,6 @@ class AttendanceRecordController extends Controller 'Employee', 'Date', 'Shift', - 'Attedance Policy', 'Clock In', 'Clock Out', 'Break Hours', @@ -775,7 +774,6 @@ class AttendanceRecordController extends Controller $record->employee->name ?? '', $record->date ? date('Y-m-d', strtotime($record->date)) : '', $record->shift->name ?? '', - $record->attendancePolicy->name ?? '', $record->clock_in ?? '', $record->clock_out ?? '', $record->break_hours ?? '', diff --git a/app/Http/Controllers/EmployeeController.php b/app/Http/Controllers/EmployeeController.php index eeef8736b..e1b4c3648 100644 --- a/app/Http/Controllers/EmployeeController.php +++ b/app/Http/Controllers/EmployeeController.php @@ -462,7 +462,7 @@ class EmployeeController extends Controller } // Load user with employee relationships - $user = User::with(['employee.branch', 'employee.department', 'employee.designation', 'employee.shift', 'employee.attendancePolicy', 'employee.documents.documentType']) + $user = User::with(['employee.branch', 'employee.department', 'employee.designation', 'employee.shift', 'employee.documents.documentType']) ->where('id', $employee->user_id) ->first(); @@ -1149,7 +1149,7 @@ class EmployeeController extends Controller { if (Auth::user()->can('export-employee')) { try { - $employees = User::with(['employee.branch', 'employee.department', 'employee.designation', 'employee.shift', 'employee.attendancePolicy']) + $employees = User::with(['employee.branch', 'employee.department', 'employee.designation', 'employee.shift']) ->where('type', 'employee') ->where(function ($q) { if (Auth::user()->can('manage-any-employees')) { @@ -1182,7 +1182,6 @@ class EmployeeController extends Controller 'Gender', 'Shift', 'Basic Salary', - 'Attedance Policy', 'Employement Type', 'Employement Status', 'City', @@ -1212,7 +1211,6 @@ class EmployeeController extends Controller $employee->gender ?? '', $employee->shift->name ?? '', $employee->base_salary ?? '', - $employee->attendancePolicy->name ?? '', $employee->employment_type ?? '', $employee->employee_status ?? 'active', $employee->city ?? '', diff --git a/app/Services/ThirteenthMonthService.php b/app/Services/ThirteenthMonthService.php index aa66e21d8..7420395c5 100644 --- a/app/Services/ThirteenthMonthService.php +++ b/app/Services/ThirteenthMonthService.php @@ -50,19 +50,22 @@ class ThirteenthMonthService $key = $periodDate->format('Y-m'); if (array_key_exists($key, $monthlyEarnings)) { + // Actual Basic Salary Earned (net of absences/tardiness) $basic = (float) ($entry->basic_salary ?? 0); - - $extraBase = 0.00; + + // Add Paid Leaves (Sick Leave, Vacation Leave, Birthday Leave) + // Excludes: LWOP (Unpaid Leaves), Holiday Pay, Overtime, Night Differential, COLA + $paidLeaves = 0.00; if (is_array($entry->earnings_breakdown)) { foreach ($entry->earnings_breakdown as $item) { $category = strtolower($item['name'] ?? ''); - if (str_contains($category, 'paid leave') || str_contains($category, 'holiday')) { - $extraBase += (float) ($item['amount'] ?? 0); + if (str_contains($category, 'paid leave')) { + $paidLeaves += (float) ($item['amount'] ?? 0); } } } - $monthlyEarnings[$key] += ($basic + $extraBase); + $monthlyEarnings[$key] += ($basic + $paidLeaves); } } } else { diff --git a/docs/PLAN-13th-month-pay.md b/docs/PLAN-13th-month-pay.md index 938197af4..723825946 100644 --- a/docs/PLAN-13th-month-pay.md +++ b/docs/PLAN-13th-month-pay.md @@ -8,10 +8,10 @@ Implement a comprehensive **13th Month Pay Module** compliant with Philippine La ## 2. Requirements & Business Rules ### A. Calculation Formula (DOLE Standard) -$$\text{13th Month Pay} = \frac{\sum (\text{Basic Salary Earned} + \text{Paid Leave Pay} + \text{Holiday Pay})}{12}$$ +$$\text{13th Month Pay} = \frac{\sum (\text{Actual Basic Salary Earned} + \text{Paid Leave Pay})}{12}$$ -* **Included Base:** Basic pay earned + Approved paid leave pay (VL/SL) + Holiday pay from processed `PayrollEntry` records in the selected year/range. -* **Excluded Base:** Overtime pay, Night Differential pay, allowances, incentives, and reimbursements. +* **Included Base:** Actual basic salary earned (after tardiness/absence deductions) + Approved Paid Leaves (Sick Leave, Vacation Leave, Birthday Leave) from processed `PayrollEntry` records. +* **Excluded Base:** Unpaid Leaves (LWOP), Holiday Pay (Regular & Special Non-Working), Overtime Pay, Night Differential Pay, COLA, allowances, incentives, and reimbursements. * **Deductions Policy:** Completely free of statutory (SSS, PhilHealth, Pag-IBIG) and loan deductions. * **Tax Exemption:** Automatically applies TRAIN Law ₱90,000 bonus tax-exemption threshold (amounts above ₱90k flagged for tax evaluation). * **Pro-rating:** Automatically pro-rates for employees hired during the year or resigned mid-year based on actual payroll records.