@section('page-title', $member->full_name . ' — Premiums') @php $currency = $member->policy->currency ?? 'USD'; $premiumCents = $member->getPremiumAmountCents(); $totalPaid = $member->premiumPayments->where('status', 'paid')->sum('amount_cents'); $missedCount = count($missedMonths); $outstanding = $missedCount * $premiumCents; $lastPmt = $member->getLastPayment(); $nextDue = $member->getNextDueDate(); $paidCount = $member->premiumPayments->where('status', 'paid')->count(); $methodLabels = ['eft' => 'EFT','rtgs' => 'RTGS','ecocash' => 'EcoCash','cheque' => 'Cheque','cash' => 'Cash','card' => 'Card','bank_transfer' => 'Bank Transfer']; @endphp {{-- Header --}}

{{ $member->full_name }}

{{ $member->member_number }} {{ $member->policy->name ?? 'No Policy' }} @php $sc = match($member->status) { 'active' => 'badge-green', 'due' => 'badge-yellow', 'pending_reactivation' => 'badge-orange', 'suspended' => 'badge-red', default => 'badge-gray', }; @endphp {{ $member->status_label }}
@if(in_array($member->status, ['suspended', 'pending_reactivation'])) @can('edit_members')
@csrf
@endcan @endif Back to Member
{{-- Stats row --}}

Monthly Premium

{{ $currency }} {{ number_format($premiumCents / 100, 2) }}

Total Paid

{{ $currency }} {{ number_format($totalPaid / 100, 2) }}

{{ $paidCount }} payment{{ $paidCount !== 1 ? 's' : '' }}

Outstanding

{{ $currency }} {{ number_format($outstanding / 100, 2) }}

{{ $missedCount }} month{{ $missedCount !== 1 ? 's' : '' }} overdue

Months Active

{{ $member->monthsActive() }}

Since {{ $member->join_date?->format('M Y') ?? '—' }}

Last Payment

@if($lastPmt)

{{ $currency }} {{ number_format($lastPmt->amount_cents / 100, 2) }}

{{ $lastPmt->paid_at?->format('d M Y') ?? $lastPmt->period_label }}

@else

No payments yet

@endif

Next Due

{{ $nextDue->format('M Y') }}

{{ $currency }} {{ number_format($premiumCents / 100, 2) }}

{{-- Overdue alert --}} @if($missedCount > 0)

{{ $missedCount }} Overdue Payment{{ $missedCount !== 1 ? 's' : '' }} — {{ $currency }} {{ number_format($outstanding / 100, 2) }} outstanding

@foreach($missedMonths as $month)

{{ $month['label'] }}

{{ $currency }} {{ number_format($premiumCents / 100, 2) }}

@can('manage_finance') @endcan
@endforeach
@endif {{-- Full Payment History --}}

Complete Payment History

All {{ $paidCount }} payments on record

{{ $currency }} {{ number_format($totalPaid / 100, 2) }} total
@forelse($member->premiumPayments as $payment) @empty @endforelse
Period Amount Method Reference Date Paid Status
{{ $payment->period_label }} {{ $currency }} {{ number_format($payment->amount_cents / 100, 2) }} {{ $methodLabels[$payment->payment_method] ?? ucfirst($payment->payment_method ?? '—') }} {{ $payment->payment_reference ?? '—' }} {{ $payment->paid_at?->format('d M Y H:i') ?? '—' }} @php $sc = match($payment->status) { 'paid' => 'badge-green', 'pending' => 'badge-yellow', 'overdue' => 'badge-red', default => 'badge-gray' }; @endphp {{ ucfirst($payment->status) }}
No payments recorded yet.
{{-- Upcoming Payments --}}

Upcoming Payments — next 3 months

@foreach($upcomingMonths as $i => $month)
@if($i === 0)

Next due

@endif

{{ $month['label'] }}

{{ $currency }} {{ number_format($premiumCents / 100, 2) }}

1 {{ date('F', mktime(0,0,0,$month['month'],1)) }}

@endforeach
{{-- Sidebar --}}
{{-- Membership Details card --}}

Membership Details

Policy
{{ $member->policy->name ?? 'N/A' }}
Currency
{{ $currency }}
Join Date
{{ $member->join_date?->format('d M Y') ?? '—' }}
Months Active
{{ $member->monthsActive() }} months
Corporate
{{ $member->corporateClient->name ?? 'Individual' }}
Status
{{ $member->status_label }}
{{-- Payment Summary card --}}

Payment Summary

Monthly Premium
{{ $currency }} {{ number_format($premiumCents / 100, 2) }}
Months Active
{{ $member->monthsActive() }}
Months Paid
{{ $paidCount }}
Months Overdue
{{ $missedCount }}
@if($lastPmt)
Last Paid
{{ $lastPmt->paid_at?->format('d M Y') ?? '—' }}
@endif
Outstanding
{{ $currency }} {{ number_format($outstanding / 100, 2) }}
Total Paid Ever
{{ $currency }} {{ number_format($totalPaid / 100, 2) }}
{{-- Record Payment Form --}} @can('manage_finance')
@csrf

Default: {{ $currency }} {{ number_format($premiumCents / 100, 2) }}

@endcan