Total Amount
{{ number_format($totalLoanAmount) }} Tshs
Paid Amount
{{ number_format($payments->sum('paid_amount')) }} Tshs
Due Amount
{{ number_format($totalLoanAmount - $payments->sum('paid_amount')) }} Tshs
All Users
{{ number_format($user->count()) }} People
Customers with Loans
@php
$count = 0;
$countedInstallations = [];
foreach ($loans as $loan) {
$totalAmount = $loan->loan_required_amount;
$paidAmount = $loan->payments->sum('paid_amount');
if ($totalAmount > $paidAmount) {
if (!in_array($loan->installation_id, $countedInstallations)) {
$count++;
$countedInstallations[] = $loan->installation_id;
}
}
}
@endphp
{{ $count }} People
Fully Paid Customers
@php
$fullyPaidCount = 0;
// Iterate through all users to check their loans
foreach ($users as $user) {
foreach ($user->loans as $loan) {
$totalAmount = $loan->loan_required_amount;
$paidAmount = $loan->payments->sum('paid_amount');
// Check if the loan is fully paid
if ($paidAmount >= $totalAmount) {
$fullyPaidCount++; // Increment count for loans with pending amount of 0
break; // No need to check further loans for this user
}
}
}
@endphp
{{ $fullyPaidCount }} People
Payments This Week
| Name | Time to Next Payment |
|---|---|
| {{ $payment->applicant_name }} | {{ $days }} {{ Str::plural('day', $days) }} |
| No payments this week. | |
Missed Payments
| Name | Days Past Due | Phone Number |
|---|---|---|
| No missed payments this week. | ||
| {{ $missed->applicant_name }} | {{ abs(round($missed->days_past_due )) }} days | {{ $missed->applicant_phone_number }} |
@if ($nearEndLoans->isEmpty())
@endif
No loans nearing end date.
@else
Loan Nearing End Date
| Name | Required | Pending Amount | Days Remaining | |
|---|---|---|---|---|
| {{ $loan->applicant_name }} | {{ number_format($loan->loan_required_amount) }} Tsh | {{ number_format($loan->loan_required_amount - $loan->payments->sum('paid_amount')) }} Tsh | {{--@php $now = Carbon::now(); $daysRemaining = $now->floatDiffInDays( $loan->loan_end_date, true, ); echo $daysRemaining < 1 ? round($daysRemaining * 24) . ' hours' : round($daysRemaining) . ' day' . (round($daysRemaining) !== 1 ? 's' : ''); @endphp | --}}@php $now = Carbon::now(); $end = Carbon::parse($loan->loan_end_date); $diffDays = $now->diffInDays($end, false); if ($diffDays < 0) { echo 'Expired'; } elseif ($diffDays <= 14) { echo intval(round($diffDays)) . ' day' . (intval(round($diffDays)) !== 1 ? 's' : ''); } else { // Usionyeshe kitu chochote (blank) kama zaidi ya 14 days echo ''; } @endphp |
{{ $nearEndLoans->onEachSide(1)->links() }}