{{-- HEADER --}} @php $statusClass = match ($sale->status) { 'completed' => 'bg-success text-white', 'cancelled' => 'bg-danger text-white', default => 'bg-secondary text-white', }; @endphp

Invoice #{{ $sale->order_number ?? '000' }}

{{ ucfirst($sale->status) }}
{{ $sale->created_at->format('d M Y, h:i A') }}
Download Invoice
{{-- CUSTOMER --}}
{{-- LEFT: Customer --}}
Customer
{{ $sale->customer_name ?? 'Walk-in Customer' }} {{ $sale->customer_phone ?? '—' }} {{ $sale->customer_email ?? '—' }} {{ $sale->created_at->format('d M Y, h:i A') }} @if (filled($sale->customer_note ?? null)) {{ $sale->customer_note }} @endif
{{-- DIVIDER --}}
{{-- RIGHT: Order Info --}}
Order Info
Salesperson
{{ $sale->salesperson_name ?? '—' }}
Business
{{ auth()->user()->business->name ?? '—' }}
Branch
{{ current_store()->name ?? '—' }}
@php $pm = (string) ($sale->payment_method ?? ''); $paymentMethodLabels = [ 'stripe' => 'Card (Stripe)', 'cash_on_delivery' => 'Cash on delivery', 'bank_transfer' => 'Bank transfer', 'easypaisa' => 'Easypaisa', 'jazzcash' => 'JazzCash', ]; $paymentLabel = $paymentMethodLabels[$pm] ?? ($pm !== '' ? strtoupper(str_replace('_', ' ', $pm)) : 'N/A'); $hasShippingAddr = filled($sale->shipping_country ?? null) || filled($sale->shipping_state ?? null) || filled($sale->shipping_city ?? null) || filled($sale->shipping_area ?? null) || filled($sale->shipping_postal_code ?? null) || filled($sale->shipping_address_line ?? null); $shippingFeeAmt = round((float) ($sale->shipping_fee ?? 0), 2); $hasShipping = $hasShippingAddr || filled($sale->shipping_method ?? null) || filled($sale->shipping_delivery_type ?? null) || filled($sale->shipping_rate_mode ?? null) || filled($sale->shipping_option_key ?? null) || $shippingFeeAmt > 0.009 || ($sale->shipping_distance_km !== null && (float) $sale->shipping_distance_km >= 0); $isPosSale = \Illuminate\Support\Str::startsWith((string) ($sale->order_number ?? ''), 'PS-'); $resolvedFulfillmentType = store_order_resolved_delivery_type($sale->shipping_delivery_type ?? null, $sale->shipping_method ?? null); $rateModeLabel = store_order_shipping_rate_label($sale->shipping_rate_mode ?? null); $deliveryPackageDisplay = store_order_delivery_package_display( $sale->shipping_method ?? null, $sale->shipping_option_key ?? null, $sale->shipping_delivery_type ?? ($resolvedFulfillmentType ?? null) ); $couponDiscountAmt = round((float) ($sale->coupon_discount ?? 0), 2); $showCoupon = $couponDiscountAmt > 0.009 || filled($sale->coupon_code ?? null); $fmt = fn ($v) => function_exists('format_currency') ? format_currency((float) $v) : number_format((float) $v, 2); @endphp {{-- SHIPPING (left) + PAYMENT (right) --}}
{{-- SHIPPING --}}
Shipping & Delivery
@if ($isPosSale && !$hasShipping)

In-store POS — no delivery snapshot.

