{{-- ========================================================= PREPARE DATA ========================================================= --}} @php $gstSale = $gstSale ?? null; $nonGstSale = $nonGstSale ?? null; $hasSeparateBills = ($gstSale !== null) || ($nonGstSale !== null); @endphp {{-- ========================================================= GST RECEIPT ========================================================= --}} @if($gstSale) @php $gstAmountPayable = (float) ( $gstSale->amount_payable ?? $gstSale->total_amount ?? 0 ); $gstReceived = $gstAmountPayable; $gstPaymentMode = $gstSale->payment_mode ?? $offlineSale->payment_mode ?? 'cash'; @endphp
{{-- ================================================= HEADER ================================================== --}}

{{ $branchInfo['name'] ?? '' }}

@if(!empty($branchInfo['address']))

{{ trim( preg_replace( '/\s+/', ' ', $branchInfo['address'] ) ) }}

@endif @if(!empty($branchInfo['phone']))

Phone: {{ $branchInfo['phone'] }}

@endif @if(!empty($branchInfo['email']))

Email: {{ $branchInfo['email'] }}

@endif {{-- COMPANY GSTIN --}} @if(!empty($branchInfo['gstin']))

GSTIN: {{ $branchInfo['gstin'] }}

@endif
GST INVOICE
{{-- ================================================= BILL DETAILS ================================================== --}}
Bill No: {{ $gstSale->order_id ?? '-' }}
Date: @if(!empty($gstSale->created_at)) {{ \Carbon\Carbon::parse( $gstSale->created_at )->format('d/m/Y H:i') }} @else {{ now()->format('d/m/Y H:i') }} @endif
{{-- CUSTOMER DETAILS --}}
Customer Details
{{-- NAME --}}
Name: {{ $customerDetails['name'] ?? 'Walk-in' }}
{{-- PHONE --}} @if(!empty($customerDetails['phone_number']))
Phone: {{ $customerDetails['phone_number'] }}
@endif {{-- ADDRESS --}} @if(!empty($customerDetails['address']))
Address: {{ trim( preg_replace( '/\s+/', ' ', $customerDetails['address'] ) ) }}
@endif {{-- CUSTOMER GSTIN --}} @if(!empty($customerDetails['gst_number']))
GSTIN: {{ $customerDetails['gst_number'] }}
@endif
{{-- ================================================= GST ITEMS ================================================== --}} @foreach($gstSale->sale_items ?? [] as $index => $item) @php $itemName = $item['name'] ?? '-'; $quantity = (float) ( $item['quantity'] ?? 0 ); $sellPrice = (float) ( $item['sell_price'] ?? 0 ); $discount = (float) ( $item['discount'] ?? 0 ); if(isset($item['item_total'])) { $itemAmount = (float) $item['item_total']; } else { $itemAmount = ($sellPrice * $quantity) - $discount; } $gstRate = (float) ( $item['gst'] ?? 0 ); @endphp {{-- SN --}} {{-- ITEM --}} {{-- QTY --}} {{-- RATE --}} {{-- AMOUNT --}} @endforeach
SN ITEMS Qty Rate Amt
{{ $index + 1 }} {{ $itemName }} @if($gstRate > 0)
GST {{ rtrim( rtrim( number_format( $gstRate, 2, '.', '' ), '0' ), '.' ) }}%
@endif
{{ rtrim( rtrim( number_format( $quantity, 2, '.', '' ), '0' ), '.' ) }} ₹{{ number_format( $sellPrice, 2 ) }} ₹{{ number_format( $itemAmount, 2 ) }}
{{-- ================================================= GST TOTALS ================================================== --}}
{{-- SUB TOTAL --}}

Sub Total: ₹{{ number_format( $gstSale->sub_total ?? 0, 2 ) }}

{{-- DISCOUNT --}} @if((float)($gstSale->discount ?? 0) > 0)

Discount: -₹{{ number_format( $gstSale->discount, 2 ) }}

@endif {{-- ADDITIONAL CHARGE --}} @if((float)($gstSale->additional_charge ?? 0) > 0)

