@extends('layouts.app') @section('title', 'Historial de Ventas') @section('content')

Historial de Ventas

@if($fecha_inicio || $fecha_fin)

Filtros: @if($fecha_inicio) Desde: {{ $fecha_inicio }} @endif @if($fecha_fin) Hasta: {{ $fecha_fin }} @endif

@endif @forelse($ventas as $venta)
ID Venta: {{ $venta->id }}    Vendedor: {{ $venta->user->name ?? '-' }}    Fecha: {{ $venta->created_at->format('d/m/Y H:i') }}    Total: ${{ number_format($venta->total, 2) }}
@foreach($venta->detalles as $detalle) @endforeach
Producto Cantidad Precio Unitario Subtotal Descuento Total LĂ­nea
{{ $detalle->producto->nombre ?? 'Producto eliminado' }} {{ $detalle->cantidad }} ${{ number_format($detalle->precio, 2) }} ${{ number_format($detalle->subtotal, 2) }} @if($detalle->descuento) ${{ number_format($detalle->descuento, 2) }} @else 0 @endif @php $totalLinea = $detalle->subtotal - ($detalle->descuento ?? 0); @endphp ${{ number_format($totalLinea, 2) }}
@if($venta->descuentos) @php $desc = json_decode($venta->descuentos, true); @endphp

Descuento general: @if(isset($desc['general'])) {{ $desc['general']['monto'] }} ({{ $desc['general']['tipo'] }}) @else 0 @endif

@endif @empty
No hay ventas registradas.
@endforelse

Generado el {{ now()->format('d/m/Y H:i') }}

@endsection