@extends('layouts.app') @section('style') @endsection @section('content')
{{ ucfirst($purchase->status) }}

@switch($purchase->status) @case('pending') Purchase is pending approval @break @case('approved') Purchase approved, waiting to be received @break @case('received') Purchase received, ready to add to inventory @break @case('completed') Purchase completed and added to inventory @break @case('delivered') Services delivered successfully @break @case('cancelled') Purchase cancelled @break @endswitch

@php $steps = [ 'pending' => ['label' => 'Pending', 'icon' => 'bx-time'], 'approved' => ['label' => 'Approved', 'icon' => 'bx-check'], 'received' => ['label' => 'Received', 'icon' => 'bx-package'], 'completed' => ['label' => 'Inventory', 'icon' => 'bx-package-check'], 'delivered' => ['label' => 'Delivered', 'icon' => 'bx-truck'] ]; $currentStep = array_search($purchase->status, array_keys($steps)); if ($currentStep === false) $currentStep = 0; @endphp @foreach($steps as $stepKey => $step)
@if($stepKey === $purchase->status || array_search($stepKey, array_keys($steps)) < $currentStep) @else {{ array_search($stepKey, array_keys($steps)) + 1 }} @endif
{{ $step['label'] }}
@endforeach
@if($purchase->status === 'pending') @endif @if($purchase->status === 'approved') @endif @if($purchase->status === 'received') @endif @if($purchase->status === 'completed') @php $hasServices = $purchase->items() ->where(function($q) { $q->where('item_type', 'service') ->orWhereHas('product', function($q) { $q->where('is_service', true); }); }) ->exists(); @endphp @if($hasServices) @endif @endif @if(in_array($purchase->status, ['pending', 'approved', 'received'])) @endif @if($purchase->status === 'pending') Edit Purchase @endif @if($purchase->grand_total > $purchase->paid_amount) Record Payment @endif
Invoice Number
{{ $purchase->invoice_no }}
Supplier
{{ $purchase->supplier->name }}
{{ $purchase->supplier->phone }}
Purchase Date
{{ $purchase->purchase_date->format('M d, Y') }}
Total Amount
KES {{ number_format($purchase->grand_total, 2) }}
Payment Status
{{ ucfirst($purchase->payment_status) }}
Paid: KES {{ number_format($purchase->paid_amount, 2) }} @if($purchase->grand_total > $purchase->paid_amount)
Due: KES {{ number_format($purchase->grand_total - $purchase->paid_amount, 2) }} @endif
Invoice Number

{{ $purchase->invoice_no }}

Supplier
{{ $purchase->supplier->name }}

{{ $purchase->supplier->phone }}

Purchase Date
{{ $purchase->purchase_date->format('M d, Y') }}

{{ $purchase->purchase_date->format('h:i A') }}

Total Amount

KES {{ number_format($purchase->grand_total, 2) }}

Purchase Items
@foreach($purchase->items as $item) @endforeach
Type Item Qty Unit Price Tax Total Status
@if($item->item_type === 'service' || ($item->product && $item->product->is_service)) Service @else Inventory @endif @if($item->item_type === 'service') {{ $item->description }} @else {{ $item->product->name ?? 'Product #' . $item->product_id }} @endif @if($item->item_type === 'product' && $item->product)
SKU: {{ $item->product->sku }} @endif @if($item->batch_number)
Batch: {{ $item->batch_number }} @endif @if($item->expiry_date)
Expires: {{ $item->expiry_date->format('M d, Y') }} @endif
{{ $item->quantity }} KES {{ number_format($item->unit_price, 2) }} @if($item->tax_percent) {{ $item->tax_percent }}%
KES {{ number_format($item->tax_amount, 2) }} @else - @endif
KES {{ number_format($item->total, 2) }} @if($item->added_to_stock) In Stock @elseif($item->item_type === 'service' || ($item->product && $item->product->is_service)) Service @else Pending @endif
Activity Timeline
Purchase Created

{{ $purchase->created_at->format('M d, Y h:i A') }}

Created by: {{ $purchase->creator->name ?? 'System' }}

@if($purchase->approved_at)
Purchase Approved

{{ $purchase->approved_at->format('M d, Y h:i A') }}

Approved by: {{ $purchase->approver->name ?? 'System' }}

@endif @if($purchase->received_at)
Purchase Received

{{ $purchase->received_at->format('M d, Y h:i A') }}

Received by: {{ auth()->user()->name }}

@endif @if($purchase->status === 'completed')
Added to Inventory

{{ $purchase->updated_at->format('M d, Y h:i A') }}

Inventory updated by system

@endif
@if($purchase->notes)
Notes

{{ $purchase->notes }}

@endif
@endsection @section('script') @endsection