@include('print.common.css')
{{ $invoiceData['name'] }}
@include('print.common.header')
#{{ $sale->return_code }}
{{ __('sale.return.date') }}: {{ $sale->formatted_return_date }}
{{ __('app.time') }}: {{ $sale->format_created_time }}
@if($sale->reference_no) {{ __('sale.sale_invoice_number') }}: {{ $sale->reference_no }}
@endif
{{ __('sale.return_to') }}
{{ $sale->party->first_name.' '. $sale->party->last_name }}
{{ $sale->party->billing_address }}
@php $isHasBatchItem = ($sale->itemTransaction->where('tracking_type', 'batch')->count() > 0) ? true : false; //Return from Controller $totalBatchTrackingRowCount = ($isHasBatchItem) ? $batchTrackingRowCount : 0; @endphp @if(app('company')['show_hsn']) @endif @if($isHasBatchItem) @if(app('company')['enable_batch_tracking']) @endif @if(app('company')['enable_mfg_date']) @endif @if(app('company')['enable_exp_date']) @endif @if(app('company')['enable_model']) @endif @if(app('company')['enable_color']) @endif @if(app('company')['enable_size']) @endif @endif @if(app('company')['show_mrp']) @endif @if(app('company')['show_discount']) @endif @if(app('company')['tax_type'] != 'no-tax') @endif @php $i=1; @endphp @foreach($sale->itemTransaction as $transaction) @if(app('company')['show_hsn']) @endif @if($isHasBatchItem) @if(app('company')['enable_batch_tracking']) @endif @if(app('company')['enable_mfg_date']) @endif @if(app('company')['enable_exp_date']) @endif @if(app('company')['enable_model']) @endif @if(app('company')['enable_color']) @endif @if(app('company')['enable_size']) @endif @endif @if(app('company')['show_mrp']) @endif @if(app('company')['show_discount']) @endif @if(app('company')['tax_type'] != 'no-tax') @endif @endforeach @if(app('company')['show_discount']) @endif @if(app('company')['tax_type'] != 'no-tax') @endif @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 @php $noteColumns = 4 + $totalBatchTrackingRowCount + app('company')['show_hsn'] + app('company')['show_mrp'] - ((app('company')['tax_type'] =='no-tax') ? 1 : 0) - (app('company')['show_discount'] ? 0 : 1); $noteRosSpan = 4 - ((app('company')['tax_type'] =='no-tax') ? 1 : 0); $amountInWordsRowSpan = 3 + app('company')['show_party_due_payment'] + app('company')['is_enable_secondary_currency']; @endphp @if(app('company')['tax_type'] != 'no-tax') @endif @if(app('company')['is_enable_secondary_currency']) @endif @if(app('company')['show_party_due_payment']) @php $partyTotalDue = $sale->party->getPartyTotalDueBalance(); $partyTotalDueBalance = $partyTotalDue['status']=='you_pay' ? (-1 * $partyTotalDue['balance']) : $partyTotalDue['balance']; @endphp @endif
# {{ __('item.item') }}{{ __('item.hsn') }}{{ __('item.batch_no') }}{{ __('item.mfg_date') }}{{ __('item.exp_date') }}{{ __('item.model_no') }}{{ __('item.color') }}{{ __('item.size') }}{{ __('item.mrp') }}{{ __('app.qty') }} {{ __('app.price_per_unit') }}{{ __('app.discount') }}{{ __('tax.tax') }}{{ __('app.total') }}
{{ $i++ }} {{ $transaction->item->name }} {{ $transaction->description }} @if ($transaction->itemSerialTransaction->count() > 0)
{{ $transaction->itemSerialTransaction->pluck('itemSerialMaster.serial_code')->implode(',') }}
@endif
{{ $transaction->item->hsn }} {{ $transaction->batch ? $transaction->batch->itemBatchMaster->batch_no : '' }} {{ $transaction->batch ? $formatDate->toUserDateFormat($transaction->batch->itemBatchMaster->mfg_date) : '' }} {{ $transaction->batch ? $formatDate->toUserDateFormat($transaction->batch->itemBatchMaster->exp_date) : '' }} {{ $transaction->batch ? $transaction->batch->itemBatchMaster->model_no : ''}} {{ $transaction->batch ? $transaction->batch->itemBatchMaster->color :'' }} {{ $transaction->batch ? $transaction->batch->itemBatchMaster->size : '' }} {{ $formatNumber->formatWithPrecision($transaction->batch ? $transaction->batch->itemBatchMaster->mrp : $transaction->mrp)}} {{ $formatNumber->formatQuantity($transaction->quantity) }} {{ $formatNumber->formatWithPrecision($transaction->unit_price) }}
{{ $transaction->unit->name }}
{{ $formatNumber->formatWithPrecision($transaction->discount_amount) }}
({{ $formatNumber->formatWithPrecision($transaction->discount) }} {{ ($transaction->discount_type == 'fixed') ? '$' : '%' }})
{{ $formatNumber->formatWithPrecision($transaction->tax_amount) }}
({{ $transaction->tax->rate }}%)
{{ $formatNumber->formatWithPrecision($transaction->total) }}
{{ __('app.total') }} {{ $formatNumber->formatWithPrecision($sale->itemTransaction->sum('quantity')) }} {{ $formatNumber->formatWithPrecision($sale->itemTransaction->sum('discount_amount')) }} {{ $formatNumber->formatWithPrecision($sale->itemTransaction->sum('tax_amount')) }} {{ $formatNumber->formatWithPrecision($sale->itemTransaction->sum('total')) }}
Note:
{{ $sale->note }}
{{ __('app.subtotal') }} {{ $formatNumber->formatWithPrecision($subtotal) }}
{{ __('app.discount') }} {{ $formatNumber->formatWithPrecision($discount) }}
{{ __('tax.tax') }} {{ $formatNumber->formatWithPrecision($taxAmount) }}
{{ __('app.round_off') }} {{ $formatNumber->formatWithPrecision($sale->round_off) }}
{{ __('app.amount_in_words') }}:
{{ ucwords($formatNumber->spell($sale->grand_total)) }}
{{ __('app.grand_total') }} {{ $formatNumber->formatWithPrecision($sale->grand_total) }}
{{ __('currency.converted_to').'-'.$sale->currency->code }} {{$formatNumber->formatWithPrecision($sale->grand_total * $sale->exchange_rate)}}
{{ __('payment.paid_amount') }} {{$formatNumber->formatWithPrecision($sale->paid_amount)}}
{{ __('payment.balance') }} {{$formatNumber->formatWithPrecision($sale->grand_total - $sale->paid_amount)}}
{{ __('app.total_due_balance') }} {{$formatNumber->formatWithPrecision($partyTotalDueBalance)}}
@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->discount_amount) * $item->quantity; 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->discount_amount) * $item->quantity; return $totalOfEachItem; /* if ($item->tax_type == 'inclusive') { return calculatePrice($totalOfEachItem, $item->tax->rate, needInclusive: true); } else { return calculatePrice($totalOfEachItem, $item->tax->rate, needInclusive: false); }*/ }); 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 $cs_gst = $i_gst = ''; $cs_gst_amt = $i_gst_amt = ''; if(empty($sale->state_id) || app('company')['state_id'] == $sale->state_id){ $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 @endif @endforeach
{{ __('tax.tax') }} {{ __('tax.taxable_amount') }} {{ __('tax.rate') }} {{ __('tax.tax_amount') }}
{{ __('item.hsn') }} {{ __('tax.taxable_amount') }} {{ __('tax.cgst') }} {{ __('tax.sgst') }} {{ __('tax.igst') }} {{ __('tax.tax_amount') }}
{{ __('tax.rate') }}% {{ __('app.amount') }} {{ __('tax.rate') }}% {{ __('app.amount') }} {{ __('tax.rate') }}% {{ __('app.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 }} {{ $cs_gst }} {{ $cs_gst_amt }} {{ $i_gst }} {{ $i_gst_amt }} {{ $formatNumber->formatWithPrecision($summary['total_tax']) }}
@endif @include('print.common.bank-signature')