@extends('admin.layout.app') @section('title', 'Vendor Sales Report') @section('content')

Vendor Sales Report

Reset Attribution is inferred by matching `vendor_products.sp` to the sold item price.
Summary
Vendors
{{ $totals['vendors_count'] ?? 0 }}
Orders
{{ $totals['orders_count'] ?? 0 }}
Qty Sold
{{ $totals['qty_sold'] ?? 0 }}
Revenue
₹{{ number_format($totals['revenue'] ?? 0, 2) }}
@php // Group by vendor from productBreakdown to create vendor summary $vendorSummary = $productBreakdown->groupBy('vendor_id')->map(function ($items, $vendorId) { return (object) [ 'vendor_id' => $vendorId, 'business_name' => $items->first()->business_name ?? null, 'vendor_name' => $items->first()->vendor_name ?? null, 'qty_sold' => $items->sum('qty_sold'), 'revenue' => $items->sum('revenue'), ]; })->values(); @endphp
Vendor-wise Sales
@forelse($vendorSummary as $row) @empty @endforelse
Vendor Qty Sold Revenue (₹)
{{ $row->business_name ?? $row->vendor_name ?? ('Vendor #' . $row->vendor_id) }} {{ $row->qty_sold }} ₹{{ number_format($row->revenue, 2) }}
No vendor sales found for this period.
@if($viewType === 'daily' && $dailyBreakdown)
Daily Breakdown
@forelse($dailyBreakdown as $row) @empty @endforelse
Date Orders Qty Sold Revenue (₹)
{{ \Carbon\Carbon::parse($row->date)->format('d M Y') }} {{ $row->orders_count }} {{ $row->qty_sold }} ₹{{ number_format($row->revenue, 2) }}
No daily sales found.
@endif @if($viewType === 'monthly' && $monthlyBreakdown)
Monthly Breakdown
@forelse($monthlyBreakdown as $row) @empty @endforelse
Month Orders Qty Sold Revenue (₹)
{{ \Carbon\Carbon::create($row->year, $row->month)->format('M Y') }} {{ $row->orders_count }} {{ $row->qty_sold }} ₹{{ number_format($row->revenue, 2) }}
No monthly sales found.
@endif @if($viewType === 'summary')
Product Breakdown (Attributed)
{{ $productBreakdown->count() }} rows
@forelse($productBreakdown as $row) @empty @endforelse
Vendor Product Qty Sold Revenue (₹)
{{ $row->business_name ?? $row->vendor_name ?? ('Vendor #' . $row->vendor_id) }} {{ $row->product_name ?? ('Product #' . $row->product_id) }} {{ $row->qty_sold }} ₹{{ number_format($row->revenue, 2) }}
No attributed product sales found.
@endif
@endsection