@extends('layouts/acc_layout') @section('title', '| Loan Register Report') @section('content') @php use Carbon\Carbon; $projectSelected = isset($_GET['searchProject']) ? $_GET['searchProject'] : null; $projectTypeSelected = isset($_GET['searchProjectType']) ? $_GET['searchProjectType'] : null; $branchSelected = isset($_GET['searchBranch']) ? $_GET['searchBranch'] : null; //$fdrTypeSelected = isset($_GET['searchFdrType']) ? $_GET['searchFdrType'] : null; $bankSelected = isset($_GET['searchBank']) ? $_GET['searchBank'] : null; $bankBranchSelected = isset($_GET['searchBankBranch']) ? $_GET['searchBankBranch'] : null; $dateFromSelected = isset($_GET['dateFrom']) ? $_GET['dateFrom'] : $softwareStartDate; $dateToSelected = isset($_GET['dateTo']) ? $_GET['dateTo'] : $softwareDate; $firstRequest = isset($_GET['firstRequest']) ? '1' : null; /*var_dump($bankBranchSelected); exit();*/ $userBranchId = Auth::user()->branchId; @endphp

Loan Register Report

{{--
kxghixd
--}}
{!! Form::open(['url' => 'viewLoanRegisterReport','method' => 'get']) !!} {!! Form::hidden('firstRequest',0) !!}
{!! Form::label('', 'Project:', ['class' => 'control-label pull-left']) !!}
{!! Form::label('', 'Project Type:', ['class' => 'control-label pull-left']) !!}
{{--
{!! Form::label('searchBranch', 'Branch:', ['class' => 'control-label pull-left']) !!}
--}} {{--
{!! Form::label('searchLoanType', 'LoanType Type:', ['class' => 'control-label pull-left']) !!}
@php $loanTypes = array(''=>'All') + $fdrTypes; @endphp {!! Form::select('searchFdrType',$fdrTypes,$fdrTypeSelected,['id'=>'searchFdrType','class'=>'form-control input-sm']) !!}
--}}
{!! Form::label('searchBank', 'Bank Name:', ['class' => 'control-label pull-left']) !!}
@php $banks = array(''=>'All') + $banks; @endphp
{!! Form::select('searchBank',$banks,$bankSelected,['id'=>'searchBank','class'=>'form-control input-sm']) !!}
{!! Form::label('searchBankBranch', 'B.Branch:', ['class' => 'control-label pull-left']) !!}
@php //$bankBranches = array(''=>'All') + $bankBranches; @endphp
{{-- {!! Form::select('searchBankBranch',$bankBranches,$bankBranchSelected,['id'=>'searchBankBranch','class'=>'form-control input-sm']) !!} --}}
{!! Form::label('', ' ', ['class' => 'control-label']) !!}
{!! Form::text('dateFrom',$dateFromSelected,['id'=>'dateFrom','placeholder'=>'From','class'=>'form-control input-sm','readonly','style'=>'cursor:pointer']) !!}
{!! Form::text('dateTo',$dateToSelected,['id'=>'dateTo','placeholder'=>'To','class'=>'form-control input-sm','readonly','style'=>'cursor:pointer']) !!}
{!! Form::submit('Search',['id'=>'search','class'=>'btn btn-primary btn-xs','style'=>'font-size:15px;']) !!}
{!! Form::close() !!}
{{-- End Filtering Group --}} @if($firstRequest!=null) @php if($branchSelected=='0'){ $selectedBranchName = "All Branches"; } else{ $selectedBranchName = DB::table('gnr_branch')->where('id',$branchSelected)->value('name'); } $selectedProjectName = DB::table('gnr_project')->where('id',$projectSelected)->value('name'); @endphp