@elseif ($hasShipping) @php $rft = $resolvedFulfillmentType ?? ''; $ftBadge = match ($rft) { 'pickup' => ['bg' => '#fff7ed', 'color' => '#b45309', 'label' => 'Pickup'], 'delivery' => ['bg' => '#eff6ff', 'color' => '#1d4ed8', 'label' => 'Delivery'], default => ['bg' => '#f8fafc', 'color' => '#475569', 'label' => store_order_delivery_type_label($rft)], }; @endphp
{{ $ftBadge['label'] }}
@if ($deliveryPackageDisplay !== '') Package {{ $deliveryPackageDisplay }} @if ($rateModeLabel) ({{ $rateModeLabel }}) @endif @endif @if ($sale->shipping_distance_km !== null) Distance {{ number_format((float) $sale->shipping_distance_km, 2) }} km @endif @if ($shippingFeeAmt > 0.009) Charge {{ $fmt($shippingFeeAmt) }} @endif {{-- Full address from checkout --}} @if (filled($sale->shipping_address_line ?? null)) Street {{ $sale->shipping_address_line }} @endif @php $addrLineParts = array_filter([ filled($sale->shipping_state ?? null) ? 'State / Province: ' . $sale->shipping_state : null, filled($sale->shipping_city ?? null) ? 'City: ' . $sale->shipping_city : null, filled($sale->shipping_area ?? null) ? 'Area: ' . $sale->shipping_area : null, filled($sale->shipping_postal_code ?? null) ? 'Postal Code: ' . $sale->shipping_postal_code : null, filled($sale->shipping_country ?? null) ? 'Country: ' . strtoupper($sale->shipping_country) : null, ]); @endphp @if (count($addrLineParts)) Address {{ implode(', ', $addrLineParts) }} @endif @if (($sale->shipping_customer_lat ?? null) !== null && ($sale->shipping_customer_lng ?? null) !== null) @php $mapsUrl = 'https://www.google.com/maps?q=' . $sale->shipping_customer_lat . ',' . $sale->shipping_customer_lng; @endphp Map View on Google Maps @endif
@else

No shipping details on this order.

@endif
{{-- DIVIDER --}}
{{-- PAYMENT --}}
Payment
Method {{ $paymentLabel }} @if (($sale->payment_method ?? '') === 'stripe' || filled($sale->card_last_four ?? null)) Card @if (filled($sale->card_holder_name ?? null)){{ $sale->card_holder_name }}@endif @if (filled($sale->card_last_four ?? null)) ****{{ $sale->card_last_four }}@endif @if (!filled($sale->card_holder_name ?? null) && !filled($sale->card_last_four ?? null))—@endif @endif @if (filled($sale->transaction_id ?? null)) Txn ID {{ $sale->transaction_id }} @endif @if (filled($sale->payment_proof_path ?? null)) Proof View @endif Status @php $psCls = match ((string)($sale->payment_status ?? '')) { 'paid' => ['bg' => '#dcfce7', 'color' => '#15803d'], 'partial' => ['bg' => '#fef3c7', 'color' => '#b45309'], 'unpaid' => ['bg' => '#fee2e2', 'color' => '#b91c1c'], default => ['bg' => '#f1f5f9', 'color' => '#64748b'], }; @endphp {{ strtoupper((string)($sale->payment_status ?? 'unknown')) }} Paid {{ $fmt($sale->amount_paid ?? 0) }} Due @if (($sale->amount_due ?? 0) > 0) {{ $fmt($sale->amount_due) }} @else Cleared @endif
{{-- ITEMS --}}
@foreach($sale->orderDetails as $item) @endforeach
Item Price Qty Total Price Subtotal Excl. Tax Discount Tax Total Payable
{{ Str::limit($item->product_name, 30) }} @if ($item->variant_name) {{ Str::limit($item->variant_name, 30) }} @endif {{ number_format($item->base_unit_price, 2) }} {{ $item->quantity }} {{ number_format($item->base_unit_price * $item->quantity, 2) }} {{ number_format($item->subtotal * $item->quantity, 2) }} {{ number_format($item->discount_per_unit * $item->quantity, 2) }} {{ number_format($item->tax_per_unit * $item->quantity, 2) }} {{ number_format($item->line_total, 2) }}
{{-- ORDER SUMMARY --}}
{{ __('Order summary') }}
@if ($showCoupon) @endif @if ($hasShipping || $shippingFeeAmt > 0.009) @endif
{{ __('Base Price') }} {{ $fmt($sale->order_base_price) }}
{{ __('Subtotal') }} {{ $fmt($sale->subtotal) }}
{{ __('Discount') }} {{ $fmt($sale->total_discount) }}
{{ __('Coupon') }}@if (filled($sale->coupon_code)) ({{ $sale->coupon_code }})@endif -{{ $couponDiscountAmt > 0.009 ? $fmt($couponDiscountAmt) : $fmt(0) }}
{{ __('Tax') }} {{ $fmt($sale->total_tax) }}
{{ __('Shipping') }} @if (($resolvedFulfillmentType ?? '') === 'pickup') — {{ __('Pickup') }} @elseif ($deliveryPackageDisplay !== '') — {{ $deliveryPackageDisplay }} @endif {{ $fmt($shippingFeeAmt) }}
{{ __('Grand Total') }} {{ $fmt($sale->grand_total) }}
{{ __('Paid') }} {{ $fmt($sale->amount_paid ?? 0) }}
{{ __('Due') }} {{ $fmt($sale->amount_due ?? 0) }}