@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.
{{-- TABS --}}
@foreach([
'ventas' => 'Ventas',
'productos' => 'Productos más vendidos',
'inventario' => 'Inventario valorizado',
'utilidades' => 'Utilidades'
] as $k => $label)
{{ $label }}
@endforeach
{{-- =========================================================
FILTROS
========================================================== --}}
@if($tipo !== 'inventario')
@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) }}
Métodos de pago
| Método |
Operaciones |
Total |
@forelse(($porMetodo ?? collect()) as $row)
|
{{ $row->metodo_pago }}
|
{{ $row->n }}
|
S/ {{ number_format($row->monto, 2) }}
|
@empty
|
No hay información.
|
@endforelse
@endif
{{-- =========================================================
PRODUCTOS
========================================================== --}}
@if($tipo === 'productos')
| Producto |
Unidades |
Ingresos |
@forelse(($topProductos ?? collect()) as $producto)
|
{{ $producto->nombre }}
|
{{ number_format($producto->unidades, 0) }}
|
S/ {{ number_format($producto->ingresos, 2) }}
|
@empty
|
No hay información.
|
@endforelse
@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) }}
| Producto |
Categoría |
Stock |
P. compra |
P. venta |
Valor venta |
@forelse(($invProductos ?? collect()) as $producto)
|
{{ $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
) }}
|
@empty
|
No hay productos.
|
@endforelse
@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) }}%
| Comprobante |
Fecha |
Cliente |
Cajero |
Pago |
Total |
Costo |
Utilidad |
Margen |
Acción |
@forelse(($utilidades ?? collect()) as $venta)
|
{{ $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
|
@empty
|
No hay ventas para los filtros seleccionados.
|
@endforelse
{{-- PRODUCTOS CON MAYOR UTILIDAD --}}
Productos con mayor utilidad
Se calcula usando el costo del lote cuando está disponible.
| Producto |
Unidades |
Venta neta |
Costo |
Utilidad |
Margen |
@forelse(($productosUtilidad ?? collect()) as $producto)
|
{{ $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) }}%
|
@empty
|
No hay información.
|
@endforelse
@endif
{{-- =============================================================
CHART.JS
============================================================== --}}
@endsection