@php function parseItemTaxIds($taxIds) { if (empty($taxIds)) return []; if (is_array($taxIds)) return array_map('intval', $taxIds); $decoded = json_decode($taxIds, true); if (is_array($decoded)) return array_map('intval', $decoded); if (strpos($taxIds, ',') !== false) return array_map('intval', array_filter(explode(',', $taxIds))); return $taxIds ? [intval($taxIds)] : []; } $taxesMap = \App\Models\Tax::pluck('rate', 'id')->toArray(); $taxNamesMap = \App\Models\Tax::pluck('name', 'id')->toArray(); $taxBreakdown = []; foreach ($estimation->items as $item) { if (($item->item_type ?? 'product') !== 'product') continue; $itemTaxIds = parseItemTaxIds($item->tax_ids); foreach ($itemTaxIds as $taxId) { $taxName = $taxNamesMap[$taxId] ?? 'Tax'; $taxRate = $taxesMap[$taxId] ?? 0; $taxAmount = ($item->amount * $taxRate) / 100; $key = $taxName . ' (' . $taxRate . '%)'; if (!isset($taxBreakdown[$key])) $taxBreakdown[$key] = ['name' => $taxName, 'rate' => $taxRate, 'amount' => 0]; $taxBreakdown[$key]['amount'] += $taxAmount; } } $calculatedTaxTotal = array_sum(array_column($taxBreakdown, 'amount')); $grandTotal = $estimation->subtotal + $calculatedTaxTotal - ($estimation->discount_amount ?? 0); $itemsList = ''; foreach ($estimation->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

👤 Prepared For

{{ ucfirst($estimation->status) }}

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

@if($estimation->email)

{{ $estimation->email }}

@endif @if($estimation->phone)

📞 {{ $estimation->phone }}

@endif @if($estimation->address)

{{ $estimation->address }}

@endif

đŸ“Ļ Line Items

@forelse($estimation->items as $item) @php $itemTaxIds = parseItemTaxIds($item->tax_ids); @endphp @empty @endforelse
DESCRIPTIONQTYRATETAXESAMOUNT
{{ $item->description }}
@if($item->long_description)
{{ $item->long_description }}
@endif
{{ number_format($item->quantity, 2) }} {{ number_format($item->rate, 2) }}
@foreach($itemTaxIds as $taxId){{ $taxesMap[$taxId] ?? 0 }}%@endforeach @if(empty($itemTaxIds))No tax@endif
{{ number_format($item->amount, 2) }}
No items found
Subtotal{{ $estimation->currency ?? 'INR' }} {{ number_format($estimation->subtotal, 2) }}
@if(($estimation->discount_amount ?? 0) > 0)
Discount-{{ number_format($estimation->discount_amount, 2) }}
@endif @if(count($taxBreakdown) > 0)
Tax Breakdown
@foreach($taxBreakdown as $key => $tax)
{{ $key }}{{ number_format($tax['amount'], 2) }}
@endforeach
@endif
Total Tax{{ number_format($calculatedTaxTotal, 2) }}
Total{{ $estimation->currency ?? 'INR' }} {{ number_format($grandTotal, 2) }}
Estimated Total
{{ $estimation->currency ?? 'INR' }} {{ number_format($grandTotal, 2) }}
@if($estimation->valid_until)
VALID UNTIL: {{ $estimation->valid_until->format('d M Y') }}
@endif

â„šī¸ Details

Number{{ $estimation->estimation_number }}
Subject{{ $estimation->subject ?? '-' }}
Date{{ $estimation->date ? $estimation->date->format('d M Y') : '-' }}
Valid Until{{ $estimation->valid_until ? $estimation->valid_until->format('d M Y') : '-' }}

⚡ Actions

@if($estimation->status === 'draft')@endif @if(in_array($estimation->status, ['draft', 'sent'])) @endif
@if($hasBrands) @endif