diff --git a/app/Services/PayrollService.php b/app/Services/PayrollService.php index 7475820dc..9aea07987 100644 --- a/app/Services/PayrollService.php +++ b/app/Services/PayrollService.php @@ -58,6 +58,7 @@ class PayrollService $earnedBasicSalary = 0; $holidayPay = 0; + $holidayPremiumPay = 0; $holidayDaysNotWorked = 0; $regularOtTotal = 0; $nightDiffAmount = 0; @@ -192,6 +193,7 @@ class PayrollService $premium = ($earnedDaily - $proratedDailyRate); if ($isRegularHoliday || $isSpecialHoliday) { $holidayPay += $premium; + $holidayPremiumPay += $premium; } // Rest Day Premium removed per client request } @@ -303,8 +305,10 @@ class PayrollService // 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); + // Basic = CutOff - Leaves - Holidays (only the unworked holiday portion), then add them back as separate earning lines + // Any extra premium earned from working on a holiday is an addition, NOT deducted from base salary. + $holidayPayNotWorked = max(0, $holidayPay - $holidayPremiumPay); + $earnedBasicSalary = max(0, $cutOffSalary - $paidLeavesAmount - $holidayPayNotWorked); // We explicitly deduct absent days (LWOP) $absenceDeduction = $absencesCount * $actualDailyRate;