@php $totalAdvance = (float) $list->sum('amount'); $totalInstallments = (int) $list->sum('installment_count'); // Each row's own per-instalment figure, added up — the instalment counts differ, so // this is not $totalAdvance / $totalInstallments. $totalPerInstall = (float) $list->sum(function ($item) { return $item->installment_count > 0 ? $item->amount / $item->installment_count : 0; }); @endphp
Total: {{ $list->count() }} Total Advance: {{ number_format($list->sum('amount'), 2) }} TK Approved: {{ number_format($list->where('status','approved')->sum('amount'), 2) }} TK Pending: {{ number_format($list->where('status','pending')->sum('amount'), 2) }} TK
@canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history']) @endcanany {{-- The Total row lives in , above the rows, so it stays put under the sticky header instead of sitting at the far end of a long list. --}} @canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history']) @endcanany @forelse($list as $item) @php $perInstall = $item->installment_count > 0 ? $item->amount / $item->installment_count : 0; @endphp @canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history']) @endcanany @empty @endforelse
# Manager Month Status Description Created By Approved By Date Advance Amount (TK) Installments Per Install (TK)Action
Total: {{ number_format($totalAdvance, 2) }} {{ $totalInstallments }} {{ number_format($totalPerInstall, 2) }}
{{ $loop->iteration }} {{ $item->reseller->name_with_type ?? 'N/A' }} {{ $item->advance_month ? $item->advance_month->format('M Y') : '-' }} @if($item->recovery_start_month)
Recovery from {{ $item->recovery_start_month->format('M Y') }} @endif
@include('partials.approval-status', ['item' => $item]) @include('partials.approval-comment', ['item' => $item]) {{ $item->description ?? '-' }} {{ $item->createdBy->name ?? 'N/A' }} @if($item->approved_by) {{ $item->approvedBy->name ?? 'N/A' }}
{{ $item->approved_at ? $item->approved_at->format('d M Y') : '' }} @else - @endif
{{ $item->created_at->format('d M Y h:i A') }} {{ number_format($item->amount, 2) }} {{ $item->installment_count }} {{ number_format($perInstall, 2) }} {{-- An approved advance stays editable/deletable, but only for a user who also holds the *-approved permission. --}} @php $isApproved = $item->status === 'approved'; $canEditRow = auth()->user()->can('reseller-advance-commission-edit') && (!$isApproved || auth()->user()->can('reseller-advance-commission-edit-approved')); $canDeleteRow = auth()->user()->can('reseller-advance-commission-delete') && (!$isApproved || auth()->user()->can('reseller-advance-commission-delete-approved')); @endphp @if ($canEditRow) @endif @if ($canDeleteRow)
@csrf @method('DELETE')
@endif @can('reseller-advance-commission-approve') @include('partials.approval-decision-buttons', [ 'item' => $item, 'url' => route('reseller-advance-commission.approve', $item->id), 'label' => 'advance entry', 'size' => 'btn-xs', ]) @endcan @php $advPaid = (float) ($item->payments_sum_amount ?? 0); $advRemaining = max(0, (float) $item->amount - $advPaid); @endphp @if ($item->status === 'approved') @can('reseller-advance-commission-payment') @if ($advRemaining > 0) @endif @if ($advPaid > 0) @endif @endcan @endif @can('reseller-advance-commission-history') History @endcan
No advance commission records found.
{{-- Edit Modal --}}