{{$business->name}}

Commission Agent Report

@if(!empty($location_details))

Location: {{ $location_details->name }}

@endif @if(!empty($start_date) && !empty($end_date))

From {{ @format_date($start_date) }} to {{ @format_date($end_date) }}

@endif
@php $current_agent = null; $agent_qty = 0; $agent_cost = 0; $agent_sale = 0; $agent_profit = 0; $total_qty = 0; $total_cost = 0; $total_sale = 0; $total_profit = 0; @endphp @foreach($report_data as $data) @php $profit = $data->net_sale - $data->total_cost; @endphp @if ($current_agent !== $data->agent_name && $current_agent !== null) {{-- Print Agent Subtotal --}} @php // Reset Agent Totals $agent_qty = 0; $agent_cost = 0; $agent_sale = 0; $agent_profit = 0; @endphp @endif @if($current_agent !== $data->agent_name) @php $current_agent = $data->agent_name; @endphp @endif @php $p_class = $profit >= 0 ? 'profit-pos' : 'profit-neg'; @endphp @php $agent_qty += $data->quantity; $agent_cost += $data->total_cost; $agent_sale += $data->net_sale; $agent_profit += $profit; $total_qty += $data->quantity; $total_cost += $data->total_cost; $total_sale += $data->net_sale; $total_profit += $profit; @endphp @endforeach @if($current_agent !== null) {{-- Final Agent Subtotal --}} @endif
Item Name ItemCode Sold Qty Total Cost Cost Code Net Sale Profit OR Loss
{{ $data->agent_name }}
{{ $data->product_name }} {{ $data->sku }} {{ @num_format($data->quantity) }} {{ @num_format($data->total_cost) }} {{ $data->cost_code }} {{ @num_format($data->net_sale) }}{{ @num_format($profit) }}