Invoice

AdBazzar AdBazzar Chennai, India
+91 8531345678
adbazzar@gmail.com
Invoice ID: #{{ $invoice->order_random_id }}
Invoice Date: {{ \Carbon\Carbon::parse($invoice->order_date)->format('M d, Y') }}
BILL TO {{ $invoice->user->name ?? 'N/A' }}
{{ $invoice->delivery_address }}
Phone: {{ $invoice->user->phone_number ?? 'N/A' }}
@php // Decode all necessary fields $price_details = is_string($invoice->price_details) ? json_decode($invoice->price_details, true) : $invoice->price_details; $quantities = is_string($invoice->quantity) ? json_decode($invoice->quantity, true) : $invoice->quantity; $product_names = is_string($invoice->product_details_name) ? json_decode($invoice->product_details_name, true) : $invoice->product_details_name; $variant_ids = is_string($invoice->variant_id) ? json_decode($invoice->variant_id, true) : $invoice->variant_id; // Decode imei_serial_numbers $imei_serial_numbers = is_string($invoice->imei_serial_numbers) ? json_decode($invoice->imei_serial_numbers, true) : $invoice->imei_serial_numbers; // Ensure all decoded variables are arrays, even if null $price_details = is_array($price_details) ? $price_details : []; $quantities = is_array($quantities) ? $quantities : []; $product_names = is_array($product_names) ? $product_names : []; $variant_ids = is_array($variant_ids) ? $variant_ids : []; $imei_serial_numbers = is_array($imei_serial_numbers) ? $imei_serial_numbers : []; @endphp @foreach ($product_names as $key => $product_name) @endforeach
Description Quantity Unit Price Subtotal
{{ $product_name }} @if (isset($variant_ids[$key]) && $variant_ids[$key] != 'N/A' && $variant_ids[$key] != '')
Variant: {{ $variant_ids[$key] }} @endif {{-- Display IMEI/Serial Number --}} @if (isset($imei_serial_numbers[$key]) && $imei_serial_numbers[$key] != '')
IMEI/Serial: {{ $imei_serial_numbers[$key] }} @endif @if (isset($invoice->instruction))
Instructions: {{ $invoice->instruction }} @endif
{{ $quantities[$key] ?? 1 }} ₹{{ number_format(floatval($price_details[$key] ?? 0), 2, '.', ',') }} ₹{{ number_format(floatval($price_details[$key] ?? 0) * ($quantities[$key] ?? 1), 2, '.', ',') }}
@php $is_gst = \App\Models\User::where('role', 'admin')->where('is_gst', 1)->exists(); $gst_rate = 18; $subtotal_items = 0; if (isset($price_details) && isset($quantities)) { foreach ($price_details as $key => $price) { $subtotal_items += floatval($price ?? 0) * ($quantities[$key] ?? 1); } } $amount_payable = $invoice->amount; $beforeGstValue = 0; $cgst = 0; $sgst = 0; $totalGst = 0; $finalTotalAmount = $amount_payable; if ($is_gst && $amount_payable > 0 && $gst_rate > 0) { $beforeGstValue = round($amount_payable / (1 + $gst_rate / 100), 2); $totalGst = round($amount_payable - $beforeGstValue, 2); $cgst = round($totalGst / 2, 2); $sgst = round($totalGst / 2, 2); } else { $beforeGstValue = $amount_payable; $totalGst = 0; } @endphp @if ($is_gst) @endif
Subtotal (Items): ₹{{ number_format($subtotal_items, 2, '.', ',') }}
Cash Wallet Used: ₹{{ number_format($invoice->cash_wallet ?? 0, 2, '.', ',') }}
Shopping Wallet Used: ₹{{ number_format($invoice->shopp_wallet ?? 0, 2, '.', ',') }}
Delivery Fee: ₹{{ number_format($invoice->delivery_fee ?? 0, 2, '.', ',') }}
Amount Payable: ₹{{ number_format($amount_payable, 2, '.', ',') }}
Before GST Value: ₹{{ number_format($beforeGstValue, 2, '.', ',') }}
SGST ({{ $gst_rate / 2 }}%): +₹{{ number_format($sgst, 2, '.', ',') }}
CGST ({{ $gst_rate / 2 }}%): +₹{{ number_format($cgst, 2, '.', ',') }}
Total (incl. GST): ₹{{ number_format($finalTotalAmount, 2, '.', ',') }}