{{-- New-Unity ERP | Finance/Resources/Views/cxc/statement_pdf.blade.php | v2.0 | 27/07/2026 --}} {{-- v2.0 — Resumen de antigüedad al pie, historial de pagos por factura, footer con vigencia. --}} {{-- v1.0 — Estado de cuenta CxC para DomPDF: encabezado, tabla de antigüedad y totales. --}} {{-- Encabezado --}}
{{ config('app.name', 'Sweet Works ERP') }}
{{ __('finance.statement') }}
{{ __('finance.generated-on') }} {{ now()->format('d/m/Y') }}
{{-- Datos del cliente --}}
{{ __('finance.col-customer') }}: {{ $customer->commercial_name ?: $customer->name }} @if($customer->rfc)    RFC: {{ $customer->rfc }}@endif
@php $grandTotal = 0; $sections = [ 'current' => ['label' => __('finance.aging-current'), 'items' => $current, 'overdue' => false], '0-30' => ['label' => __('finance.aging-0-30'), 'items' => $buckets['0-30'], 'overdue' => true], '31-60' => ['label' => __('finance.aging-31-60'), 'items' => $buckets['31-60'], 'overdue' => true], '61-90' => ['label' => __('finance.aging-61-90'), 'items' => $buckets['61-90'], 'overdue' => true], '90+' => ['label' => __('finance.aging-90plus'), 'items' => $buckets['90+'], 'overdue' => true], ]; // Aging summary totals $agingSummary = [ 'current' => 0, '0-30' => 0, '31-60' => 0, '61-90' => 0, '90+' => 0, ]; foreach ($sections as $key => $section) { foreach ($section['items'] as $item) { $agingSummary[$key] += $item['balance']; } } @endphp @foreach($sections as $key => $section) @if(count($section['items']) > 0) @php $sectionTotal = 0; @endphp @foreach($section['items'] as $item) @php $inv = $item['invoice']; $bal = $item['balance']; $sectionTotal += $bal; $grandTotal += $bal; $folio = ($inv->serie ?? '') . ($inv->folio ?? $inv->id); $daysOv = $item['days_overdue']; // positive = overdue, negative = remaining @endphp {{-- Historial de pagos de esta factura --}} @if($inv->arPayments && $inv->arPayments->count() > 0) @foreach($inv->arPayments as $pago) @endforeach @endif @endforeach @endif @endforeach
{{ __('finance.col-folio') }} {{ __('finance.col-date') }} {{ __('finance.col-due') }} {{ __('finance.col-total') }} {{ __('finance.col-paid') }} {{ __('finance.col-balance') }} {{ __('finance.days-overdue') }}
{{ $section['label'] }}
{{ $folio }} {{ $inv->fecha_emision ? \Carbon\Carbon::parse($inv->fecha_emision)->format('d/m/Y') : '—' }} {{ $inv->expiration_date ? \Carbon\Carbon::parse($inv->expiration_date)->format('d/m/Y') : '—' }} ${{ number_format($inv->total, 2) }} ${{ number_format($inv->cxc_paid_amount, 2) }} ${{ number_format($bal, 2) }} @if($daysOv > 0) {{ $daysOv }} @elseif($daysOv < 0) {{ abs($daysOv) }}d rest. @else hoy @endif
{{ __('finance.payment-history-pdf') }}: {{ $folio }}
{{ \App\Modules\Finance\Models\ArPayment::methodLabel($pago->payment_method) }} @if($pago->reference) — {{ $pago->reference }}@endif {{ $pago->payment_date->format('d/m/Y') }} -${{ number_format($pago->amount, 2) }}
{{ __('finance.aging-total') }} {{ $section['label'] }} ${{ number_format($sectionTotal, 2) }}
{{ __('finance.aging-total') }} ${{ number_format($grandTotal, 2) }}
{{-- Resumen de Antigüedad --}}
{{ __('finance.aging-summary-pdf') }} {{ __('finance.col-balance') }}
{{ __('finance.aging-current') }} ${{ number_format($agingSummary['current'], 2) }}
{{ __('finance.aging-0-30') }} ${{ number_format($agingSummary['0-30'], 2) }}
{{ __('finance.aging-31-60') }} ${{ number_format($agingSummary['31-60'], 2) }}
{{ __('finance.aging-61-90') }} ${{ number_format($agingSummary['61-90'], 2) }}
{{ __('finance.aging-90plus') }} ${{ number_format($agingSummary['90+'], 2) }}
{{ __('finance.aging-total') }} ${{ number_format($grandTotal, 2) }}