@extends('layouts.app') @section('title','Profit Report')@section('page-title','Profit & Margin Report') @section('content')
@if(auth()->user()->isAdmin())
@endif
@foreach([['$'.number_format($summary['total_revenue'],2),'Total Revenue (USD)','stat-card-1','bi-graph-up-arrow'],['$'.number_format($summary['total_cost'],2),'Total COGS','stat-card-2','bi-cart-dash'],['$'.number_format($summary['gross_profit'],2),'Gross Profit','stat-card-3','bi-piggy-bank'],[number_format($summary['avg_margin'],1).'%','Avg Gross Margin','stat-card-4','bi-percent']] as [$val,$label,$cls,$icon])
{{ $val }}
{{ $label }}
@endforeach
@if($profitData->count())
Top 10 by Profit
@php $top10 = $profitData->sortByDesc('profit')->take(10); $maxP = $top10->max('profit') ?: 1; @endphp @foreach($top10 as $row)
{{ Str::limit($row['product'],40) }}${{ number_format($row['profit'],2) }} ({{ number_format($row['margin'],1) }}%)
@endforeach
@endif
Full Profit Detail
{{ $profitData->count() }} products sold
@forelse($profitData->sortByDesc('profit') as $row) @empty @endforelse @if($profitData->count()) @endif
ProductCategoryQtyRevenue (USD)COGSGross ProfitMargin
{{ $row['product'] }} {{ $row['category'] }} {{ number_format($row['qty']) }} ${{ number_format($row['revenue'],2) }} ${{ number_format($row['cost'],2) }} {{ $row['profit']>=0?'+':'' }}${{ number_format($row['profit'],2) }} {{ number_format($row['margin'],1) }}%

No sales in this period.

TOTALS{{ number_format($profitData->sum('qty')) }}${{ number_format($summary['total_revenue'],2) }}${{ number_format($summary['total_cost'],2) }}${{ number_format($summary['gross_profit'],2) }}{{ number_format($summary['avg_margin'],1) }}%
@endsection