@extends('layouts.app') @section('title', 'Loan Details - ' . $loan->loan_number) @section('content')
@if($loan->status === 'pending') @elseif($loan->status === 'waiting') @elseif($loan->status === 'approved') @endif
Loan Information
{{ $loan->loan_number }}
{{ number_format($loan->amount, 2) }}
{{ number_format($loan->outstanding_balance, 2) }}
{{ $loan->interest_rate }}%
{{ $loan->duration_months }} months
{{ number_format($loan->monthly_payment, 2) }}
{{ number_format($loan->total_repayment, 2) }}
{{ $loan->application_date->format('M d, Y') }}
{{ ucfirst($loan->loan_type) }}
{{ $loan->purpose }}
{{ ucfirst($loan->status) }}
@if($loan->status === 'pending')
Loan Approval Actions
@if(Auth::user()->hasPermission('loans.approve', 'approve'))
@csrf
@endif @if(Auth::user()->hasPermission('loans.reject', 'reject')) @endif @if(Auth::user()->hasPermission('loans.wait', 'wait')) Put on Wait @endif @if(Auth::user()->hasPermission('loans.delete', 'delete'))
@csrf @method('DELETE')
@endif
@endif @if($loan->status === 'approved' || $loan->status === 'disbursed') @endif @if($loan->status === 'rejected' && Auth::user()->hasPermission('loans.delete'))
Loan Actions
@csrf @method('DELETE')
@endif
Payment Summary
{{ number_format($totalPaid, 2) }}
{{ number_format($remainingBalance, 2) }}
{{ number_format($loan->total_repayment - $loan->amount, 2) }}
@if($nextDueDate) {{ $nextDueDate->format('M d, Y') }} @else No pending payments @endif
@if($nextDueDate && $nextDueDate->gt(now())) {{ now()->diffInDays($nextDueDate) }} days @elseif($nextDueDate && $nextDueDate->lt(now())) Overdue by {{ now()->diffInDays($nextDueDate) }} days @else - @endif
@if($loan->collaterals->count() > 0)
@foreach($loan->collaterals as $collateral)
{{ $collateral->type }} - {{ $collateral->description }}
Value: ${{ number_format($collateral->value, 2) }} | Condition: {{ $collateral->condition }} @if($collateral->document_path) | View Document @endif
@endforeach
@else No collateral @endif
@if($loan->guarantors->count() > 0)
@foreach($loan->guarantors as $guarantor)
{{ $guarantor->name }} ({{ $guarantor->phone }})
Relationship: {{ $guarantor->relationship }} | ID: {{ $guarantor->id_number }} @if($guarantor->id_document_path) | View ID @endif
{{ $guarantor->address }}
@endforeach
@else No guarantors @endif
Repayment Progress
@php $progress = $loan->total_repayment > 0 ? (($totalPaid) / $loan->total_repayment) * 100 : 0; @endphp
{{ number_format($progress, 1) }}%
Paid ${{ number_format($totalPaid, 2) }}
Outstanding ${{ number_format($remainingBalance, 2) }}
Total ${{ number_format($loan->total_repayment, 2) }}
Recent Payments
@if($loan->status === 'approved' || $loan->status === 'disbursed') Record Payment @endif
@if($loan->repayments->count() > 0)
@foreach($loan->repayments->sortByDesc('payment_date')->take(5) as $repayment) @endforeach
Date Amount Method Reference Notes Recorded By
{{ $repayment->payment_date->format('M d, Y') }} ${{ number_format($repayment->amount, 2) }} {{ ucfirst(str_replace('_', ' ', $repayment->payment_method)) }} {{ $repayment->reference ?: '-' }} {{ $repayment->notes ?: 'No notes' }} @if($repayment->creator) {{ $repayment->creator->name }} @else System @endif
@if($loan->repayments->count() > 5) @endif @else

No payments recorded yet.

@endif
@if($loan->status === 'approved' && Auth::user()->hasPermission('loans.disburse', 'disburse'))
Loan Disbursement
@if($errors->any()) @endif
@csrf
Ready for Disbursement

You are about to disburse ${{ number_format($loan->amount, 2) }} to the client.

@error('disbursement_date')
{{ $message }}
@enderror
@error('disbursement_method')
{{ $message }}
@enderror
@endif
@endsection