Staff Payment History - {{ $staff->name }} ({{ $staff->user_id }})

@if ($paidLeaveDays > 0)

Paid Leave Applied: {{ $paidLeaveDays }} day(s) — ₹ {{ number_format($paidLeaveAmount, 2) }} added to salary

@endif @php $totalSalary = 0; $totalAdvance = 0; @endphp @foreach ($rows as $i => $row) @php $salary = $row->calculated_salary; if ($salaryHistory) { switch ($row->duty_type) { case 'full_day': $salary = $salaryHistory->salary; break; case 'half_day': $salary = $salaryHistory->salary / 2; break; case 'one_half_day': $salary = $salaryHistory->salary * 1.5; break; case 'double_duty': $salary = $salaryHistory->salary * 2; break; case 'hour_based': if (!empty($row->attendance_checkin) && !empty($row->attendance_checkout)) { $ci = \Carbon\Carbon::parse($row->attendance_checkin); $co = \Carbon\Carbon::parse($row->attendance_checkout); if ($co->lessThan($ci)) $co->addDay(); $salary = round(($salaryHistory->salary / 10) * ($ci->diffInMinutes($co) / 60), 2); } else { $salary = 0; } break; } } $advances = \App\Models\AdvanceSalary::where('staff_id', $row->staff_id) ->whereDate('date', $row->attendance_date) ->pluck('amount'); $advanceSum = $advances->sum(); $advanceStr = $advances->isEmpty() ? '-' : $advances->map(fn($a) => number_format($a, 2))->implode(' + '); $totalSalary += $salary; $totalAdvance += $advanceSum; @endphp @endforeach @if ($paidLeaveDays > 0) @endif
S.No Date Attendance Duty Type Calculated Salary Advance Received
{{ $i + 1 }} {{ \Carbon\Carbon::parse($row->attendance_date)->format('d/m/Y') }} {{ ucfirst($row->attendance_type ?? '-') }} {{ ucfirst($row->duty_type ?? '-') }} ₹ {{ number_format($salary, 2) }} {{ $advanceStr }}
Total ₹ {{ number_format($totalSalary, 2) }} ₹ {{ number_format($totalAdvance, 2) }}
+ Paid Leave ({{ $paidLeaveDays }} day(s)): ₹ {{ number_format($paidLeaveAmount, 2) }}
Grand Total (Salary + Paid Leave − Advance) ₹ {{ number_format($totalSalary + $paidLeaveAmount - $totalAdvance, 2) }}