Cuentas de Pedidos (Entregados + Adelantos Pendientes)

{{-- Filtros --}}
{{-- Botones --}}
{{-- Tabla Detalle --}} @if ($pedidos && count($pedidos) > 0)
@foreach ($pedidos as $pedido) @php if ($pedido->estado->nombre === 'Entregado') { $subtotal = $pedido->detallePedidos->sum(fn($d) => $d->precio * $d->cantidad); $total = $subtotal - ($pedido->descuento ?? 0); } else { $subtotal = 0; $total = $pedido->adelanto; } @endphp @endforeach
Cliente Fecha Pedido @if ($sortField === 'created_at') {{ $sortDirection === 'asc' ? '↑' : '↓' }} @endif Fecha Entrega @if ($sortField === 'fecha_entrega') {{ $sortDirection === 'asc' ? '↑' : '↓' }} @endif Descuento Detalles Total Pedido
{{ $pedido->cliente }} {{ \Carbon\Carbon::parse($pedido->created_at)->format('d/m/Y H:i') }} {{ \Carbon\Carbon::parse($pedido->fecha_entrega)->format('d/m/Y') }} {{ number_format($pedido->descuento ?? 0, 2) }} @if ($pedido->estado->nombre === 'Entregado')
    @foreach ($pedido->detallePedidos as $detalle)
  • {{ $detalle->producto->nombre ?? 'Producto' }} - Cant: {{ $detalle->cantidad }} x {{ number_format($detalle->precio, 2) }} = {{ number_format($detalle->cantidad * $detalle->precio, 2) }}
  • @endforeach
@else Adelanto: {{ number_format($pedido->adelanto, 2) }} @endif
{{ number_format($total, 2) }}
TOTAL GENERAL (Incl. adelantos Pendientes): {{ number_format($totalGeneral, 2) }}
@else

No hay pedidos para los filtros seleccionados.

@endif