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

Income Management

Track all income sources from loans, charges, and penalties

Loan Charges Summary

Income generated from loan-related charges

Total Amount

{{ formatCurrencyDecimals($loanCharges->sum(function($loan) { return $loan->charges->sum('pivot.amount'); })) }}

@if($loanCharges->count() > 0)
Loan Code
Charge Type
{{getCurrencyCode()}} Amount
Date Applied
Actions
@foreach ($loanCharges as $loanCharge) @foreach ($loanCharge->charges as $charge)
{{ $loanCharge?->loan_code }}
{{ $loanCharge?->charge?->name }}
{{ formatAmount($charge?->pivot->amount) }} {{ $charge?->pivot->created_at ? \Carbon\Carbon::parse($charge->pivot->created_at)->format('d M, Y') : 'N/A' }} View Loan
@endforeach @endforeach
@else

No loan charges found

No income from loan charges has been recorded yet.

@endif

Client Charges Summary

Income generated from client-specific charges

Total Amount

{{ formatCurrencyDecimals($clientCharges->sum('charge.amount')) }}

@if($clientCharges->count() > 0)
Charge Type
{{getCurrencyCode()}} Amount
Date Paid
Client Name
Actions
@foreach ($clientCharges as $clientCharge)
{{ $clientCharge?->charge?->name }}
{{ formatAmount($clientCharge?->charge?->amount) }} {{ $clientCharge?->created_at->format('D, d M Y') }}
{{ $clientCharge?->fullname }}
@if ($clientCharge) View Client @endif
@endforeach
@else

No client charges found

No income from client charges has been recorded yet.

@endif

Loan Interests Summary

Income generated from loan interest payments

Total Amount

{{ formatCurrencyDecimals($loanInterests->sum('interest_paid')) }}

@if($loanInterests->count() > 0)
Loan Code
{{getCurrencyCode()}} Interest Amount
Date Paid
Payment Status
Actions
@foreach ($loanInterests as $loanInterest)
{{ $loanInterest?->loan?->loan_code }}
{{ formatAmount($loanInterest?->interest_paid) }} {{ $loanInterest?->updated_at->format('D, d M Y') }} {{ ucfirst($loanInterest->status ?? 'pending') }} @if ($loanInterest?->loan) View Loan @endif
@endforeach
@else

No loan interests found

No income from loan interests has been recorded yet.

@endif

Loan Penalties Summary

Income generated from loan penalty charges

Total Amount

{{ formatCurrencyDecimals($loanPenalties->sum('amount')) }}

@if($loanPenalties->count() > 0)
Loan Code
Penalty Type
{{getCurrencyCode()}} Amount
Date Applied
Status
Actions
@foreach ($loanPenalties as $penalty)
{{ $penalty?->loan?->loan_code }}
{{ $penalty?->loanProductPenalty?->name ?? 'Late Payment' }}
{{ formatAmount($penalty?->amount) }} {{ $penalty?->created_at?->format('D, d M Y') ?? 'N/A' }} {{ isset($penalty->payment) && $penalty->payment ? 'Paid' : 'Pending' }} @if ($penalty?->loan) View Loan @endif
@endforeach
@else

No loan penalties found

No income from loan penalties has been recorded yet.

@endif

Overall Income Summary

Loan Charges

{{ formatCurrencyDecimals($loanCharges->sum(function($loan) { return $loan->charges->sum('pivot.amount'); })) }}

Client Charges

{{ formatCurrencyDecimals($clientCharges->sum('charge.amount')) }}

Loan Interests

{{ formatCurrencyDecimals($loanInterests->sum('interest_paid')) }}

Loan Penalties

{{ formatCurrencyDecimals($loanPenalties->sum('amount')) }}

Total Income

@php $grandTotal = $loanCharges->sum(function($loan) { return $loan->charges->sum('pivot.amount'); }) + $clientCharges->sum('charge.amount') + $loanInterests->sum('interest_paid') + $loanPenalties->sum('amount'); @endphp {{ formatCurrencyDecimals($grandTotal) }}

@endsection