@php $rawEarnings = $payrollEntry->earnings_breakdown ?? []; $meta = $rawEarnings['meta'] ?? []; $summary = $rawEarnings['summary'] ?? []; unset($rawEarnings['meta'], $rawEarnings['summary']); $earnings = array_values($rawEarnings); $deductions = array_values($payrollEntry->deductions_breakdown ?? []); function extractAmount($array, $keywords) { $keywords = (array) $keywords; foreach ($array as $item) { if (!isset($item['name'])) continue; foreach ($keywords as $keyword) { if (stripos($item['name'], $keyword) !== false) { return $item['amount']; } } } return 0; } // Map dynamic earnings natively $basicSalary = extractAmount($earnings, 'Basic Salary') ?: $payrollEntry->basic_salary; $nightDiff = extractAmount($earnings, 'Night Diff'); $overtime = extractAmount($earnings, ['Overtime', 'Reg. OT']); $holidayPay = extractAmount($earnings, 'Holiday'); $adjustment = extractAmount($earnings, 'Adjustment'); // Map explicit deductions natively $undertimeDed = extractAmount($deductions, 'Undertime'); $sss = extractAmount($deductions, 'SSS'); $phic = extractAmount($deductions, 'PhilHealth'); $hdmf = extractAmount($deductions, 'Pag-IBIG'); $tax = extractAmount($deductions, ['Tax', 'Withholding']); // Explicit penalties $tardiness = extractAmount($deductions, ['Late', 'Tardiness']); $absences = extractAmount($deductions, 'Absence'); $payType = $meta['pay_type'] ?? 'Monthly'; $formatter = class_exists('NumberFormatter') ? new \NumberFormatter("en", \NumberFormatter::SPELLOUT) : null; $words = $formatter ? ucwords($formatter->format($payrollEntry->net_pay)) . " Pesos Only" : "PHP " . $payrollEntry->net_pay; if ($formatter && strpos((string)$payrollEntry->net_pay, '.') !== false) { $parts = explode('.', number_format($payrollEntry->net_pay, 2, '.', '')); $cents = (int)$parts[1]; if ($cents > 0) { $words = ucwords($formatter->format((int)$parts[0])) . " Point " . ucwords($formatter->format($cents)) . " Pesos Only"; } } @endphp
{{ $companySettings['titleText'] ?? 'Your Company Name' }}
{{ $companySettings['companyAddress'] ?? 'Your Company Address' }}
PAYSLIP
{{ \Carbon\Carbon::parse($payrollEntry->payrollRun->pay_period_start)->format('M d, Y') }} - {{ \Carbon\Carbon::parse($payrollEntry->payrollRun->pay_period_end)->format('M d, Y') }} ({{ $payType }})
Employee Name: {{ $employee->name }} Employee ID: {{ $employeeData->employee_id ?? '' }}
Department: {{ $employeeData->department->name ?? 'N/A' }} Designation: {{ $employeeData->designation->name ?? 'N/A' }}
Payment Date: {{ \Carbon\Carbon::parse($payrollEntry->payrollRun->pay_date)->format('d M, Y') }} Status: {{ ucfirst($payrollEntry->payslip->status ?? 'Generated') }}
EARNINGS AMOUNT DEDUCTIONS AMOUNT
Basic Salary {{ formatCurrency($basicSalary) }} Undertime Deduction {{ formatCurrency($undertimeDed) }}
Night Differential {{ formatCurrency($nightDiff) }} SSS Contribution (EE) {{ formatCurrency($sss) }}
Overtime {{ formatCurrency($overtime) }} PhilHealth Contribution (EE) {{ formatCurrency($phic) }}
Holiday Pay {{ formatCurrency($holidayPay) }} Pag-IBIG Contribution (EE) {{ formatCurrency($hdmf) }}
Adjustment + {{ formatCurrency($adjustment) }} Withholding Tax {{ formatCurrency($tax) }}
Total Earnings {{ formatCurrency($payrollEntry->gross_pay) }} Total Deductions {{ formatCurrency($payrollEntry->total_deductions) }}
Tardiness {{ formatCurrency($tardiness) }}
Absences {{ formatCurrency($absences) }}
Undertime {{ formatCurrency($undertimeDed) }}
Attendance Summary
Days Worked: {{ $summary['days_worked'] ?? 0 }} Absences: {{ $summary['absences'] ?? 0 }} Leaves: {{ $summary['leaves'] ?? 0 }}
Expected Hours: {{ isset($summary['expected_hours']) ? $summary['expected_hours'].'h' : '0.00h' }} Rendered Hours: {{ isset($summary['rendered_hours']) ? $summary['rendered_hours'].'h' : '0.00h' }} Reg. OT: {{ isset($summary['reg_ot']) ? $summary['reg_ot'].'h' : '0h' }}
Night Diff: {{ isset($summary['night_diff']) ? $summary['night_diff'].'h' : '0h' }} Holiday: {{ isset($summary['holiday']) ? $summary['holiday'].'h' : '0h' }}
Net Pay: {{ \App\Models\Currency::getDefaultCurrency()->symbol ?? '?' }} {{ number_format($payrollEntry->net_pay, 2) }}
Amount in words: {{ $words }}