@extends('admin.layouts.app')
@section('title','Purchase Details')
@section('content')
<div class="page-shell"><div class="page-head"><div><h1 class="page-title">Purchase {{ $purchase->invoice_no }}</h1><div class="page-subtitle">Supplier: {{ $purchase->supplier_name }} · Date: {{ $purchase->purchase_date }} · PO: {{ $purchase->po_no ?: '—' }}</div></div><a href="{{ route('admin.purchases.edit',$purchase) }}" class="btn">Edit</a></div>
<div class="grid-6"><div class="stat"><div class="k">Type</div><div class="v">{{ $purchase->purchase_type }}</div></div><div class="stat"><div class="k">Approval</div><div class="v">{{ $purchase->approval_status }}</div></div><div class="stat"><div class="k">Received</div><div class="v">{{ $purchase->received_status }}</div></div><div class="stat"><div class="k">Landed Cost</div><div class="v">{{ number_format($purchase->landed_cost,2) }}</div></div><div class="stat"><div class="k">Paid</div><div class="v">{{ number_format($purchase->paid_amount,2) }}</div></div><div class="stat"><div class="k">Due</div><div class="v">{{ number_format($purchase->due_amount,2) }}</div></div></div>
<div class="card panel-tight table-wrap"><table class="table"><thead><tr><th>Product</th><th>Code</th><th>Qty</th><th>Unit Cost</th><th>Landed</th><th>Batch</th><th>Expiry</th><th>Discount</th><th>Line Total</th></tr></thead><tbody>@forelse($purchase->items as $item)<tr><td>{{ $item->product_name }}</td><td>{{ $item->product_code }}</td><td>{{ $item->qty }}</td><td>{{ number_format($item->unit_cost,2) }}</td><td>{{ number_format($item->landed_unit_cost,2) }}</td><td>{{ $item->batch_no ?: '—' }}</td><td>{{ $item->expiry_date ?: '—' }}</td><td>{{ number_format($item->discount,2) }}</td><td>{{ number_format($item->line_total,2) }}</td></tr>@empty<tr><td colspan="9">No purchase items found.</td></tr>@endforelse</tbody></table></div>
<div class="card panel-tight table-wrap" style="margin-top:12px"><h5>Payment History</h5><table class="table"><thead><tr><th>Date</th><th>Amount</th><th>Method</th><th>Type</th><th>Notes</th></tr></thead><tbody>@forelse($payments as $p)<tr><td>{{ $p->payment_date }}</td><td>{{ number_format($p->amount,2) }}</td><td>{{ $p->payment_method }}</td><td>{{ $p->payment_type }}</td><td>{{ $p->notes }}</td></tr>@empty<tr><td colspan="5">No partial payment history yet.</td></tr>@endforelse</tbody></table></div></div>
@endsection
