@extends('dashboard.layouts.app') @section('content') @include('components.alert') @php $isSaleOrder = ($purchase->invoice_type ?? null) === 'sale'; $canCreateInvoice = !$isSaleOrder && in_array($purchase->status, ['approved', 'purchased'], true) && !$purchase->purchaseInvoice; $hasInvoice = $purchase->purchase_invoice_id || $purchase->student_invoice_id || $purchase->details->contains(fn ($detail) => !empty($detail->student_invoice_id)); $statusClass = $hasInvoice ? 'pi-pill--success' : 'pi-pill--warn'; $statusLabel = $hasInvoice ? 'Invoiced' : 'Pending'; $defaultVendorId = old('vendor_id', $purchase->vendors->first()?->id); $invoiceDate = old('invoice_date', now()->toDateString()); $dueDate = old('due_date', $purchase->due_date ?: $purchase->required_by); @endphp
@if(!$canCreateInvoice)
This order is currently {{ $purchase->status }}, already has a purchase invoice, or belongs to the sales order flow.
@endif

Order Summary

The invoice amount is copied from the approved purchase.

{{ $statusLabel }}
Order Number
#{{ $purchase->purchase_number }}
Order Name
{{ $purchase->name ?: '--' }}
Subtotal {{ number_format((float) $purchase->sub_total, 2) }}
VAT {{ number_format((float) ($purchase->vat_amount ?? 0), 2) }}
Shipping {{ number_format((float) ($purchase->shipping_cost ?? 0), 2) }}
Invoice Total {{ number_format((float) $purchase->total, 2) }}

Vendor Bill Details

This posts payable. Payment is recorded after the invoice is created.

No treasury movement
@csrf @if($errors->any())
Purchase invoice was not created.
Please fix the highlighted issue and submit again.
@endif
@error('vendor_id')
{{ $message }}
@enderror
@error('vendor_invoice_number')
{{ $message }}
@enderror
@error('invoice_date')
{{ $message }}
@enderror
@error('due_date')
{{ $message }}
@enderror
@error('cost_center_id')
{{ $message }}
@enderror
Journal Entry Preview
Debit: Operating Expenses {{ number_format((float) (($purchase->sub_total ?? 0) + ($purchase->shipping_cost ?? 0)), 2) }}
@if((float) ($purchase->vat_amount ?? 0) > 0)
Debit: VAT Input {{ number_format((float) $purchase->vat_amount, 2) }}
@endif
Credit: Accounts Payable {{ number_format((float) $purchase->total, 2) }}
Cancel
@endsection