{{-- One paysheet, in the View as PDF layout; shared by pdf.blade.php and bulk-pdf.blade.php --}}
@php
$details = $paysheet->paysheetDetails;
$companyName = $paysheet->project?->project_name
?? $paysheet->client?->company_name
?? ($details->first()->company_name ?? 'N/A');
$pdfMonth = $paysheet->month ?: optional($details->first())->month;
try {
$monthLabel = $pdfMonth ? \Carbon\Carbon::parse($pdfMonth . '-01')->format('F-Y') : '-';
} catch (\Exception $e) {
$monthLabel = $pdfMonth;
}
$pdfDate = $paysheet->paysheet_date ?: $paysheet->invoice_date;
// Numeric columns in the same order as the paysheet page's detail rows
$numericFields = [
'pay_days', 'ba', 'da', 'hra', 'conveyance', 'medical_allowance',
'other_allowance', 'incentive', 'ot', 'earned_gross', 'epf_wages',
'employee_pf', 'employee_esi', 'net_pay', 'employer_pf', 'employer_esi',
'ctc', 'service_charge', 'sub_total', 'cgst', 'sgst', 'igst',
'cess_amount', 'total_cost',
];
// TOTAL row covers Gross and Emp Deductions through Grand Total only
$totalFields = [
'earned_gross', 'employee_pf', 'employee_esi', 'net_pay', 'employer_pf',
'employer_esi', 'ctc', 'service_charge', 'sub_total', 'cgst', 'sgst',
'igst', 'cess_amount', 'total_cost',
];
// CGST/SGST rates from the per-row slab ("9+9" => CGST 9, SGST 9); distinct values listed together
$trimRate = fn ($rate) => rtrim(rtrim(number_format((float) $rate, 2, '.', ''), '0'), '.');
$rateLabel = function ($rates) use ($trimRate) {
$list = $rates->filter(fn ($r) => $r !== null && $r !== '')->map($trimRate)->unique()->values();
return $list->isEmpty() ? '' : '
' . $list->implode('% / ') . '%';
};
$cgstLabel = $rateLabel($details->map(fn ($d) => explode('+', (string) $d->sgst_cgst_slab)[0] ?? null));
$sgstLabel = $rateLabel($details->map(fn ($d) => explode('+', (string) $d->sgst_cgst_slab)[1] ?? null));
@endphp
| Paysheet No: {{ $paysheet->paysheet_no ?: ($paysheet->invoice_number ?: '-') }} | Company: {{ $companyName }} | Month: {{ $monthLabel }} | Date: {{ $pdfDate ? \Carbon\Carbon::parse($pdfDate)->format('d-m-Y') : '-' }} | Total Employees: {{ $details->count() }} |
| SL No |
Name | Category | Paid Days |
BA | DA | HRA | Conv. | Med Allow |
Other Allow |
Incentive | OT | Gross | EPF Wages |
Emp Deductions | Net Pay | Emr Deductions | CTC | Service Charge |
Sub Total |
CGST{!! $cgstLabel !!} | SGST{!! $sgstLabel !!} | IGST | Cess | Grand Total |
||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| EPF 12% |
ESI 0.75% |
EPF 13% |
ESI 3.25% |
|||||||||||||||||||||||
| {{ $i + 1 }} | {{ $detail->employee_name ?: '-' }} | {{ $detail->category ?: '-' }} | @foreach($numericFields as $field){{ number_format((float) $detail->{$field}, 2) }} | @endforeach|||||||||||||||||||||||
| No employee details found | ||||||||||||||||||||||||||
| TOTAL | @foreach($numericFields as $field) | {{ in_array($field, $totalFields) ? number_format((float) $details->sum($field), 2) : '' }} | @endforeach||||||||||||||||||||||||