@php $razonSocial = optional($company)->company_name ?: optional($company)->name ?: 'EMPRESA'; $range = $planillaData['range'] ?? null; $rangoLabel = ''; if ($range && !empty($range['label'])) { $rangoLabel = $range['label']; } // Helper para formato dinero $money = fn($v) => number_format((float) $v, 2, '.', ','); // Construir listado de tipos de ingreso/descuento (columnas dinámicas) $incomeTypes = $planillaData['income_types'] ?? []; $deductionTypes = $planillaData['deduction_types'] ?? []; @endphp
@if (!empty($logoPath)) logo @endif
{{ strtoupper($razonSocial) }}
PLANILLA DE SUELDOS {{ $rangoLabel ? '— ' . $rangoLabel : '' }}
Personal Permanente
@php $grandTotals = [ 'salario_devengado' => 0, 'h_extra' => 0, 'isss' => 0, 'afp' => 0, 'renta' => 0, 'total_ingresos' => 0, 'total_descs' => 0, 'liquido_recibir' => 0, 'ingresos_by_type' => array_fill_keys($incomeTypes, 0), 'descuentos_by_type' => array_fill_keys($deductionTypes, 0), ]; @endphp @foreach ($planillaData['departments'] ?? [] as $deptName => $employees)
{{ strtoupper($deptName) }}
@php $deptTotals = [ 'salario_devengado' => 0, 'h_extra' => 0, 'isss' => 0, 'afp' => 0, 'renta' => 0, 'total_ingresos' => 0, 'total_descs' => 0, 'liquido_recibir' => 0, 'ingresos_by_type' => array_fill_keys($incomeTypes, 0), 'descuentos_by_type' => array_fill_keys($deductionTypes, 0), ]; @endphp @foreach ($incomeTypes as $t) @endforeach @foreach ($deductionTypes as $t) @endforeach @foreach ($employees as $emp) @foreach ($incomeTypes as $t) @endforeach @foreach ($deductionTypes as $t) @endforeach @php $deptTotals['salario_devengado'] += $emp['salario_devengado']; $deptTotals['h_extra'] += $emp['h_extra']; $deptTotals['isss'] += $emp['isss']; $deptTotals['afp'] += $emp['afp']; $deptTotals['renta'] += $emp['renta']; $deptTotals['total_ingresos'] += $emp['total_ingresos']; $deptTotals['total_descs'] += $emp['total_descs']; $deptTotals['liquido_recibir'] += $emp['liquido_recibir']; foreach ($incomeTypes as $t) { $deptTotals['ingresos_by_type'][$t] += $emp['ingresos_by_type'][$t] ?? 0; } foreach ($deductionTypes as $t) { $deptTotals['descuentos_by_type'][$t] += $emp['descuentos_by_type'][$t] ?? 0; } @endphp @endforeach @foreach ($incomeTypes as $t) @endforeach @foreach ($deductionTypes as $t) @endforeach
Emp. Empleado Salario Días Trab. Salario Devengado H. Extra{{ $t }}Total Ingresos ISSS AFP Renta{{ $t }}Total Descs. Líquido a Recibir
{{ $emp['emp_code'] }} {{ $emp['nombre'] }} {{ $money($emp['salario_base']) }} {{ $emp['dias_trabajados'] }} {{ $money($emp['salario_devengado']) }} {{ $money($emp['h_extra']) }}{{ $money($emp['ingresos_by_type'][$t] ?? 0) }}{{ $money($emp['total_ingresos']) }} {{ $money($emp['isss']) }} {{ $money($emp['afp']) }} {{ $money($emp['renta']) }}{{ $money($emp['descuentos_by_type'][$t] ?? 0) }}{{ $money($emp['total_descs']) }} {{ $money($emp['liquido_recibir']) }}
SUBTOTAL {{ strtoupper($deptName) }} {{ $money($deptTotals['salario_devengado']) }} {{ $money($deptTotals['h_extra']) }}{{ $money($deptTotals['ingresos_by_type'][$t]) }}{{ $money($deptTotals['total_ingresos']) }} {{ $money($deptTotals['isss']) }} {{ $money($deptTotals['afp']) }} {{ $money($deptTotals['renta']) }}{{ $money($deptTotals['descuentos_by_type'][$t]) }}{{ $money($deptTotals['total_descs']) }} {{ $money($deptTotals['liquido_recibir']) }}
@php // acumular grandTotals $grandTotals['salario_devengado'] += $deptTotals['salario_devengado']; $grandTotals['h_extra'] += $deptTotals['h_extra']; $grandTotals['isss'] += $deptTotals['isss']; $grandTotals['afp'] += $deptTotals['afp']; $grandTotals['renta'] += $deptTotals['renta']; $grandTotals['total_ingresos'] += $deptTotals['total_ingresos']; $grandTotals['total_descs'] += $deptTotals['total_descs']; $grandTotals['liquido_recibir'] += $deptTotals['liquido_recibir']; foreach ($incomeTypes as $t) { $grandTotals['ingresos_by_type'][$t] += $deptTotals['ingresos_by_type'][$t]; } foreach ($deductionTypes as $t) { $grandTotals['descuentos_by_type'][$t] += $deptTotals['descuentos_by_type'][$t]; } @endphp @endforeach
TOTAL GENERAL Total Devengado: ${{ $money($grandTotals['salario_devengado']) }} Total Ingresos: ${{ $money($grandTotals['total_ingresos']) }} Total Descs.: ${{ $money($grandTotals['total_descs']) }} Líquido a Recibir: ${{ $money($grandTotals['liquido_recibir']) }}