@php $data = $this->getReportData(); @endphp {{-- Summary Cards --}}

Total Piutang

Rp {{ number_format($data['totalPiutang'], 0, ',', '.') }}

{{ $data['orderCount'] }} invoice

Belum Jatuh Tempo

Rp {{ number_format($data['current'], 0, ',', '.') }}

1-30 Hari

Rp {{ number_format($data['days1_30'], 0, ',', '.') }}

31-60 Hari

Rp {{ number_format($data['days31_60'], 0, ',', '.') }}

>60 Hari

Rp {{ number_format($data['days61_90'] + $data['over90'], 0, ',', '.') }}

{{-- Per Customer --}}

Piutang Per Pelanggan

@forelse($data['perCustomer'] as $cust) @empty @endforelse
Pelanggan Invoice Sisa Tagihan
{{ $cust->customer_name ?? 'Walk-in' }} {{ $cust->total_orders }} Rp {{ number_format($cust->total_balance, 0, ',', '.') }}
Tidak ada piutang
{{-- Aging Bar Visual --}}

Aging Breakdown

@php $total = max($data['totalPiutang'], 1); $bars = [ ['label' => 'Belum Jatuh Tempo', 'value' => $data['current'], 'color' => '#059669'], ['label' => '1-30 Hari', 'value' => $data['days1_30'], 'color' => '#D97706'], ['label' => '31-60 Hari', 'value' => $data['days31_60'], 'color' => '#EA580C'], ['label' => '61-90 Hari', 'value' => $data['days61_90'], 'color' => '#DC2626'], ['label' => '> 90 Hari', 'value' => $data['over90'], 'color' => '#991B1B'], ]; @endphp @foreach($bars as $bar)
{{ $bar['label'] }} Rp {{ number_format($bar['value'], 0, ',', '.') }}
@endforeach
{{-- Detail Table --}}

Detail Piutang

Semua invoice yang belum lunas

@forelse($data['agingDetails'] as $detail) @php $order = $detail['order']; $rowColor = match($detail['bucket']) { 'current' => '', '1-30' => 'background:#FFFBEB;', '31-60' => 'background:#FFF7ED;', '61-90' => 'background:#FEF2F2;', '>90' => 'background:#FEF2F2;', default => '', }; @endphp @empty @endforelse
No. Invoice Pelanggan Tanggal Jatuh Tempo Hari Lewat Total Terbayar Sisa
{{ $order->order_number }} {{ $order->customer_name ?? $order->customer?->name ?? 'Walk-in' }} {{ $order->created_at->format('d M Y') }} {{ $order->due_date ? $order->due_date->format('d M Y') : '-' }} {{ $detail['days_overdue'] > 0 ? $detail['days_overdue'] . ' hari' : 'On time' }} Rp {{ number_format($order->total, 0, ',', '.') }} Rp {{ number_format($order->amount_paid, 0, ',', '.') }} Rp {{ number_format($detail['balance'], 0, ',', '.') }}
Tidak ada piutang. Semua invoice sudah lunas.