@extends('layouts.app') @section('title', 'Dashboard de Costos') @section('page-title', 'Costos Operativos') @section('breadcrumb') @endsection @section('content') {{-- ═══ FILTRO ═══ --}}
{{-- ═══ KPIs RESUMEN ═══ --}}

S/ {{ number_format($totalCostos, 0) }}

Costo Total

S/ {{ number_format($totalVentas, 0) }}

Ventas del Mes

S/ {{ number_format(abs($resultado), 0) }}

{{ $resultado >= 0 ? 'Resultado (+)' : 'Pérdida (-)' }}

{{ number_format($margenGlobal, 1) }}%

Margen Neto

{{ $numOPs }}

OPs del Mes

S/ {{ number_format($totalGastosFijos, 0) }}

Gastos Fijos

{{-- ═══ DESGLOSE DE COSTOS ═══ --}}
Desglose de Costos del Mes
@php $filas = [ ['Materia Prima', $totalMP, 'text-primary', 'fas fa-apple-alt'], ['Insumos Químicos', $totalInsumos, 'text-info', 'fas fa-flask'], ['Envases / Empaques', $totalEnvases, 'text-secondary','fas fa-box'], ['Mano de Obra Directa', $totalMOD, 'text-success', 'fas fa-hard-hat'], ['Mano de Obra Indirecta', $totalMOI, 'text-warning', 'fas fa-user-tie'], ]; $catLabels = \App\Models\GastoOperativo::$CATEGORIAS; @endphp @foreach($filas as [$label, $monto, $color, $icon]) @endforeach @foreach($gastosPorCategoria as $cat => $monto) @endforeach
ConceptoMonto%
{{ $label }} S/ {{ number_format($monto, 2) }} {{ $totalCostos > 0 ? number_format(($monto/$totalCostos)*100, 1).'%' : '—' }}
{{ $catLabels[$cat]['label'] ?? $cat }} S/ {{ number_format($monto, 2) }} {{ $totalCostos > 0 ? number_format(($monto/$totalCostos)*100, 1).'%' : '—' }}
TOTAL COSTOS S/ {{ number_format($totalCostos, 2) }} 100%
{{-- Gastos Fijos registrados --}}
Gastos Operativos Registrados
Ver todos
@if($totalGastosFijos == 0)
No hay gastos registrados para este período. Registrar ahora
@else @foreach($gastosPorCategoria as $cat => $monto) @endforeach
{{ \App\Models\GastoOperativo::$CATEGORIAS[$cat]['label'] ?? $cat }} S/ {{ number_format($monto, 2) }}
@endif
{{-- ═══ COSTO POR OP ═══ --}}
Rentabilidad por Orden de Producción
@if($resumenOPs->isEmpty())
No hay órdenes de producción en este período.
@else
@foreach($resumenOPs as $r) @php $pct = $r['margen_pct']; $cls = is_null($pct) ? 'secondary' : ($pct >= 20 ? 'success' : ($pct >= 0 ? 'warning' : 'danger')); @endphp {{-- Detalle costos expandible --}} @endforeach
OP C. Directo C. Indirecto Total Costo Venta Margen %
{{ $r['op']->numero }}
{{ $r['op']->tipo_produccion }}
S/ {{ number_format($r['costo_directo'], 2) }} S/ {{ number_format($r['costo_moi'], 2) }} S/ {{ number_format($r['costo_total'], 2) }} {{ $r['precio_venta'] > 0 ? 'S/ '.number_format($r['precio_venta'], 2) : '—' }} {{ $r['precio_venta'] > 0 ? 'S/ '.number_format($r['margen'], 2) : '—' }} @if(!is_null($pct)) {{ number_format($pct, 1) }}% @else @endif
MP: S/ {{ number_format($r['costo_mp'],2) }} | Ins: S/ {{ number_format($r['costo_insumos'],2) }} | Env: S/ {{ number_format($r['costo_envases'],2) }} MOD: S/ {{ number_format($r['costo_mod'],2) }} (prorateado {{ $numOPs }} OP{{ $numOPs>1?'s':'' }})
TOTAL MES S/ {{ number_format($totalCostos, 2) }} S/ {{ number_format($totalVentas, 2) }} S/ {{ number_format($resultado, 2) }} {{ number_format($margenGlobal, 1) }}%
@endif
{{-- Despachos del mes --}}
Despachos de Materiales a Producción
Ver todos
@if($despachosMes->isEmpty())
Sin despachos en este período.
@else @foreach($despachosMes as $d) @endforeach
OPFechaEstadoCosto
{{ $d->numero }} {{ $d->ordenProduccion?->numero ?? '—' }} {{ $d->fecha->format('d/m') }} {{ ucfirst($d->estado) }} S/ {{ number_format($d->costo_total, 2) }}
@endif
@endsection