@extends('layouts.app') @php($canManage = auth()->user()->isAdminOrStaff()) @php($balance = $payment->balance()) @section('title', 'Invoice '.$payment->invoice_number) @section('subtitle', $payment->student?->user?->name) @section('content') Payments @if ($canManage) Edit invoice @endif

Invoice summary

{{ \App\Models\Payment::STATUSES[$payment->status] ?? ucfirst($payment->status) }}
Billed to
{{ $payment->student?->user?->name }}
{{ $payment->student?->student_number }} · {{ $payment->student?->course?->name ?? 'No course' }}
Due date
{{ $payment->due_date?->format('j M Y') }}
@if ($payment->status === 'overdue')
{{ $payment->due_date?->diffForHumans() }}
@endif
Issued
{{ $payment->created_at->format('j M Y') }}
Recorded by
{{ $payment->recorder?->name ?? 'System' }}
@foreach (['Amount' => $payment->amount, 'Discount' => $payment->discount] as $label => $value)
{{ $label }} {{ money($value) }}
@endforeach
Total due {{ money($payment->totalDue()) }}
Amount paid {{ money($payment->amount_paid) }}
Balance {{ money($balance) }}
@if ($payment->notes)
Notes
{{ $payment->notes }}
@endif

Payment trail

{{ money($payment->amount_paid) }} recorded
@if ($payment->paid_at) Last payment on {{ $payment->paid_at->format('j M Y, g:i A') }} via {{ \App\Models\Payment::METHODS[$payment->method] ?? 'not specified' }} @if ($payment->reference) · Ref: {{ $payment->reference }} @endif @else No payments recorded yet. @endif
@if ($canManage && $balance > 0 && $payment->status !== 'cancelled')

Record a payment

@csrf
{{ setting('currency_symbol', 'KSh') }}
Maximum outstanding: {{ money($balance) }}.
@endif @if ($canManage && $balance > 0 && $payment->status !== 'cancelled')

M-Pesa STK push

{{ $mpesaConfigured ? 'Daraja live' : 'Simulation' }}
@if (! $mpesaEnabled)
M-Pesa is disabled in system settings.
@else
@csrf
{{ setting('currency_symbol', 'KSh') }}
@if (! $mpesaConfigured)
Simulation mode: requests are created in-app. Complete them below to post a receipt and update the books.
@endif @endif @php($pendingSimulated = $mpesaTransactions->where('status', 'pending')->where('is_simulated', true)) @if ($pendingSimulated->isNotEmpty())
Awaiting completion
@foreach ($pendingSimulated as $transaction)
{{ money($transaction->amount) }} · {{ \App\Support\PhoneNumber::display($transaction->phone) }}
{{ $transaction->created_at->format('j M Y, g:i A') }}
@csrf
@endforeach
@endif @if ($mpesaTransactions->isNotEmpty())
Recent requests
@foreach ($mpesaTransactions as $transaction)
{{ money($transaction->amount) }} · {{ $transaction->mpesa_receipt ?? $transaction->created_at->format('j M, g:i A') }} @if ($transaction->is_simulated)Sim@endif
{{ \App\Models\MpesaTransaction::STATUSES[$transaction->status] ?? ucfirst($transaction->status) }}
@endforeach Open M-Pesa centre
@endif
@endif

Quick links

Student profile All invoices for this student @if ($canManage) Email a reminder @if ($smsEnabled)
@csrf
@endif @endif
@if ($canManage && $payment->status !== 'cancelled')
@csrf @method('DELETE')
@endif
@endsection