@include('pdf.partials.styles-unified')

REPORTE DE CAJAS | {{ $empresa->name }}

Período: {{ $fechaInicio }} - {{ $fechaFin }}

Total de cajas: {{ $cajas->count() }}

Cajas cerradas: {{ $totales['cajas_cerradas'] }} | Cajas abiertas: {{ $totales['cajas_abiertas'] }}

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

@forelse($cajas as $caja) @empty @endforelse
ID Usuario Fecha Apertura Fecha Cierre Monto Apertura Ingresos Egresos Pagos Calculado Monto Cierre Dif. Estado
#{{ $caja->id }} {{ $caja->usuario->name ?? 'N/A' }} {{ $caja->fecha_apertura ? \Carbon\Carbon::parse($caja->fecha_apertura)->format('d/m/Y H:i') : 'N/A' }} @if($caja->fecha_cierre) {{ \Carbon\Carbon::parse($caja->fecha_cierre)->format('d/m/Y H:i') }} @else Sin cerrar @endif S/ {{ number_format($caja->monto_apertura, 2) }} S/ {{ number_format($caja->total_ingresos, 2) }} S/ {{ number_format($caja->total_egresos, 2) }} S/ {{ number_format($caja->total_pagos, 2) }} S/ {{ number_format($caja->monto_calculado, 2) }} @if($caja->monto_cierre) S/ {{ number_format($caja->monto_cierre, 2) }} @else - @endif @if($caja->diferencia !== null) @if($caja->diferencia == 0) S/ 0.00 @elseif($caja->diferencia > 0) +S/ {{ number_format($caja->diferencia, 2) }} @else S/ {{ number_format($caja->diferencia, 2) }} @endif @else - @endif @if($caja->estado_caja == 1) Abierta @else Cerrada @endif
No se encontraron cajas
TOTALES: S/ {{ number_format($totales['total_aperturas'], 2) }} S/ {{ number_format($totales['total_ingresos'], 2) }} S/ {{ number_format($totales['total_egresos'], 2) }} S/ {{ number_format($totales['total_pagos'], 2) }} S/ {{ number_format($totales['total_calculado'], 2) }} S/ {{ number_format($totales['total_cierres'], 2) }}
@if(isset($detallePagosPorCaja) && count($detallePagosPorCaja) > 0) @foreach($cajas as $caja) @if(isset($detallePagosPorCaja[$caja->id]) && (is_array($detallePagosPorCaja[$caja->id]) ? count($detallePagosPorCaja[$caja->id]) : $detallePagosPorCaja[$caja->id]->count()) > 0) @php $reports = $detallePagosPorCaja[$caja->id]; @endphp

RESUMEN DE VENTAS - CAJA #{{ $caja->id }} ({{ $caja->usuario->name ?? 'N/A' }})

Fecha Apertura: {{ $caja->fecha_apertura ? \Carbon\Carbon::parse($caja->fecha_apertura)->format('d/m/Y H:i') : 'N/A' }}

Total Registros: {{ is_array($reports) ? count($reports) : $reports->count() }}

