@extends('layouts.app') @section('title', 'Purchase') @section('page', 'purchases') @php $statusVariant = fn ($s) => match ($s) { 'Received' => 'success', 'Ordered' => 'info', 'Partial' => 'warning', 'Cancelled' => 'danger', default => 'neutral', }; @endphp @section('content') @if (session('success')) {{ session('success') }} @endif @if ($errors->any()) {{ $errors->first() }} @endif

Total Orders

{{ $totalOrders }}

In selected period

Ordered

{{ $ordered }}

Awaiting delivery

Received

{{ $received }}

Fully received

Total Value

{{ number_format($totalValue, 2) }}

In selected period

@forelse ($purchases as $row) @php $purchaseItemsPayload = $row->items->map(static function ($item) { return [ 'stock_item_id' => $item->stock_item_id, 'code' => $item->stockItem?->code, 'name' => $item->stockItem?->name, 'qty' => $item->qty, 'unit_cost' => (float) $item->unit_cost, ]; })->values(); $typeVariant = $row->type === 'Return' ? 'warning' : 'info'; $paymentLabel = match ($row->payment_method) { 'credit' => 'Credit', 'bank' => 'Bank', default => 'Cash', }; $paymentVariant = match ($row->payment_method) { 'credit' => 'warning', 'bank' => 'info', default => 'success', }; @endphp {{ $row->po_number }} {{ $row->type }} {{ $row->purchase_date?->format('Y-m-d') }} {{ $row->supplier?->name ?? '—' }} {{ $row->warehouse?->name ?? '—' }} {{ $row->items_count }} {{ number_format((float) $row->total, 2) }} {{ $paymentLabel }} {{ $row->status }}
@empty No purchase orders for this period. Adjust the date filter or add a purchase. @endforelse
@endsection @push('styles') @endpush @push('scripts') @endpush