{{-- bhai ye code pura revamp hoga fast fixing --}} @extends('layouts.pdf') @section('title') {{ $extra['module_name'] }} @endsection @section('content') {{--

Printing Date & Time: {{ $extra['current_date_time'] }}

--}}
@include('admin.partials.header', ['extra' => $extra]) @php $counter = 1; $total_doc_total_amount = 0; $total_doc_paid_amount = 0; $total_doc_balance_amount = 0; $total_amount = 0; $counter2 = 1; $total_received_amount = 0; $total_amount = 0; $total_amount_purchase_order = 0; @endphp @if ($list_extra_data['pr_status'] == 'Received' || $list_extra_data['pr_status'] == 'All')

{{__('lang.received_amount')}} {{$transaction->systemSettingCurrency()}}

@if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @if ($list_extra_data['group'] == 1) @php $receipt_with_group = []; foreach ($receipts as $rv) { if (empty($rv->deleted_at)) { $transaction_cr = App\Models\ActualReceived::where('id', $rv->id) ->with('transaction_cr') ->first(); $customer_name = App\Models\IncomeExpenseHead::find($transaction_cr['transaction_cr'][0]->income_expense_head_id); $receipt_with_group[$customer_name->IncomeExpenseGroup->name][$customer_name->IncomeExpenseType->name][] = $rv; } } @endphp @endif @if ($list_extra_data['group'] == 1) @foreach ($receipt_with_group as $parent_key => $parent) @foreach ($parent as $child_key => $childs) @foreach ($childs as $receipt) @if ($extra['status'] == 1) @endif @php $transaction_cr = App\Models\ActualReceived::where('id', $receipt->id) ->with('transaction_cr') ->first(); $customer_name = App\Models\IncomeExpenseHead::find($transaction_cr['transaction_cr'][0]->income_expense_head_id); @endphp @if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @endforeach @endforeach @endforeach @if ($extra['status'] == 1) @else @endif @else @foreach ($receipts as $receipt) {{-- Deleted At not working on query end will check why hotfixing for now. --}} @if (empty($receipt->deleted_at)) @if ($extra['status'] == 1) @endif @php $transaction_cr = App\Models\ActualReceived::where('id', $receipt->id) ->with('transaction_cr') ->first(); $customer_name = App\Models\IncomeExpenseHead::find($transaction_cr['transaction_cr'][0]->income_expense_head_id); @endphp @if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @endif @endforeach @if ($extra['status'] == 1) @else @endif @endif
{{__('lang.sno')}}{{__('lang.account_name')}} {{__('lang.registration_no')}} {{__('lang.mode_of_payment')}} {{__('lang.bank')}} {{__('lang.name')}} {{__('lang.voucher_no')}}{{__('lang.voucher_date')}}{{__('lang.received_amount')}} {{$transaction->systemSettingCurrency()}}
{{ $parent_key }}
            {{ $child_key }}
{{ $loop->index + 1 }}{{ App\Models\Common::showHeads($customer_name) == '.. ' ? $receipt->name : App\Models\Common::showHeads($customer_name) }} {{ $receipt->registration_no ?? '-' }} {{ ucfirst(!empty($receipt->made_of_payment) ? $receipt->made_of_payment : 'JV') ?? 'JV' }} {{ $receipt->head_name ?? $receipt->name }} {{ $receipt->receipt_no ?? $receipt->jv_no }} {{ App\Models\Common::viewDate($receipt->voucher_date) }} {{ $transaction->convert_money_format($receipt->actual_amount ?? $receipt->cr) }}
{{__('lang.total_received')}} {{ $transaction->convert_money_format($total_received_amount) }} {{__('lang.total_received')}} {{ $transaction->convert_money_format($total_received_amount) }}
{{ $counter2 }}{{ App\Models\Common::showHeads($customer_name) == '.. ' ? $receipt->name : App\Models\Common::showHeads($customer_name) }} {{ $receipt->registration_no ?? '-' }} {{ ucfirst(!empty($receipt->made_of_payment) ? $receipt->made_of_payment : 'JV') ?? 'JV' }} {{ $receipt->head_name ?? $receipt->name }} {{ $receipt->receipt_no ?? $receipt->jv_no }} {{ App\Models\Common::viewDate($receipt->voucher_date) }} {{ $transaction->convert_money_format($receipt->actual_amount ?? $receipt->cr) }}
{{__('lang.total_received')}} {{ $transaction->convert_money_format($total_received_amount) }} {{__('lang.total_received')}} {{ $transaction->convert_money_format($total_received_amount) }}
@endif @if ($list_extra_data['pr_status'] == 'Paid' || $list_extra_data['pr_status'] == 'All')

