@extends('layouts.portal') @section('title', 'Payments') @section('subtitle', 'Verify learner payment proofs, issue receipts and keep the ledger of everything received.') @section('actions') Overdue invoices@endsection @section('content') @php $f = $filters; $st = $f['status'] ?? null; $tabs = ['' => 'All', 'paid' => 'Paid', 'pending' => 'Pending', 'failed' => 'Rejected', 'refunded' => 'Refunded']; $img = fn ($p) => in_array(strtolower(pathinfo((string) $p->proof_path, PATHINFO_EXTENSION)), ['jpg', 'jpeg', 'png', 'webp', 'gif'], true); @endphp
Paid this month{{ money($kpi['month']) }}{{ now()->format('F Y') }}
Total collected{{ money($kpi['collected']) }}verified payments
Awaiting verification{{ money($kpi['pending_amount']) }}{{ $pending->count() }} payment{{ $pending->count() === 1 ? '' : 's' }} in the queue
Refunded{{ money($kpi['refunded']) }}marked as refunded

Payment proofs to verify

{{ $pending->count() ? $pending->count().' pending' : 'All caught up' }}
@if($pending->isEmpty()) @else
@foreach($pending as $p) @php $who = $p->user?->name ?? $p->invoice?->customer_name ?? 'Unknown customer'; @endphp
@if($p->proof_path) @if($img($p)) Payment proof uploaded by {{ $who }} @else
PDF proof
@endif @else

Reference only
@endif

{{ $who }} {{ money2($p->amount) }}

@if($p->invoice)Invoice {{ $p->invoice->number }} (balance {{ money2($p->invoice->balance()) }})@endif Method {{ $methods[$p->method] ?? ucfirst(str_replace('_', ' ', (string) $p->method)) }} @if($p->transaction_ref)Ref {{ $p->transaction_ref }}@endif Submitted {{ $p->created_at->diffForHumans() }}
@if($p->invoice && (float) $p->amount > $p->invoice->balance() + 0.01)
Amount is more than the invoice balance — it cannot be approved as is.
@endif
@csrf
@endforeach
@endif

Payment ledger

@forelse($payments as $p) @php $who = $p->user?->name ?? $p->invoice?->customer_name ?? '—'; @endphp @empty @endforelse
ReceiptCustomerInvoiceAmountStatusActions
@if($p->receipt_no && $p->status === 'paid'){{ $p->receipt_no }}@elseif($p->receipt_no){{ $p->receipt_no }}@elsePending@endif{{ ($p->paid_at ?? $p->created_at)->format('d M Y, g:i A') }} {{ $who }}@if($p->transaction_ref)Ref {{ $p->transaction_ref }}@endif @if($p->invoice){{ $p->invoice->number }}@else—@endif {{ money2($p->amount) }}{{ $methods[$p->method] ?? ucfirst(str_replace('_', ' ', (string) $p->method)) }}
@if($p->proof_path)@endif @if($p->status === 'paid')
@csrf
@elseif($p->status === 'pending') Review @endif
{{ $payments->links() }} @foreach($pending as $p) @endforeach @foreach($payments->where('status', 'paid') as $p) @endforeach @endsection