@extends('layouts.finance') @section('title', 'Inventory') @section('subtitle', 'Voucher stock, costs and margins') @section('content') @php $dateFilter = $dateFilter ?? ['active' => false, 'from' => null, 'to' => null, 'label' => null]; $activeTab = $activeTab ?? request('tab', 'available'); $rangeParams = ($dateFilter['active'] ?? false) ? ['from' => $dateFilter['from'], 'to' => $dateFilter['to']] : []; $soldVouchers = $soldVouchers ?? collect(); $soldVoucherError = $soldVoucherError ?? null; $soldVoucherRange = $soldVoucherRange ?? ['label' => now()->startOfMonth()->format('d M Y').' to '.now()->endOfMonth()->format('d M Y')]; $totalUnits = $products->sum(fn($p) => $p->stock); $totalValuePkr = $products->sum(fn($p) => (float) ($p->total_cost ?? ($p->stock * (float) $p->cost_price))); $soldQty = $soldVouchers->sum(fn($row) => (int) ($row['sold_qty'] ?? 0)); $soldRevenue = $soldVouchers->sum(fn($row) => (float) ($row['revenue'] ?? 0)); $soldProfit = $soldVouchers->sum(fn($row) => (float) ($row['profit'] ?? 0)); @endphp @include('dashboard.cards._date-filter', [ 'dateFilter' => $dateFilter, 'filterRoute' => 'finance.inventory', 'filterHidden' => ['tab' => $activeTab], ])
Available Vouchers Sold Vouchers
@if($activeTab === 'available')
@include('partials.kpi', ['label' => 'SKUs', 'value' => $products->count()]) @include('partials.kpi', ['label' => 'Total Units', 'value' => number_format($totalUnits)]) @include('partials.kpi', ['label' => 'Total Value', 'value' => 'PKR '.number_format($totalValuePkr, 2)])

Available Voucher Inventory

Expiry Priority {{ $inventorySource ?? 'examism_v3' }}
@if($inventoryError)
{{ $inventoryError }}
@endif @forelse($products as $product) @empty @endforelse
SKUNameSourceAvailable QtyAvg CostTotal CostSellCur.
{{ $product->sku }} {{ $product->name }} {{ $product->category }} {{ number_format($product->stock) }} {{ $metrics->money($product->cost_price, $product->currency) }} {{ $metrics->money($product->total_cost ?? ($product->stock * (float) $product->cost_price), $product->currency) }} {{ $metrics->money($product->selling_price, $product->currency) }} {{ $product->currency }}
No available inventory found in examism_v3.
@else

Sold Vouchers

Sale price and profit for {{ $soldVoucherRange['label'] }}
{{ number_format($soldQty) }} sold
@if($soldVoucherError)
{{ $soldVoucherError }}
@endif
@include('partials.kpi', ['label' => 'Sold Qty', 'value' => number_format($soldQty)]) @include('partials.kpi', ['label' => 'Sale Amount', 'value' => $metrics->money($soldRevenue, 'PKR'), 'color' => '#10b981']) @include('partials.kpi', ['label' => 'Profit', 'value' => $metrics->money($soldProfit, 'PKR'), 'color' => $soldProfit >= 0 ? '#10b981' : '#ef4444'])
@forelse($soldVouchers as $row) @empty @endforelse
Voucher Sold Qty Avg Sale Price Total Sale Avg Buying Total Cost Profit Margin
{{ $row['title'] ?? '-' }} {{ number_format((int) ($row['sold_qty'] ?? 0)) }} {{ $metrics->money((float) ($row['sale_price_per_voucher'] ?? 0), 'PKR') }} {{ $metrics->money((float) ($row['revenue'] ?? 0), 'PKR') }} {{ $metrics->money((float) ($row['buying_price_per_voucher'] ?? 0), 'PKR') }} {{ $metrics->money((float) ($row['cogs'] ?? 0), 'PKR') }} {{ $metrics->money((float) ($row['profit'] ?? 0), 'PKR') }} {{ number_format((float) ($row['margin'] ?? 0), 1) }}%
No sold vouchers found for this date range.
@endif @endsection