@extends('layouts.app') @section('title', 'AR Aging') @section('nav_reports', 'bg-teal-50 text-teal-700 font-semibold') @section('page_title', 'Reports') @section('page_subtitle', 'AR Aging') @section('content') @php $bucketMeta = [ 'in_house' => ['In-House', 'text-blue-700'], 'current' => ['Current', 'text-gray-600'], 'd1_30' => ['1–30 days', 'text-amber-600'], 'd31_60' => ['31–60 days', 'text-orange-600'], 'd60_plus' => ['60+ days', 'text-red-600'], ]; @endphp @include('reports._filter', [ 'active' => 'reports.ar-aging', 'mode' => 'none', 'title' => 'AR Aging / Outstanding Balances', 'subtitle' => 'Live snapshot as of ' . $today->format('l, F j, Y'), ]) {{-- Summary tiles --}}

Total Outstanding

₱{{ number_format($totalOutstanding, 2) }}

{{ $accounts }} account{{ $accounts !== 1 ? 's' : '' }} owing

In-House Exposure

₱{{ number_format($inHouseExposure, 2) }}

still checked in

Departed Owing

₱{{ number_format($departedOwing, 2) }}

checked out, unpaid

Credit Balances

₱{{ number_format($creditTotal < 0 ? -$creditTotal : 0, 2) }}

{{ count($credits) }} over-payment{{ count($credits) !== 1 ? 's' : '' }}

{{-- Aging bucket strip --}}
@foreach($bucketMeta as $key => [$label, $color])

{{ $label }}

₱{{ number_format($buckets[$key], 0) }}

@endforeach
{{-- Main table --}}

Outstanding Balances

Highest balance first · in-house guests and departed-but-unpaid stays

@if(empty($rows))

No outstanding balances — everyone's settled. 🎉

@else
@foreach($rows as $row) @php [$blabel, $bcolor] = $bucketMeta[$row['bucket']]; @endphp @endforeach
Guest / Booking Room Check-out Aging Charges Paid Balance

{{ $row['guest_name'] }}

{{ $row['booking_no'] }}

{{ $row['room_no'] }}

{{ $row['room_type'] }}

{{ $row['check_out']->format('M j, Y') }} {{ $blabel }} @if($row['days_past'] !== null && $row['days_past'] > 0) · {{ $row['days_past'] }}d @endif ₱{{ number_format($row['charges'], 2) }} ₱{{ number_format($row['paid'], 2) }} ₱{{ number_format($row['balance'], 2) }}
Total Outstanding ₱{{ number_format($totalOutstanding, 2) }}
@endif
@if(!empty($credits))

Credit Balances — possible refunds due

@foreach($credits as $c) @endforeach
{{ $c['guest_name'] }} {{ $c['booking_no'] }} Room {{ $c['room_no'] }} +₱{{ number_format($c['credit'], 2) }}
@endif @endsection