{{-- resources/views/livewire/cxc/index.blade.php --}}
{{-- ── HEADER ──────────────────────────────────── --}}
💰 Cuentas por cobrar
Facturas a crédito · antigüedad · registro de pagos
{{-- ── MENSAJES ─────────────────────────────────── --}} @if($mensaje_exito)
✅ {{ $mensaje_exito }}
@endif @if($mensaje_error)
❌ {{ $mensaje_error }}
@endif {{-- ── KPIs ────────────────────────────────────── --}}
Total pendiente
₡{{ number_format($totales->total_pendiente ?? 0, 0) }}
{{ $totales->total_facturas ?? 0 }} facturas
🔴 Vencido
₡{{ number_format($totales->total_vencido ?? 0, 0) }}
✅ Cobrado
₡{{ number_format($totales->total_cobrado ?? 0, 0) }}
Total facturado
₡{{ number_format($totales->total_facturado ?? 0, 0) }}
@if($vista_activa === 'antiguedad') {{-- ── VISTA ANTIGÜEDAD ─────────────────────── --}}
Antigüedad de saldos
@php $total_ant = ($antiguedad['rango_0_30'] ?? 0) + ($antiguedad['rango_31_60'] ?? 0) + ($antiguedad['rango_61_90'] ?? 0) + ($antiguedad['rango_mas_90'] ?? 0); @endphp @foreach([ ['label' => '0–30 días (vigente)', 'key' => 'rango_0_30', 'color' => 'var(--green)'], ['label' => '31–60 días', 'key' => 'rango_31_60', 'color' => 'var(--orange)'], ['label' => '61–90 días', 'key' => 'rango_61_90', 'color' => 'var(--red)'], ['label' => 'Más de 90 días', 'key' => 'rango_mas_90', 'color' => '#7F1D1D'], ] as $rango) @php $monto = $antiguedad[$rango['key']] ?? 0; $pct = $total_ant > 0 ? ($monto / $total_ant * 100) : 0; @endphp
{{ $rango['label'] }}
₡{{ number_format($monto, 0) }}
{{ number_format($pct, 1) }}%
@endforeach
Total pendiente ₡{{ number_format($total_ant, 0) }}
@endif {{-- ── FILTROS ──────────────────────────────────── --}}
{{-- ── TABLA ────────────────────────────────────── --}}
@forelse($cxcs as $cxc) @empty @endforelse
Cliente Factura Emitida Vence Total Pendiente Estado REP Acciones
{{ $cxc->tercero?->nombre ?? '—' }}
{{ $cxc->tercero?->cedula_numero }}
{{ $cxc->factura?->consecutivo }} {{ $cxc->fecha_emision->format('d M Y') }} @php $diasVencida = $cxc->diasVencida(); @endphp {{ $cxc->fecha_vencimiento->format('d M Y') }} @if($diasVencida > 0) · {{ $diasVencida }}d @endif ₡{{ number_format($cxc->monto_total, 2) }} ₡{{ number_format($cxc->monto_pendiente, 2) }} {{ match($cxc->estado) { 'pagado' => '✓ Pagado', 'vencido' => '🔴 Vencido', 'parcial' => '◑ Parcial', 'pendiente'=> '⏳ Pendiente', default => $cxc->estado, } }} @if($cxc->factura?->rep_requerido) @if($cxc->factura->rep_generado) ✓ REP @else ⏳ REP @endif @else @endif
@if($cxc->estado !== 'pagado') @endif @if($cxc->tercero?->email) @endif
No hay cuentas por cobrar con los filtros seleccionados
@if($cxcs->hasPages())
{{ $cxcs->links() }}
@endif
{{-- ── MODAL REGISTRAR PAGO ─────────────────────── --}} @if($pagando_cxc_id) @php $cxc_modal = $cxcs->firstWhere('id', $pagando_cxc_id) ?? \App\Models\CuentaPorCobrar::with('tercero')->find($pagando_cxc_id); @endphp
💵 Registrar pago
{{ $cxc_modal?->tercero?->nombre }} · Pendiente: ₡{{ number_format($cxc_modal?->monto_pendiente ?? 0, 2) }}
@if($pago_error)
❌ {{ $pago_error }}
@endif
@if($cxc_modal?->factura?->rep_requerido && !$cxc_modal?->factura?->rep_generado)
⚠️ Esta factura tiene IVA diferido. Al completar el pago se generará automáticamente el REP para Hacienda.
@endif
@endif