@php $adminProfile = \App\Models\Admin::find(session('admin_id')); $shopName = $adminProfile && $adminProfile->shop_name ? $adminProfile->display_shop_name : ($adminProfile->name ?? 'Mandi Management'); $showReceiptLogo = (bool) ($adminProfile->show_pos_receipt_logo ?? false); $shopLogo = null; $invoiceStatus = strtolower((string) ($invoice->status ?? 'unpaid')); $invoiceStatusLabel = match ($invoiceStatus) { 'paid' => __('Paid'), 'partial' => __('Partial'), 'unpaid' => __('Unpaid'), 'received' => __('Received'), default => ucfirst($invoiceStatus), }; $customerName = $invoice->customer?->display_name ?: __('Walk-in Customer'); $adminName = $adminProfile?->name ?: __('Admin'); if ($showReceiptLogo && $adminProfile && $adminProfile->pos_receipt_logo) { $logoPath = storage_path('app/public/' . $adminProfile->pos_receipt_logo); if (file_exists($logoPath)) { $logoMime = mime_content_type($logoPath) ?: 'image/png'; $shopLogo = 'data:' . $logoMime . ';base64,' . base64_encode(file_get_contents($logoPath)); } } @endphp @php $invoiceDate = $invoice->invoice_date ? \Illuminate\Support\Carbon::parse($invoice->invoice_date) : $invoice->created_at; @endphp
@php $otherChargesTotal = (float) ($invoice->other_charges_total ?? 0); $visibleCharges = $invoice->charges->filter(fn ($charge) => (float) ($charge->amount ?? 0) > 0)->values(); $visibleOtherChargesTotal = (float) $visibleCharges->sum(fn ($charge) => (float) ($charge->amount ?? 0)); $grossItemsTotal = (float) $invoice->items->sum(fn ($item) => (float) $item->qty * (float) $item->price); $itemDiscountTotal = max($grossItemsTotal - (float) $invoice->subtotal, 0); $invoiceDiscount = (float) ($invoice->discount ?? 0); $hasDiscount = $itemDiscountTotal > 0 || $invoiceDiscount > 0; $subTotalAfterAllDiscounts = max($grossItemsTotal - $itemDiscountTotal - $invoiceDiscount, 0); $invoicePayable = $subTotalAfterAllDiscounts; $netPayable = $customerSelected ?? false ? max((float) $totalPayable, 0) : $invoicePayable; @endphp
@if ($shopLogo)
@endif

{{ $shopName }}

{{ $adminProfile?->display_address ?: 'N/A' }}
{{ __('Phone') }}: {{ $adminProfile->phone ?? 'N/A' }}
{{ __('Sales Receipt') }}
{{ __('Dated:') }} {{ $invoiceDate?->format('d/m/Y') }}
{{ __('Time:') }} {{ $invoice->created_at->format('h:i A') }}
{{ __('Inv #:') }} {{ $invoice->invoice_number }}
{{ __('Status:') }} {{ $invoiceStatusLabel }}
{{-- @if((float) ($invoice->cut_total ?? 0) > 0)
{{ __('Cut:') }} Rs. {{ number_format((float) $invoice->cut_total, 2) }}
@endif --}}
{{ __('Customer:') }} {{ $customerName }}
{{--
{{ __('Phone:') }} {{ $invoice->customer->phone ?? 'N/A' }}
--}} {{--
{{ __('Address:') }} {{ $invoice->customer->address ?? 'N/A' }}
--}}
{{ __('Admin:') }} {{ $adminName }}
@foreach ($invoice->items as $item) @endforeach
{{ __('Item Description') }} {{ __('Price') }} {{ __('Qty.') }} {{ __('Amount') }}
{{ $item->product?->display_name ?: $item->product_name }} @if($item->product?->unit)
{{ $item->product->unit->display_name }}
@endif
{{ number_format((float) $item->price, 2) }} {{ number_format((float) $item->qty, 2) }} {{ number_format((float) $item->total, 2) }}
{{ __('Total Items') }} {{ number_format($invoice->items->count(), 2) }}
{{--
{{ __('No. Of Qty.:') }} {{ number_format((float) $invoice->items->sum('qty'), 2) }}
--}}
{{ __('Gross Amount:') }} Rs. {{ number_format($grossItemsTotal, 2) }}
@if($itemDiscountTotal > 0)
- {{ __('Item Discount') }} Rs. {{ number_format($itemDiscountTotal, 2) }}
@endif @if($invoiceDiscount > 0)
- {{ __('Invoice Discount') }} Rs. {{ number_format($invoiceDiscount, 2) }}
@endif @if($hasDiscount)
{{ __('Sub Total Amount:') }} Rs. {{ number_format($subTotalAfterAllDiscounts, 2) }}
@endif @if($visibleCharges->count() > 0)
{{ __('Other Charges') }} Rs. {{ number_format($visibleOtherChargesTotal, 2) }}
@foreach($visibleCharges as $charge)
+ {{ $charge->name }} Rs. {{ number_format((float) $charge->amount, 2) }}
@endforeach @endif @if($customerSelected ?? false) @if(($previousDue ?? 0) > 0)
{{ __('Previous Due') }} Rs. {{ number_format((float) $previousDue, 2) }}
@endif @if(($previousDuePaid ?? 0) > 0)
{{ __('Due Paid') }} Rs. {{ number_format((float) $previousDuePaid, 2) }}
@endif {{-- @if(($remainingPreviousDue ?? 0) > 0)
{{ __('Remaining Previous Due') }} Rs. {{ number_format((float) $remainingPreviousDue, 2) }}
@endif --}}
{{ __('Total Payable') }} Rs. {{ number_format((float) $totalPayable, 2) }}
{{ __('Paid Amount') }} Rs. {{ number_format((float) $invoice->paid_amount, 2) }}
@if(($changeAmount ?? 0) > 0)
{{ __('Change') }} Rs. {{ number_format((float) $changeAmount, 2) }}
@endif
{{ __('Due') }} Rs. {{ number_format((float) $dueAmount, 2) }}
@else
{{ __('Total Payable') }} Rs. {{ number_format((float) $invoicePayable, 2) }}
{{ __('Paid Amount') }} Rs. {{ number_format((float) $invoice->paid_amount, 2) }}
@if(($changeAmount ?? 0) > 0)
{{ __('Change') }} Rs. {{ number_format((float) $changeAmount, 2) }}
@endif @if((float) ($invoice->cut_total ?? 0) > 0)
{{ __('Freight Amount') }} Rs. {{ number_format((float) $invoice->cut_total, 2) }}
@endif
{{ __('Net Payable:') }} Rs. {{ number_format((float) $netPayable, 2) }}
@endif
{{--
AMOUNT IN FIGURES: Rs. {{ number_format((float) $netPayable, 2) }}
--}} @if (!empty($adminProfile->receipt_terms) && !empty($adminProfile->show_receipt_terms))
{{ $adminProfile->receipt_terms }}
@endif
* {{ __('Thanks for shopping with us') }} *
{{--
{{ __('Thanks for shopping with us') }}
--}}
Powered By Power Edge IT Services SMC PVT LTD