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

Loan Details

{{ $loan->loan_code }}

{{ \App\Constants\LoanConstants::getStatusName($loan->level_status_id) }}

Client Information

Avatar Fullname Gender Phone ID No Location @if ($loan->loan_category_id == \App\Constants\LoanConstants::INDIVIDUAL_LOAN)
Profile Picture
{{ $loan->individualClient->client->fullname }} {{ $loan->individualClient->client->gender }} {{ $loan->individualClient->client->phone }} {{ $loan->individualClient->client->idnumber }} {{ $loan->individualClient->client->location }}
@else @foreach ($loan->groupClients as $groupClient)
Profile Picture
{{ $groupClient->client->fullname }} {{ $groupClient->client->gender }} {{ $groupClient->client->phone }} {{ $groupClient->client->idnumber }} {{ $groupClient->client->location }}
@endforeach @endif

Actions

@if (Auth::user()->can('loans-edit') && $loan->level_status_id == \App\Constants\LoanConstants::PENDING) Edit Loan @endif @if (Auth::user()->can('loans-approve') && $loan->level_status_id != \App\Constants\LoanConstants::DECLINED && $loan->level_status_id != \App\Constants\LoanConstants::APPROVED) Update Status @endif @if (Auth::user()->can('loans-approve') && $loan->level_status_id == \App\Constants\LoanConstants::APPROVED && is_null($loan->disbursement_on))

Disburse Loan

Make sure there is enough funds on the funds account. Disbursing the loan will deduct the loan principal amount from this account.

Are you sure you want to disburse this loan?

@csrf @method('PUT')
@endif @if (Auth::user()->can('loan-payment')) View Schedule @endif @if (Auth::user()->can('loan-payment') && $loan->level_status_id == \App\Constants\LoanConstants::APPROVED && !is_null($loan->disbursement_on)) Payment Details @endif @if (Auth::user()->can('file-create')) Add Files @endif @if (Auth::user()->can('penalty-show') && !is_null($loan->disbursement_on) && $loan->level_status_id == 1) Manage Fines @if ($loan->hasPendingPenalties()) @endif @endif @if (Auth::user()->can('loans-create')) Add Collateral @endif

Basic Information

Loan Code: {{ $loan->loan_code }}
Loan Status: {{ \App\Constants\LoanConstants::getStatusName($loan->level_status_id) }}
Loan Type: {{ $loan->loanType->product_name }}
Loan Officer: {{ $loan?->officers?->fullname ?? 'N/A' }}
Interest Type: {{ \App\Constants\LoanConstants::getInterestTypeName($loan->loanType->interest_method) }}

Financial Information

Principal Amount: {{ formatCurrencyDecimals($loan->principal_amount) }}
Interest Rate: {{ formatAmount($loan->interest_rate) }}%
Interest Amount: @if ( $loan->loanType->interest_method == \App\Constants\LoanConstants::DECLINING_BALANCE && $loan->level_status_id == \App\Constants\LoanConstants::PENDING) To be calculated @else {{ formatCurrencyDecimals($loan->interest_amount) }} @endif
Total Loan Amount: @if ( $loan->loanType->interest_method == \App\Constants\LoanConstants::DECLINING_BALANCE && $loan->level_status_id == \App\Constants\LoanConstants::PENDING) To be calculated @else {{ formatCurrencyDecimals($loan->loan_amount) }} @endif
Current Balance: @if ( $loan->loanType->interest_method == \App\Constants\LoanConstants::DECLINING_BALANCE && $loan->level_status_id == \App\Constants\LoanConstants::PENDING) To be calculated @else {{ formatCurrencyDecimals($loan->repaymentSchedules->sum('balance')) }} @endif

Additional Information

Number of Installments:

{{ formatAmount($loan->installments) }}

First Installment Date:

{{ date('d M, Y (D)', strtotime($loan->first_installment_date)) }}

@if (!is_null($loan->disbursement_on))

Disbursement Information

Disbursed On:

{{ $loan->disbursement_on?->format('l, d F Y') }}

@endif @if ($loan->comment)

Comments

{{ $loan->comment }}

@endif
@if ($loan->loanFiles->count() > 0)
File Name Upload Date @if (Auth::user()->can('file-delete') || Auth::user()->can('file-show')) Actions @endif @foreach ($loan->loanFiles as $file)
{{ $file->file_name }}
{{ $file->created_at?->format('d M, Y H:i') ?? 'N/A' }}
@if (Auth::user()->can('file-show')) @endif @if (Auth::user()->can('file-delete')) @endif
@endforeach
@else

