@push('header') @endpush
{{-- Report Header --}}

Moon Traders
Product Wise Sales Report
Period: {{ \Carbon\Carbon::parse($startDate)->format('d-M-Y') }} to {{ \Carbon\Carbon::parse($endDate)->format('d-M-Y') }} @php $filters = []; if ($employeeId) $filters[] = 'Salesman: ' . ($employees->firstWhere('id', $employeeId)->name ?? ''); if ($vehicleId) $filters[] = 'Vehicle: ' . ($vehicles->firstWhere('id', $vehicleId)->vehicle_number ?? ''); if ($warehouseId) $filters[] = 'Warehouse: ' . ($warehouses->firstWhere('id', $warehouseId)->warehouse_name ?? ''); @endphp @if(count($filters) > 0)
{!! implode(' | ', $filters) !!} @endif

@foreach ($productSales as $product) @endforeach @if($productSales->count() > 0) @endif
Sr# Product Name Avg Price Sold Qty Rtn Qty Short Qty Net Sales Net Profit NP %
{{ $loop->iteration }} {{ $product->product_name }} {{ number_format($product->avg_selling_price, 2) }} {{ number_format($product->total_sold, 0) }} {{ number_format($product->total_returned, 0) }} {{ number_format($product->total_shortage, 0) }} {{ number_format($product->total_sales_value, 2) }} {{ number_format($product->net_profit, 2) }} @php $npMargin = $product->total_sales_value > 0 ? ($product->net_profit / $product->total_sales_value) * 100 : 0; @endphp {{ number_format($npMargin, 2) }}%
Total ({{ $productSales->count() }} Rows): {{ number_format($totals['total_sold'], 0) }} {{ number_format($totals['total_returned'], 0) }} {{ number_format($totals['total_shortage'], 0) }} {{ number_format($totals['total_sales_value'], 2) }} {{ number_format($totals['net_profit'], 2) }} @php $totalNpMargin = $totals['total_sales_value'] > 0 ? ($totals['net_profit'] / $totals['total_sales_value']) * 100 : 0; @endphp {{ number_format($totalNpMargin, 2) }}%
@push('scripts') @endpush