@php function fm($amount) { return rtrim(rtrim(number_format((float) $amount, 2, '.', ''), '0'), '.'); } $totalSalary = 0; $totalBonus = 0; $totalExtra = 0; $totalGrossPayable = 0; $totalPF = 0; $totalNextPayable = 0; $totalPaid = 0; foreach ($employees as $emp) { $salaryRow = $paidMap->get($emp->id); $baseSalary = (float) ($emp->computed_gross_salary ?? 0); if ($baseSalary <= 0) { $baseSalary = (float) ($emp->base_salary ?? 0); } if ($baseSalary <= 0) { $baseSalary = (float) ($emp->salary ?? 0); } if ($salaryRow) { $bonusAmount = (float) ($salaryRow->bonus_amount ?? 0); $extraAmount = (float) ($salaryRow->extra_amount ?? 0); $grossWithBonus = (float) ($salaryRow->salary_amount ?? ($baseSalary + $bonusAmount + $extraAmount)); $netPayable = (float) ($salaryRow->net_payable ?? $salaryRow->payment_amount ?? 0); $alreadyPaid = (float) ($salaryRow->payment_amount ?? 0); } else { $bonusAmount = 0; $extraAmount = 0; $grossWithBonus = $baseSalary; $pf = (float) ($emp->computed_pf_default ?? 0); $netPayable = max(0, $grossWithBonus - $pf); $alreadyPaid = 0; } $pfAmount = max(0, $grossWithBonus - $netPayable); $remaining = max(0, $netPayable - $alreadyPaid); $totalSalary += $baseSalary; $totalBonus += $bonusAmount; $totalExtra += $extraAmount; $totalGrossPayable += $grossWithBonus; $totalPF += $pfAmount; $totalNextPayable += $netPayable; $totalPaid += $alreadyPaid; } $totalDue = max(0, $totalNextPayable - $totalPaid); @endphp
Salary Summary ({{ \Carbon\Carbon::createFromFormat('Y-m', $month)->format('F Y') }})
Total Salary
{{ fm($totalSalary) }}
Total Bonus
{{ fm($totalBonus) }}
Total Extra
{{ fm($totalExtra) }}
Gross
{{ fm($totalGrossPayable) }}
Total PF
{{ fm($totalPF) }}
Next Payable
{{ fm($totalNextPayable) }}
Already Paid
{{ fm($totalPaid) }}
Remaining
{{ fm($totalDue) }}
Quick Tools
Bonus, extra amount, remarks and column controls
Show Columns:
@forelse($employees as $i => $emp) @php $salaryRow = $paidMap->get($emp->id); $isPaid = $salaryRow && $salaryRow->status === 'paid'; $isPartial = $salaryRow && $salaryRow->status !== 'paid' && (float)($salaryRow->payment_amount ?? 0) > 0; $baseSalary = (float) ($emp->computed_gross_salary ?? 0); if ($baseSalary <= 0) { $baseSalary = (float) ($emp->base_salary ?? 0); } if ($baseSalary <= 0) { $baseSalary = (float) ($emp->salary ?? 0); } $bonusType = $salaryRow ? (string)($salaryRow->bonus_type ?? 'percent') : 'percent'; $bonusValue = $salaryRow ? (float)($salaryRow->bonus_value ?? 0) : 0; $bonusAmount = $salaryRow ? (float)($salaryRow->bonus_amount ?? 0) : 0; $extraAmount = $salaryRow ? (float)($salaryRow->extra_amount ?? 0) : 0; if (!$salaryRow) { $bonusAmount = 0; $extraAmount = 0; $bonusType = 'fixed'; $bonusValue = 0; } if ($bonusType !== 'fixed') { $bonusType = 'fixed'; $bonusValue = $bonusAmount; } $grossWithBonus = $salaryRow ? (float)($salaryRow->salary_amount ?? ($baseSalary + $bonusAmount + $extraAmount)) : ($baseSalary + $bonusAmount + $extraAmount); $pfAmount = $salaryRow ? max(0, $grossWithBonus - (float)($salaryRow->net_payable ?? 0)) : (float) ($emp->computed_pf_default ?? 0); $nextPayable = $salaryRow ? (float)($salaryRow->net_payable ?? 0) : max(0, $grossWithBonus - $pfAmount); $alreadyPaid = $salaryRow ? (float)($salaryRow->payment_amount ?? 0) : 0; $remaining = max(0, $nextPayable - $alreadyPaid); @endphp @empty @endforelse
# Name Emp ID Base Salary Bonus Extra PF Next Pay Method Status Remarks Action
{{ $i + 1 }} {{ $emp->name }} {{ $emp->e_id ?? '--' }} {{ fm($baseSalary) }} @if($isPaid)
{{ fm($bonusAmount) }}
@else @if($isPartial)
Partial exists
@endif @endif
@if($isPaid)
{{ fm($extraAmount) }}
@else @endif
{{ fm($pfAmount) }} @if(!$isPaid) @endif
{{ fm($nextPayable) }}
@if($isPartial)
Paid: {{ fm($alreadyPaid) }}
Due: {{ fm($remaining) }}
@endif
@if($isPaid)
-
@else @if($isPartial)
Last paid {{ fm($alreadyPaid) }}
@endif @endif
@if($isPaid)
{{ $salaryRow->paymentMethod->name ?? '-' }}
@else @endif
@if($isPaid) Paid @elseif($isPartial) Partial @else Unpaid @endif @if($isPaid)
{{ $salaryRow->remarks ?: '-' }}
@else @endif
No active employees found.