@if ($canManage) {{ __('Add loan') }} @endif
@if ($loans->isEmpty()) @if ($canManage) {{ __('Add a loan') }} @endif @else
@foreach ($loans as $loan)

{{ $loan->lender }}

{{ $loan->status === 'active' ? __('Active') : __('Closed') }}

{{ $loan->member->name ?? __('—') }} @if ($loan->source) · {{ __('deducts from') }} {{ $loan->source->name }} @endif

{{ __('Principal') }}

{{ $loan->currency_code }} {{ number_format($loan->principal, 2) }}

{{-- Progress --}}
{{ __('Paid') }} {{ $loan->currency_code }} {{ number_format($loan->paid_amount, 2) }} {{ __('Outstanding') }} {{ $loan->currency_code }} {{ number_format($loan->outstanding_amount, 2) }}

{{ $loan->progress_pct }}% · {{ $loan->installments->where('status', 'paid')->count() }}/{{ $loan->installments->count() }} {{ __('installments') }}

{{ $expandedId === $loan->id ? __('Hide schedule') : __('View schedule') }} @if ($canManage) {{ __('Edit') }} @endif
@if ($expandedId === $loan->id)
@foreach ($loan->installments->sortBy('sequence') as $i) @endforeach
# {{ __('Due') }} {{ __('Amount') }} {{ __('Status') }} {{ __('Action') }}
{{ $i->sequence }} {{ $i->due_date?->format('j M Y') }} {{ number_format($i->amount, 2) }} @if ($i->status === 'paid') {{ __('Paid') }}@if ($i->household_income_id) · {{ __('salary') }} @endif @else {{ __('Pending') }} @endif @if ($canManage) @if ($i->status === 'paid') @else @endif @endif
@endif
@endforeach
@endif
{{ $editingId ? __('Edit loan') : __('Add loan') }}

{{ __('When you record that salary, the next installment is deducted automatically.') }}

{{ __('Cancel') }} {{ __('Save loan') }}