{{ app('company')['name'] }}
{{ app('company')['address'] }}

@if(app('company')['mobile'] || app('company')['email']) {{ app('company')['mobile'] ? app('company')['mobile'] : ''}}{{ app('company')['email'] ? ', '.app('company')['email'] : '' }} @endif @if(app('company')['tax_number']!= '' && app('company')['tax_type'] != 'no-tax')
{{ app('company')['tax_type'] == 'gst' ? 'GST:' : __('tax.tax') . ':' }} {{ app('company')['tax_number'] }} @endif

--------{{ $invoiceData['name'] }}--------
{{ __('print.name') }}: {{ $sale->party->first_name.' '. $sale->party->last_name }}
{{ __('print.mobile') }}: {{ $sale->party->mobile }}
{{ __('print.seller') }}: {{ $sale->user->first_name.' '. $sale->user->last_name }}
{{-- Party Tax/GST Number --}} @include('print.common.party-tax-details', ['model' => $sale, 'isPOSInvoice' => true])
{{ __('print.invoice') }}: #{{ $sale->sale_code }}
{{ __('print.date') }}: {{ $sale->formatted_sale_date }}
{{ __('print.time') }}: {{ $sale->format_created_time }}
@if(!empty($sale->reference_no))
{{ __('print.reference_no') }}: {{ $sale->reference_no }}
@endif
{{ __('print.payment_method') }}: {{ $sale->paymentTransaction->map(function ($payment) { return $payment->paymentType->name . (!empty($payment->note) ? '-' . $payment->note : ''); })->unique()->implode(', ') }}
@php $i=1; @endphp @foreach($sale->itemTransaction as $transaction) @php $displayUnitPrice = $transaction->unit_price; $displayLineTotal = $displayUnitPrice * $transaction->quantity; @endphp {{-- Note: Calculate Total = (Unit Price - Discount) + Tax Here we are showing only Total, in below destriburted the discount and Tax --}} @endforeach @php $totalQty = $sale->itemTransaction->sum(function ($transaction) { return $transaction->quantity; }); @endphp
# {{ __('print.description') }} {{ __('print.price_per_unit') }} {{ __('print.qty') }} {{ __('print.total') }}
{{ $i++ }} {{ $transaction->item->name }} {{ $transaction->description }} {{-- Show Brand Name --}} @include('print.common.brand-details', ['model' => $transaction]) @if ($transaction->itemSerialTransaction->count() > 0)
{{ $transaction->itemSerialTransaction->pluck('itemSerialMaster.serial_code')->implode(',') }}
@endif
{{ $formatNumber->formatWithPrecision($displayUnitPrice) }} {{ $formatNumber->formatQuantity($transaction->quantity) }}{{ $formatNumber->formatWithPrecision($displayLineTotal) }}
{{ __('app.total') }} {{ $formatNumber->formatWithPrecision($sale->grand_total) }}
@php $subtotal = $sale->itemTransaction->sum(function ($transaction) { /*if($transaction->tax_type == 'inclusive'){ $unitPrice = calculatePrice($transaction->unit_price, $transaction->tax->rate, needInclusive: true); }else{ $unitPrice = calculatePrice($transaction->unit_price, $transaction->tax->rate, needInclusive: false); }*/ $unitPrice = $transaction->unit_price; return $unitPrice * $transaction->quantity; }); $discount = $sale->itemTransaction->sum(function ($transaction) { return $transaction->discount_amount; }); $taxAmount = $sale->itemTransaction->sum(function ($transaction) { return $transaction->tax_amount; }); @endphp
{{ __('print.discount') }}
{{ $formatNumber->formatWithPrecision(-$discount) }}
{{ __('print.grand_total') }}
{{ $formatNumber->formatWithPrecision($sale->grand_total) }}
@if(app('company')['tax_type'] != 'no-tax')
{{ __('print.tax') }}
{{ $formatNumber->formatWithPrecision($taxAmount) }}
@endif
{{ __('print.paid_amount') }}
{{ $formatNumber->formatWithPrecision($sale->paid_amount) }}
{{ __('print.balance') }}
{{ $formatNumber->formatWithPrecision($sale->grand_total - $sale->paid_amount) }}
{{ __('print.return_amount') }}
{{ $formatNumber->formatWithPrecision($sale->change_return) }}
@if(app('company')['show_mrp']) @php $savedAmount = $sale->itemTransaction->sum(function ($transaction) { if($transaction->mrp > 0){ return ($transaction->mrp * $transaction->quantity) - $transaction->total; }else{ return 0; } }); @endphp
{{ __('print.you_saved') }}
{{ $formatNumber->formatWithPrecision($savedAmount) }}
@endif @if(app('company')['show_party_due_payment']) @php $partyTotalDue = $sale->party->getPartyTotalDueBalance(); $partyTotalDueBalance = $partyTotalDue['balance']; @endphp
{{ __('print.previous_due') }}
{{ $formatNumber->formatWithPrecision($partyTotalDueBalance - ($sale->grand_total - $sale->paid_amount) ) }}
{{ __('print.total_due_balance') . ($partyTotalDue['status'] == 'you_pay' ? '(You Pay)' : '(Receive)') }}
{{ $formatNumber->formatWithPrecision($partyTotalDueBalance) }}
@endif
@if(app('company')['show_tax_summary'] && app('company')['tax_type'] != 'no-tax') @if(app('company')['tax_type'] == 'tax') @else {{-- GST --}} @endif @php if(app('company')['tax_type'] == 'tax'){ $taxSummary = $sale->itemTransaction ->groupBy('tax_id') ->map(function ($group) { $firstItem = $group->first(); $totalTaxableAmount = $group->sum(function ($item) use ($firstItem) { $totalOfEachItem = ($item->unit_price * $item->quantity) - $item->discount_amount; return $totalOfEachItem; /* if ($item->tax_type == 'inclusive') { return calculatePrice($totalOfEachItem, $firstItem->tax->rate, needInclusive: true); } else { return calculatePrice($totalOfEachItem, $firstItem->tax->rate, needInclusive: false); }*/ }); return [ 'tax_id' => $firstItem->tax_id, 'tax_name' => $firstItem->tax->name, 'tax_rate' => $firstItem->tax->rate, 'total_taxable_amount' => $totalTaxableAmount, 'total_tax' => $group->sum('tax_amount') ]; }) ->values(); } else{ //GST $taxSummary = $sale->itemTransaction ->groupBy('item.hsn') // First group by HSN ->map(function ($hsnGroup) { return $hsnGroup->groupBy('tax_id') // Then group by tax_id within each HSN group ->map(function ($group) { $firstItem = $group->first(); $totalTaxableAmount = $group->sum(function ($item) { $totalOfEachItem = ($item->unit_price * $item->quantity) - $item->discount_amount; return $totalOfEachItem; }); return [ 'hsn' => $firstItem->item->hsn, 'tax_id' => $firstItem->tax_id, 'tax_name' => $firstItem->tax->name, 'tax_rate' => $firstItem->tax->rate, 'total_taxable_amount' => $totalTaxableAmount, 'total_tax' => $group->sum('tax_amount') ]; }); }) ->flatMap(function ($hsnGroup) { return $hsnGroup; }) ->values(); } @endphp @foreach($taxSummary as $summary) @if(app('company')['tax_type'] == 'tax') @else @php $isCSGST = (empty($sale->state_id) || app('company')['state_id'] == $sale->state_id) ? true:false; @endphp @php $cs_gst = $i_gst = ''; $cs_gst_amt = $i_gst_amt = ''; if($isCSGST){ $cs_gst = ($summary['tax_rate']/2).'%'; $cs_gst_amt = $formatNumber->formatWithPrecision($summary['total_tax']/2); }else{ $i_gst = ($summary['tax_rate']).'%'; $i_gst_amt = $formatNumber->formatWithPrecision($summary['total_tax']); } @endphp @if($isCSGST) @else @endif @endif @endforeach
{{ __('print.tax') }} {{ __('print.taxable_amount') }} {{ __('print.rate') }} {{ __('print.tax_amount') }}
{{ __('print.hsn') }} {{ __('print.taxable_amount') }} {{ __('print.gst') }} {{ __('print.tax_amount') }}
{{ __('print.rate') }}% {{ __('print.amount') }}
{{ $summary['tax_name'] }} {{ $formatNumber->formatWithPrecision($summary['total_taxable_amount']) }} {{ $summary['tax_rate'] }}% {{ $formatNumber->formatWithPrecision($summary['total_tax']) }}
{{ $summary['hsn'] }} {{ $formatNumber->formatWithPrecision($summary['total_taxable_amount']) }} {{ $cs_gst }} {{ $cs_gst_amt }} {{ $i_gst }} {{ $i_gst_amt }}{{ $formatNumber->formatWithPrecision($summary['total_tax']) }}
@endif
@if(app('company')['is_saudi']) @endif