@extends('layouts.app') @section('title', 'Payment Management') @section('content')

Payments

Collect outstanding payments or view completed payments.

Bulk Recovery

{{ $tab === 'pending' ? 'Pending and partially paid invoices. Pay the remaining balance to complete an invoice.' : 'Fully paid invoices. Open an invoice to view and download it.' }}

Reset
@foreach (['Invoice / Date', 'Customer', 'Safebox', 'Type', 'Amount (RM)', 'Paid (RM)', 'Balance (RM)', 'Status', 'Invoice'] as $heading) @endforeach @forelse ($invoices as $invoice) @php $status = strtolower(trim((string) $invoice->status)); $paidAmount = (float) ($invoice->paid_amount ?? 0); if ($paidAmount <= 0) { $paidAmount = (float) ($invoice->received_payment_amount ?? 0); } $balanceAmount = max(0, (float) $invoice->total_amount - $paidAmount); $statusClass = match ($status) { 'paid' => 'bg-green-50 text-green-800', 'pending' => 'bg-yellow-50 text-yellow-800', 'partial' => 'bg-blue-50 text-blue-800', default => 'bg-gray-100 text-gray-700', }; $invoiceUrl = route('customers.invoice.show', [ 'client' => $invoice->client_id, 'registration' => $invoice->registration_id, 'invoice_id' => $invoice->id, ]); @endphp @empty @endforelse
{{ $heading }}
{{ $invoice->invoice_number }}
{{ $invoice->invoice_date?->format('d-m-Y') ?? 'N/A' }}
{{ $invoice->client_name ?? 'N/A' }}
{{ $invoice->client_phone ?? 'N/A' }}
@foreach ($invoice->customer?->customerMembers ?? [] as $member)
{{ $member->proof_type === 'ic_number' ? 'IC Number' : ucwords(str_replace('_', ' ', $member->proof_type ?? 'ID')) }}: {{ $member->proof_number ?? 'N/A' }}
@endforeach
{{ $invoice->locker_number ?? 'N/A' }} {{ ['create' => 'Registration', 'add' => 'Locker Add', 'renewal' => 'Renewal', 'change' => 'Change'][$invoice->payment_type] ?? ucwords(str_replace('_', ' ', $invoice->payment_type ?? 'N/A')) }} {{ number_format($invoice->total_amount, 2) }} {{ number_format($paidAmount, 2) }} {{ number_format($balanceAmount, 2) }} {{ $status === 'partial' ? 'Partially Paid' : ucfirst($status ?: 'Unknown') }} @if ($invoice->customer && $invoice->lockerRegistration)
{{ $status === 'paid' ? 'View / Download' : 'View' }} @if (in_array($status, ['pending', 'partial'], true) && $balanceAmount > 0)
@csrf
@endif
@else Registration unavailable @endif
No invoices match your filters.
{{ $invoices->appends(request()->query())->links() }}
@endsection