@php $items = $order->items ?? collect(); $first = $items->first(); $symbol = $first->converted_currency_symbol ?? session('currency_symbol', '₹'); $rate = $first->converted_currency_value ?? (float) session('currency_rate', 1); $shortcut = session('currency_shortcut', 'INR'); // Subtotal (converted) – sum of line subtotals $subtotalConverted = $items->sum(function ($item) use ($rate) { if (!is_null($item->sub_total_converted)) { return (float) $item->sub_total_converted; } $lineRate = $item->converted_currency_value ?? $rate; $qty = $item->product_quantity ?? 1; $base = ($item->product_price ?? 0) * $qty; return $base * $lineRate; }); // Shipping pieces (converted) $shippingConv = $first->shipping_charge_converted ?? 0; $fuelConv = $first->fuel_surcharge_converted ?? 0; $gstConv = $first->gst_converted ?? 0; $pgConv = $first->payment_gateway_charge_converted ?? 0; $shippingTotal = $first->shipping_charge_total_converted ?? ($shippingConv + $fuelConv + $gstConv + $pgConv); // Discount amount (converted – we stored amount in discounted_per) $discountConv = $first->discounted_per ?? 0; // Grand total (converted) $grandTotalConv = $first->final_amount_converted ?? ($subtotalConverted + $shippingTotal - $discountConv); // Helper for currency format function invCurrency($symbol, $shortcut, $amount) { if ($shortcut == 'AED') { return number_format($amount, 2) . ' ' . $symbol; } return $symbol . ' ' . number_format($amount, 2); } use Carbon\Carbon; $orderDate = null; if (!empty($order->order_created_at)) { try { $orderDate = Carbon::parse($order->order_created_at); } catch (\Throwable $e) { $orderDate = null; } } elseif (!empty($order->created_at)) { $orderDate = $order->created_at instanceof \Carbon\Carbon ? $order->created_at : Carbon::parse($order->created_at); } @endphp
{{-- HEADER --}}
Golden Era Consumer Durables
1299, 2nd Floor, 41st Cross, 25th Main Rd,
Jayanagara 9th Block, Jayanagar,
Bengaluru, Karnataka 560056, India
PROFORMA INVOICE
Invoice No: {{ $order->invoice_id ?? ('GLOBAL-UTH000' . $order->order_id) }}
Order ID: #{{ $order->order_id }}
Billed Date: @if($orderDate) {{ $orderDate->format('d/m/Y') }} @else - @endif
{{-- BILL TO / BILLING ADDRESS --}}
Billed To

{{ $order->user_name }}

@if($order->user_email)

Email: {{ $order->user_email }}

@endif @if($order->user_phone)

Phone: {{ $order->user_country_code ? '+' . $order->user_country_code . ' ' : '' }} {{ $order->user_phone }}

@endif {{-- NEW FIELDS ADDED BELOW --}} @if(!empty($order->user_payment_type))

Payment Type: {{ $order->user_payment_type }}

@endif @if(!empty($order->user_payment_id))

Payment ID: {{ $order->user_payment_id }}

@endif

Payment Status: {{ ucfirst($order->user_payment_status ?? 'pending') }}

Billing Address

{{ $order->user_name }}

Address: {{ $order->user_address }}

City: {{ $order->user_city }}

State: {{ $order->user_state }}

Pincode: {{ $order->user_pincode }}

Country: {{ $order->country }}

{{-- ORDER SUMMARY TABLE --}}
Order Summary
@forelse($items as $index => $item) @php $qty = $item->product_quantity ?? 1; $lineRate = $item->converted_currency_value ?? $rate; $basePrice = $item->product_price ?? 0; // line subtotal (converted) if (!is_null($item->sub_total_converted)) { $lineSubtotalConv = (float) $item->sub_total_converted; } elseif (!is_null($item->sub_total)) { $lineSubtotalConv = (float) $item->sub_total * $lineRate; } else { $lineSubtotalConv = ($basePrice * $qty) * $lineRate; } // unit price $unitPriceConv = $qty > 0 ? $lineSubtotalConv / $qty : $lineSubtotalConv; @endphp @empty @endforelse
Sl. No. Product Unit Price Qty Line Total
{{ $index + 1 }} {{ $item->product_name }}
@if($item->product_category) {{ $item->product_category }} @endif
{{ invCurrency($symbol, $shortcut, $unitPriceConv) }} {{ $qty }} {{ invCurrency($symbol, $shortcut, $lineSubtotalConv) }}
No products found. Products may have been cancelled.
{{-- TOTALS / CHARGES --}} @if($items->count())
@if($discountConv > 0) @endif @if($shippingTotal > 0) @endif
Sub Total {{ invCurrency($symbol, $shortcut, $subtotalConverted) }}
Discount - {{ invCurrency($symbol, $shortcut, $discountConv) }}
Shipping Charge {{ invCurrency($symbol, $shortcut, $shippingTotal) }}
Grand Total {{ invCurrency($symbol, $shortcut, $grandTotalConv) }}
@endif