@include('loan.payments.partials.flash') @php $grain = (string) ($payload['grain'] ?? 'branch'); $totals = $payload['totals'] ?? []; $prior = $payload['prior'] ?? []; $periodLabel = (string) ($payload['period_label'] ?? ''); $priorLabel = (string) ($payload['prior_label'] ?? ''); $identityLabel = $grain === 'officer' ? 'Officer' : 'Branch'; $pctClass = static function (float $pct): string { if ($pct >= 85) { return 'text-emerald-700'; } if ($pct >= 70) { return 'text-amber-700'; } return 'text-rose-700'; }; $pts = static function (float $current, float $previous): string { $delta = round($current - $previous, 1); $sign = $delta > 0 ? '+' : ''; return $sign.number_format($delta, 1).' pts'; }; $filterQuery = collect(request()->query())->except(['page'])->all(); $branchSelected = (int) ($loanBranchId ?? 0) > 0 || trim((string) ($branch ?? '')) !== ''; $clearBranchQuery = collect($filterQuery)->except(['loan_branch_id', 'branch', 'employee_id'])->all(); $chips = [ ['label' => 'OTC%', 'display' => number_format((float) ($totals['otc_percent'] ?? 0), 1).'%'], ['label' => 'OC%', 'display' => number_format((float) ($totals['oc_percent'] ?? 0), 1).'%'], ['label' => 'GC%', 'display' => number_format((float) ($totals['gc_percent'] ?? 0), 1).'%'], ['label' => 'Arrears', 'display' => 'KES '.number_format((float) ($totals['arrears'] ?? 0), 0)], ['label' => 'Disbursed', 'display' => 'KES '.number_format((float) ($totals['disbursed_loan'] ?? 0), 0)], ]; if ($priorLabel !== '' && (float) ($prior['loan_plus_charges'] ?? 0) > 0.01) { $chips[] = [ 'label' => 'vs '.$priorLabel, 'display' => 'OTC '.$pts((float) ($totals['otc_percent'] ?? 0), (float) ($prior['otc_percent'] ?? 0)), ]; } @endphp
@if ($grain === 'officer' && $branchSelected)

Officers in this branch. Back to branches

@elseif ($grain === 'officer')

Showing loan officers in your visibility scope. Ranked by OTC% (quality), then OC%, then GC%.

@else

Corporate view — open a branch to see which officers drive that result. Ranked by OTC% first.

@endif
@if ($grain === 'officer') @endif @forelse ($payload['rows'] ?? [] as $row) @php $drillHref = null; if ($grain === 'branch') { $drill = $filterQuery; if ((int) $row->loan_branch_id > 0) { $drill['loan_branch_id'] = (int) $row->loan_branch_id; unset($drill['branch']); } else { $drill['branch'] = (string) $row->branch; unset($drill['loan_branch_id']); } $drillHref = route('loan.book.collections.rates', $drill); } @endphp @if ($grain === 'officer') @endif @empty @endforelse @if (($payload['rows'] ?? collect())->isNotEmpty()) @if ($grain === 'officer') @endif @endif
# {{ $identityLabel }}Branch Disbursed Loan Loan + Charges OTC OC DD7 CG7 Penalties Arrears OTC % OC % GC %
{{ $loop->iteration }} {{ $row->label }} @if ((int) ($row->loan_count ?? 0) > 0) {{ number_format((int) $row->loan_count) }} loan{{ (int) $row->loan_count === 1 ? '' : 's' }} @endif {{ $row->branch }}{{ number_format($row->disbursed_loan, 0) }} {{ number_format($row->loan_plus_charges, 0) }} {{ number_format($row->otc, 0) }} {{ number_format($row->oc, 0) }} {{ number_format($row->dd7, 0) }} {{ number_format($row->cg7, 0) }} {{ number_format($row->penalties, 0) }} {{ number_format($row->arrears, 0) }} {{ number_format($row->otc_percent, 1) }}% {{ number_format($row->oc_percent, 1) }}% {{ number_format($row->gc_percent, 1) }}%
No loans were disbursed in {{ $periodLabel }} for this scope.
TOTAL {{ number_format((int) ($totals['loan_count'] ?? 0)) }} loans {{ number_format($totals['disbursed_loan'] ?? 0, 0) }} {{ number_format($totals['loan_plus_charges'] ?? 0, 0) }} {{ number_format($totals['otc'] ?? 0, 0) }} {{ number_format($totals['oc'] ?? 0, 0) }} {{ number_format($totals['dd7'] ?? 0, 0) }} {{ number_format($totals['cg7'] ?? 0, 0) }} {{ number_format($totals['penalties'] ?? 0, 0) }} {{ number_format($totals['arrears'] ?? 0, 0) }} {{ number_format($totals['otc_percent'] ?? 0, 1) }}% {{ number_format($totals['oc_percent'] ?? 0, 1) }}% {{ number_format($totals['gc_percent'] ?? 0, 1) }}%