{{-- Quotation receipt layout for MRP tier (no separate Price column; no payment/due sections) --}} @php $lang = $lang ?? 0; // 0=en,1=si,2=ta if (!is_int($lang)) { if (is_numeric($lang)) { $lang = (int) $lang; } else { $key = strtolower(trim((string) $lang)); if (in_array($key, ['sinhala', 'si'], true)) { $lang = 1; } elseif (in_array($key, ['tamil', 'ta'], true)) { $lang = 2; } else { $lang = 0; } } } $langSuffix = $lang == 1 ? '_si' : ($lang == 2 ? '_ta' : '_en'); $format = strtolower($format ?? request('format', 'pos')); $paperSetting = $paperSetting ?? (request('paper_mm') ?? request('paper_width_mm') ?? request('paper_width') ?? ($receiptSettings['paper_width_mm'] ?? $receiptSettings['receipt_paper_width'] ?? ($location->paper_width ?? $location->receipt_width ?? 80))); $paperSetting = is_numeric($paperSetting) ? (float) $paperSetting : 80; $isWideFormat = in_array($format, ['wide', 'letter', 'legal'], true); $isAnyAFormat = strpos($format, 'a') === 0; $isWide = ($paperSetting >= 150) || $isAnyAFormat || $isWideFormat; $isAutoPrint = ((int) request('autoprint', 0) === 1); $includeRemark = !$isAutoPrint || (bool) ($quotation->print_remark ?? false) || ((int) request('include_remark', 0) === 1); $includeNotes = !$isAutoPrint || (bool) ($quotation->print_notes ?? false) || ((int) request('include_notes', 0) === 1); $psMode = strtolower((string) request('ps_mode', '')); $isPeriodSummaryActual = (($quotation->kind ?? null) === 'period_summary') && in_array($psMode, ['b', 'actual', 'actual_rates', 'rate', 'rates'], true); @endphp @if(($receiptSettings['receipt_show_logo'] ?? 1) && $location && $location->logo)
Logo
@endif @if($receiptSettings['receipt_show_title'] ?? 1)
{{ $receiptSettings['business_name'] ?? config('app.name', 'POS System') }}
@endif @if($receiptSettings['receipt_show_address'] ?? 1)
{{ $receiptSettings['business_address'] ?? config('app.address', 'Store Address') }}
@endif @if($receiptSettings['receipt_show_phone'] ?? 1)
{{ $receiptSettings['business_phone'] ?? config('app.phone', 'Tel: 0000000000') }}
@endif @if($receiptSettings['receipt_show_email'] ?? 1)
{{ $receiptSettings['business_email'] ?? '' }}
@endif
@if($receiptSettings['receipt_show_date'] ?? 1) @endif @php $customerName = null; $customerPin = null; if (!empty($quotation->customer) && !empty($quotation->customer->name)) { $customerName = $quotation->customer->name; $customerPin = $quotation->customer->pin ?? null; } elseif (!empty($quotation->customer_name)) { $customerName = $quotation->customer_name; } @endphp @if(!empty($customerName) && ($receiptSettings['receipt_show_customer'] ?? 1)) @php $explicitTier = request('price_tier', request('tier', null)); $tier = ($explicitTier === null || $explicitTier === '') ? (int) (($quotation->customer?->price_tier ?? null) ?? ($location->default_price_tier ?? 3)) : (int) $explicitTier; $tierLabels = [ 0 => 'Normal', 1 => 'Wholesale', 2 => 'Special', 3 => 'MRP', ]; $tierLabel = $tierLabels[$tier] ?? null; @endphp @if(!empty($tierLabel)) @endif @if(!empty($customerPin) && ($receiptSettings['receipt_show_customer_pin'] ?? 0)) @endif @endif @if($receiptSettings['receipt_show_cashier'] ?? 1) @endif @if(!empty($quotation->remark) && $includeRemark) @endif
{{ $receiptSettings['receipt_text_quotation' . $langSuffix] ?? ($receiptSettings['receipt_text_invoice' . $langSuffix] ?? 'Quotation') }} {{ $quotation->bill_no }}
{{ $receiptSettings['receipt_text_date' . $langSuffix] ?? 'Date' }} {{ optional($quotation->quotation_date)->format('Y-m-d') ?? now()->format('Y-m-d') }}
{{ $receiptSettings['receipt_text_customer' . $langSuffix] ?? 'Customer' }} {{ $customerName }}
{{ $receiptSettings['receipt_text_customer_rate' . $langSuffix] ?? 'Customer Rate' }} {{ $tierLabel }}
{{ $receiptSettings['receipt_text_customer_pin' . $langSuffix] ?? 'ID' }} {{ $customerPin }}
{{ $receiptSettings['receipt_text_cashier' . $langSuffix] ?? 'Cashier' }} {{ $quotation->user->name ?? '-' }}
{{ $receiptSettings['receipt_text_remark' . $langSuffix] ?? 'Remark' }} {{ $quotation->remark }}
@php $mrpTotal = 0; $netSubtotal = 0; $itemDiscountTotal = 0; $itemsForRender = $quotation->items; $groups = $isPeriodSummaryActual ? $itemsForRender->groupBy(function ($i) { return (string) ($i->product_id ?? $i->product_name ?? ''); }) : collect(); @endphp @if($isPeriodSummaryActual) @foreach($groups as $group) @php $first = $group->first(); $product = $first?->product; $productName = ($lang ?? 0) === 0 ? ($first?->product_name ?? 'Product') : (!empty($first?->product_name_local) ? $first->product_name_local : ($first?->product_name ?? 'Product')); @endphp @foreach($group as $item) @php $product = $item->product; $mrp = 0; if (!empty($product)) { $mrp = (float) ($product->default_price ?? $product->price_sale ?? 0); } if ($mrp <= 0) { $mrp = (float) ($item->price ?? 0); } $qty = (float) ($item->qty ?? 0); $price = (float) ($item->price ?? 0); $itemTotal = (float) ($item->amount ?? ($qty * $price)); $itemSaving = max(($mrp * $qty) - $itemTotal, 0); $mrpTotal += $mrp * $qty; $netSubtotal += $itemTotal; $itemDiscountTotal += $itemSaving; $unitName = ''; $uid = (int)($product?->unit_id ?? 0); if ($uid > 0 && isset($unitCodesById) && is_array($unitCodesById) && isset($unitCodesById[$uid])) { $unitName = trim((string)$unitCodesById[$uid]); } elseif (isset($product?->unit)) { $unitName = trim((string)$product->unit); } @endphp @endforeach @endforeach @else @foreach($quotation->items as $item) @php $product = $item->product; $productName = ($lang ?? 0) === 0 ? ($item->product_name ?? 'Product') : (!empty($item->product_name_local) ? $item->product_name_local : ($item->product_name ?? 'Product')); $mrp = 0; if (!empty($product)) { $mrp = (float) ($product->default_price ?? $product->price_sale ?? 0); } if ($mrp <= 0) { $mrp = (float) ($item->price ?? 0); } $qty = (float) ($item->qty ?? 0); $price = (float) ($item->price ?? 0); $itemTotal = (float) ($item->amount ?? ($qty * $price)); $itemSaving = max(($mrp * $qty) - $itemTotal, 0); $mrpTotal += $mrp * $qty; $netSubtotal += $itemTotal; $itemDiscountTotal += $itemSaving; $unitName = ''; $uid = (int)($product?->unit_id ?? 0); if ($uid > 0 && isset($unitCodesById) && is_array($unitCodesById) && isset($unitCodesById[$uid])) { $unitName = trim((string)$unitCodesById[$uid]); } elseif (isset($product?->unit)) { $unitName = trim((string)$product->unit); } @endphp @endforeach @endif
{{ $receiptSettings['receipt_text_qty' . $langSuffix] ?? 'Qty' }} {{ $receiptSettings['receipt_text_mrp' . $langSuffix] ?? 'MRP' }} {{ $receiptSettings['receipt_text_amount' . $langSuffix] ?? 'Amount' }}
@if($receiptSettings['receipt_show_barcode'] ?? 1) @php $code = trim((string)($product?->barcode ?? '')); if ($code === '') { $code = trim((string)($product?->sku ?? '')); } @endphp @if($code !== '') {{ $code }} @endif @endif {{ $productName }}
{{ number_format($qty, 2) }}@if(($receiptSettings['receipt_show_unit'] ?? 1) && $unitName !== ''){{ $unitName }}@endif {{ number_format($mrp, 2) }} {{ number_format($itemTotal, 2) }}
@if($receiptSettings['receipt_show_barcode'] ?? 1) @php $code = trim((string)($product?->barcode ?? '')); if ($code === '') { $code = trim((string)($product?->sku ?? '')); } @endphp @if($code !== '') {{ $code }} @endif @endif {{ $productName }}
{{ number_format($qty, 2) }}@if(($receiptSettings['receipt_show_unit'] ?? 1) && $unitName !== ''){{ $unitName }}@endif {{ number_format($mrp, 2) }} {{ number_format($itemTotal, 2) }}
@php $billDiscount = (float) ($quotation->discount ?? 0); $invoiceAmount = max($netSubtotal - $billDiscount, 0); $totalSaving = $itemDiscountTotal + $billDiscount; @endphp
@if($receiptSettings['receipt_show_discounts'] ?? 1) @if($itemDiscountTotal > 0 || $billDiscount > 0) @endif @if($itemDiscountTotal > 0 && ($receiptSettings['receipt_show_item_discount'] ?? 1)) @endif @if($billDiscount > 0) @endif @endif @if($receiptSettings['receipt_show_after_discounts'] ?? 1) @endif
{{ $receiptSettings['receipt_text_received_discounts' . $langSuffix] ?? 'Received Discounts' }}
{{ $receiptSettings['receipt_text_item_discount' . $langSuffix] ?? 'Item Discount' }} ({{ number_format($itemDiscountTotal, 2) }})
{{ $receiptSettings['receipt_text_bill_discount' . $langSuffix] ?? 'Bill Discount' }} ({{ number_format($billDiscount, 2) }})
{{ $receiptSettings['receipt_text_after_discounts' . $langSuffix] ?? 'After Discounts' }}
{{ $receiptSettings['receipt_text_invoice_amount' . $langSuffix] ?? 'Invoice Amount' }} {{ number_format($invoiceAmount, 2) }}
@if(($receiptSettings['receipt_show_your_saving'] ?? 1) && $totalSaving > 0)
{{ $receiptSettings['receipt_text_your_saving' . $langSuffix] ?? 'Your Saving' }}
{{ number_format($totalSaving, 2) }}
@endif
{{ $receiptSettings['receipt_text_sold_items' . $langSuffix] ?? 'Sold Items' }}: {{ number_format($quotation->items->count()) }}
@if(!empty($quotation->notes) && $includeNotes)
{{ $receiptSettings['receipt_text_notes' . $langSuffix] ?? 'Notes' }}
{{ $quotation->notes }}
@endif
{{ $receiptSettings['receipt_footer_text' . $langSuffix] ?? 'Thank you! Come again.' }}
Powered by Yashan.dev thisurababi@gmail.com +94 76 12 48 041 | +94 78 91 31 950