{{-- resources/views/purchases/index.blade.php --}} @extends('layouts.app') @section('title', 'Purchases') @section('content')

Purchases

New Purchase
@if(session('ok'))
{{ session('ok') }}
@endif @forelse($purchases as $purchase) @php $collapseId = 'purchaseItems'.$purchase->id; $hasItems = $purchase->items && $purchase->items->count() > 0; @endphp {{-- Summary Row --}} {{-- Click to view items --}} {{-- Collapsible Items Row --}} @empty @endforelse
ID Invoice Date Supplier Subtotal Paid Due Items
{{ $purchase->id }} {{ $purchase->invoice_no }} {{ $purchase->date ? \Carbon\Carbon::parse($purchase->date)->format('d-m-Y') : '-' }} {{ $purchase->supplier->name ?? 'N/A' }} {{ number_format((float)$purchase->total, 2) }} {{ number_format((float)$purchase->paid, 2) }} {{ number_format((float)$purchase->due, 2) }} @if($hasItems) @else No items @endif
Items Invoice: {{ $purchase->invoice_no }} | Date: {{ $purchase->date ? \Carbon\Carbon::parse($purchase->date)->format('d-m-Y') : '-' }}
@if(!$hasItems)
No items found.
@else
@foreach($purchase->items as $item) @endforeach
Product Qty Cost / unit Line Total
{{ $item->product->name ?? 'Deleted product' }} {{ $item->qty }} {{ number_format((float)$item->cost, 2) }} {{ number_format((float)$item->total, 2) }}
@endif
No purchases found.
{{ $purchases->links() }}
@endsection