Fix: Extract holiday pay from basic salary, remove Rest Day Premium, fix holiday count in payslip summary
This commit is contained in:
@@ -58,7 +58,7 @@ class PayrollService
|
||||
|
||||
$earnedBasicSalary = 0;
|
||||
$holidayPay = 0;
|
||||
$restDayPremium = 0;
|
||||
$holidayDaysNotWorked = 0;
|
||||
$regularOtTotal = 0;
|
||||
$nightDiffAmount = 0;
|
||||
$paidLeavesCount = 0;
|
||||
@@ -183,9 +183,8 @@ class PayrollService
|
||||
$premium = ($earnedDaily - $actualDailyRate);
|
||||
if ($isRegularHoliday || $isSpecialHoliday) {
|
||||
$holidayPay += $premium;
|
||||
} else {
|
||||
$restDayPremium += $premium;
|
||||
}
|
||||
// Rest Day Premium removed per client request
|
||||
}
|
||||
|
||||
// 2. Overtime Calculation (Compounded)
|
||||
@@ -233,12 +232,9 @@ class PayrollService
|
||||
$daysWorked++; // Treat as paid day
|
||||
$paidLeavesCount++;
|
||||
} elseif ($isRegularHoliday) {
|
||||
if ($isDailyWage) {
|
||||
// Daily/Rank & File: DOLE requires 100% holiday pay even if not worked
|
||||
$holidayPay += $actualDailyRate;
|
||||
}
|
||||
// Monthly employees: their fixed cut-off salary already covers this day.
|
||||
// No additional holiday pay needed. Don't count as absence.
|
||||
// All employees: extract holiday as separate earning line
|
||||
$holidayPay += $actualDailyRate;
|
||||
$holidayDaysNotWorked++;
|
||||
} else {
|
||||
// Only count as absent if NOT a rest day AND NOT a special holiday
|
||||
// Monthly employees' fixed salary covers special holidays automatically.
|
||||
@@ -267,8 +263,10 @@ class PayrollService
|
||||
// they get their exact fixed cut-off pay (Monthly / Divisor)
|
||||
$cutOffSalary = $grossMonthly / $divisor;
|
||||
|
||||
// Extract paid leaves from their basic salary to show it explicitly in the earnings
|
||||
$earnedBasicSalary = max(0, $cutOffSalary - $paidLeavesAmount);
|
||||
// Extract paid leaves AND holiday pay from basic to show them as separate line items
|
||||
// This matches the client's expected payslip format:
|
||||
// Basic = CutOff - Leaves - Holidays, then add them back as separate earning lines
|
||||
$earnedBasicSalary = max(0, $cutOffSalary - $paidLeavesAmount - $holidayPay);
|
||||
|
||||
// We explicitly deduct absent days (LWOP)
|
||||
$absenceDeduction = $absencesCount * $actualDailyRate;
|
||||
@@ -358,12 +356,10 @@ class PayrollService
|
||||
['name' => 'Holiday Pay', 'amount' => number_format($holidayPay, 2, '.', '')],
|
||||
]);
|
||||
|
||||
if ($restDayPremium > 0) {
|
||||
$earnings[] = ['name' => 'Rest Day Premium', 'amount' => number_format($restDayPremium, 2, '.', '')];
|
||||
}
|
||||
// Rest Day Premium removed per client request
|
||||
|
||||
// 7. Totals (Intermediate for Tax)
|
||||
$totalEarnings = $earnedBasicSalary + $paidLeavesAmount + $nightDiffAmount + $regularOtTotal + $holidayPay + $restDayPremium;
|
||||
$totalEarnings = $earnedBasicSalary + $paidLeavesAmount + $nightDiffAmount + $regularOtTotal + $holidayPay;
|
||||
|
||||
// 8. Withholding Tax Calculation (Based on Gross per user request)
|
||||
$tax = 0.00;
|
||||
@@ -419,7 +415,7 @@ class PayrollService
|
||||
'reg_ot_hours' => number_format($totalOvertimeHours, 2),
|
||||
'reg_ot_amount' => $regularOtTotal,
|
||||
'night_diff_amount' => $nightDiffAmount,
|
||||
'holiday' => $holidayPay,
|
||||
'holiday' => $holidayDaysNotWorked,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Night Diff:</strong> {{ isset($summary['night_diff_hours']) ? $summary['night_diff_hours'].'h' : (isset($summary['night_diff']) ? $summary['night_diff'].'h' : '0h') }}</td>
|
||||
<td><strong>Holiday:</strong> {{ isset($summary['holiday']) ? $summary['holiday'].'h' : '0h' }}</td>
|
||||
<td><strong>Holiday:</strong> {{ $summary['holiday'] ?? 0 }}</td>
|
||||
<td><strong>Leaves:</strong> {{ $summary['leaves'] ?? 0 }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user