@extends('admin.admin_dashboard') @section('admin') @php $totalAmount = $purchase->total_amount ?? 0; $paidAmount = $purchase->paid_amount ?? 0; $dueAmount = $totalAmount - $paidAmount; @endphp
{{-- LEFT --}}
{{-- FILTER BOX (Template style) --}}
Filter
List
{{-- PURCHASE DETAILS BOX --}}
Purchase Order: {{ $purchase->purchase_no }} {{-- Purchase status badge --}} @if($purchase->status === 'draft') Draft @elseif($purchase->status === 'approved') Approved @elseif($purchase->status === 'cancelled') Cancelled @else Unknown @endif {{-- Payment status badge --}} @if($purchase->payment_status === 'paid') Paid @elseif($purchase->payment_status === 'partial') Partial @elseif($purchase->payment_status === 'unpaid') Unpaid @else Unknown @endif

Vendor: {{ $purchase->vendor->name ?? 'N/A' }}

Contact: {{ $purchase->vendor->phone ?? 'N/A' }}

@if(optional($purchase->vendor)->email)

Email: {{ $purchase->vendor->email }}

@endif

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

Created By: {{ $purchase->creator->name ?? 'N/A' }}

@if($purchase->approved_at)

Approved At: {{ $purchase->approved_at->format('d M Y H:i') }}

@endif

Purchase Items
@foreach($purchase->items as $item) @endforeach
# Product Quantity Unit Price Total
{{ $loop->iteration }} {{ $item->product->name ?? 'N/A' }} {{ $item->quantity }} ৳{{ number_format($item->unit_price, 2) }} ৳{{ number_format($item->total, 2) }}
Total Amount: ৳{{ number_format($totalAmount, 2) }}
Paid: ৳{{ number_format($paidAmount, 2) }}
Due: ৳{{ number_format($dueAmount, 2) }}
@if($purchase->notes)
Notes: {{ $purchase->notes }}
@endif
{{-- PAYMENT HISTORY --}} @if($purchase->status === 'approved' && $purchase->payments->count() > 0)
Payment History
@foreach($purchase->payments as $payment) @endforeach
Date Amount Method Notes Recorded By
{{ optional($payment->payment_date)->format('d M Y') }} ৳{{ number_format($payment->amount ?? 0, 2) }} {{ ucfirst($payment->payment_method ?? '-') }} {{ $payment->notes ?? '-' }} {{ $payment->creator->name ?? 'N/A' }}
@endif {{-- ACCOUNTING ENTRY --}} @if($purchase->journalEntry)
Accounting Entry

Entry No: {{ $purchase->journalEntry->entry_no }}

Date: {{ optional($purchase->journalEntry->entry_date)->format('d M Y') }}

@foreach($purchase->journalEntry->lines as $line) @endforeach
Account Debit Credit
{{ $line->account->name ?? 'N/A' }} {{ ($line->debit ?? 0) > 0 ? '৳'.number_format($line->debit, 2) : '-' }} {{ ($line->credit ?? 0) > 0 ? '৳'.number_format($line->credit, 2) : '-' }}
@endif
{{-- RIGHT --}}
{{-- ACTIONS --}}
Actions
@if($purchase->status === 'draft')
@csrf
Edit Purchase
@csrf @method('DELETE')
@endif @if($purchase->status === 'approved' && $dueAmount > 0) Add Payment @endif @if($purchase->status === 'approved')
@csrf
@endif Back to List
{{-- SUMMARY --}}
Summary

Total Items: {{ $purchase->items->count() }}

Total Quantity: {{ $purchase->items->sum('quantity') }}

Total Amount: ৳{{ number_format($totalAmount, 2) }}

Paid Amount: ৳{{ number_format($paidAmount, 2) }}

Due Amount: ৳{{ number_format($dueAmount, 2) }}

@endsection