@php use Carbon\Carbon; $party = 'Dr'; switch ($name) { case 'Purchase': $party = 'Cr'; break; case 'Sales': $party = 'Dr'; break; case 'Purchase Return': $party = 'Dr'; break; case 'Sales Return': $party = 'Cr'; break; default: $party = 'Dr'; break; } @endphp @foreach ($vouchers as $voucher) @php $businessType = $party == 'Cr' ? ($voucher->creditLedger != null && $voucher->creditLedger->gst != null && $voucher->creditLedger->gst != 0 ? 'B2B' : 'B2C') : ($voucher->debitLedger != null && $voucher->debitLedger->gst != null && $voucher->debitLedger->gst != 0 ? 'B2B' : 'B2C'); @endphp @if ($businessType == 'B2B') @if (($party == 'Cr' && $voucher->creditLedger == null) || ($party == 'Dr' && $voucher->debitLedger == null)) @php $ledgerName = ''; @endphp @foreach ($paymentLedgers as $paymentLedger) @php $ledger = App\Models\AccountingVoucherDetails::where('accounting_voucher_id', $voucher->id) ->where('ledger_id', $paymentLedger->id) ->first(); if ($ledger) { $ledgerName .= $paymentLedger->name . ', '; } @endphp @endforeach @endif @if ($voucher->status != 0) @if ($voucher->is_accounts_only == 0) @php $taxableValue = $voucher->items->sum('taxable_value'); $cgst = $voucher->items->sum('cgst'); $sgst = $voucher->items->sum('sgst'); $igst = $voucher->items->sum('igst'); $cess = $voucher->items->sum('cess'); $total = $voucher->items->sum('total'); @endphp @else @php $taxableValue = 0; $cgst = 0; $sgst = 0; $igst = 0; $cess = 0; $total = $voucher->amount; foreach ($voucher->accountingVoucherDetails as $key => $detail) { if ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'CGST') { $cgst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'SGST') { $sgst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'IGST') { $igst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'CESS') { $cess += $detail->amount; } elseif ( $detail->ledger->group->name == 'Sales Accounts' || $detail->ledger->group->name == 'Purchase Accounts' ) { $taxableValue += $detail->amount; } } $total = $cgst + $sgst + $igst + $cess + $taxableValue; @endphp @endif @else @endif @endif @endforeach @foreach ($vouchers as $voucher) @php $businessType = $party == 'Cr' ? ($voucher->creditLedger != null && $voucher->creditLedger->gst != null && $voucher->creditLedger->gst != 0 ? 'B2B' : 'B2C') : ($voucher->debitLedger != null && $voucher->debitLedger->gst != null && $voucher->debitLedger->gst != 0 ? 'B2B' : 'B2C'); @endphp @if ($businessType == 'B2C') @if (($party == 'Cr' && $voucher->creditLedger == null) || ($party == 'Dr' && $voucher->debitLedger == null)) @php $ledgerName = ''; @endphp @foreach ($paymentLedgers as $paymentLedger) @php $ledger = App\Models\AccountingVoucherDetails::where('accounting_voucher_id', $voucher->id) ->where('ledger_id', $paymentLedger->id) ->first(); if ($ledger) { $ledgerName .= $paymentLedger->name . ', '; } @endphp @endforeach @endif @if ($voucher->status != 0) @if ($voucher->is_accounts_only == 0) @php $taxableValue = $voucher->items->sum('taxable_value'); $cgst = $voucher->items->sum('cgst'); $sgst = $voucher->items->sum('sgst'); $igst = $voucher->items->sum('igst'); $cess = $voucher->items->sum('cess'); $total = $voucher->items->sum('total'); @endphp @else @php $taxableValue = 0; $cgst = 0; $sgst = 0; $igst = 0; $cess = 0; $total = $voucher->amount; foreach ($voucher->accountingVoucherDetails as $key => $detail) { if ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'CGST') { $cgst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'SGST') { $sgst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'IGST') { $igst += $detail->amount; } elseif ($detail->ledger->tax_type != null && $detail->ledger->tax_type == 'CESS') { $cess += $detail->amount; } elseif ( $detail->ledger->group->name == 'Sales Accounts' || $detail->ledger->group->name == 'Purchase Accounts' ) { $taxableValue += $detail->amount; } } $total = $cgst + $sgst + $igst + $cess + $taxableValue; @endphp @endif @else @endif @endif @endforeach
Voucher Number Voucher Date Voucher Type Party Name Party Address Party Pincode Party GSTIN Party Code Taxable Value CGST SGST IGST CESS Total Business Type Supplier Inv No Supplier Inv Date Status
B2B
{{ $voucher->voucher_number }} {{ Carbon::parse($voucher->voucher_date)->format('d-m-Y') }} {{ $voucher->voucherType->name }} {{ $party == 'Cr' ? ($voucher->creditLedger != null ? $voucher->creditLedger->name : $ledgerName) : ($voucher->debitLedger != null ? $voucher->debitLedger->name : $ledgerName) }} {{ $party == 'Cr' ? $voucher->creditLedger?->address : $voucher->debitLedger?->address }} {{ $party == 'Cr' ? $voucher->creditLedger?->pin_code : $voucher->debitLedger?->pin_code }} {{ $party == 'Cr' ? $voucher->creditLedger?->gst : $voucher->debitLedger?->gst }} {{ $party == 'Cr' ? $voucher->creditLedger?->ledger_code : $voucher->debitLedger?->ledger_code }} {{ $taxableValue }} {{ $cgst }} {{ $sgst }} {{ $igst }} {{ $cess }} {{ $total }} {{ $businessType }} {{ $voucher->supplier_invoice_no }} {{ $voucher->supplier_invoice_date != null ? Carbon::parse($voucher->supplier_invoice_date)->format('d-m-Y') : '' }} {{ $voucher->status == 0 ? 'Cancelled' : '' }}
{{ $voucher->voucher_number }} {{ Carbon::parse($voucher->voucher_date)->format('d-m-Y') }} {{ $voucher->voucherType->name }} {{ $party == 'Cr' ? ($voucher->creditLedger != null ? $voucher->creditLedger->name : $ledgerName) : ($voucher->debitLedger != null ? $voucher->debitLedger->name : $ledgerName) }} {{ $party == 'Cr' ? $voucher->creditLedger?->address : $voucher->debitLedger?->address }} {{ $party == 'Cr' ? $voucher->creditLedger?->pin_code : $voucher->debitLedger?->pin_code }} {{ $party == 'Cr' ? $voucher->creditLedger?->gst : $voucher->debitLedger?->gst }} {{ $party == 'Cr' ? $voucher->creditLedger?->ledger_code : $voucher->debitLedger?->ledger_code }} {{ $businessType }} {{ $voucher->supplier_invoice_no }} {{ $voucher->supplier_invoice_date != null ? Carbon::parse($voucher->supplier_invoice_date)->format('d-m-Y') : '' }} Cancelled
B2C
{{ $voucher->voucher_number }} {{ Carbon::parse($voucher->voucher_date)->format('d-m-Y') }} {{ $voucher->voucherType->name }} {{ $party == 'Cr' ? ($voucher->creditLedger != null ? $voucher->creditLedger->name : $ledgerName) : ($voucher->debitLedger != null ? $voucher->debitLedger->name : $ledgerName) }} {{ $party == 'Cr' ? $voucher->creditLedger?->address : $voucher->debitLedger?->address }} {{ $party == 'Cr' ? $voucher->creditLedger?->pin_code : $voucher->debitLedger?->pin_code }} {{ $party == 'Cr' ? $voucher->creditLedger?->gst : $voucher->debitLedger?->gst }} {{ $party == 'Cr' ? $voucher->creditLedger?->ledger_code : $voucher->debitLedger?->ledger_code }} {{ $taxableValue }} {{ $cgst }} {{ $sgst }} {{ $igst }} {{ $cess }} {{ $total }} {{ $businessType }} {{ $voucher->supplier_invoice_no }} {{ $voucher->supplier_invoice_date != null ? Carbon::parse($voucher->supplier_invoice_date)->format('d-m-Y') : '' }} {{ $voucher->status == 0 ? 'Cancelled' : '' }}
{{ $voucher->voucher_number }} {{ Carbon::parse($voucher->voucher_date)->format('d-m-Y') }} {{ $voucher->voucherType->name }} {{ $party == 'Cr' ? ($voucher->creditLedger != null ? $voucher->creditLedger->name : $ledgerName) : ($voucher->debitLedger != null ? $voucher->debitLedger->name : $ledgerName) }} {{ $party == 'Cr' ? $voucher->creditLedger?->address : $voucher->debitLedger?->address }} {{ $party == 'Cr' ? $voucher->creditLedger?->pin_code : $voucher->debitLedger?->pin_code }} {{ $party == 'Cr' ? $voucher->creditLedger?->gst : $voucher->debitLedger?->gst }} {{ $party == 'Cr' ? $voucher->creditLedger?->ledger_code : $voucher->debitLedger?->ledger_code }} {{ $businessType }} {{ $voucher->supplier_invoice_no }} {{ $voucher->supplier_invoice_date != null ? Carbon::parse($voucher->supplier_invoice_date)->format('d-m-Y') : '' }} {{ $voucher->status == 0 ? 'Cancelled' : '' }}