@isset($exportar) @php echo pack("CCC",0xef,0xbb,0xbf); // BOM para UTF-8 en Excel header("Cache-Control: maxage=1"); header("Pragma: public"); header('Content-type: application/vnd.ms-excel'); header("Content-Disposition: attachment; filename=Balance_Prueba.xls"); header("Pragma: no-cache"); header("Expires: 0"); @endphp @endisset @isset($Balance) @php $fmt = function($val) { $rounded = round($val, 2); if (request()->has('exportar')) { return sprintf("%.2f", $rounded); } return number_format($rounded, 0, ',', '.'); }; $numStyle = request()->has('exportar') ? 'style="mso-number-format:\'\#\,\#\#0\.00\';"' : ''; $decStyle = 'style="mso-number-format:\'0\.00\';"'; // Para la columna C $tipoBalance = $tipoBalance ?? 'prueba'; $titulo = ($tipoBalance == 'general') ? 'ESTADO DE SITUACIÓN FINANCIERA (BALANCE GENERAL)' : 'BALANCE DE PRUEBA'; @endphp

{{ $titulo }}

Periodo: {{ $fi }} al {{ $ff }}

@if($tipoBalance == 'prueba') @else @endif @foreach ($Balance as $b) @php $rowClass = ''; $indent = ''; if ($b->t == 'Clase') { $rowClass = 'table-primary fw-bold'; $indent = ''; } elseif ($b->t == 'Grupo') { $rowClass = 'table-info fw-bold'; $indent = '   '; } elseif ($b->t == 'Cuenta') { $rowClass = 'table-light fw-bold text-primary'; $indent = '      '; } elseif ($b->t == 'Subcuenta') { $rowClass = 'fw-semibold text-secondary'; $indent = '         '; } else { $indent = '            '; } @endphp @if($tipoBalance == 'prueba') @else @php // Inversión de Naturaleza para Pasivo y Patrimonio $clase = substr($b->cuentaNum, 0, 1); $valorFinal = $b->saldo_final; if (in_array($clase, ['2', '3'])) { $valorFinal = -$b->saldo_final; } @endphp @endif @endforeach @if($tipoBalance == 'prueba') @php $clases = $Balance->where('t', 'Clase'); @endphp @else @php $sf_total = $Balance->where('t', 'Clase')->sum('sf_c'); @endphp @endif
T C CUENTA NOMBRE CUENTASaldo Inicial Débitos Créditos Saldo FinalVALOR
{{ $b->t }} {{ $b->c }} @if($b->t == 'Auxiliar')      @endif {{ $b->cuentaNum }} {!! $indent !!} {{ $b->NombreCuenta }} {{ $fmt($b->saldo_inicial) }} {{ $fmt($b->debito) }} {{ $fmt(abs($b->credito)) }} {{ $fmt($b->saldo_final) }} {{ $fmt($valorFinal) }}
@if($tipoBalance == 'prueba') TOTAL SUMA CLASES 1-9 (NETO) @else DIFERENCIA (ACTIVO - PASIVO - PATRIMONIO) @endif {{ $fmt($clases->sum('si_c') / 100) }} {{ $fmt($clases->sum('deb_c') / 100) }} {{ $fmt($clases->sum('cre_c') / 100) }} {{ $fmt($clases->sum('sf_c') / 100) }} {{ $fmt($sf_total / 100) }}
@endisset