@extends('layouts.admin') @section('page-title','Profit & Loss') @section('topbar-actions')
@foreach(['all'=>'All Time','month'=>'This Month','year'=>'This Year'] as $val=>$label) @endforeach
⬇️ Export CSV
@endsection @section('content') {{-- KPI STRIP --}}
Gross Revenue
${{ number_format($summary['revenue'],2) }}
Selling price × qty sold
Cost of Goods
${{ number_format($summary['cogs'],2) }}
Cost price × qty sold
Gross Profit
${{ number_format($summary['grossProfit'],2) }}
Revenue − COGS
Gross Margin
{{ $summary['margin'] }}%
Gross profit / revenue
{{-- CHARTS --}}
📈 Revenue vs Gross Profit (Monthly)
🍩 Revenue by Category
{{-- PRODUCT BREAKDOWN TABLE --}}
📋 Product P&L Breakdown
@if($byProd->isEmpty())

No confirmed or delivered orders yet.

@else @foreach($byProd as $row) @php $marginColor = $row->margin >= 50 ? 'var(--green)' : ($row->margin >= 25 ? 'var(--amber)' : 'var(--red)'); @endphp @endforeach
Product Qty Sold Revenue COGS Gross Profit Margin
{{ $row->product_name }} {{ number_format($row->qty_sold) }} ${{ number_format($row->revenue,2) }} ${{ number_format($row->cogs,2) }} ${{ number_format($row->gross_profit,2) }} {{ $row->margin }}%
@endif
@endsection @push('scripts') @endpush