@php $taxesMap = \App\Models\Tax::pluck('rate', 'id')->toArray(); $taxNamesMap = \App\Models\Tax::pluck('name', 'id')->toArray(); function parseItemTaxIds($taxIds) { if (empty($taxIds)) return []; if (is_array($taxIds)) return array_map('intval', $taxIds); if (is_string($taxIds)) { $decoded = json_decode($taxIds, true); if (is_array($decoded)) return array_map('intval', $decoded); if (strpos($taxIds, ',') !== false) return array_map('intval', explode(',', $taxIds)); return $taxIds ? [intval($taxIds)] : []; } return is_numeric($taxIds) ? [intval($taxIds)] : []; } $taxBreakdown = []; $totalTax = 0; foreach ($invoice->items as $item) { if (($item->item_type ?? 'product') === 'product' && $item->tax_ids) { $itemTaxIds = parseItemTaxIds($item->tax_ids); foreach ($itemTaxIds as $taxId) { $taxRate = $taxesMap[$taxId] ?? 0; $taxName = $taxNamesMap[$taxId] ?? 'Tax'; $taxAmount = ($item->amount * $taxRate) / 100; $totalTax += $taxAmount; $key = $taxName . ' (' . $taxRate . '%)'; if (!isset($taxBreakdown[$key])) $taxBreakdown[$key] = ['rate' => $taxRate, 'amount' => 0]; $taxBreakdown[$key]['amount'] += $taxAmount; } } } if ($totalTax == 0 && $invoice->tax > 0) $totalTax = $invoice->tax; $grandTotal = $invoice->subtotal - ($invoice->discount ?? 0) + $totalTax; $itemsList = ''; foreach ($invoice->items as $item) { if (($item->item_type ?? 'product') === 'product') { $itemsList .= "β€’ " . $item->description . " (Qty: " . number_format($item->quantity, 0) . " Γ— β‚Ή" . number_format($item->rate, 2) . ")\n"; } } $brandLogos = collect([]); $hasBrands = false; try { if (class_exists('Modules\Brand\Models\Brand')) { $brandLogos = \Modules\Brand\Models\Brand::where('is_active', 1)->orderBy('sort_order')->get(); $hasBrands = $brandLogos->count() > 0; } } catch (\Exception $e) {} @endphp
@if(session('success'))
βœ… {{ session('success') }}
@endif @if(session('error'))
❌ {{ session('error') }}
@endif

πŸ‘€ Bill To

{{ ucfirst(str_replace('_', ' ', $invoice->status)) }}

{{ $invoice->customer->name ?? 'N/A' }}

@if($invoice->email)

{{ $invoice->email }}

@endif @if($invoice->phone)

πŸ“ž {{ $invoice->phone }}

@endif @if($invoice->address)

{{ $invoice->address }}

@endif @if($invoice->city || $invoice->state)

{{ $invoice->city }}{{ $invoice->city && $invoice->state ? ', ' : '' }}{{ $invoice->state }}{{ $invoice->zip_code ? ' ' . $invoice->zip_code : '' }}

@endif

πŸ“¦ Line Items

@forelse($invoice->items as $item) @if(($item->item_type ?? 'product') === 'section') @elseif(($item->item_type ?? 'product') === 'note') @else @php $itemTaxIds = parseItemTaxIds($item->tax_ids); $product = $item->product; @endphp @endif @empty @endforelse
DESCRIPTIONQTYUNIT RATETAXESDISCOUNTHSN CodeAMOUNT
{{ $item->description }}
{{ $item->long_description ?: $item->description }}
{{ $item->description }}
@if($item->long_description)
{{ $item->long_description }}
@endif
{{ number_format($item->quantity, 2) }} @php $unitText = $item->unit ?? ($product && $product->unit ? $product->unit->short_name : null); @endphp @if($unitText) {{ $unitText }} @else - @endif {{ number_format($item->rate, 2) }}
@foreach($itemTaxIds as $taxId) {{ $taxesMap[$taxId] ?? 0 }}% @endforeach @if(empty($itemTaxIds)) - @endif
@if(($item->discount_amount ?? 0) > 0) -β‚Ή{{ number_format($item->discount_amount, 2) }}
({{ $item->discount_type === 'percentage' ? number_format($item->discount_value, 2) . '%' : 'β‚Ή' . number_format($item->discount_value, 2) }})
@else - @endif
@if($product && $product->hsn_code) {{ $product->hsn_code }} @else - @endif {{ number_format($item->amount, 2) }}
No items
Subtotal{{ $invoice->currency ?? 'INR' }} {{ number_format($invoice->subtotal, 2) }}
@if(($invoice->discount ?? 0) > 0)
Discount- {{ $invoice->currency ?? 'INR' }} {{ number_format($invoice->discount, 2) }}
@endif @if(count($taxBreakdown) > 0)
πŸ“Š Tax Breakdown
@foreach($taxBreakdown as $key => $tax)
{{ $key }}{{ $invoice->currency ?? 'INR' }} {{ number_format($tax['amount'], 2) }}
@endforeach
@endif
Total Tax{{ $invoice->currency ?? 'INR' }} {{ number_format($totalTax, 2) }}
Total{{ $invoice->currency ?? 'INR' }} {{ number_format($grandTotal, 2) }}
Amount Paid{{ $invoice->currency ?? 'INR' }} {{ number_format($invoice->amount_paid, 2) }}
Amount Due{{ $invoice->currency ?? 'INR' }} {{ number_format($invoice->amount_due, 2) }}
@if($invoice->payments && $invoice->payments->count() > 0)

πŸ’³ Payment History

@foreach($invoice->payments as $payment)
{{ $payment->payment_number ?? 'Payment' }}
{{ $payment->payment_date?->format('d M Y') ?? $payment->created_at->format('d M Y') }} β€’ {{ ucfirst($payment->payment_method ?? 'Cash') }}
β‚Ή{{ number_format($payment->amount, 2) }}
@endforeach
@endif
{{ $invoice->amount_due > 0 ? 'Amount Due' : 'Fully Paid' }}
{{ $invoice->currency ?? 'INR' }} {{ number_format($invoice->amount_due, 2) }}
@if($invoice->due_date)
DUE: {{ $invoice->due_date->format('d M Y') }}
@endif

ℹ️ Details

Number{{ $invoice->invoice_number }}
Date{{ $invoice->date?->format('d M Y') ?? '-' }}
Due Date{{ $invoice->due_date?->format('d M Y') ?? '-' }}
Status{{ ucfirst(str_replace('_', ' ', $invoice->status)) }}

⚑ Actions

@if($invoice->status === 'draft')@endif @if($invoice->amount_due > 0 && !in_array($invoice->status, ['cancelled']))@endif @if(!in_array($invoice->status, ['cancelled', 'paid']))@endif @if($invoice->status === 'paid')

βœ“ Fully Paid

@endif

πŸ• Activity

Created
{{ $invoice->created_at->format('d M Y, h:i A') }}
@if($invoice->status === 'sent')
Sent
{{ $invoice->updated_at->format('d M Y, h:i A') }}
@endif @if($invoice->status === 'paid')
Paid
{{ $invoice->updated_at->format('d M Y, h:i A') }}
@endif @if($invoice->status === 'cancelled')
Cancelled
{{ $invoice->updated_at->format('d M Y, h:i A') }}
@endif
@if($hasBrands) @endif

🧾 Payment Receipt

Loading payment details...