{{-- --}} @php $gtLoanAmount = 0; $gtLoanOpeningBalance = 0; $gtLoanAditionPrincipal = 0; $gtLoanAditionInterest = 0; $gtLoanPaymentPrincipal = 0; $gtLoanPaymentInterest = 0; $gtClosingBalance = 0; $rowNumbers = 0; $bankBranchHavingAccount = DB::table('gnr_bank_branch')->whereIn('id',$bankBranchList)->get(); @endphp @foreach($bankBranchHavingAccount as $branch) @php $bankName = DB::table('gnr_bank')->where('id',$branch->bankId_fk)->value('name'); @endphp @php $index = 1; $sLoanAmount = 0; $sOpeingBalance = 0; $sAditionPrincipal = 0; $sAditionInterest = 0; $sPaymentPrincipal = 0; $sPaymentInterest = 0; $sClosingBalance = 0; //$tClosingBalance = 0; @endphp @foreach($loanAccounts as $loanAccount) @if($loanAccount->bankBranchId_fk==$branch->id) @php /*$poeningBalance = DB::table('acc_loan_register_account')->where('id',$loanAccount->id)->select('');*/ $totalPayment = DB::table('acc_loan_register_payments')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('totalAmount'); $loanInterestPayment = DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('totalAmount'); $loanInterest = $loanInterestPayment- $totalPayment; $aditionPrincipleAmount = DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('principalAmount'); $aditionInterestAmount = DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('interestAmount'); $paymentPrincipalAmount = DB::table('acc_loan_register_payments')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('principalAmount'); $paymentInterestAmount = DB::table('acc_loan_register_payments')->where('accId_fk',$loanAccount->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('interestAmount'); $loan = $loanAccount->loanAmount +$aditionPrincipleAmount+$aditionInterestAmount-$paymentPrincipalAmount+$paymentInterestAmount; //$loanInterest =$loanAccount-> /* $bankChange = DB::table('acc_fdr_interest')->where('fdrAccId_fk',$loanAccounts->id)->where('receiveDate','>=',$startDate)->where('receiveDate','<=',$endDate)->sum('bankCharge'); $taxAmount = DB::table('acc_fdr_interest')->where('fdrAccId_fk',$loanAccounts->id)->where('receiveDate','>=',$startDate)->where('receiveDate','<=',$endDate)->sum('taxAmount'); $netInterest = DB::table('acc_fdr_interest')->where('fdrAccId_fk',$loanAccounts->id)->where('receiveDate','>=',$startDate)->where('receiveDate','<=',$endDate)->sum('netInterestAmount'); $receiveAbleAmount = $loanAccounts->principalAmount + $netInterest; $closingDate = DB::table('acc_fdr_close')->where('accId_fk',$loanAccounts->id)->where('closingDate','<=',$endDate)->value('closingDate'); if ($closingDate!=null && $closingDate!='') { $interestTillNow = DB::table('acc_fdr_interest')->where('fdrAccId_fk',$loanAccounts->id)->sum('netInterestAmount'); $closingAmount = $loanAccounts->principalAmount + $interestTillNow; } else{ $closingAmount = 0; } //////// $principaAmount = 0; $accOpeningDate = Carbon::parse($loanAccounts->openingDate); if ($accOpeningDate->gte($startDate)) { $principaAmount = $loanAccounts->principalAmount; } $openingNetInterest = DB::table('acc_fdr_interest')->where('fdrAccId_fk',$loanAccounts->id)->where('receiveDate','<',$startDate)->sum('netInterestAmount'); $openingBalance = 0; if ($accOpeningDate->lt($startDate)) { $openingBalance = $loanAccounts->principalAmount; } $openingBalance = $openingBalance + $openingNetInterest; $balance = $openingBalance + $principaAmount + $interest - $bankChange - $taxAmount - $closingAmount;*/ //$openingBalance = $openingBalance + $loanInterest; @endphp {{----}} @php $sLoanAmount = $sLoanAmount + $loanAccount->loanAmount; $sOpeingBalance = $sOpeingBalance + $loanInterest; $sAditionPrincipal = $sAditionPrincipal + $aditionPrincipleAmount; $sAditionInterest = $sAditionInterest + $aditionInterestAmount; $sPaymentPrincipal = $sPaymentPrincipal + $paymentPrincipalAmount; $sPaymentInterest = $sPaymentInterest + $paymentInterestAmount; $sClosingBalance = $sClosingBalance + $loan; $rowNumbers++; $index++; @endphp @endif @endforeach {{-- Account --}} @php $gtLoanAmount = $gtLoanAmount + $sLoanAmount; $gtLoanOpeningBalance = $gtLoanOpeningBalance + $sOpeingBalance; $gtLoanAditionPrincipal = $gtLoanAditionPrincipal + $sAditionPrincipal; $gtLoanAditionInterest = $gtLoanAditionInterest + $sAditionInterest; $gtLoanPaymentPrincipal = $gtLoanPaymentPrincipal + $sPaymentPrincipal; $gtLoanPaymentInterest = $gtLoanPaymentInterest + $sPaymentInterest; $gtClosingBalance = $gtClosingBalance + $sClosingBalance; @endphp @endforeach {{-- Branch --}}
SL# Loan Received
Date
Account No Account Name Loan
Duration
Interest
Rate (%)
Loan Amount (Tk) Opening Balance Addition Payment Closing BalanceInterest Bank Charge Tax Net Interest Receiveable Amount Closing Date Closing Amount Balance
Principal Interest Bank Charge Principal Interest Bank Charge
{{$bankName.', '.$branch->name}}
{{$index}} {{date('d-m-Y',strtotime($loanAccount->loanDate))}} {{$loanAccount->accNo}} {{$loanAccount->loanDuration}} {{$loanAccount->interestRate}} {{number_format($loanAccount->loanAmount,2)}} {{number_format($loanInterest,2,'.',',')}} {{number_format($aditionPrincipleAmount,2)}} {{number_format($aditionInterestAmount,2,'.',',')}} {{number_format($paymentPrincipalAmount,2,'.',',')}} {{number_format($paymentInterestAmount,2,'.',',')}} {{number_format($loan,2,'.',',')}}{{number_format($bankChange,2,'.',',')}} @if($closingDate==null) {{"-"}} @else {{date('d-m-Y',strtotime($closingDate))}} @endif @if($closingDate==null) {{"-"}} @else {{number_format($closingAmount,2,'.',',')}} @endif {{number_format($balance,2,'.',',')}}
Sub Total {{number_format($sLoanAmount,2,'.',',')}} {{number_format($sOpeingBalance,2,'.',',')}} {{number_format($sAditionPrincipal,2,'.',',')}} {{number_format($sAditionInterest,2,'.',',')}} {{number_format($sPaymentPrincipal,2,'.',',')}} {{number_format($sPaymentInterest,2,'.',',')}} {{number_format($sClosingBalance,2,'.',',')}}
Total {{'('.$rowNumbers.')'}} {{number_format($gtLoanAmount,2,'.',',')}} {{number_format($gtLoanOpeningBalance,2,'.',',')}} {{number_format($gtLoanAditionPrincipal,2,'.',',')}} {{number_format($gtLoanAditionInterest,2,'.',',')}} {{number_format($gtLoanPaymentPrincipal,2,'.',',')}} {{number_format($gtLoanPaymentInterest,2,'.',',')}} {{number_format($gtClosingBalance,2,'.',',')}}
@endif {{-- End First Request --}}
{{-- Filtering --}}