@php if (! isset($hasLoan) || ! isset($canBookLoan) || ! isset($stage)) { $bookingContext = \App\Support\LoanBook\Application360BookingContext::resolve( $application, (bool) ($approvalEngineEnabled ?? false), ); $stage = $stage ?? $bookingContext['stage']; $hasLoan = $hasLoan ?? $bookingContext['hasLoan']; $canBookLoan = $canBookLoan ?? $bookingContext['canBookLoan']; } @endphp @if ($fragmentTab === 'overview')
@php // Lazy tab fragments skip show.blade.php, so rebuild overview locals when missing. if (! isset($overviewProfileFields) || ! isset($overviewProductFields)) { $productMeta = ($productMetaByName ?? [])[$application->product_name] ?? null; $chargesSummary = trim((string) ($productMeta['charges_summary'] ?? '')); $submittedDisplay = optional($application->submitted_at)->format('d-M-Y') ?: '—'; $termDisplay = ($application->term_value ?? $application->term_months).' '.str($application->term_unit ?? 'monthly')->headline(); $interestDisplay = $application->interest_rate !== null ? number_format((float) $application->interest_rate, 4).' % per '.($application->interest_rate_period ?? 'annual') : '—'; $activeLoanHandling = (string) data_get($application->form_meta, 'active_loan_handling', ''); $balanceCheckoffAmount = (float) data_get($application->form_meta, 'balance_checkoff.amount', 0); $balanceCheckoffNet = (float) data_get( $application->form_meta, 'balance_checkoff.net_amount', max(0, (float) $application->amount_requested - $balanceCheckoffAmount), ); $overviewProfileFields = $overviewProfileFields ?? [ ['label' => 'Client #', 'value' => $application->loanClient?->client_number ?? '—'], ['label' => 'Borrower', 'value' => $application->loanClient?->full_name ?? '—'], ['label' => 'Submitted', 'value' => $submittedDisplay], ['label' => 'Submission source', 'value' => $application->submission_source ?: '—'], ]; $displayAmount = $application->displayPrincipal(); $schedule = (array) data_get($application->form_meta, 'schedule_calculation', []); $requestedAmount = (float) ($application->amount_requested ?? 0); $amountFields = [ ['label' => 'Amount', 'value' => 'KES '.number_format($displayAmount, 2), 'numeric' => true], ]; if ($application->approved_principal !== null && abs($displayAmount - $requestedAmount) > 0.009) { $amountFields[] = [ 'label' => 'Amount requested', 'value' => 'KES '.number_format($requestedAmount, 2), 'numeric' => true, ]; } $overviewProductFields = $overviewProductFields ?? array_merge($amountFields, [ ['label' => 'Product', 'value' => $application->product_name], ...($activeLoanHandling !== '' ? [[ 'label' => 'Active-loan handling', 'value' => str($activeLoanHandling)->headline(), ]] : []), ...($activeLoanHandling === 'balance_checkoff' ? [ ['label' => 'Balance checkoff', 'value' => 'KES '.number_format($balanceCheckoffAmount, 2), 'numeric' => true], ['label' => 'Client receives', 'value' => 'KES '.number_format($balanceCheckoffNet, 2), 'numeric' => true], ] : []), ['label' => 'Loan term', 'value' => $termDisplay], ['label' => 'Term (months eq.)', 'value' => (string) $application->term_months], ['label' => 'Interest', 'value' => $interestDisplay], ['label' => 'Charges', 'value' => $chargesSummary !== '' ? $chargesSummary : '—'], ['label' => 'Repayment frequency', 'value' => str($application->term_unit ?? 'monthly')->headline()], ]); } if (! isset($timelineEvents)) { $timelineEvents = collect(); if ($approvalRequest ?? null) { foreach ($approvalRequest->actions as $action) { $timelineEvents->push([ 'label' => str($action->action_type)->headline(), 'meta' => trim(($action->actor?->name ?? 'System').($action->step_key ? ' · '.$action->step_key : '')), 'at' => $action->created_at, 'detail' => $action->comments, ]); } } if ($application->submitted_at) { $timelineEvents->push([ 'label' => 'Application submitted', 'meta' => $application->submission_source ?: 'Origination', 'at' => $application->submitted_at, 'detail' => null, ]); } $timelineEvents = $timelineEvents->sortByDesc(fn ($event) => optional($event['at'])->timestamp ?? 0)->values()->all(); } $overview = $commandCentreOverview ?? []; $askBlockers = $askReadiness['blockers'] ?? ($overview['blockers'] ?? []); $productDisplayFields = array_merge($overviewProductFields ?? [], array_filter([ ['label' => 'Est. installment', 'value' => isset($overview['installment_total']) ? number_format((float) $overview['installment_total'], 2) : null, 'numeric' => true], ['label' => 'Total repayable', 'value' => isset($overview['total_repayable']) ? number_format((float) $overview['total_repayable'], 2) : null, 'numeric' => true], ], fn ($row) => filled($row['value'] ?? null))); $purposeText = filled($application->purpose) ? $application->purpose : null; $notesText = filled($application->notes) ? $application->notes : null; @endphp
@include('loan.book.applications.partials.application-360-metadata-grid', ['fields' => $overviewProfileFields]) @include('loan.book.applications.partials.application-360-metadata-grid', ['fields' => $productDisplayFields]) @if ($askLocked ?? false)

