@php $rateOfWageAliases = [ 'basic_salary', 'da', 'hra', 'special', ]; // Only components which actually exist in this unit $rateOfWageComponents = $payrollBasicComponents->filter(function ($component) use ($rateOfWageAliases) { return in_array($component->alias, $rateOfWageAliases); }); // Total Wage column should appear right after the last present wage // component, in priority order: special > hra > da > basic_salary. $totalWageAfterAlias = null; foreach (['special', 'hra', 'da', 'basic_salary'] as $alias) { if ($rateOfWageComponents->contains('alias', $alias)) { $totalWageAfterAlias = $alias; break; } } $hasTotalWage = $totalWageAfterAlias !== null; $totalColumns = 9 + // Employee Info (count($rateOfWageComponents) + 1) + // Rate of Wage + Rate Per Day 2 + // Total Paid Days + OT Hours (count($payrollBasicComponents) + ($hasTotalWage ? 2 : 1)) + // Earnings (count($payrollDeductionComponents) + 1) + // Deductions 1; // Net Payment @endphp {{-- Heading --}} {{-- Main Header --}} {{-- Sub Header --}} {{-- Rate of Wage --}} @foreach($rateOfWageComponents as $component) @endforeach {{-- Earnings --}} @foreach($payrollBasicComponents as $component) @if($hasTotalWage && $component->alias == $totalWageAfterAlias) @endif @endforeach {{-- Deductions --}} @foreach($payrollDeductionComponents as $component) @endforeach {{-- GRAND TOTAL VARIABLES --}} @php $grandTotalPaidDays = 0; $grandTotalOTHours = 0; $grandTotalWage = 0; $grandTotalEarning = 0; $grandTotalDeduction = 0; $grandTotalNetPayment = 0; /* * Individual earning component totals */ $earningTotals = []; foreach ($payrollBasicComponents as $component) { $earningTotals[$component->id] = 0; } /* * Individual deduction component totals */ $deductionTotals = []; foreach ($payrollDeductionComponents as $component) { $deductionTotals[$component->id] = 0; } @endphp {{-- EMPLOYEE ROWS --}} @foreach($employees as $key => $employee) @php $payrollEmployeeTempStructures = isset($employee->employeeCtcMaster->payrollEmployeeTempStructures) ? $employee->employeeCtcMaster->payrollEmployeeTempStructures ->groupBy('type_id') ->toArray() : []; $salarySlip = $employee->salarySlip; $slipLogs = $salarySlip ? $salarySlip->slipLogs->keyBy('type_id') : collect(); $totalEarning = 0; $totalDeduction = 0; $totalWage = 0; @endphp {{-- Employee Details --}} {{-- RATE OF WAGE --}} @php $totalDailyRate = 0; @endphp @foreach($payrollBasicComponents as $component) @if(in_array($component->alias, $rateOfWageAliases)) @php $log = $slipLogs->get($component->id); $monthlyRate = $log->actual_salary ?? 0; $dailyRate = $maxPayDays > 0 ? ($monthlyRate / $maxPayDays) : 0; $totalDailyRate += $dailyRate; @endphp @endif @endforeach {{-- Total Rate Per Day --}} {{-- PAID DAYS --}} @php $paidDays = $salarySlip->total_paid_days ?? 0; $otHours = $salarySlip->total_overtimes ?? 0; $grandTotalPaidDays += $paidDays; $grandTotalOTHours += $otHours; @endphp {{-- OT HOURS --}} {{-- EARNINGS --}} @php $totalEarning = 0; $totalWage = 0; $wageAliases = [ 'basic_salary', 'da', 'hra', 'special' ]; @endphp @foreach($payrollBasicComponents as $component) @php $log = $slipLogs->get($component->id); $amount = $log->calculate_salary ?? 0; /* * Add to component-wise grand total */ $earningTotals[$component->id] += $amount; /* * Calculate Total Wage */ if (in_array($component->alias, $wageAliases)) { $totalWage += $amount; } else { $totalEarning += $amount; } @endphp {{-- Component Amount --}} {{-- Total Wage after the last present wage component --}} @if($hasTotalWage && $component->alias == $totalWageAfterAlias) @endif @endforeach {{-- Employee Total Earning --}} @php $employeeTotalEarning = $totalWage + $totalEarning; $grandTotalWage += $totalWage; $grandTotalEarning += $employeeTotalEarning; @endphp {{-- DEDUCTIONS --}} @foreach($payrollDeductionComponents as $component) @php $log = $slipLogs->get($component->id); $amount = $log->calculate_salary ?? 0; /* * Employee deduction total */ $totalDeduction += $amount; /* * Component-wise grand total */ $deductionTotals[$component->id] += $amount; @endphp @endforeach {{-- Employee Total Deduction --}} {{-- NET PAYMENT --}} @php $employeeNetPayment = $employeeTotalEarning - $totalDeduction; $grandTotalDeduction += $totalDeduction; $grandTotalNetPayment += $employeeNetPayment; @endphp @endforeach {{-- GRAND TOTAL ROW --}} {{-- First 9 Employee Information Columns --}} {{-- RATE OF WAGE --}} @foreach($payrollBasicComponents as $component) @if(in_array($component->alias, $rateOfWageAliases)) {{-- Not summing daily rates --}} @endif @endforeach {{-- Total Rate Per Day --}} {{-- TOTAL PAID DAYS --}} {{-- TOTAL OT HOURS --}} {{-- EARNING COMPONENT TOTALS --}} @foreach($payrollBasicComponents as $component) {{-- Total Wage --}} @if($hasTotalWage && $component->alias == $totalWageAfterAlias) @endif @endforeach {{-- TOTAL EARNING --}} {{-- DEDUCTION COMPONENT TOTALS --}} @foreach($payrollDeductionComponents as $component) @endforeach {{-- TOTAL DEDUCTION --}} {{-- NET PAYMENT --}}
Register of Wage {{ $month }}-{{ $year }}
Form B
Wage Period-Monthly Rate of Wage Total Paid Days OT Hours Earning Deduction Net Payment
Sr.No. Emp. Code UAN No. ESIC No. Name of Employee Father's/Spouse Name Gender Skill Categories Department{{ $component->name }}Rate Per Day{{ $component->name }}Total WageTotal Earning{{ $component->name }}Total Deduction
{{ $key + 1 }} {{ $employee->employee_code }} {{ $employee->uan_number }} {{ $employee->esic_no }} {{ $employee->name }} {{ $employee->father_name }} {{ $employee->gender }} {{ optional($employee->category)->name }} {{ optional($employee->department)->name }} {{ number_format($dailyRate, 2) }} {{ number_format($totalDailyRate, 2) }} {{ number_format($paidDays, 2) }} {{ number_format($otHours, 2) }} {{ number_format($amount, 2) }} {{ number_format($totalWage, 2) }} {{ number_format($employeeTotalEarning, 2) }} {{ number_format($amount, 2) }} {{ number_format($totalDeduction, 2) }} {{ number_format($employeeNetPayment, 2) }}
TOTAL - - {{ number_format($grandTotalPaidDays, 2) }} {{ number_format($grandTotalOTHours, 2) }} {{ number_format($earningTotals[$component->id], 2) }} {{ number_format($grandTotalWage, 2) }} {{ number_format($grandTotalEarning, 2) }} {{ number_format($deductionTotals[$component->id], 2) }} {{ number_format($grandTotalDeduction, 2) }} {{ number_format($grandTotalNetPayment, 2) }}