Additional Charge: +₹{{ number_format( $gstSale->additional_charge, 2 ) }}

@endif {{-- CGST --}} @if((float)($gstSale->cgst ?? 0) > 0)

CGST: ₹{{ number_format( $gstSale->cgst, 2 ) }}

@endif {{-- SGST --}} @if((float)($gstSale->sgst ?? 0) > 0)

SGST: ₹{{ number_format( $gstSale->sgst, 2 ) }}

@endif {{-- TOTAL GST --}} @if((float)($gstSale->total_tax ?? 0) > 0)

Total GST: ₹{{ number_format( $gstSale->total_tax, 2 ) }}

@endif
{{-- TOTAL --}}

TOTAL: ₹{{ number_format( $gstAmountPayable, 2 ) }}

{{-- PAYMENT MODE --}}

Paid By: {{ ucfirst($gstPaymentMode) }}

{{-- RECEIVED --}}

Received: ₹{{ number_format( $gstReceived, 2 ) }}

{{-- CHANGE --}} @if((float)($gstSale->change_amount ?? 0) > 0)

Change: ₹{{ number_format( $gstSale->change_amount, 2 ) }}

@endif
{{-- FOOTER --}}
@endif {{-- ========================================================= NON GST RECEIPT ========================================================= --}} @if($nonGstSale) @php $nonGstAmountPayable = (float) ( $nonGstSale->amount_payable ?? $nonGstSale->total_amount ?? 0 ); $nonGstReceived = $nonGstAmountPayable; $nonGstPaymentMode = $nonGstSale->payment_mode ?? $offlineSale->payment_mode ?? 'cash'; @endphp
{{-- HEADER --}}

{{ $branchInfo['name'] ?? '' }}

@if(!empty($branchInfo['address']))

{{ trim( preg_replace( '/\s+/', ' ', $branchInfo['address'] ) ) }}

@endif @if(!empty($branchInfo['phone']))

Phone: {{ $branchInfo['phone'] }}

@endif @if(!empty($branchInfo['email']))

Email: {{ $branchInfo['email'] }}

@endif
ESTIMATE
{{-- BILL DETAILS --}}
Bill No: {{ $nonGstSale->order_id ?? '-' }}
Date: @if(!empty($nonGstSale->created_at)) {{ \Carbon\Carbon::parse( $nonGstSale->created_at )->format('d/m/Y H:i') }} @else {{ now()->format('d/m/Y H:i') }} @endif
{{-- CUSTOMER DETAILS --}}
Customer Details
Name: {{ $customerDetails['name'] ?? 'Walk-in' }}
@if(!empty($customerDetails['phone_number']))
Phone: {{ $customerDetails['phone_number'] }}
@endif @if(!empty($customerDetails['address']))
Address: {{ trim( preg_replace( '/\s+/', ' ', $customerDetails['address'] ) ) }}
@endif
{{-- ================================================= NON GST ITEMS ================================================== --}} @foreach($nonGstSale->sale_items ?? [] as $index => $item) @php $itemName = $item['name'] ?? '-'; $quantity = (float) ( $item['quantity'] ?? 0 ); $sellPrice = (float) ( $item['sell_price'] ?? 0 ); $discount = (float) ( $item['discount'] ?? 0 ); if(isset($item['item_total'])) { $itemAmount = (float) $item['item_total']; } else { $itemAmount = ($sellPrice * $quantity) - $discount; } @endphp @endforeach
SN ITEMS Qty Rate Amt
{{ $index + 1 }} {{ $itemName }} {{ rtrim( rtrim( number_format( $quantity, 2, '.', '' ), '0' ), '.' ) }} ₹{{ number_format( $sellPrice, 2 ) }} ₹{{ number_format( $itemAmount, 2 ) }}
{{-- ================================================= NON GST TOTALS ================================================== --}}

Sub Total: ₹{{ number_format( $nonGstSale->sub_total ?? 0, 2 ) }}

@if((float)($nonGstSale->discount ?? 0) > 0)

Discount: -₹{{ number_format( $nonGstSale->discount, 2 ) }}

@endif @if((float)($nonGstSale->additional_charge ?? 0) > 0)

