@php $user = $payroll->user; $profile = $user?->user_profile; $address = $user?->user_address; $daysInMonth = cal_days_in_month(CAL_GREGORIAN, (int) $payroll->month, (int) $payroll->year); $payPeriod = date('F Y', mktime(0, 0, 0, (int) $payroll->month, 1, (int) $payroll->year)); $payDate = $payroll->created_at ? $payroll->created_at->format('F j, Y') : now()->format('F j, Y'); $grossSalary = $payroll->base_salary + $payroll->total_addition; $netPay = $payroll->total_payable ?? ($grossSalary - $payroll->total_deduction - $payroll->total_tax); $currentAddress = $address?->current_address ?? $address?->permanent_address; function payrollNumberToWords(float $number): string { $ones = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']; $tens = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']; $convertBelowThousand = function (int $num) use (&$convertBelowThousand, $ones, $tens): string { if ($num === 0) { return ''; } if ($num < 20) { return $ones[$num] . ' '; } if ($num < 100) { return $tens[intdiv($num, 10)] . ' ' . $convertBelowThousand($num % 10); } return $ones[intdiv($num, 100)] . ' Hundred ' . $convertBelowThousand($num % 100); }; $number = (int) round($number); if ($number === 0) { return 'Zero Rupees Only'; } $crore = intdiv($number, 10000000); $number %= 10000000; $lakh = intdiv($number, 100000); $number %= 100000; $thousand = intdiv($number, 1000); $number %= 1000; $hundred = $number; $words = ''; $words .= $crore > 0 ? $convertBelowThousand($crore) . 'Crore ' : ''; $words .= $lakh > 0 ? $convertBelowThousand($lakh) . 'Lakh ' : ''; $words .= $thousand > 0 ? $convertBelowThousand($thousand) . 'Thousand ' : ''; $words .= $hundred > 0 ? $convertBelowThousand($hundred) : ''; return trim(preg_replace('/\s+/', ' ', $words)) . ' Rupees Only'; } @endphp
Payslip
@if($logoPath ?? null) {{ $account->name }} @else
{{ strtoupper(substr($account->name, 0, 1)) }}
@endif
{{ $account->name }}
@if($account->address)
{{ $account->address }}
@endif
Pay Period
{{ $payPeriod }}
Pay Date
{{ $payDate }}
@if($userImagePath ?? null) {{ $user?->name }} @else
{{ strtoupper(substr($user?->name ?? '?', 0, 1)) }}
@endif
{{ $user?->name ?? 'N/A' }}
@if($user?->designation)
{{ $user->designation }}
@endif
@if($currentAddress)
{{ $currentAddress }}
@endif @if($user?->email)
{{ $user->email }}
@endif
Employees ID
#{{ str_pad($user?->id ?? 0, 5, '0', STR_PAD_LEFT) }}
Additions
@if($payroll->additions && $payroll->additions->count() > 0) @foreach($payroll->additions as $addition)
{{ $addition->reason }} + {{ number_format($addition->amount, 2) }}
@endforeach @else
No additions found.
@endif
Effective Work Days
{{ $daysInMonth }} Days
Bank Name
{{ $profile?->bank_name ?? 'N/A' }}
Bank Account Number
{{ $profile?->bank_account_no ?? 'N/A' }}
PAN/Tax ID
{{ $profile?->pan_card_no ?? 'N/A' }}
Deductions
@if($payroll->deductions && $payroll->deductions->count() > 0) @foreach($payroll->deductions as $deduction)
{{ $deduction->reason }} - {{ number_format($deduction->amount, 2) }}
@endforeach @else
No deductions found.
@endif
Taxes
@if($payroll->taxes && $payroll->taxes->count() > 0) @foreach($payroll->taxes as $tax)
{{ $tax->reason }} - {{ number_format($tax->amount, 2) }}
@endforeach @else
No taxes found.
@endif

Gross Salary Rs. {{ number_format($grossSalary, 2) }}
Total Additions Rs. {{ number_format($payroll->total_addition, 2) }}
Total Deduction Rs. {{ number_format($payroll->total_deduction, 2) }}
Total Tax Rs. {{ number_format($payroll->total_tax, 2) }}

Net Pay Rs. {{ number_format($netPay, 2) }}
Amount in Words {{ payrollNumberToWords((float) $netPay) }}