@php $balance=0; $closing=0; @endphp @forelse ($cashBanks->sortBy('type') as $cash) @empty @endforelse @php $accountsIds=$cashBanks->pluck('account_id')->toArray(); $total_receipt=0; $total_payment=0; @endphp @forelse ($ledgerWiseBalance->where('type',1)->where('amount','>',0) as $m=>$receipt) @php $l=count($ledgers->where('id',$receipt['ledger_id']))?$ledgers->where('id',$receipt['ledger_id'])->first():null; @endphp @php $total_receipt+=abs($receipt['amount']); $balance+=abs($receipt['amount']); @endphp @empty @endforelse @php $payments = $ledgerWiseBalance->where('type', 0)->where('amount', '>', 0)->map(function ($q) { return (object) [ 'ledger_id'=> $q->ledger_id, 'amount'=> $q->amount, 'ledger_name'=> $q->globalLedger->name ]; })->toArray(); $payments = collect(array_merge($payments, $ledgerWisePayments))->groupBy('ledger_id'); @endphp @forelse ($payments as $m=> $receipt) @php $amount = $receipt->sum('amount'); $ledgerId = $receipt->first()->ledger_id; @endphp @php $l = count($ledgers->where('id', $ledgerId))?$ledgers->where('id', $ledgerId)->first():null; @endphp @php $total_payment += $amount; $balance -= $amount; @endphp @empty @endforelse @forelse ($cashBanks->sortBy('type') as $cash) @empty @endforelse
@php $r_type=env("JOURNAL_BALANCE_TYPE", 1); $printData['start_date']=Request()->start_date?date('d-M-Y',strtotime(Request()->start_date)):date('d-M-Y'); $printData['end_date']=Request()->end_date?date('d-M-Y',strtotime(Request()->end_date)):date('d-M-Y'); // $printData['ledger_name']=count($ledgers->where('id',Request()->ledger_id))>0?$ledgers->where('id',Request()->ledger_id)->first()->name:'ledger not found'; $routeName=str_replace('_api','',Route::currentRouteName()); $printData=getPrintData($routeName,$printData); @endphp {!!$printData['head']!!}
{{__('obs.accounts_code')}} {{__('obs.accounts_name')}} {{__('obs.amount')}} {{__('obs.balance')}}
{{__('obs.opening_balance')}} {{-- @ {{Request()->start_date?date('d-M-Y',strtotime(Request()->start_date)):''}} --}}
{{ $cash->ledger?$cash->ledger->auto_code:'' }} {{ $cash->name_eng }} @if(array_key_exists($cash->account_id,$ledgerWiseBeginningBalanced)) @if($r_type) {{($ledgerWiseBeginningBalanced[$cash->account_id]['amount']<0)?number_format(abs($ledgerWiseBeginningBalanced[$cash->account_id]['amount']),2).' '.__('obs.cr'):number_format($ledgerWiseBeginningBalanced[$cash->account_id]['amount'],2)}} @else {{($ledgerWiseBeginningBalanced[$cash->account_id]['amount']<0)?'('.number_format(abs($ledgerWiseBeginningBalanced[$cash->account_id]['amount']),2).')':number_format($ledgerWiseBeginningBalanced[$cash->account_id]['amount'],2)}} @endif @php $balance+=$ledgerWiseBeginningBalanced[$cash->account_id]['amount']; @endphp @else {{number_format(0,2)}} @endif
{{__('obs.opening_balance')}} @if($r_type) {{($balance<0)?number_format(abs($balance),2).' '.__('obs.cr'):number_format($balance,2)}} @else {{($balance<0)?'('.number_format(abs($balance),2).')':number_format($balance,2)}} @endif
{{__('obs.receipt')}}
{{$l?$l->auto_code:'-'}} {{$l?$l->parentGlobal->name:'-'}}- {{$l?$l->name:'-'}} {{number_format(abs($receipt['amount']),2)}} @if($r_type) {{($balance<0)?number_format(abs($balance),2).' '.__('obs.cr'):number_format($balance,2)}} @else {{($balance<0)?'('.number_format(abs($balance),2).')':number_format($balance,2)}} @endif
{{__('obs.total_receipt')}} {{number_format($total_receipt,2)}}
{{__('obs.payment')}}
 {{$l?$l->auto_code:'-'}}   {{$l?$l->parentGlobal->name:'-'}}- {{$l?$l->name:'-'}} {{number_format($amount,2)}} @if($r_type) {{($balance<0)?number_format(abs($balance),2).' '.__('obs.cr'):number_format($balance,2)}} @else {{($balance<0)?'('.number_format(abs($balance),2).')':number_format($balance,2)}} @endif
{{__('obs.total_payment')}} ( {{number_format($total_payment,2)}} )
{{__('obs.closing_balance')}}
{{ $cash->ledger?$cash->ledger->auto_code:'' }} {{ $cash->name_eng }} @if(array_key_exists($cash->account_id,$ledgerWiseEndingBalance)) @if($r_type) {{($ledgerWiseEndingBalance[$cash->account_id]['amount']<0)?number_format(abs($ledgerWiseEndingBalance[$cash->account_id]['amount']),2).' '.__('obs.cr'):number_format($ledgerWiseEndingBalance[$cash->account_id]['amount'],2)}} @else {{($ledgerWiseEndingBalance[$cash->account_id]['amount']<0)?'('.number_format(abs($ledgerWiseEndingBalance[$cash->account_id]['amount']),2).')':number_format($ledgerWiseEndingBalance[$cash->account_id]['amount'],2)}} @endif @php $closing+=$ledgerWiseEndingBalance[$cash->account_id]['amount']; @endphp @else {{number_format(0,2)}} @endif
{{__('obs.closing_balance')}} @if($r_type) {{($closing<0)?number_format(abs($closing),2).' '.__('obs.cr'):number_format($closing,2)}} @else {{($closing<0)?'('.number_format(abs($closing),2).')':number_format($closing,2)}} @endif
{!!$printData['foot']!!}