@php $logoSetting = \App\Models\Setting::get('shop_logo', ''); $logo = $logoSetting ?: (file_exists(public_path('logo.png')) ? asset('logo.png') : ''); $qrCode = \App\Models\Setting::get('shop_qr_code', ''); $address = \App\Models\Setting::get('shop_address', ''); $gstin = \App\Models\Setting::get('shop_gstin', ''); $mobile = \App\Models\Setting::get('shop_mobile', ''); $email = \App\Models\Setting::get('shop_email', ''); $shopName = \App\Models\Setting::get('shop_name', 'Mahendra Jewellers'); $customer = $sale->customer; $totalWeight = $sale->items->sum(fn ($i) => (float) $i->weight); $billTypeLabel = [ 'gst' => 'Tax Invoice', 'cash' => 'Cash Bill', 'on_approval' => 'Approval Memo', ][$sale->sale_type] ?? 'Sale Bill'; $hsnForProduct = function ($product) { $metal = strtolower((string) ($product->metal_type ?? '')); if (str_contains($metal, 'silver')) { return \App\Models\Setting::get('hsn_silver', '7113'); } if (str_contains($metal, 'gold')) { return \App\Models\Setting::get('hsn_gold', \App\Models\Setting::get('hsn_jewellery', '7113')); } return \App\Models\Setting::get('hsn_jewellery', '7113'); }; $itemName = fn ($item) => $item->product?->product_code ?? $item->item_name ?? '-'; $hsnForItem = function ($item) use ($hsnForProduct) { if ($item->hsn_code) { return $item->hsn_code; } $metal = strtolower((string) $item->metal_type); if (str_contains($metal, 'silver')) { return \App\Models\Setting::get('hsn_silver', '7113'); } if (str_contains($metal, 'gold')) { return \App\Models\Setting::get('hsn_gold', \App\Models\Setting::get('hsn_jewellery', '7113')); } return $hsnForProduct($item->product); }; $metalSaleLabel = function ($item) { $metal = strtolower((string) ($item->metal_type ?: $item->product?->metal_type)); if (str_contains($metal, 'silver')) { return 'Silver sale'; } if (str_contains($metal, 'gold')) { return 'Gold sale'; } return ''; }; $money = fn ($value) => '₹' . \App\Support\IndianNumber::format($value, 2); $paymentLabels = [ 'cash' => 'Cash', 'upi' => 'UPI', 'card' => 'Card', 'bank_transfer' => 'Bank Transfer', 'cheque' => 'Cheque', 'adjustment' => 'Adjustment', ]; $paymentSummary = $sale->payments ->filter(fn ($payment) => (float) $payment->cash_amount > 0) ->map(fn ($payment) => ($paymentLabels[$payment->payment_mode] ?? ucfirst((string) $payment->payment_mode)) . ' ' . \App\Support\IndianNumber::format($payment->cash_amount, 2)) ->implode(' + '); @endphp
@if($logo) {{ $shopName }} @else {{ strtoupper(substr($shopName, 0, 2)) }} @endif

{{ $shopName }}

{{ $billTypeLabel }}

@if($email)

{{ $email }}

@endif @if($mobile)

{{ $mobile }}

@endif @if($address)

{{ $address }}

@endif @if($gstin)

GSTIN: {{ $gstin }}

@endif
Invoice: {{ $sale->bill_number }} Date  {{ $sale->sale_date->format('d/m/Y') }}

Invoice to:

{{ $customer?->name ?? 'Walk-in Customer' }}

@if($customer?->mobile)

{{ $customer->mobile }}

@endif @if($customer?->address)

{{ $customer->address }}

@endif @if($sale->customer_gst_number)

GSTIN: {{ $sale->customer_gst_number }}

@endif
@foreach($sale->items as $item) @endforeach
Qty. Item Description Weight Purity Rate Total
1 {{ $itemName($item) }}
{{ $item->product?->category?->name ?? ($item->product_id ? 'Jewellery' : ($metalSaleLabel($item) ?: 'Non inventory')) }} · HSN: {{ $hsnForItem($item) }}
@if($item->product?->description)
{{ $item->product->description }}
@endif
{{ \App\Support\IndianNumber::format($item->weight, 3) }} g {{ $item->purity }} {!! $item->rate ? $money($item->rate) : '-' !!} {!! $money($item->amount) !!}

Payment Info: {{ $paymentSummary ?: ucfirst((string) $sale->payment_mode) }} - {{ ucfirst((string) $sale->payment_type) }}

Items: {{ $sale->items->count() }}

Total Weight: {{ \App\Support\IndianNumber::format($totalWeight, 3) }} g

@if($sale->payment_type === 'credit')

Paid Amount: {!! $money($sale->paid_amount) !!}

Balance: {!! $money($sale->credit_amount) !!}

@else

Paid Amount: {!! $money($sale->paid_amount ?: $sale->final_amount) !!}

Balance: {!! $money($sale->credit_amount) !!}

@endif @if($gstin)

GSTIN: {{ $gstin }}

@endif @if($qrCode)
Payment QR Scan to pay
via UPI
@endif

Terms & Conditions

Goods once sold will be accepted only as per store policy. Please verify weight, purity, rate, and customer details before leaving.

@if($sale->notes)

Notes: {{ $sale->notes }}

@endif
@if($sale->sale_type === 'gst') @endif @if($sale->old_gold_amount) @endif
Taxable: {!! $money($sale->taxable_value) !!}
CGST: {!! $money($sale->cgst) !!}
SGST: {!! $money($sale->sgst) !!}
Old Gold: - {!! $money($sale->old_gold_amount) !!}
Total: {!! $money($sale->final_amount) !!}