@php use App\Models\Payroll; use App\Models\EmployeeHead; use App\Models\SalaryPayment; // Resolve month number (01–12) from key like "july" $monthNum = str_pad((string)(array_search(strtolower($monthKey), array_map('strtolower', months())) + 1), 2, '0', STR_PAD_LEFT); // Often payments.month is stored as "YYYY-MM"; support both patterns: $monthToken = $year . '-' . $monthNum; // Helper to compute additions/deductions from payroll rows for this FY + month function computeMonthTotals($employeeId, $financial_year, $monthKey) { $rows = Payroll::where('employee_id', $employeeId) ->where('financial_year', $financial_year) ->get(); $add = 0.0; $ded = 0.0; foreach ($rows as $row) { $data = is_array($row->data_column) ? $row->data_column : (json_decode($row->data_column, true) ?: []); $amount = (float) ($data[$monthKey] ?? 0); // decide operation_type from EmployeeHead $op = optional(EmployeeHead::find($row->head_id))->operation_type ?? 'pay'; if ($op === 'pay') $add += $amount; else $ded += $amount; } return [$add, $ded]; } @endphp
| SL | Employee ID | Employee Name | Department | Designation | Start Working Date | Last Working Day | Status | Gross | Addition ({{ ucfirst($monthKey) }}) | Deduction ({{ ucfirst($monthKey) }}) | Net Salary | Paid | Balance | @lang('Created By') | @lang('Created Date') | @lang('Modify By') | @lang('Modify Date') |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ ($items->currentPage() - 1) * $items->perPage() + $idx + 1 }} | {{ $item->employee_id }} | {{ $item->name }} | {{ $item->department }} | {{ $item->designation }} | {{ $item->joining_date }} | {{ $item->lastworkingdate }} | {{ $item->status }} | {{ number_format($item->gross_salary, 2) }} | {{ $addition ? number_format($addition, 2) : '-' }} | {{ $deduction ? number_format($deduction, 2) : '-' }} | {{ $net ? number_format($net, 2) : '0.00' }} | {{ $paid ? number_format($paid, 2) : '-' }} | {{ number_format($balance, 2) }} | {{ $item->created_user ?? '-' }} | {{ $item->created_date ?? '-' }} | {{ $item->updated_user ?? '-' }} | {{ $item->updated_date ?? '-' }} |
| No data | |||||||||||||||||