@extends('layouts.admin') @section('title', ($method === 'POST' ? 'Create' : 'Edit').' Invoice') @php $companiesData = $companies->map(fn ($company) => [ 'id' => $company->id, 'name' => $company->name, 'gst_number' => $company->gst_number, 'email' => $company->email, 'phone' => $company->phone, 'billing_address' => $company->billing_address, ])->values(); $selectedCustomerData = $selectedCustomer ? [ 'id' => $selectedCustomer->id, 'name' => $selectedCustomer->name, 'email' => $selectedCustomer->email, 'phone' => $selectedCustomer->mobile, 'address' => trim(implode(', ', array_filter([ $selectedCustomer->address_line_1, $selectedCustomer->address_line_2, $selectedCustomer->city, $selectedCustomer->state, $selectedCustomer->pincode, ]))), 'address_line_1' => $selectedCustomer->address_line_1, 'address_line_2' => $selectedCustomer->address_line_2, 'city' => $selectedCustomer->city, 'state' => $selectedCustomer->state, 'pincode' => $selectedCustomer->pincode, ] : null; $initialItems = old('items'); if (! $initialItems) { $initialItems = collect($items)->map(fn ($item) => [ 'item_name' => $item->item_name, 'description' => $item->description, 'quantity' => (float) ($item->quantity ?? 1), 'unit_price' => (float) ($item->unit_price ?? 0), 'discount' => (float) ($item->discount ?? 0), 'tax' => (float) ($item->tax ?? 0), ])->values()->all(); } if (empty($initialItems)) { $initialItems = [['item_name' => '', 'description' => '', 'quantity' => 1, 'unit_price' => 0, 'discount' => 0, 'tax' => 0]]; } $invoiceType = old('invoice_type', $invoice->invoice_type ?? 'customer'); @endphp @section('content')

{{ $method === 'POST' ? 'Create Invoice' : 'Edit Invoice '.$invoice->invoice_number }}

Fill in the details below to {{ $method === 'POST' ? 'create a new' : 'update this' }} invoice

@csrf @if($method !== 'POST') @method($method) @endif {{-- Step 1: Invoice Type --}}
1. Bill To
{{-- Invoice Details --}}
2. Invoice Details
@error('invoice_date')
{{ $message }}
@enderror
@error('due_date')
{{ $message }}
@enderror
{{-- Items --}}
3. Invoice Items
@error('items')
{{ $message }}
@enderror
Item Name Description Qty Unit Price Discount Tax % Total
{{-- Payment --}}
4. Payment
Totals
Subtotal
Discount
Tax
Other Charges
Grand Total
Cancel
{{-- Quick Add Company Modal --}} {{-- Quick Add Customer Modal --}} {{-- Item row template --}} @push('scripts') @endpush @endsection