Commission Owed
Employees with outstanding balances — {{ \Carbon\Carbon::parse($start)->format('d M Y') }} to {{ \Carbon\Carbon::parse($end)->format('d M Y') }}
@if(session('success'))
{{ session('success') }}
@endif
@php
$totalOwed = $owing->sum(fn($e) => round(($commissions[$e->id] ?? 0) - $e->employeePayments->sum('amount'), 2));
$totalEarned = array_sum($commissions);
@endphp
Total Owed
KSh {{ number_format($totalOwed, 2) }}
Total Earned
KSh {{ number_format($totalEarned, 2) }}
Staff Owed
{{ $owing->count() }}
@if($owing->isEmpty())
All commissions are settled for this period.
@else
@foreach($owing as $emp)
@php
$earned = $commissions[$emp->id] ?? 0;
$paid = $emp->employeePayments->sum('amount');
$balance = round($earned - $paid, 2);
$empBreakdown = $breakdown[$emp->id] ?? [];
$initials = collect(explode(' ', $emp->name))->map(fn($w) => strtoupper($w[0]))->take(2)->implode('');
@endphp
{{ $initials }}
{{ $emp->name }}
{{ $emp->display_role }}
Earned
KSh {{ number_format($earned, 2) }}
Paid
KSh {{ number_format($paid, 2) }}
Owed
KSh {{ number_format($balance, 2) }}
@if(count($empBreakdown))
| Date & Time |
Service |
Client |
Vehicle |
Sale |
Commission |
@foreach($empBreakdown as $line)
| {{ $line['sale_date'] }} |
{{ $line['service_name'] }} |
{{ $line['client'] }} |
@if($line['vehicle'] !== '—')
{{ $line['vehicle'] }}
@else
—
@endif
|
{{ $line['sale_total'] > 0 ? 'KSh ' . number_format($line['sale_total'], 2) : '—' }}
|
KSh {{ number_format($line['amount'], 2) }} |
@endforeach
| {{ count($empBreakdown) }} service{{ count($empBreakdown) !== 1 ? 's' : '' }} |
KSh {{ number_format($earned, 2) }} |
@else
No service records found for this period.
@endif
@endforeach
@endif