@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
| # | Manager | Month | Status | Description | Created By | Approved By | Date | Advance Amount (TK) | Installments | Per Install (TK) | @canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history'])Action | @endcanany
|---|---|---|---|---|---|---|---|---|---|---|---|
| Total: | {{ number_format($totalAdvance, 2) }} | {{ $totalInstallments }} | {{ number_format($totalPerInstall, 2) }} | @canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history'])@endcanany | |||||||
| {{ $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) }} | @canany(['reseller-advance-commission-edit','reseller-advance-commission-approve','reseller-advance-commission-delete','reseller-advance-commission-history']){{-- 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) @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 | @endcanany
| No advance commission records found. | |||||||||||