@php $sym = config('pos.company.currency_symbol'); $billable = $split ?? $order; $lines = ($split ? $split->items : $order->items)->where('status', '!=', 'void'); $happySaved = $lines->sum(fn ($i) => $i->original_price ? ((float) $i->original_price - (float) $i->unit_price) * $i->quantity : 0); $documentType = $documentType ?? ((! $split && (bool) ($order->proforma ?? false)) ? 'bill' : 'receipt'); $isBill = $documentType === 'bill'; $receipt = [ 'show_logo' => \App\Models\Setting::get('receipt', 'show_logo', true), 'show_business_name' => \App\Models\Setting::get('receipt', 'show_business_name', true), 'show_landmark' => \App\Models\Setting::get('receipt', 'show_landmark', true), 'landmark' => \App\Models\Setting::get('receipt', 'landmark', ''), 'show_customer_details' => \App\Models\Setting::get('receipt', 'show_customer_details', true), 'show_business_contacts' => \App\Models\Setting::get('receipt', 'show_business_contacts', true), 'show_phone' => \App\Models\Setting::get('receipt', 'show_phone', true), 'show_alternative_phone' => \App\Models\Setting::get('receipt', 'show_alternative_phone', false), 'show_email' => \App\Models\Setting::get('receipt', 'show_email', false), 'show_website' => \App\Models\Setting::get('receipt', 'show_website', false), 'show_kra_pin' => \App\Models\Setting::get('receipt', 'show_kra_pin', true), 'show_order_details' => \App\Models\Setting::get('receipt', 'show_order_details', true), 'header_text' => \App\Models\Setting::get('receipt', 'header_text', ''), 'footer_text' => \App\Models\Setting::get('receipt', 'footer_text', 'Thank you for dining with us!'), ]; $logoPath = \App\Models\Setting::get('general', 'logo_path', config('pos.company.logo_path')); // Normalize legacy paths to the path relative to storage/app/public. $logoRelativePath = ltrim((string) $logoPath, '/'); foreach (['storage/app/public/', 'public/storage/', 'storage/'] as $prefix) { if (str_starts_with($logoRelativePath, $prefix)) { $logoRelativePath = substr($logoRelativePath, strlen($prefix)); break; } } $logoUrl = $logoRelativePath !== '' ? asset('storage/' . $logoRelativePath) : null; $customerPayment = ($split ? $split->payments : $order->payments)->first(fn ($payment) => $payment->customer); $receiptCustomer = $customerPayment?->customer; @endphp @if ($receipt['show_logo'] && $logoPath)
@endif @if ($receipt['show_business_name'])
{{ \App\Models\Setting::get('general', 'company_name', config('pos.company.name')) }}
@endif @if ($receipt['show_business_contacts']) @if (config('pos.company.address'))
{{ config('pos.company.address') }}
@endif @if ($receipt['show_landmark'] && $receipt['landmark'])
{{ $receipt['landmark'] }}
@endif @if ($receipt['show_phone'] && \App\Models\Setting::get('general', 'business_phone', config('pos.company.phone', '')))
{{ \App\Models\Setting::get('general', 'business_phone', config('pos.company.phone', '')) }}
@endif @if ($receipt['show_alternative_phone'] && \App\Models\Setting::get('general', 'alternative_phone', ''))
Alt: {{ \App\Models\Setting::get('general', 'alternative_phone', '') }}
@endif @if ($receipt['show_email'] && \App\Models\Setting::get('general', 'business_email', ''))
{{ \App\Models\Setting::get('general', 'business_email', '') }}
@endif @if ($receipt['show_website'] && \App\Models\Setting::get('general', 'business_website', ''))
{{ \App\Models\Setting::get('general', 'business_website', '') }}
@endif @if ($receipt['show_kra_pin'] && \App\Models\Setting::get('general', 'company_pin', config('pos.company.kra_pin', '')))
KRA PIN: {{ \App\Models\Setting::get('general', 'company_pin', config('pos.company.kra_pin', '')) }}
@endif @if (config('pos.company.till_number') || config('pos.company.paybill_number'))
@if (config('pos.company.till_number')) Till: {{ config('pos.company.till_number') }} @endif @if (config('pos.company.till_number') && config('pos.company.paybill_number')) · @endif @if (config('pos.company.paybill_number')) Paybill: {{ config('pos.company.paybill_number') }} @endif
@endif @endif @if (trim((string) $receipt['header_text']) !== '')
{{ $receipt['header_text'] }}
@endif @if ($isBill)
BILL
@endif
@if ($receipt['show_order_details'])
Order: {{ $order->order_number }}
@if ($split)
{{ $split->label }}
@endif
{{ $order->table->name ?? $order->sale_type->label() }}
Waiter: {{ $order->waiter->name ?? '-' }}@if ($order->cashier) · Cashier: {{ $order->cashier->name }}@endif
@endif
{{ now(config('pos.company.timezone', 'Africa/Nairobi'))->format('d M Y, H:i') }}
@if ($receipt['show_customer_details'] && $receiptCustomer)
Customer: {{ $receiptCustomer->name }}
@if ($receiptCustomer->phone)
Phone: {{ $receiptCustomer->phone }}
@endif @if ($receiptCustomer->kra_pin)
KRA PIN: {{ $receiptCustomer->kra_pin }}
@endif @endif
@forelse ($lines as $item) @empty @endforelse
{{ $item->quantity }}x {{ $item->product->name }}@if ($item->discount_percent > 0) (-{{ rtrim(rtrim(number_format($item->discount_percent, 2), '0'), '.') }}%)@endif {{ number_format($item->line_total, 2) }}
No items

@if ($happySaved > 0) @endif @if (! $split) @endif
Subtotal{{ number_format($billable->subtotal, 2) }}
Happy hour saved you{{ number_format($happySaved, 2) }}
Discount-{{ number_format($billable->discount_total, 2) }}
Service charge{{ number_format($order->service_charge_total, 2) }}
VAT{{ number_format($billable->tax_total, 2) }}
Levy{{ number_format($billable->levy_total, 2) }}
TOTAL{{ $sym }} {{ number_format($billable->grand_total, 2) }}

@if ($isBill)
Please settle with the cashier.
@else @php $creditPayment = ($split ? $split->payments : $order->payments)->first(fn ($payment) => ($payment->paymentMethod->type ?? null) === 'credit' || strtolower((string) $payment->method) === 'credit'); @endphp @if ($creditPayment)
DUE
@if ($creditPayment->customer)
Customer: {{ $creditPayment->customer->name }}
@endif @endif
Payments
@forelse (($split ? $split->payments : $order->payments) as $payment)
{{ $payment->paymentMethod->name ?? $payment->method }} {{ number_format($payment->amount, 2) }}
@if ($payment->reference_number)
Ref: {{ $payment->reference_number }}
@endif @empty
No payment recorded yet
@endforelse
@if (trim((string) $receipt['footer_text']) !== '')
{{ $receipt['footer_text'] }}
@endif @endif