@extends('master.app') @section('title', 'Customer Aging Report') @section('pageCSS') @endsection @section('body')

Customer Aging Report

Outstanding invoices grouped by age buckets (As Of: {{ $asOf }})
@if($info && $info->business_name)
{{ $info->business_name }}
@endif
{{-- Filters --}}
{{-- KPI --}}
0 - 30 Days
{{ number_format($kpi->b0_30, 2) }}
31 - 60 Days
{{ number_format($kpi->b31_60, 2) }}
61 - 90 Days
{{ number_format($kpi->b61_90, 2) }}
90+ Days
{{ number_format($kpi->b90_plus, 2) }}
Total Outstanding
{{ number_format($kpi->total, 2) }}
Based on invoice balances.
{{-- Currency Totals (useful when all currency) --}} @if(request('currency_id','all') === 'all')
@foreach($totalsByCurrency as $t) @if($t['total'] > 0) @endif @endforeach @if(collect($totalsByCurrency)->sum('total') <= 0) @endif
Currency 0-30 31-60 61-90 90+ Total
{{ $t['currency'] }} {{ number_format($t['b0_30'],2) }} {{ number_format($t['b31_60'],2) }} {{ number_format($t['b61_90'],2) }} {{ number_format($t['b90_plus'],2) }} {{ number_format($t['total'],2) }}
No totals
@endif {{-- Summary Table --}}
@forelse($rows as $i => $r) @php $custName = $customerNames[$r->customer_id] ?? 'Unknown'; $curName = $currencyNames[$r->currency_id] ?? '-'; @endphp @empty @endforelse {{-- Footer Totals --}}
# Customer CUR 0-30 31-60 61-90 90+ Total Action
{{ method_exists($rows,'firstItem') ? $rows->firstItem() + $i : ($i+1) }} {{ $custName }} {{ $curName }} {{ number_format((float)$r->b0_30, 2) }} {{ number_format((float)$r->b31_60, 2) }} {{ number_format((float)$r->b61_90, 2) }} {{ number_format((float)$r->b90_plus, 2) }} {{ number_format((float)$r->total_outstanding, 2) }} Details
No data found
Grand Total {{ number_format($kpi->b0_30,2) }} {{ number_format($kpi->b31_60,2) }} {{ number_format($kpi->b61_90,2) }} {{ number_format($kpi->b90_plus,2) }} {{ number_format($kpi->total,2) }}
{{-- Pagination --}} @if(! $isPrint && method_exists($rows, 'links'))
{{ $rows->links('pagination::bootstrap-4') }}
@endif {{-- Details Invoices (only when a single customer selected) --}} @if($customerId)
Invoice Details (Selected Customer)
Showing invoices with invoice_date <= {{ $asOf }}
@php $asOfCarbon = \Carbon\Carbon::parse($asOf); @endphp @forelse($details as $k => $b) @php $age = $asOfCarbon->diffInDays(\Carbon\Carbon::parse($b->invoice_date)); @endphp @empty @endforelse
# Date Invoice # Title CUR Final Received Balance Age
{{ $k+1 }} {{ $b->invoice_date }} {{ $b->invoice_number }} {{ $b->title }} {{ optional($b->currency)->title_en }} {{ number_format((float)$b->final_amount,2) }} {{ number_format((float)$b->received,2) }} {{ number_format((float)$b->balance,2) }} {{ $age }}d
No invoices
@endif
@endsection