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

@if(app('company')['mobile'] || app('company')['email']) {{ app('company')['mobile'] ? 'M: '. app('company')['mobile'] : ''}}{{ app('company')['email'] ? ', Mail: '.app('company')['email'] : '' }} @endif

--------{{ $invoiceData['name'] }}--------
{{ __('app.name') }}: {{ $sale->party->first_name.' '. $sale->party->last_name }}
{{ __('app.mobile') }}: {{ $sale->party->mobile }}
{{ __('sale.seller') }}: {{ $sale->user->first_name.' '. $sale->user->last_name }}
{{ __('sale.invoice') }}: #SL0040
{{ __('app.date') }}: {{ $sale->formatted_sale_date }}
{{ __('app.time') }}: {{ $sale->format_created_time }}
@php $i=1; @endphp @foreach($sale->itemTransaction as $transaction) {{-- 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
# {{ __('app.description') }} {{ __('app.price_per_unit') }} {{ __('app.qty') }} {{ __('app.total') }}
{{ $i++ }} {{ $transaction->item->name }} {{ $transaction->description }} @if ($transaction->itemSerialTransaction->count() > 0)
{{ $transaction->itemSerialTransaction->pluck('itemSerialMaster.serial_code')->implode(',') }}
@endif
{{ $formatNumber->formatWithPrecision($transaction->total/$transaction->quantity) }} {{ $formatNumber->formatQuantity($transaction->quantity) }}{{ $formatNumber->formatWithPrecision($transaction->total) }}
{{ __('app.total') }} {{ $formatNumber->formatQuantity($totalQty) }} {{ $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
{{ __('app.subtotal') }}
{{ $formatNumber->formatWithPrecision($subtotal) }}
{{ __('app.discount') }}
{{ $formatNumber->formatWithPrecision(-$discount) }}
@if(app('company')['tax_type'] != 'no-tax')
{{ __('tax.tax') }}
{{ $formatNumber->formatWithPrecision($taxAmount) }}
@endif
{{ __('app.round_off') }}
{{ $formatNumber->formatWithPrecision($sale->round_off) }}
{{ __('app.grand_total') }}
{{ $formatNumber->formatWithPrecision($sale->grand_total) }}
{{ __('payment.paid_amount') }}
{{ $formatNumber->formatWithPrecision($sale->paid_amount) }}
{{ __('payment.balance') }}
{{ $formatNumber->formatWithPrecision($sale->grand_total - $sale->paid_amount) }}
@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
{{ __('app.you_saved') }}
{{ $formatNumber->formatWithPrecision($savedAmount) }}
@endif @if(app('company')['show_party_due_payment']) @php $partyTotalDue = $sale->party->getPartyTotalDueBalance(); $partyTotalDueBalance = $partyTotalDue['balance']; @endphp
{{ __('app.previous_due') }}
{{ $formatNumber->formatWithPrecision($partyTotalDueBalance - ($sale->grand_total - $sale->paid_amount) ) }}
{{ __('app.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->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 $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
{{ __('tax.tax') }} {{ __('tax.taxable_amount') }} {{ __('tax.rate') }} {{ __('tax.tax_amount') }}
{{ __('item.hsn') }} {{ __('tax.taxable_amount') }} {{ __('tax.gst') }} {{ __('tax.tax_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 }} {{ $i_gst }} {{ $i_gst_amt }}{{ $formatNumber->formatWithPrecision($summary['total_tax']) }}
@endif