@extends('layouts.app') @section('titulo', 'Reportes') @section('contenido') @php $tipo = $tipo ?? 'ventas'; $desde = $desde ?? now()->startOfMonth()->toDateString(); $hasta = $hasta ?? now()->toDateString(); @endphp
{{-- HEADER --}}

Reportes

Consulta ventas, productos, inventario y utilidad.

⬇ Exportar Excel
{{-- TABS --}}
@foreach([ 'ventas' => 'Ventas', 'productos' => 'Productos más vendidos', 'inventario' => 'Inventario valorizado', 'utilidades' => 'Utilidades' ] as $k => $label) {{ $label }} @endforeach
{{-- ========================================================= FILTROS ========================================================== --}} @if($tipo !== 'inventario')
{{-- DESDE --}}
{{-- HASTA --}}
@if($tipo === 'utilidades') {{-- VENDEDOR --}}
{{-- ORDEN --}}
@endif
@endif {{-- ========================================================= VENTAS ========================================================== --}} @if($tipo === 'ventas')
Ventas
S/ {{ number_format($kpis['total'] ?? 0, 2) }}
IGV
S/ {{ number_format($kpis['igv'] ?? 0, 2) }}
Operaciones
{{ number_format($kpis['num'] ?? 0) }}
Ticket promedio
S/ {{ number_format($kpis['ticket'] ?? 0, 2) }}

Ventas por día

Métodos de pago

@forelse(($porMetodo ?? collect()) as $row) @empty @endforelse
Método Operaciones Total
{{ $row->metodo_pago }} {{ $row->n }} S/ {{ number_format($row->monto, 2) }}
No hay información.
@endif {{-- ========================================================= PRODUCTOS ========================================================== --}} @if($tipo === 'productos')

Productos más vendidos

@forelse(($topProductos ?? collect()) as $producto) @empty @endforelse
Producto Unidades Ingresos
{{ $producto->nombre }} {{ number_format($producto->unidades, 0) }} S/ {{ number_format($producto->ingresos, 2) }}
No hay información.
@endif {{-- ========================================================= INVENTARIO ========================================================== --}} @if($tipo === 'inventario')
Valor a costo
S/ {{ number_format($invKpis['costo'] ?? 0, 2) }}
Valor a venta
S/ {{ number_format($invKpis['venta'] ?? 0, 2) }}
Unidades
{{ number_format($invKpis['unidades'] ?? 0) }}
@forelse(($invProductos ?? collect()) as $producto) @empty @endforelse
Producto Categoría Stock P. compra P. venta Valor venta
{{ $producto->nombre }} {{ $producto->categoria?->nombre ?? '—' }} {{ number_format($producto->stock, 0) }} S/ {{ number_format($producto->precio_compra, 2) }} S/ {{ number_format($producto->precio_venta, 2) }} S/ {{ number_format( $producto->stock * $producto->precio_venta, 2 ) }}
No hay productos.
@endif {{-- ========================================================= UTILIDADES ========================================================== --}} @if($tipo === 'utilidades') {{-- KPIs --}}
Ventas
S/ {{ number_format($utilidadKpis['ventas'] ?? 0, 2) }}
Costo
S/ {{ number_format($utilidadKpis['costo'] ?? 0, 2) }}
Utilidad
S/ {{ number_format($utilidadKpis['utilidad'] ?? 0, 2) }}
Margen
{{ number_format($utilidadKpis['margen'] ?? 0, 2) }}%
Unidades
{{ number_format($utilidadKpis['unidades'] ?? 0, 0) }}
{{-- INFORMACIÓN DEL IGV --}}
Cálculo de utilidad
La venta se calcula sin IGV antes de compararla contra el costo.
IGV aplicado: {{ number_format($igvUtilidad ?? 0, 2) }}%
{{-- GRÁFICO --}}

Utilidad por venta

Primeras 10 operaciones según el orden seleccionado.

{{-- TABLA DE VENTAS --}}

Detalle de utilidad por venta

{{ $utilidadKpis['operaciones'] ?? 0 }} operaciones encontradas.

Margen: {{ number_format($utilidadKpis['margen'] ?? 0, 2) }}%
@forelse(($utilidades ?? collect()) as $venta) @empty @endforelse
Comprobante Fecha Cliente Cajero Pago Total Costo Utilidad Margen Acción
{{ $venta->numero_comprobante }} {{ $venta->created_at->format('d/m/Y H:i') }} {{ $venta->cliente }} {{ $venta->cajero ?: '—' }} {{ $venta->metodo_pago }} S/ {{ number_format($venta->total, 2) }} S/ {{ number_format($venta->costo, 2) }} S/ {{ number_format($venta->utilidad, 2) }} {{ number_format($venta->margen, 2) }}% 🖨 Ticket
No hay ventas para los filtros seleccionados.
{{-- PRODUCTOS CON MAYOR UTILIDAD --}}

Productos con mayor utilidad

Se calcula usando el costo del lote cuando está disponible.

@forelse(($productosUtilidad ?? collect()) as $producto) @empty @endforelse
Producto Unidades Venta neta Costo Utilidad Margen
{{ $producto->nombre }} {{ number_format($producto->unidades, 0) }} S/ {{ number_format($producto->venta, 2) }} S/ {{ number_format($producto->costo, 2) }} S/ {{ number_format($producto->utilidad, 2) }} {{ number_format($producto->margen, 2) }}%
No hay información.
@endif
{{-- ============================================================= CHART.JS ============================================================== --}} @endsection