@extends('dashboard.layouts.app') @section('content') @include('components.alert')
New Payment
Incoming
{{ number_format($summary['incoming_total'] ?? 0, 2) }}
Outgoing
{{ number_format($summary['outgoing_total'] ?? 0, 2) }}
Net Cash Flow
{{ number_format($summary['net_cash_flow'] ?? 0, 2) }}
Pending
{{ number_format($summary['pending_count'] ?? 0) }}
@forelse ($payments as $payment) @php $statusClass = match ($payment->status) { 'posted' => 'ui-pill--success', 'draft' => 'ui-pill--warn', 'pending' => 'ui-pill--primary', 'reversed' => 'ui-pill--danger', 'voided' => 'ui-pill--neutral', default => 'ui-pill--neutral', }; $statusLabel = match ($payment->status) { 'posted' => 'Posted', 'draft' => 'Draft', 'pending' => 'Pending', 'reversed' => 'Reversed', 'voided' => 'Voided', default => ucfirst($payment->status), }; $directionLabel = match ($payment->direction) { 'incoming' => 'Incoming', 'outgoing' => 'Outgoing', 'transfer' => 'Transfer', default => ucfirst($payment->direction), }; $directionIcon = match ($payment->direction) { 'incoming' => 'fa-arrow-down', 'outgoing' => 'fa-arrow-up', 'transfer' => 'fa-exchange-alt', default => 'fa-circle', }; $directionTone = match ($payment->direction) { 'incoming' => 'payment-type-cell--incoming', 'outgoing' => 'payment-type-cell--outgoing', 'transfer' => 'payment-type-cell--transfer', default => '', }; $moneyTone = match ($payment->direction) { 'incoming' => 'money-cell--incoming', 'outgoing' => 'money-cell--outgoing', 'transfer' => 'money-cell--transfer', default => '', }; $moneyPrefix = match ($payment->direction) { 'incoming' => '+', 'outgoing' => '-', default => '', }; $reference = $payment->reference_no ?: $payment->journalEntry?->reference_no; $studentInvoiceAllocations = $payment->allocations ->where('allocatable_type', \App\Models\StudentInvoice::class) ->filter(fn ($allocation) => $invoiceSettlements->has((int) $allocation->allocatable_id)); $settledInvoiceIds = $studentInvoiceAllocations ->pluck('allocatable_id') ->map(fn ($id) => (int) $id) ->unique() ->values(); $settlementInvoiceTotal = $settledInvoiceIds->sum(fn ($id) => (float) ($invoiceSettlements[$id]['total'] ?? 0)); $settlementPaidAmount = $settledInvoiceIds->sum(fn ($id) => (float) ($invoiceSettlements[$id]['paid'] ?? 0)); $settlementRemainingAmount = $settledInvoiceIds->sum(fn ($id) => (float) ($invoiceSettlements[$id]['remaining'] ?? 0)); $allocationPercent = $settlementInvoiceTotal > 0 ? min(100, round(($settlementPaidAmount / $settlementInvoiceTotal) * 100, 2)) : 0; $settlementState = $settlementInvoiceTotal <= 0 || $settlementPaidAmount <= 0 ? 'unpaid' : ($settlementRemainingAmount > 0.001 ? 'partial' : 'paid'); $settlementLabel = match ($settlementState) { 'paid' => 'Paid', 'partial' => 'Partial', default => 'Unpaid', }; $settlementPillClass = match ($settlementState) { 'paid' => 'ui-pill--success', 'partial' => 'ui-pill--warn', default => 'ui-pill--danger', }; $settlementFillClass = match ($settlementState) { 'paid' => 'allocation-meter__fill--full', 'partial' => 'allocation-meter__fill--partial', default => 'allocation-meter__fill--empty', }; $firstAllocation = $studentInvoiceAllocations->first() ?: $payment->allocations->first(); $allocationDocument = $firstAllocation?->allocatable; $allocationReference = $allocationDocument->invoice_number ?? $allocationDocument->bill_no ?? $allocationDocument->reference_no ?? null; $canEdit = in_array($payment->status, ['draft', 'pending'], true); @endphp {{ $payment->payment_no }}
{{ $payment->party_name }} {{ $payment->party_ref ?: ucfirst($payment->party_type) }}
{{ $directionLabel }} @if ($payment->status === 'posted') @endif {{ $statusLabel }} {{ ucwords(str_replace('_', ' ', $payment->payment_method ?? 'cash')) }} {{ $payment->costCenter ? $payment->costCenter->code . ' - ' . $payment->costCenter->title : '-' }} @if ($payment->journalEntry) {{ $reference ?: 'JE-' . $payment->journalEntry->id }} @elseif ($reference) {{ $reference }} @else - @endif {{ $payment->fromAccount?->title ?? '-' }} {{ $payment->toAccount?->title ?? '-' }} {{ $moneyPrefix }}{{ number_format((float) ($payment->treasury_amount ?? $payment->amount), 2) }} {{ $payment->treasury_currency ?: $payment->currency }} {{-- @if ($studentInvoiceAllocations->isNotEmpty())
{{ $settlementLabel }} {{ number_format($settlementPaidAmount, 2) }} / {{ number_format($settlementInvoiceTotal, 2) }}
@if ($allocationReference)
{{ $allocationReference }}{{ $settledInvoiceIds->count() > 1 ? ' +' . ($settledInvoiceIds->count() - 1) : '' }} @if ($settlementRemainingAmount > 0) - Remain {{ number_format($settlementRemainingAmount, 2) }} @endif
@endif
@else - @endif --}} {{ optional($payment->payment_date)->format('Y-m-d') ?? $payment->payment_date }}
@if ($payment->journalEntry) @endif @if ($canEdit) @else @endif @if ($payment->status === 'draft') @endif
@empty
No payments found.

Start by creating a new payment.

@endforelse
@if ($payments->hasPages())
{{ $payments->appends(request()->except('page'))->links('pagination::bootstrap-5') }}
@endif
@foreach ($payments as $payment) @if ($payment->status === 'draft') @endif @endforeach @endsection