@extends('layout.main') @section('content')

Bad Loans

Loans in default or requiring immediate attention

@if (Auth::user()->can('loans-create')) Add New Loan @endif
@if($loans->count() > 0)

Critical Attention Required

{{ $loans->count() }} loan{{ $loans->count() !== 1 ? 's' : '' }} requiring immediate collection or recovery action.
@endif
Bad Loans
{{ $loans->count() }}
Amount at Risk
{{ formatAmount($loans->sum('loan_amount')) }}
Potential Loss
{{ formatAmount($loans->sum('principal_amount')) }}
Affected Clients
{{ $loans->where('loan_category_id', \App\Constants\LoanConstants::INDIVIDUAL_LOAN)->count() + $loans->where('loan_category_id', '!=', \App\Constants\LoanConstants::INDIVIDUAL_LOAN)->flatMap->groupClients->unique('client_id')->count() }}

High-Risk Loans Requiring Action

High Risk @if($loans->count() > 0) {{ number_format(($loans->sum('loan_amount') / $loans->sum('principal_amount') - 1) * 100, 1) }}% avg. loss exposure @endif
Loan Code Borrower(s) Type Product Principal ({{ getCurrencyCode() }}) Interest Rate Interest ({{ getCurrencyCode() }}) Total Owed ({{ getCurrencyCode() }}) Status Actions @forelse ($loans as $loan)
{{ $loan?->loan_code }}
@if ($loan?->loan_category_id == \App\Constants\LoanConstants::INDIVIDUAL_LOAN)
{{ substr(optional($loan?->individualClient)?->client?->fullname, 0, 1) }}
{{ optional($loan?->individualClient)?->client?->fullname }}
High Risk Client
@else
Group at Risk
@foreach ($loan?->groupClients as $index => $groupClient) @if ($index < 2)
{{ $groupClient?->client?->fullname }}
@elseif ($index == 2)
+{{ $loan?->groupClients->count() - 2 }} more borrowers
@break @endif @endforeach
@endif
{{ \App\Constants\LoanConstants::getLoanTypeName($loan?->loan_category_id) }}
{{ $loan?->loanType?->product_name }}
{{ formatAmount($loan?->principal_amount) }}
{{ $loan?->interest_rate }}%
{{ formatAmount($loan?->interest_amount) }}
{{ formatAmount($loan?->loan_amount) }}
{{ \App\Constants\LoanConstants::getStatusName($loan?->level_status_id) }} @if (Auth::user()->can('loans-show'))
@if (Auth::user()->can('loans-manage')) @endif
@endif
@empty

No bad loans found

Excellent! Your loan portfolio is performing well.

Keep up the great risk management! 🎉
@endforelse
@endsection