@php $logoPath = public_path('images/LOGO1.png'); $logoBase64 = ''; if (file_exists($logoPath)) { $logoData = file_get_contents($logoPath); $logoBase64 = 'data:image/png;base64,' . base64_encode($logoData); } $totalAcordado = $facturas->sum('monto_total'); $totalAbonado = $facturas->sum(fn($f) => $f->pagos->sum('monto_pagado')); $totalDeuda = $facturas->sum('deuda_restante'); $nFacturas = $facturas->count(); $pctGlobal = $totalAcordado > 0 ? ($totalAbonado / $totalAcordado) * 100 : 0; $closestFac = $facturas->sortBy('fecha_vencimiento')->first(); @endphp {{-- FOOTER MUST BE DEFINED BEFORE CONTENT IN DOMPDF TO SHOW ON ALL PAGES --}} {{-- ── HEADER ── --}}
@if($logoBase64) Logo @else
@endif
Cornejo & Cubas
Abogados
Sistema de Gestión de Expedientes Jurídicos

ESTADO DE CUENTA

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

{{-- ── SUMMARY CARD ── --}}
{{ number_format($pctGlobal, 0) }}%
ABONADO
SALDO PENDIENTE DE PAGO
S/ {{ number_format($totalDeuda, 2) }}
@if($closestFac) {{ str_replace('FAC', 'RH', $closestFac->numero_factura) }} · vence el {{ $closestFac->fecha_vencimiento ? $closestFac->fecha_vencimiento->format('d/m/Y') : 'N/A' }} @else No hay RH registrados. @endif
TOTAL ACORDADO
S/ {{ number_format($totalAcordado, 2) }}
TOTAL ABONADO
S/ {{ number_format($totalAbonado, 2) }}
N° RECIBOS POR HONORARIOS
{{ str_pad($nFacturas, 4, '0', STR_PAD_LEFT) }}
{{-- ── CLIENT DATA ── --}}
👤 DATOS DEL CLIENTE
NOMBRE COMPLETO
{{ $cliente->nombre_completo }}
DNI / RUC
{{ $cliente->dni_ruc ?? 'No registrado' }}
TELÉFONO
{{ $cliente->telefono ?? 'No registrado' }}
CORREO
{{ $cliente->correo ?? 'No registrado' }}
{{-- ── FACTURAS ── --}}
📄 RH / CUENTAS POR COBRAR
@forelse($facturas as $fac) @php $abonado = $fac->pagos->sum('monto_pagado'); $pct = $fac->monto_total > 0 ? min(($abonado / $fac->monto_total) * 100, 100) : 0; @endphp @empty @endforelse
RH CONCEPTO EMISIÓN VENCIMIENTO ESTADO ACORDADO ABONADO RESTANTE
{{ str_replace('FAC', 'RH', $fac->numero_factura) }} {{ Str::limit($fac->concepto, 25) }} {{ $fac->fecha_emision->format('d/m/Y') }} {{ $fac->fecha_vencimiento ? $fac->fecha_vencimiento->format('d/m/Y') : '—' }} @if($fac->estado == 'Pendiente') Pendiente @elseif($fac->estado == 'Parcial') Parcial @else Pagado @endif S/ {{ number_format($fac->monto_total, 2) }} S/ {{ number_format($abonado, 2) }}
S/ {{ number_format($fac->deuda_restante, 2) }}
No hay RH registrados.
TOTALES S/ {{ number_format($totalAcordado, 2) }} S/ {{ number_format($totalAbonado, 2) }} S/ {{ number_format($totalDeuda, 2) }}
{{-- ── PAGOS REGISTRADOS ── --}} @foreach($facturas as $fac) @if($fac->pagos->count() > 0)
💵 PAGOS REGISTRADOS · {{ str_replace('FAC', 'RH', $fac->numero_factura) }}
@php $acumulado = 0; @endphp @foreach($fac->pagos->sortBy('fecha_pago') as $i => $pago) @php $acumulado += $pago->monto_pagado; @endphp @endforeach
# FECHA TIPO MÉTODO REFERENCIA MONTO ACUMULADO
{{ $i + 1 }} {{ $pago->fecha_pago->format('d/m/Y') }} Abono {{ $pago->metodo_pago ?? 'N/A' }} {{ $pago->referencia ?? '—' }} + S/ {{ number_format($pago->monto_pagado, 2) }} S/ {{ number_format($acumulado, 2) }}
TOTAL ABONADO S/ {{ number_format($acumulado, 2) }}
@endif @endforeach {{-- ── WATERMARK & STAMP ── --}}
@if($nFacturas > 0) @if($totalDeuda == 0)
PAGADO AL DÍA
TODOS LOS RH CANCELADOS
@elseif($totalAbonado > 0)
PAGO PARCIAL
{{ number_format($pctGlobal, 0) }}% ABONADO
@else
PENDIENTE
SIN ABONOS REGISTRADOS
@endif @endif
Este documento es generado automáticamente por
Cornejo & Cubas Abogados
y tiene carácter informativo.