@php $i = 1; $totalCantidadPollos = 0; $totalPesoNeto = 0; $totalPromedio = 0; $totalTotalVenta = 0; $totalDeudaAnterior = 0; $total = 0; $totalMontoPagado = 0; $totalPendiente = 0; @endphp @foreach($reports as $pago) @php $totalCantidadPollos += $pago->cantidad_pollos ?? 0; $totalPesoNeto += $pago->peso_total_neto ?? 0; $totalPromedio += $pago->promedio ?? 0; $totalTotalVenta += $pago->venta_dia ?? 0; $totalDeudaAnterior += $pago->deuda_anterior ?? 0; $total += $pago->total ?? 0; $totalMontoPagado += $pago->monto_recibido ?? 0; $totalPendiente += $pago->saldo_a_cobrar ?? 0; @endphp @endforeach
Cliente Unid. KG Precio Precios Vta. Día Deuda Ant. Total Abono Saldo Prom.
{{ $i++ }} {{ $pago->cliente ?? '-' }} {{ number_format($pago->cantidad_pollos ?? 0, 0) }} {{ number_format($pago->peso_total_neto ?? 0, 2) }} S/ {{ number_format($pago->precio ?? 0, 2) }} @if(isset($pago->precios_unicos) && !empty($pago->precios_unicos)) {{ $pago->precios_unicos }} @elseif(isset($pago->precios_anteriores) && !empty($pago->precios_anteriores)) {{ $pago->precios_anteriores }} @else S/ {{ number_format($pago->precio ?? 0, 2) }} @endif S/ {{ number_format($pago->venta_dia ?? 0, 2) }} S/ {{ number_format($pago->deuda_anterior ?? 0, 2) }} S/ {{ number_format($pago->total ?? 0, 2) }} S/ {{ number_format($pago->monto_recibido ?? 0, 2) }} S/ {{ number_format($pago->saldo_a_cobrar ?? 0, 2) }} {{ number_format($pago->promedio ?? 0, 2) }}
TOTALES: {{ number_format($totalCantidadPollos, 0) }} {{ number_format($totalPesoNeto, 2) }} - - S/ {{ number_format($totalTotalVenta, 2) }} S/ {{ number_format($totalDeudaAnterior, 2) }} S/ {{ number_format($total, 2) }} S/ {{ number_format($totalMontoPagado, 2) }} S/ {{ number_format($totalPendiente, 2) }} {{ number_format($totalPromedio, 2) }}
@endif @endforeach @endif @if(isset($movimientosPorCaja) && count($movimientosPorCaja) > 0) @foreach($cajas as $caja) @if(isset($movimientosPorCaja[$caja->id]) && $movimientosPorCaja[$caja->id]->count() > 0)

DETALLE DE MOVIMIENTOS - CAJA #{{ $caja->id }} ({{ $caja->usuario->name ?? 'N/A' }})

Fecha Apertura: {{ $caja->fecha_apertura ? \Carbon\Carbon::parse($caja->fecha_apertura)->format('d/m/Y H:i') : 'N/A' }}

Monto Apertura: S/ {{ number_format($caja->monto_apertura, 2) }}

Total Movimientos: {{ $movimientosPorCaja[$caja->id]->count() }}

@php $ingresos = $movimientosPorCaja[$caja->id]->where('tipo', 'Ingreso'); $egresos = $movimientosPorCaja[$caja->id]->where('tipo', 'Egreso'); $pagos = $movimientosPorCaja[$caja->id]->where('tipo', 'Pago'); $pagosHistoricos = $movimientosPorCaja[$caja->id]->where('tipo', 'PagoHistorico'); @endphp @if($ingresos->count() > 0)

INGRESOS ({{ $ingresos->count() }})

@php $index = 1; @endphp @foreach($ingresos as $movimiento) @endforeach
Cliente Fecha Método de Pago Banco (Account) N° Operación Descripción Monto
{{ $index++ }} {{ $movimiento['cliente_nombre'] ?? '-' }} {{ \Carbon\Carbon::parse($movimiento['fecha'])->format('d/m/Y H:i') }} {{ $movimiento['metodo_pago_nombre'] ?? '-' }} {{ $movimiento['account_nombre'] ?? '-' }} {{ $movimiento['num_operacion'] }} {{ $movimiento['descripcion'] }} +S/ {{ number_format($movimiento['monto'], 2) }}
TOTAL INGRESOS: S/ {{ number_format($ingresos->sum('monto'), 2) }}
@endif @if($egresos->count() > 0)

EGRESOS ({{ $egresos->count() }})

@foreach($egresos as $movimiento) @endforeach
Fecha Referencia N° Operación Descripción Monto
{{ \Carbon\Carbon::parse($movimiento['fecha'])->format('d/m/Y H:i') }} {{ $movimiento['referencia'] }} {{ $movimiento['num_operacion'] }} {{ $movimiento['descripcion'] }} -S/ {{ number_format($movimiento['monto'], 2) }}
TOTAL EGRESOS: S/ {{ number_format($caja->total_egresos, 2) }}
@endif @if($pagos->count() > 0)

PAGOS ({{ $pagos->count() }})

@php $indexPagos = 1; @endphp @foreach($pagos as $movimiento) @endforeach
Cliente Fecha Método de Pago Banco N° Operación Descripción Monto
{{ $indexPagos++ }} {{ $movimiento['cliente_nombre'] ?? '-' }} {{ \Carbon\Carbon::parse($movimiento['fecha'])->format('d/m/Y H:i') }} {{ $movimiento['metodo_pago_nombre'] ?? '-' }} {{ $movimiento['banco_nombre'] ?? '-' }} {{ $movimiento['num_operacion'] }} {{ $movimiento['descripcion'] }} +S/ {{ number_format($movimiento['monto'], 2) }}
TOTAL PAGOS: S/ {{ number_format($pagos->sum('monto'), 2) }}
@endif @if($pagosHistoricos->count() > 0)

