@if(isset($includeSummary) && $includeSummary) {{-- SUMMARY RECEIPT - Shows combined payment information --}}
@if ($receiptSettings->show_restaurant_logo) @php $logoUrl = restaurant()->logo_url; $logoBase64 = null; if ($logoUrl) { try { if (!preg_match('/^https?:\/\//', $logoUrl)) { $logoUrl = url($logoUrl); } $logoImageContents = @file_get_contents($logoUrl); if ($logoImageContents !== false) { $logoBase64 = 'data:image/png;base64,' . base64_encode($logoImageContents); } } catch (\Exception $e) { $logoBase64 = null; } } @endphp @if ($logoBase64) @else @endif @endif
{{ restaurant()->name }}
{!! nl2br(branch()->address) !!}
@lang('modules.customer.phone'):{{ restaurant()->phone_number }}
@if ($receiptSettings->show_tax) @foreach ($taxDetails as $taxDetail)
{{ $taxDetail->tax_name }}: {{ $taxDetail->tax_id }}
@endforeach @endif
{{ $order->show_formatted_order_number }} {{ $order->date_time->timezone(timezone())->format(dateFormat() . ' ' . timeFormat()) }}
@php $tokenNumber = $order->kot->whereNotNull('token_number')->first()?->token_number; @endphp @if ($tokenNumber)
@lang('modules.order.tokenNumber') {{ $tokenNumber }}
@endif @if($receiptSettings->show_table_number || $receiptSettings->show_total_guest)
@if ($receiptSettings->show_table_number && $order->table && $order->table->table_code) @lang('modules.settings.tableNumber'): {{ $order->table->table_code }} @endif @if ($receiptSettings->show_total_guest && $order->number_of_pax) @lang('modules.order.noOfPax'): {{ $order->number_of_pax }} @endif
@endif @if ($receiptSettings->show_waiter && $order->waiter && $order->waiter->name)
@lang('modules.order.waiter'): {{ $order->waiter->name }}
@endif @if ($receiptSettings->show_order_type)
{{ Str::title(ucwords(str_replace('_', ' ', $order->order_type))) }} @if ($order->order_type === 'pickup') @if ($order->pickup_date) : {{ \Carbon\Carbon::parse($order->pickup_date)->format(dateFormat() . ' ' . timeFormat()) }} @endif @endif
@endif @if ($receiptSettings->show_customer_name && $order->customer && $order->customer->name)
@lang('modules.customer.customer'): {{ $order->customer->name }}
@endif @if ($receiptSettings->show_customer_address && $order->customer && $order->customer->delivery_address)
@lang('modules.customer.customerAddress'): {{ $order->customer->delivery_address }}
@endif @if ($receiptSettings->show_customer_phone && $order->customer && $order->customer->phone)
@lang('modules.customer.phone'): {{ $order->customer->phone }}
@endif
@lang('modules.order.totalSplits'): {{ count($splitReceipts) }}
{{-- All Order Items --}} @foreach ($order->items as $item) @endforeach
@lang('modules.order.qty') @lang('modules.menu.itemName') @lang('modules.order.price') @lang('modules.order.amount')
{{ $item->quantity }} {{ $item->menuItem->item_name }} @if (isset($item->menuItemVariation))
({{ $item->menuItemVariation->variation }}) @endif @foreach ($item->modifierOptions as $modifier) @php if ($order->order_type_id) { $modifier->setPriceContext($order->order_type_id, $order?->delivery_app_id); } @endphp
• {{ $modifier->name ?? $modifier->pivot->modifier_option_name }} (+{{ currency_format($modifier->pivot->modifier_option_price ?? $modifier->price, restaurant()->currency_id) }})
@endforeach
{{ currency_format($item->price, restaurant()->currency_id) }} {{ currency_format($item->amount, restaurant()->currency_id) }}
{{-- Order Totals --}}
@lang('modules.order.subTotal'): {{ currency_format($order->sub_total, restaurant()->currency_id) }}
@if (!is_null($order->discount_amount))
@lang('modules.order.discount') @if ($order->discount_type == 'percent') ({{ rtrim(rtrim($order->discount_value, '0'), '.') }}%) @endif -{{ currency_format($order->discount_amount, restaurant()->currency_id) }}
@endif @if(function_exists('module_enabled') && module_enabled('Loyalty') && $order->loyalty_points_redeemed > 0 && $order->loyalty_discount_amount > 0)
@lang('loyalty::app.loyaltyDiscount') ({{ number_format($order->loyalty_points_redeemed) }} @lang('loyalty::app.points')) -{{ currency_format($order->loyalty_discount_amount, restaurant()->currency_id) }}
@endif @if(function_exists('module_enabled') && module_enabled('Loyalty') && ($order->stamp_discount_amount > 0 || $order->items()->where('is_free_item_from_stamp', true)->exists()))
@lang('app.stampDiscount') @if($order->items()->where('is_free_item_from_stamp', true)->exists()) (@lang('app.freeItem')) @endif @if($order->stamp_discount_amount > 0) -{{ currency_format($order->stamp_discount_amount, restaurant()->currency_id) }} @else @lang('app.free') @endif
@endif @php // Calculate discounted subtotal (after all discounts) $discountedSubtotal = $order->sub_total - ($order->discount_amount ?? 0) - ($order->loyalty_discount_amount ?? 0) - ($order->stamp_discount_amount ?? 0); @endphp @if (!empty($order->charges) && $order->charges->count() > 0) @foreach ($order->charges as $charge)
{{ $charge->charge->charge_name }} @if ($charge->charge->charge_type == 'percent') ({{ $charge->charge->charge_value }}%) @endif: {{ currency_format($charge->charge->getAmount($discountedSubtotal), restaurant()->currency_id) }}
@endforeach @endif @if ($order->tip_amount > 0)
@lang('modules.order.tip'): {{ currency_format($order->tip_amount, restaurant()->currency_id) }}
@endif @if ($order->order_type === 'delivery' && !is_null($order->delivery_fee))
@lang('modules.delivery.deliveryFee'): @if($order->delivery_fee > 0) {{ currency_format($order->delivery_fee, restaurant()->currency_id) }} @else @lang('modules.delivery.freeDelivery') @endif
@endif @if ($taxMode == 'order') @foreach ($order->taxes as $taxItem) @if($taxItem->tax)
{{ $taxItem->tax->tax_name }} ({{ $taxItem->tax->tax_percent }}%): @php // Calculate service charges on discounted subtotal $serviceTotal = 0; if ($order->charges && $order->charges->count() > 0) { foreach ($order->charges as $chargeRelation) { $charge = $chargeRelation->charge; if ($charge) { $chargeAmount = $charge->getAmount((float)$discountedSubtotal); $serviceTotal += (float)$chargeAmount; } } } // Check if service charges should be included in tax base $restaurant = restaurant(); $includeChargesInTaxBase = false; if ($restaurant && isset($restaurant->include_charges_in_tax_base)) { $includeChargesInTaxBase = (bool)$restaurant->include_charges_in_tax_base; } // Tax base = (subtotal - discounts) + service charges (if enabled) $taxBase = $includeChargesInTaxBase ? ($discountedSubtotal + $serviceTotal) : $discountedSubtotal; $taxBase = max(0, (float)$taxBase); // Calculate tax on tax_base $taxAmount = ($taxItem->tax->tax_percent / 100) * $taxBase; @endphp {{ currency_format($taxAmount, restaurant()->currency_id) }}
@endif @endforeach @else @if($order->total_tax_amount > 0) @php $taxTotals = []; $totalTax = 0; foreach ($order->items as $item) { $qty = $item->quantity ?? 1; $taxBreakdown = is_array($item->tax_breakup) ? $item->tax_breakup : (json_decode($item->tax_breakup, true) ?? []); foreach ($taxBreakdown as $taxName => $taxInfo) { if (!isset($taxTotals[$taxName])) { $taxTotals[$taxName] = [ 'percent' => $taxInfo['percent'] ?? 0, 'amount' => ($taxInfo['amount'] ?? 0) * $qty ]; } else { $taxTotals[$taxName]['amount'] += ($taxInfo['amount'] ?? 0) * $qty; } } $totalTax += $item->tax_amount ?? 0; } @endphp
@foreach ($taxTotals as $taxName => $taxInfo)
{{ $taxName }} ({{ $taxInfo['percent'] }}%) {{ currency_format($taxInfo['amount'], restaurant()->currency_id) }}
@endforeach
@lang('modules.order.totalTax'): {{ currency_format($totalTax, restaurant()->currency_id) }}
@endif @endif
@lang('modules.order.total'): {{ currency_format($order->total, restaurant()->currency_id) }}
@if ($receiptSettings->show_payment_status)
@lang('modules.order.paymentStatus'): @if($order->status === 'paid') @lang('modules.order.paid') @else @lang('modules.order.unpaid') @endif
@endif
@endif {{-- INDIVIDUAL SPLIT RECEIPTS --}} @foreach ($splitReceipts as $splitData)
@if ($receiptSettings->show_restaurant_logo) @php $logoUrl = restaurant()->logo_url; $logoBase64 = null; if ($logoUrl) { try { // If the URL is relative, prepend the app URL if (!preg_match('/^https?:\/\//', $logoUrl)) { $logoUrl = url($logoUrl); } $logoImageContents = @file_get_contents($logoUrl); if ($logoImageContents !== false) { $logoBase64 = 'data:image/png;base64,' . base64_encode($logoImageContents); } } catch (\Exception $e) { $logoBase64 = null; } } @endphp @if ($logoBase64) @else @endif @endif
{{ restaurant()->name }}
{!! nl2br(branch()->address) !!}
@lang('modules.customer.phone'):{{ restaurant()->phone_number }}
@if ($receiptSettings->show_tax) @foreach ($taxDetails as $taxDetail)
{{ $taxDetail->tax_name }}: {{ $taxDetail->tax_id }}
@endforeach @endif
{{ $order->show_formatted_order_number }} {{ $order->date_time->timezone(timezone())->format(dateFormat() . ' ' . timeFormat()) }}
@php $tokenNumber = $order->kot->whereNotNull('token_number')->first()?->token_number; @endphp @if ($tokenNumber)
@lang('modules.order.tokenNumber') {{ $tokenNumber }}
@endif @if($receiptSettings->show_table_number || $receiptSettings->show_total_guest)
@if ($receiptSettings->show_table_number && $order->table && $order->table->table_code) @lang('modules.settings.tableNumber'): {{ $order->table->table_code }} @endif @if ($receiptSettings->show_total_guest && $order->number_of_pax) @lang('modules.order.noOfPax'): {{ $order->number_of_pax }} @endif
@endif @if ($receiptSettings->show_waiter && $order->waiter && $order->waiter->name)
@lang('modules.order.waiter'): {{ $order->waiter->name }}
@endif @if ($receiptSettings->show_order_type)
{{ Str::title(ucwords(str_replace('_', ' ', $order->order_type))) }} @if ($order->order_type === 'pickup') @if ($order->pickup_date) : {{ \Carbon\Carbon::parse($order->pickup_date)->format(dateFormat() . ' ' . timeFormat()) }} @endif @endif
@endif @if ($receiptSettings->show_customer_name && $order->customer && $order->customer->name)
@lang('modules.customer.customer'): {{ $order->customer->name }}
@endif @if ($receiptSettings->show_customer_address && $order->customer && $order->customer->delivery_address)
@lang('modules.customer.customerAddress'): {{ $order->customer->delivery_address }}
@endif @if ($receiptSettings->show_customer_phone && $order->customer && $order->customer->phone)
@lang('modules.customer.phone'): {{ $order->customer->phone }}
@endif {{-- Show payer name and split info --}}
@if($splitData['total_splits'] > 1) @endif
@if ($splitData['payer_name']) @lang('modules.order.guest'): {{ $splitData['payer_name'] }} @endif @lang('modules.order.split'): {{ $splitData['split_number'] }} of {{ $splitData['total_splits'] }}
@foreach ($splitData['items'] as $itemData) @php $item = $itemData['item']; @endphp @endforeach
@lang('modules.order.qty') @lang('modules.menu.itemName') @lang('modules.order.price') @lang('modules.order.amount')
{{ $itemData['allocated_quantity'] }} {{ $item->menuItem->item_name }} @if (isset($item->menuItemVariation))
({{ $item->menuItemVariation->variation }}) @endif @foreach ($item->modifierOptions as $modifier) @php if ($order->order_type_id) { $modifier->setPriceContext($order->order_type_id, $order?->delivery_app_id); } @endphp
• {{ $modifier->name ?? $modifier->pivot->modifier_option_name }} (+{{ currency_format($modifier->pivot->modifier_option_price ?? $modifier->price, restaurant()->currency_id) }})
@endforeach
{{ currency_format($itemData['allocated_price'], restaurant()->currency_id) }} {{ currency_format($itemData['allocated_amount'], restaurant()->currency_id) }}
@lang('modules.order.subTotal'): {{ currency_format($splitData['allocated_amounts']['subtotal'], restaurant()->currency_id) }}
@if ($splitData['allocated_amounts']['discount_amount'] > 0)
@lang('modules.order.discount') @if ($order->discount_type == 'percent') ({{ rtrim(rtrim($order->discount_value, '0'), '.') }}%) @endif -{{ currency_format($splitData['allocated_amounts']['discount_amount'], restaurant()->currency_id) }}
@endif @if(function_exists('module_enabled') && module_enabled('Loyalty') && isset($splitData['allocated_amounts']['loyalty_discount_amount']) && $splitData['allocated_amounts']['loyalty_discount_amount'] > 0)
@lang('loyalty::app.loyaltyDiscount') -{{ currency_format($splitData['allocated_amounts']['loyalty_discount_amount'], restaurant()->currency_id) }}
@endif @if(function_exists('module_enabled') && module_enabled('Loyalty') && isset($splitData['allocated_amounts']['stamp_discount_amount']) && $splitData['allocated_amounts']['stamp_discount_amount'] > 0)
@lang('app.stampDiscount') -{{ currency_format($splitData['allocated_amounts']['stamp_discount_amount'], restaurant()->currency_id) }}
@endif @if (!empty($splitData['allocated_amounts']['charges_breakdown'])) @foreach ($splitData['allocated_amounts']['charges_breakdown'] as $chargeData)
{{ $chargeData['charge']->charge->charge_name }} @if ($chargeData['charge']->charge->charge_type == 'percent') ({{ $chargeData['charge']->charge->charge_value }}%) @endif: {{ currency_format($chargeData['amount'], restaurant()->currency_id) }}
@endforeach @endif @if ($splitData['allocated_amounts']['tip_amount'] > 0)
@lang('modules.order.tip'): {{ currency_format($splitData['allocated_amounts']['tip_amount'], restaurant()->currency_id) }}
@endif @if ($order->order_type === 'delivery' && !is_null($order->delivery_fee))
@lang('modules.delivery.deliveryFee'): @if($splitData['allocated_amounts']['delivery_fee'] > 0) {{ currency_format($splitData['allocated_amounts']['delivery_fee'], restaurant()->currency_id) }} @else @lang('modules.delivery.freeDelivery') @endif
@endif @if ($taxMode == 'order') {{-- Order-level tax: Use pre-calculated breakdown from controller --}} @if(!empty($splitData['allocated_amounts']['tax_breakdown'])) @foreach ($splitData['allocated_amounts']['tax_breakdown'] as $taxData)
{{ $taxData['name'] }} ({{ number_format($taxData['percent'], 2) }}%) {{ currency_format($taxData['amount'], restaurant()->currency_id) }}
@endforeach @if(count($splitData['allocated_amounts']['tax_breakdown']) > 1)
@lang('modules.order.totalTax'): {{ currency_format($splitData['allocated_amounts']['tax_amount'], restaurant()->currency_id) }}
@endif @endif @else {{-- Item-level tax: Use pre-calculated breakdown from controller --}} @if($splitData['allocated_amounts']['tax_amount'] > 0) @if(!empty($splitData['allocated_amounts']['tax_breakdown'])) @foreach ($splitData['allocated_amounts']['tax_breakdown'] as $taxData)
{{ $taxData['name'] }} ({{ number_format($taxData['percent'], 2) }}%) {{ currency_format($taxData['amount'], restaurant()->currency_id) }}
@endforeach @endif
@lang('modules.order.totalTax'): {{ currency_format($splitData['allocated_amounts']['tax_amount'], restaurant()->currency_id) }}
@endif @endif
@lang('modules.order.total'): {{ currency_format($splitData['allocated_amounts']['total'], restaurant()->currency_id) }}
@if ($receiptSettings->show_payment_status)
@lang('modules.order.paymentStatus'): @if($order->status === 'paid') @lang('modules.order.paid') @else @lang('modules.order.unpaid') @endif
@endif
@endforeach