{{ $askLockReason ?? 'Loan request is locked for this stage.' }}

@if (! ($askAmountLocked ?? true) || ! ($askProductLocked ?? true))

The requested amount and product can still be revised from Edit application.

@endif @endif
Purpose
{{ $purposeText ?? 'Not provided' }}
Notes
{{ $notesText ?? 'Not provided' }}
@include('loan.book.applications.partials.application-360-origination-fees-summary') @if (! empty($askBlockers))

Current blockers

    @foreach ($askBlockers as $blocker)
  • {{ is_array($blocker) ? ($blocker['label'] ?? '') : $blocker }} @if (is_array($blocker) && ! empty($blocker['action_url'])) — {{ $blocker['action_label'] ?? 'Open' }} @endif
  • @endforeach
@endif @include('loan.book.applications.partials.application-360-timeline')
@endif @if ($fragmentTab === 'evidence')
@include('loan.book.applications.partials.application-360-evidence-body')
@endif @if ($fragmentTab === 'guarantors')
@include('loan.book.applications.partials.application-360-guarantors')
@endif @if ($fragmentTab === 'appraisal' && ($application->requiresRetailAppraisal() ?? false))
@include('loan.book.applications.partials.application-360-appraisal')
@endif @if ($fragmentTab === 'mpesa_analysis')
@include('loan.book.applications.partials.application-360-mpesa-analysis-results', [ 'application' => $application, 'statementAnalyses' => $statementAnalyses ?? collect(), 'statementSnapshot' => $statementSnapshot ?? null, 'statementCapabilities' => $statementCapabilities ?? ['ok' => false, 'errors' => []], 'providerSummary' => $providerSummary ?? ['wallet_currency' => 'KES', 'analysis_cost' => 10, 'wallet_ok' => false], 'resultsAnalysis' => $resultsAnalysis ?? null, 'canRequestAnalysis' => auth()->user()?->hasLoanPermission('statement-analysis.request') ?? false, 'canAttachSnapshot' => auth()->user()?->hasLoanPermission('statement-analysis.attach') ?? false, 'canRefreshAnalysis' => auth()->user()?->hasLoanPermission('statement-analysis.refresh') ?? false, ])
@endif @if ($fragmentTab === 'credit_decision')
@if ($creditDecisionRecord ?? null) @include('loan.book.applications.partials.application-360-credit-decision') @else

No credit decision yet

@endif
@endif @if ($fragmentTab === 'approval')
@include('loan.book.applications.partials.approval-panel')
@endif @if ($fragmentTab === 'origination_fees')
@include('loan.book.applications.partials.application-360-origination-fees')
@endif @if ($fragmentTab === 'documents') @include('loan.book.applications.partials.application-360-documents-tab') @endif @if ($fragmentTab === 'disbursement')
@include('loan.book.applications.partials.application-360-disbursement-panel', [ 'application' => $application, 'disbursementWorkspace' => $disbursementWorkspace ?? [], 'disbursementAllowed' => $disbursementAllowed ?? false, 'approvalEngineEnabled' => $approvalEngineEnabled ?? false, 'hasLoan' => $hasLoan ?? null, 'canBookLoan' => $canBookLoan ?? null, ])
@endif