PAGOS HISTÓRICOS ({{ $pagosHistoricos->count() }})

@php $indexPagosHistoricos = 1; @endphp @foreach($pagosHistoricos as $movimiento) @endforeach
Cliente Fecha Método de Pago Banco N° Operación Descripción Monto
{{ $indexPagosHistoricos++ }} {{ $movimiento['cliente_nombre'] ?? '-' }} {{ \Carbon\Carbon::parse($movimiento['fecha'])->format('d/m/Y H:i') }} {{ $movimiento['metodo_pago_nombre'] ?? '-' }} {{ $movimiento['banco_nombre'] ?? '-' }} {{ $movimiento['num_operacion'] }} {{ $movimiento['descripcion'] }} +S/ {{ number_format($movimiento['monto'], 2) }}
TOTAL PAGOS HISTÓRICOS: S/ {{ number_format($pagosHistoricos->sum('monto'), 2) }}
@endif @if(isset($resumenPorCuentas) && $resumenPorCuentas->isNotEmpty())

RESUMEN POR CUENTAS

@foreach($resumenPorCuentas as $resumen) @endforeach
Cuenta (Banco) Monto Total Cantidad de Pagos Último Pago
{{ $resumen->banco_name }} S/ {{ number_format($resumen->monto_total, 2) }} {{ $resumen->cantidad_pagos }} pagos {{ $resumen->ultimo_pago }}
TOTALES: S/ {{ number_format($resumenPorCuentas->sum('monto_total'), 2) }} {{ $resumenPorCuentas->sum('cantidad_pagos') }} pagos
@endif @php $totalPagosResumen = $caja->total_pagos; $totalIngresosResumen = $caja->total_ingresos; $totalResumenPagos = $totalPagosResumen + $totalIngresosResumen; @endphp

RESUMEN DE PAGOS

Total Pagos: +S/ {{ number_format($totalPagosResumen, 2) }}
Total Ingresos: S/ {{ number_format($totalIngresosResumen, 2) }}
Total: S/ {{ number_format($totalResumenPagos, 2) }}
@php $transferencias = $movimientosPorCaja[$caja->id]->where('tipo', 'Transferencia') ?? collect(); @endphp @if($transferencias->count() > 0)

TRANSFERENCIAS ({{ $transferencias->count() }})

@foreach($transferencias as $transferencia) @endforeach
Fecha Referencia Cuenta Origen Cuenta Destino N° Operación Descripción Monto
{{ \Carbon\Carbon::parse($transferencia['fecha'])->format('d/m/Y H:i') }} {{ $transferencia['referencia'] }} {{ $transferencia['cuenta_origen'] ?? '-' }} {{ $transferencia['cuenta_destino'] ?? '-' }} {{ $transferencia['num_operacion'] }} {{ $transferencia['descripcion'] }} S/ {{ number_format($transferencia['monto'], 2) }}
TOTAL TRANSFERENCIAS: S/ {{ number_format($transferencias->sum('monto'), 2) }}
@endif

RESUMEN FINAL DE LA CAJA

@if($caja->monto_cierre) @if($caja->diferencia !== null) @endif @endif
Monto Apertura: S/ {{ number_format($caja->monto_apertura, 2) }}
Total Ingresos: +S/ {{ number_format($caja->total_ingresos, 2) }}
Total Egresos: -S/ {{ number_format($caja->total_egresos, 2) }}
Total Pagos: +S/ {{ number_format($caja->total_pagos, 2) }}
MONTO CALCULADO: S/ {{ number_format($caja->monto_calculado, 2) }}
Monto Cierre: S/ {{ number_format($caja->monto_cierre, 2) }}
Diferencia: @if($caja->diferencia == 0) S/ 0.00 @elseif($caja->diferencia > 0) +S/ {{ number_format($caja->diferencia, 2) }} @else S/ {{ number_format($caja->diferencia, 2) }} @endif
@endif @endforeach @endif