No files uploaded

This loan doesn't have any files yet.

@if (Auth::user()->can('file-create')) Upload Files @endif
@endif
@if ($loan->collaterals->count() > 0)
Collateral Type Collateral Name Estimated Value ({{ getCurrencyCode() }}) @if (Auth::user()->can('loans-edit') || Auth::user()->can('loans-delete')) Actions @endif @foreach ($loan->collaterals as $collateral) {{ $collateral->type }} {{ $collateral->name }} {{ formatAmount($collateral->estimated_value) }}
@if (Auth::user()->can('loans-edit')) @endif @if (Auth::user()->can('loans-delete')) @endif
@endforeach

Collateral Summary

Total Items:

{{ $loan->collaterals->count() }}

Total Estimated Value:

{{ formatCurrencyDecimals($loan->collaterals->sum('estimated_value')) }}

@else

No collaterals added

This loan doesn't have any collateral items yet.

@if (Auth::user()->can('loans-create')) Add Collateral @endif
@endif
@if ($loan->charges)

Loan Charges

Charge Name Charge Type Charge Amount ({{ getCurrencyCode() }}) @forelse($loan->charges as $charge) {{ $charge->name }} {{ $charge->format == 'rate' ? 'Rate' . ' ' . $charge->amount . '%' : 'Fixed' }} {{ formatAmount($charge->pivot->amount) }} @empty No charges applied @endforelse
@endif @if ($loan->penalties && $loan->penalties->count() > 0)

Penalty Charges

@foreach ($loan->penalties as $penalty) @endforeach
Date Type Amount ({{ getCurrencyCode() }}) Status
{{ $penalty->created_at?->format('d M, Y') }} {{ $penalty->type ?? 'Late Payment' }} {{ formatAmount($penalty->amount) }} {{ ucfirst($penalty->status ?? 'pending') }}
Total Penalties: {{ formatCurrencyDecimals($loan->penalties->sum('amount')) }}
@endif

Total Charges Summary

Loan Charge:

{{ formatCurrencyDecimals( $loan->charges->sum(function ($charge) { return $charge->pivot->amount; }), ) }}

Penalties:

{{ formatCurrencyDecimals($loan->penalties?->sum('amount') ?? 0) }}

Total Charges: @php $totalCharges = $loan->charges->sum(function ($charge) { return $charge->pivot->amount; }) + ($loan->penalties?->sum('amount') ?? 0); @endphp

{{ formatCurrencyDecimals($totalCharges) }}

@if (!$loan->charge && !$loan->loanDisbursementFees && (!$loan->penalties || $loan->penalties->count() === 0))

No charges applied

This loan doesn't have any charges or fees yet.

@endif
@if ($loan->level_status_id == 1)
@if ($loan->repaymentSchedules->count() > 0)
Total Installments

{{ $loan->repaymentSchedules->count() }}

Paid

{{ $loan->repaymentSchedules->where('status', 'paid')->count() }}

Partial

{{ $loan->repaymentSchedules->where('status', 'partial')->count() }}

Pending

{{ $loan->repaymentSchedules->where('status', 'pending')->count() }}

# Date Installment Amount Principal Paid Interest Paid Balance Days in Arrears Status Actions @foreach ($loan->repaymentSchedules as $index => $schedule) {{ $index + 1 }} {{ $schedule->date?->format('d M, Y') ?? 'N/A' }} {{ formatAmount($schedule->amount) }} {{ formatAmount($schedule->principal_paid) }} {{ formatAmount($schedule->interest_paid) }} {{ formatAmount($schedule->balance) }} {{ formatAmount($schedule->days_in_arrears ?? 0) }} {{ ucfirst($schedule->status) }} @if (Auth::user()->can('loans-edit')) @endif @endforeach Loan Totals {{ formatAmount($loan->repaymentSchedules()->sum('amount')) }} {{ formatAmount($loan->repaymentSchedules()->sum('principal_paid')) }} {{ formatAmount($loan->repaymentSchedules()->sum('interest_paid')) }} {{ formatAmount($loan->repaymentSchedules()->sum('balance')) }}
@else

No repayment schedule

This loan doesn't have a repayment schedule yet.

@endif
@endif
@endsection