{{__('lang.paid_amount')}}

@if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @if ($extra['status'] == 1) @endif @if ($list_extra_data['group'] == 1) @php $arr = []; $sorted_array = []; foreach ($infos->merge($journal_cr) as $in) { if($in->type == 'purchase_order') { $head_code = App\Models\IncomeExpenseHead::where(['reference_id' => $in->vendor_id, 'reference_type' => 'vendor'])->first(); $name = ucfirst($head_code->IncomeExpenseGroup->code . '.' . $head_code->IncomeExpenseType->code . '.' . $head_code->code . ' ' . $head_code->name); } else { $dr_account = App\Models\Transaction::where(['voucher_no' => trim($in->pv_no), 'voucher_type' => 'PV'])->get(); $head_code = App\Models\IncomeExpenseHead::find($dr_account[1]->income_expense_head_id); $name = ucfirst($head_code->IncomeExpenseGroup->code . '.' . $head_code->IncomeExpenseType->code . '.' . $head_code->code . ' ' . $head_code->name); } $arr[] = [ 'name' => $name == '.. ' ? $in->name : $name, 'pv_no' => !empty($in->pv_no) ? $in->pv_no : $in->jv_no, 'head_code' => !empty($head_code->id) ? $head_code->id : $in->income_expenses_head_id, 'type' => $in->type, 'voucher_type' => $in->voucher_type, 'particulars' => $in->particulars, 'amount' => !empty($in->amount) ? $in->amount : $in->dr, 'payee_name' => $in->payee_name, 'mode_of_payment' => !empty($in->mode_of_payment) ? $in->mode_of_payment : 'JV', 'branch' => $in->branch, 'voucher_date' => $in->voucher_date, 'created_by' => $in->created_by, 'vendor_id' => $in->vendor_id, 'purchase_id' => $in->purchase_id, 'vendor_name' => $in->vendor_name, 'group' => !empty($head_code->IncomeExpenseGroup->name) ? $head_code->IncomeExpenseGroup->name : App\Models\IncomeExpenseGroup::find($in->income_expense_group_id)->name, 'sub_group' => !empty($head_code->IncomeExpenseType->name) ? $head_code->IncomeExpenseType->name : App\Models\IncomeExpenseType::find($in->income_expense_type_id)->name, ]; } foreach ($arr as $item) { if ($extra['status'] == 1) { $sorted_array[$item['group']][$item['sub_group']][] = $item; $sorted_array[$item['group']][$item['sub_group']]['sub_amount'] += $item['amount']; } else { $sorted_array[$item['group']][$item['sub_group']][$item['name']]['name'] = $item['name']; $sorted_array[$item['group']][$item['sub_group']][$item['name']]['head_code'] = $item['head_code']; $sorted_array[$item['group']][$item['sub_group']][$item['name']]['amount'] += $item['amount']; $sorted_array[$item['group']][$item['sub_group']]['sub_amount'] += $item['amount']; } } @endphp @foreach ($sorted_array as $key1 => $values) @if ($extra['status'] == 1) @foreach ($values as $key => $item) @php unset($item['sub_amount']); @endphp @foreach ($item as $i) @php if ($i['type'] == 'general') { $type = 'General'; } else { $type = 'Purchase Order'; } @endphp @php $bank = App\Models\PaymentVoucher::with('transaction_cr') ->where('pv_no', trim($i['pv_no'])) ->first(); $dr_account = App\Models\PaymentVoucher::with('transaction_dr') ->where('pv_no', trim($i['pv_no'])) ->first(); if ($info->mode_of_payment == 'cash') { $bank_name = '-'; } else { $head_code = App\Models\IncomeExpenseHead::find($dr_account['transaction_cr'][0]->income_expense_head_id); $bank_name = $head_code->IncomeExpenseGroup->code . '.' . $head_code->IncomeExpenseType->code . '.' . $head_code->code . ' ' . $head_code->name; } @endphp @endforeach @if ($extra['status'] == 1) @else @endif @endforeach @else @php $counter++; $total_amount += $item['amount']; @endphp @foreach ($values as $key => $item) @php unset($item['sub_amount']); @endphp @foreach ($item as $k => $small_item) @php $total_amount += $small_item['amount']; @endphp @endforeach @endforeach @endif @endforeach @else @foreach ($infos->merge($journal_cr) as $info) @if ($extra['status'] == 1) @endif @php if ($info->type == 'general') { $dr_account = App\Models\PaymentVoucher::with('transaction_dr') ->where('pv_no', trim($info->pv_no)) ->first(); $head_code = App\Models\IncomeExpenseHead::find($dr_account['transaction_dr'][0]->income_expense_head_id); $name = ucfirst($head_code->IncomeExpenseGroup->code . '.' . $head_code->IncomeExpenseType->code . '.' . $head_code->code . ' ' . $head_code->name); } else { $name = $info->vendor_name ?? $info->name; } @endphp @if ($extra['status'] == 1) @php if ($info->type == 'general') { $type = 'General'; } else { $type = 'Purchase order'; } @endphp @endif @php $bank = App\Models\PaymentVoucher::with('transaction_cr') ->where('pv_no', trim($info->pv_no)) ->first(); if ($info->mode_of_payment == 'cash') { $bank_name = '-'; } else { $head_code = App\Models\IncomeExpenseHead::find($dr_account['transaction_cr'][0]->income_expense_head_id); $bank_name = $head_code->IncomeExpenseGroup->code . '.' . $head_code->IncomeExpenseType->code . '.' . $head_code->code . ' ' . $head_code->name; } @endphp @if ($extra['status'] == 1) @php if ($info->type == 'general') { $pv_no = $info->pv_no; } else { $pv_no = $info->purchase_id; } @endphp @endif @if ($extra['status'] == 1) @endif @php $total_amount += $info->amount ?? $info->total_dr_amount; @endphp @endforeach @endif @if ($extra['status'] == 1) @else @endif
{{__('lang.sno')}}{{__('lang.account_name')}} {{__('lang.expense_type')}} {{__('lang.mode_of_payment')}} {{__('lang.bank')}} {{__('lang.name')}} {{__('lang.voucher_no')}}{{__('lang.voucher_date')}} {{__('lang.paid_amount')}}
{{ $key1 }}
           {{ $key }}
{{ $counter }} {{ $i['name'] ?? $i['vendor_name'] }} {{ $type ?? '-' }} {{ ucfirst($i['mode_of_payment']) }}{{ $bank_name }} {{ $i['pv_no'] ?? '-' }} {{ $i['voucher_date'] ?? '-' }} {{ $transaction->convert_money_format($i['amount']) }}
{{__('lang.sub_group_total')}} {{ $transaction->convert_money_format($values[$key]['sub_amount'] ?? 0) }} {{__('lang.sub_group_total')}} {{ $transaction->convert_money_format($values[$key]['sub_amount'] ?? 0) }}
{{ $key1 }}
           {{ $key }}
{{ $small_item['name'] }} {{ $transaction->convert_money_format($small_item['amount']) }}
{{__('lang.sub_group_total')}} {{ $transaction->convert_money_format($values[$key]['sub_amount']) }}
{{ $counter }}{{ $name == '.. ' ? $info->name : $name }}{{ $type ?? '-' }} {{ ucfirst($info->mode_of_payment) }}{{ $bank_name }} {{ $pv_no ?? $info->jv_no }} {{ $info->voucher_date }} {{ $transaction->convert_money_format($info->amount ?? $info->total_dr_amount) }}
{{__('lang.total_paid')}} {{ $transaction->convert_money_format($total_amount) }} {{__('lang.total_paid')}} {{ $transaction->convert_money_format($total_amount) }}

@if ($list_extra_data['pr_status'] == 'All')
{{__('lang.balance')}}
{{ $transaction->convert_money_format($total_received_amount - $total_amount) }}
@endif @endif
@stop