@php use App\Support\FinanceApplicationStatuses; $monthNames = [ 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December', ]; $monthSelectOptions = []; foreach ($monthNames as $num => $label) { $monthSelectOptions[] = ['value' => (string) $num, 'label' => $label]; } $yearSelectOptions = collect($yearOptions ?? [])->map(fn ($y) => ['value' => (string) $y, 'label' => (string) $y])->all(); $statusFilterOptions = [['value' => '', 'label' => 'All statuses']]; foreach (($statusOptions ?? []) as $st) { $statusFilterOptions[] = ['value' => (string) $st, 'label' => FinanceApplicationStatuses::label($st)]; } $selectedStatusStr = $selectedStatus !== null ? (string) $selectedStatus : ''; $financeHouseFilterOptions = [['value' => '', 'label' => 'All finance houses']]; foreach (($financeHouseOptions ?? []) as $house) { $financeHouseFilterOptions[] = ['value' => (string) $house, 'label' => (string) $house]; } $selectedFinanceHouseStr = $selectedFinanceHouse !== null ? (string) $selectedFinanceHouse : ''; $userFilterOptions = [['value' => '', 'label' => 'All salespeople']]; foreach (($users ?? []) as $u) { $userLabel = trim(($u->name ?? '').' '.($u->surname ?? '')); $userFilterOptions[] = ['value' => (string) $u->id, 'label' => $userLabel !== '' ? $userLabel : ('User #'.$u->id)]; } $selectedUserStr = $selectedUserId !== null ? (string) $selectedUserId : ''; $canUpdateApplications = (bool) ($canUpdateApplications ?? false); $summaryMetrics = [ ['label' => 'Total', 'key' => 'total'], ['label' => 'Submitted', 'key' => 'submitted'], ['label' => 'Pending', 'key' => 'pending'], ['label' => 'Approved', 'key' => 'approved', 'value_class' => 'text-emerald-700'], ['label' => 'Declined', 'key' => 'declined', 'value_class' => 'text-red-700'], ['label' => 'Cancelled', 'key' => 'cancelled'], ]; @endphp {{ __('Finance Applications') }}
@foreach ($summaryMetrics as $metric)
{{ $metric['label'] }}
{{ number_format((int) data_get($summary, $metric['key'], 0)) }}
@endforeach
@if (! empty($isDealerWideView) && $isDealerWideView)
@endif

{{ number_format(count($applications ?? [])) }} record(s)

@forelse ($applications as $application) @php $salesperson = trim(($application->user?->name ?? '').' '.($application->user?->surname ?? '')); $creator = trim(($application->createdBy?->name ?? '').' '.($application->createdBy?->surname ?? '')); $editPayload = $canUpdateApplications ? [ 'updateUrl' => route('finance-applications.update', $application), 'leadLabel' => $application->lead?->displayNameForTable() ?? '', 'applicationDate' => optional($application->application_date)->format('Y-m-d') ?? '', 'applicantName' => $application->applicant_name, 'vehicleMake' => $application->vehicle_make ?? '', 'vehicleModel' => $application->vehicle_model ?? '', 'vehicleVariant' => $application->vehicle_variant ?? '', 'vehicleYear' => $application->vehicle_year ?? '', 'stockNumber' => $application->stock_number ?? '', 'financeHouse' => $application->finance_house ?? '', 'amountFinanced' => $application->amount_financed, 'deposit' => $application->deposit, 'termMonths' => $application->term_months, 'status' => $application->status, 'statusLabel' => \App\Support\FinanceApplicationStatuses::label((string) $application->status), 'isFinal' => \App\Support\FinanceApplicationStatuses::isFinal((string) $application->status), 'referenceNumber' => $application->reference_number ?? '', 'notes' => $application->notes ?? '', ] : null; @endphp @empty @endforelse
Date Lead Applicant Vehicle Finance house Amount Deposit Term Status Reference Salesperson Created by Notes
{{ optional($application->application_date)->format('Y-m-d') ?? '—' }} {{ $application->lead?->displayNameForTable() ?? '—' }} {{ $application->applicant_name }} {{ $application->displayVehicle() }} {{ $application->finance_house ?? '—' }} {{ $application->formattedAmountFinanced() }} {{ $application->formattedDeposit() }} {{ $application->term_months ?? '—' }} {{ $application->statusLabel() }} {{ $application->reference_number ?? '—' }} {{ $salesperson !== '' ? $salesperson : '—' }} {{ $creator !== '' ? $creator : '—' }}
No finance applications found for this period.
@if ($canUpdateApplications) @endif