Additional Charge: +₹{{ number_format( $nonGstSale->additional_charge, 2 ) }}

@endif

TOTAL: ₹{{ number_format( $nonGstAmountPayable, 2 ) }}

Paid By: {{ ucfirst($nonGstPaymentMode) }}

Received: ₹{{ number_format( $nonGstReceived, 2 ) }}

@if((float)($nonGstSale->change_amount ?? 0) > 0)

Change: ₹{{ number_format( $nonGstSale->change_amount, 2 ) }}

@endif
@endif {{-- ========================================================= FALLBACK OLD BILLS ========================================================= --}} @if(!$hasSeparateBills) @php $fallbackAmountPayable = (float) ( $offlineSale->amount_payable ?? $offlineSale->total_amount ?? 0 ); $fallbackReceived = $fallbackAmountPayable; $fallbackPaymentMode = $offlineSale->payment_mode ?? 'cash'; @endphp
{{-- HEADER --}}

{{ $branchInfo['name'] ?? '' }}

@if(!empty($branchInfo['address']))

{{ trim( preg_replace( '/\s+/', ' ', $branchInfo['address'] ) ) }}

@endif @if(!empty($branchInfo['phone']))

Phone: {{ $branchInfo['phone'] }}

@endif @if(!empty($branchInfo['email']))

Email: {{ $branchInfo['email'] }}

@endif
SALES RECEIPT
{{-- BILL NO --}}
Bill No: {{ $offlineSale->order_id ?? '-' }}
{{-- DATE --}}
Date: @if(!empty($offlineSale->created_at)) {{ \Carbon\Carbon::parse( $offlineSale->created_at )->format('d/m/Y H:i') }} @else {{ now()->format('d/m/Y H:i') }} @endif
{{-- CUSTOMER --}}
Customer Details
Name: {{ $customerDetails['name'] ?? 'Walk-in' }}
@if(!empty($customerDetails['phone_number']))
Phone: {{ $customerDetails['phone_number'] }}
@endif @if(!empty($customerDetails['address']))
Address: {{ trim( preg_replace( '/\s+/', ' ', $customerDetails['address'] ) ) }}
@endif
{{-- ================================================= FALLBACK ITEMS ================================================== --}} @foreach($offlineSale->sale_items ?? [] as $index => $item) @php $itemName = $item['name'] ?? '-'; $quantity = (float) ( $item['quantity'] ?? 0 ); $sellPrice = (float) ( $item['sell_price'] ?? 0 ); $discount = (float) ( $item['discount'] ?? 0 ); if(isset($item['item_total'])) { $itemAmount = (float) $item['item_total']; } else { $itemAmount = ($sellPrice * $quantity) - $discount; } @endphp @endforeach
SN ITEMS Qty Rate Amt
{{ $index + 1 }} {{ $itemName }} {{ rtrim( rtrim( number_format( $quantity, 2, '.', '' ), '0' ), '.' ) }} ₹{{ number_format( $sellPrice, 2 ) }} ₹{{ number_format( $itemAmount, 2 ) }}
{{-- ================================================= FALLBACK TOTALS ================================================== --}}

Sub Total: ₹{{ number_format( $offlineSale->sub_total ?? 0, 2 ) }}

@if((float)($offlineSale->discount ?? 0) > 0)

Discount: -₹{{ number_format( $offlineSale->discount, 2 ) }}

@endif @if((float)($offlineSale->additional_charge ?? 0) > 0)

Additional Charge: +₹{{ number_format( $offlineSale->additional_charge, 2 ) }}

@endif

TOTAL: ₹{{ number_format( $fallbackAmountPayable, 2 ) }}

Paid By: {{ ucfirst($fallbackPaymentMode) }}

Received: ₹{{ number_format( $fallbackReceived, 2 ) }}

@if((float)($offlineSale->change_amount ?? 0) > 0)

Change: ₹{{ number_format( $offlineSale->change_amount, 2 ) }}

@endif
{{-- FOOTER --}}
@endif
{{-- ============================================================= AUTO PRINT ============================================================= --}}