@php use Carbon\Carbon; $bankIds = DB::table('gnr_bank')->pluck('id')->toArray(); /*$date = Carbon::toDay(); $startDate = $date->format('Y-m-d'); $endDate = $date->addDays(2)->format('Y-m-d');*/ $loanAccountIds = DB::table('acc_loan_register_payment_schedule')->whereBetween('paymentDate',[$startDate,$endDate])->pluck('accId_fk')->toArray(); /*$accounts = DB::table('acc_loan_register_account')->where('status',1)->whereIn('id',$loanAccountIds)->get();*/ /*$accounts = DB::table('acc_loan_register_account as t1') ->join('acc_loan_register_payment_schedule as t2','t1.id','t2.accId_fk') ->where('t1.status',1) ->whereBetween('t2.paymentDate',[$startDate,$endDate]) ->select('t1.*') ->orderBy('t2.paymentDate') ->get();*/ $activeProjectTypeList = array(); foreach ($accounts as $key => $account) { array_push($activeProjectTypeList, $account->projectTypeId_fk); } $projectTypes = DB::table('gnr_project_type')->whereIn('id',$activeProjectTypeList)->get(); @endphp

Loan Register Installment Report

{{-- --}} {{-- --}} {{-- --}} @php $gTloanAmount = 0; $gTinstallmentSize = 0; $gTloanAmount = 0; $gTcurrentMonthPayment = 0; $gTcurrentMonthDue = 0; @endphp @foreach($projectTypes as $projectType) @php $index = 0; $sTloanAmount = 0; $sTinstallmentSize = 0; $sTcurrentMonthPayment = 0; $sTcurrentMonthDue = 0; @endphp @foreach($accounts as $key => $account) @if($account->projectTypeId_fk==$projectType->id) @php $bankName = DB::table('gnr_bank')->where('id',$account->bankId_fk)->value('name'); if ($account->phase>0) { $accNoPhaseCycleValue = "- / ".str_pad($account->phase,3,'0',STR_PAD_LEFT)." / ".str_pad($account->cycle,3,'0',STR_PAD_LEFT); } else{ $accNoPhaseCycleValue = $account->accNo." / - / -"; } $installmentSize = (float) DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->value('totalAmount'); $installmentDate = DB::table('acc_loan_register_payment_schedule')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->value('paymentDate'); if ($installmentDate==null) { $installmentDate = "-"; } else{ $installmentDate = date('d-m-Y',strtotime($installmentDate)); } $paymentDateInThisMonth = DB::table('acc_loan_register_payments')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->orderBy('id','desc')->value('paymentDate'); if ($paymentDateInThisMonth==null) { $paymentDateInThisMonth = "-"; } else{ $paymentDateInThisMonth = date('d-m-Y',strtotime($paymentDateInThisMonth)); } $paymentAmountInThisMonth = (float) DB::table('acc_loan_register_payments')->where('accId_fk',$account->id)->where('paymentDate','>=',$startDate)->where('paymentDate','<=',$endDate)->sum('totalAmount'); $thisMonthDue = $installmentSize - $paymentAmountInThisMonth; @endphp @php $count = 1; $isChanged = 0; if ($key>0) { if ($accounts[$key-1]->bankId_fk!=$account->bankId_fk) { $isChanged = 1; } } if ($key == 0 || $isChanged == 1) { ////// $count = DB::table('acc_loan_register_account')->where('status',1)->whereIn('id',$loanAccountIds); ////// $count = $count->where('bankId_fk',$account->bankId_fk)->count(); } @endphp @if($isChanged==1 || $key==0) @endif {{-- --}} {{-- --}} {{-- --}} @php $sTloanAmount = $sTloanAmount + $account->loanAmount; $sTinstallmentSize = $sTinstallmentSize + $installmentSize; $sTcurrentMonthPayment = $sTcurrentMonthPayment + $paymentAmountInThisMonth; $sTcurrentMonthDue = $sTcurrentMonthDue + $thisMonthDue; @endphp @endif @endforeach {{-- Account --}} {{-- --}} {{-- --}} @php $gTloanAmount = $gTloanAmount + $sTloanAmount; $gTinstallmentSize = $gTinstallmentSize + $sTinstallmentSize; $gTcurrentMonthPayment = $gTcurrentMonthPayment + $sTcurrentMonthPayment; $gTcurrentMonthDue = $gTcurrentMonthDue + $sTcurrentMonthDue; @endphp @endforeach {{-- Project Type --}} {{-- --}} {{-- --}}
SL# Date Bank/Donar Account No / Phase/ Cycle Loan Amount Installment SizeCurrent Month Loan InstallmentCurrent Month Loan Installment Re-Payment Current Month Loan
Installment Due (Tk)
Date Amount (Tk) Date Amount (Tk)
{{$projectType->name}}
{{++$index}} {{$installmentDate}}{{$bankName}}{{$bankName}}{{$accNoPhaseCycleValue}} {{number_format($account->loanAmount,2,'.',',')}} {{number_format($installmentSize,2,'.',',')}}{{number_format($installmentSize,2,'.',',')}}{{$paymentDateInThisMonth}} {{number_format($paymentAmountInThisMonth,2,'.',',')}} {{number_format($thisMonthDue,2,'.',',')}}
Sub Total {{number_format($sTloanAmount,2,'.',',')}} {{number_format($sTinstallmentSize,2,'.',',')}} {{number_format($sTinstallmentSize,2,'.',',')}} {{number_format($sTcurrentMonthPayment,2,'.',',')}} {{number_format($sTcurrentMonthDue,2,'.',',')}}
Total {{number_format($gTloanAmount,2,'.',',')}} {{number_format($gTinstallmentSize,2,'.',',')}} {{number_format($gTinstallmentSize,2,'.',',')}} {{number_format($gTcurrentMonthPayment,2,'.',',')}} {{number_format($gTcurrentMonthDue,2,'.',',')}}