Estado de resultados
@php
$ventasNetas = floatval($data['ventas_netas'] ?? 0);
$pct = fn($v) => $ventasNetas > 0 ? number_format(($v / $ventasNetas) * 100, 1) . '%' : '-';
@endphp
| Ventas brutas |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($data['ventas_brutas'] ?? 0) }} |
— |
| Menos: Devoluciones |
({{ \App\Helpers\FormatoMonedaHelper::formatCurrency($data['devoluciones'] ?? 0) }}) |
— |
| Ventas netas |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($data['ventas_netas'] ?? 0) }} |
100% |
| Menos: Costo de ventas |
({{ \App\Helpers\FormatoMonedaHelper::formatCurrency($data['costo_ventas'] ?? 0) }}) |
{{ $pct($data['costo_ventas'] ?? 0) }} |
| Margen operacional |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($data['margen_operacional'] ?? 0) }} |
{{ $pct($data['margen_operacional'] ?? 0) }} |
| Menos: Total gastos |
({{ \App\Helpers\FormatoMonedaHelper::formatCurrency($data['total_gastos'] ?? 0) }}) |
{{ $pct($data['total_gastos'] ?? 0) }} |
| EBITDA |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($data['ebitda'] ?? 0) }} |
{{ $pct($data['ebitda'] ?? 0) }} |
| Menos: Impuesto a la renta ({{ $data['porcentaje_impuesto'] ?? 25 }}%) |
({{ \App\Helpers\FormatoMonedaHelper::formatCurrency($data['impuesto_renta'] ?? 0) }}) |
{{ $pct($data['impuesto_renta'] ?? 0) }} |
| UTILIDAD NETA |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($data['utilidad_neta'] ?? 0) }} |
{{ $pct($data['utilidad_neta'] ?? 0) }} |
@if(!empty($gastos) && count($gastos) > 0)
Gastos registrados
| Fecha |
Categoría |
Monto |
Detalle |
@foreach($gastos as $g)
| {{ \Carbon\Carbon::parse($g['fecha_gasto'])->format('d/m/Y') }} |
{{ $g['categoria_label'] ?? $g['categoria_gasto'] }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($g['monto_gasto'] ?? 0) }} |
{{ \Illuminate\Support\Str::limit($g['detalle_gasto'] ?? '', 60) }} |
@endforeach
@endif
@if(!empty($meses) && count($meses) > 0)
Resumen mensual
| Mes |
Ventas |
Costo |
Margen Op. |
Gastos |
EBITDA |
Utilidad |
@foreach($meses as $m)
| {{ $m['etiqueta'] ?? $m['mes'] ?? '-' }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['ventas_netas'] ?? 0) }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['costo_ventas'] ?? 0) }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['margen_operacional'] ?? 0) }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['total_gastos'] ?? 0) }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['ebitda'] ?? 0) }} |
{{ \App\Helpers\FormatoMonedaHelper::formatCurrencyWithSymbol($m['utilidad_neta'] ?? 0) }} |
@endforeach
@endif
@if(!empty($meses) && count($meses) >= 2)
@php
$nM = count($meses);
$lblPdf = function($etq) use ($nM) {
$m = preg_match('/^([a-záéíóúñ]{3})/i', $etq ?? '', $mx) ? $mx[1] : '';
$y = preg_match('/\d{4}/', $etq ?? '', $yx) ? substr($yx[0], -2) : '';
return $nM > 10 ? strtoupper($m[0] ?? '') . $y : strtolower($m) . ($y ? "'" . $y : '');
};
@endphp
Evolución de utilidad
@php
$utilidades = array_column($meses, 'utilidad_neta');
$maxU = max(array_map('abs', array_merge($utilidades, [1])));
@endphp
@foreach($meses as $m)
@php
$barH = $maxU > 0 ? max(4, (int)((abs($m['utilidad_neta'] ?? 0) / $maxU) * 42)) : 4;
$barColor = ($m['utilidad_neta'] ?? 0) >= 0 ? '#16a34a' : '#dc2626';
@endphp
|
{{ $lblPdf($m['etiqueta'] ?? '') }}
|
@endforeach
Ventas vs Gastos vs Utilidad
@php
$ventasArr = array_column($meses, 'ventas_netas');
$gastosArr = array_column($meses, 'total_gastos');
$maxV = max(array_merge($ventasArr, $gastosArr, array_map('abs', $utilidades), [1]));
@endphp
@foreach($meses as $m)
@php
$scale = $maxV > 0 ? 36 / $maxV : 0;
$hv = max(2, (int)(($m['ventas_netas'] ?? 0) * $scale));
$hg = max(2, (int)(($m['total_gastos'] ?? 0) * $scale));
$hu = max(2, (int)(abs($m['utilidad_neta'] ?? 0) * $scale));
@endphp
|
{{ $lblPdf($m['etiqueta'] ?? '') }}
|
@endforeach
■ Ventas ■ Gastos ■ Utilidad
Evolución de ventas
@php $maxVn = max(array_column($meses, 'ventas_netas') ?: [1]); @endphp
@foreach($meses as $m)
@php
$barV = $maxVn > 0 ? max(4, (int)(($m['ventas_netas'] ?? 0) / $maxVn * 42)) : 4;
@endphp
|
{{ $lblPdf($m['etiqueta'] ?? '') }}
|
@endforeach
Evolución de gastos
@php $maxTg = max(array_column($meses, 'total_gastos') ?: [1]); @endphp
@foreach($meses as $m)
@php
$barG = $maxTg > 0 ? max(4, (int)(($m['total_gastos'] ?? 0) / $maxTg * 42)) : 4;
@endphp
|
{{ $lblPdf($m['etiqueta'] ?? '') }}
|
@endforeach
@endif