@foreach ($salesVoucherTypes as $key => $salesVoucherType) @php $baseQuery = \App\Models\AccountingVoucher::where('voucher_type_id', $salesVoucherType->id) ->whereDate('voucher_date', '>=', $fromDate) ->whereDate('voucher_date', '<=', $toDate); $startVoucherNumber = (clone $baseQuery)->orderBy('id', 'asc')->first(); $endVoucherNumber = (clone $baseQuery)->orderBy('id', 'desc')->first(); $vouchersCount = (clone $baseQuery)->count(); $vouchersCancelled = (clone $baseQuery)->where('status', 0)->count(); $netIssued = $vouchersCount - $vouchersCancelled; @endphp @endforeach @foreach ($returnVoucherTypes as $key => $returnVoucherType) @php $baseQuery = \App\Models\AccountingVoucher::where('voucher_type_id', $returnVoucherType->id) ->whereDate('voucher_date', '>=', $fromDate) ->whereDate('voucher_date', '<=', $toDate); $startVoucherNumber = (clone $baseQuery)->orderBy('id', 'asc')->first(); $endVoucherNumber = (clone $baseQuery)->orderBy('id', 'desc')->first(); $vouchersCount = (clone $baseQuery)->count(); $vouchersCancelled = (clone $baseQuery)->where('status', 0)->count(); $netIssued = $vouchersCount - $vouchersCancelled; @endphp @endforeach
Nature Of Document Voucher Number Voucher Count Cancelled Net Issued
From To
Invoices For OutWard Supply
{{ $salesVoucherType->name }}{{$startVoucherNumber ? $startVoucherNumber->voucher_number : ''}} {{$endVoucherNumber ? $endVoucherNumber->voucher_number : ''}} {{$vouchersCount}} {{$vouchersCancelled}} {{$netIssued}}
Credit Note
{{ $returnVoucherType->name }}{{$startVoucherNumber ? $startVoucherNumber->voucher_number : ''}} {{$endVoucherNumber ? $endVoucherNumber->voucher_number : ''}} {{$vouchersCount}} {{$vouchersCancelled}} {{$netIssued}}