@php use App\Models\Payment; use Illuminate\Support\Str; $money = fn ($value) => 'R '.number_format((float) $value, 2); $status = $filters['status'] ?? 'all'; $period = $filters['period'] ?? 'all'; $search = $filters['search'] ?? ''; $paymentBadge = function ($payment) { return match ($payment->status) { Payment::STATUS_SUCCEEDED => 'status-badge status-paid', Payment::STATUS_PENDING => 'status-badge status-partially-paid', Payment::STATUS_FAILED => 'status-badge status-overdue', Payment::STATUS_REJECTED => 'status-badge status-void', Payment::STATUS_CANCELLED => 'status-badge status-cancelled', default => 'status-badge status-draft', }; }; @endphp @can('view-financial-reports') Export Collections Export Payments @endcan Create invoice

Total Received

{{ $money($summary['total_received']) }}

Approved payments.

Outstanding Balance

{{ $money($summary['outstanding_balance']) }}

Collectible balances.

Overdue Balance

{{ $money($summary['overdue_balance']) }}

Past-due balances.

Partially Paid

{{ $summary['partially_paid_count'] }}

{{ $money($summary['partially_paid_balance']) }} due.

Pending Verification

{{ $summary['pending_verification_count'] }}

{{ $money($summary['pending_verification_amount']) }} pending.

Collections register

Filter records

Find balances and payment activity.

Reset

Needs Collection

Collect these balances.

@if ($needsCollection->isEmpty()) @else
@foreach ($needsCollection as $invoice) @php $balanceDue = (float) ($invoice->balance_due ?? $invoice->remainingBalance()); $paidTotal = (float) ($invoice->paid_total ?? $invoice->totalPaid()); $creditedTotal = (float) ($invoice->credited_total ?? $invoice->totalCredited()); $payUrl = $invoice->publicPayUrl(); $lastReminder = $invoice->reminders->first(); $daysOverdue = $invoice->due_date->isPast() && ! $invoice->due_date->isToday() ? $invoice->due_date->diffInDays(today()) : 0; @endphp
{{ $invoice->invoice_number }}

{{ $invoice->client?->name }}

{{ $invoice->client?->email ?: 'No email' }}

{{ $invoice->statusLabel() }}
Invoice Total
{{ $money($invoice->grand_total) }}
Paid
{{ $money($paidTotal) }}
Credited
{{ $money($creditedTotal) }}
Balance Due
{{ $money($balanceDue) }}

Due Date

{{ $invoice->due_date->format('d M Y') }}

@if ($daysOverdue > 0)

{{ $daysOverdue }} {{ Str::plural('day', $daysOverdue) }} overdue

@endif

Last Reminder

{{ $lastReminder?->sent_at?->format('d M Y H:i') ?? 'None yet' }}

{{ $invoice->reminders->count() }} sent

Next Action

{{ $balanceDue > 0 ? 'Collect balance' : 'No action' }}

@can('record-payments') Record payment @endcan @can('send-invoice-reminders')
@csrf
@endcan View invoice
@endforeach
{{ $needsCollection->links() }}
@endif

Recent Payments

Approved payments only.

@if ($recentPayments->isEmpty()) @else
@foreach ($recentPayments as $payment)

{{ $payment->invoice?->client?->name ?? 'Client unavailable' }}

@if ($payment->invoice) {{ $payment->invoice->invoice_number }} @else

Invoice unavailable

@endif
{{ $payment->statusLabel() }}
Method
{{ $payment->methodLabel() }}
Paid Date
{{ $payment->paid_at?->format('d M Y') ?? 'Not set' }}
Reference
{{ $payment->payment_reference ?: ($payment->gateway_reference ?: 'No reference') }}
Amount
{{ $money($payment->amount_paid) }}
@endforeach
{{ $recentPayments->links() }}
@endif

Pending verification

Approve before counting as received.

@forelse ($pendingVerification as $payment)

{{ $payment->invoice?->invoice_number }}

{{ $payment->invoice?->client?->name }} - {{ $payment->methodLabel() }}

{{ $payment->statusLabel() }}
Submitted {{ $money($payment->amount_paid) }}

{{ $payment->created_at->format('d M Y H:i') }} - {{ $payment->payment_reference ?: ($payment->gateway_reference ?: 'No reference') }}

@if ($payment->hasProof()) View proof @endif @can('record-payments')
@csrf
@csrf
@endcan
@empty @endforelse

Partially Paid

Paid partly, balance due.

@forelse ($partiallyPaidInvoices as $invoice) @php $payUrl = $invoice->publicPayUrl(); $paidTotal = (float) ($invoice->paid_total ?? $invoice->totalPaid()); $progress = min(100, round(($paidTotal / max(1, (float) $invoice->grand_total)) * 100)); @endphp
{{ $invoice->invoice_number }}

{{ $invoice->client?->name }}

Remaining

{{ $money($invoice->balance_due ?? $invoice->remainingBalance()) }}

{{ $money($paidTotal) }} paid of {{ $money($invoice->grand_total) }}
@empty @endforelse