@extends('layouts/microfin_layout') @section('title', '|Periodic Collection Component Wise Report') @section('content') @include('successMsg') @php $branchId = Auth::user()->branchId; $loanProductCategorySelected = isset($_GET['searchLoanProduct']) ? $_GET['searchLoanProduct'] : null; @endphp
{!! Form::open(['url' =>'mfnPeriodicCollectionComponentReport','method' =>'get']) !!}
{!! Form::label('', 'Branch:', ['class' => 'control-label pull-left']) !!}

{!! Form::label('', 'Funding Org:', ['class' => 'control-label pull-left']) !!}
{!! Form::label('', 'Product Ctg:', ['class' => 'control-label pull-left']) !!}
{!! Form::label('', 'Product:', ['class' => 'control-label pull-left']) !!}
{!! Form::label('startDate', 'Start Date:', ['class' => 'control-label pull-left']) !!}
{!! Form::text('startDate',$startDateFromarte, ['class' => 'form-control', 'id' => 'startDate','readonly']) !!}

{!! Form::label('endDate', 'End Date:', ['class' => 'control-label pull-left','required']) !!}
{!! Form::text('endDate',$endDateFromarte, ['class' => 'form-control', 'id' => 'endDate','readonly','required']) !!}

{!! Form::label('', 'Loan Optaion:', ['class' => 'control-label pull-left']) !!}
{!! Form::select('searchLoanProduct',['1'=>'Loan Product','2'=>'Loan Product Category'],$loanProductCategorySelected,['id'=>'searchLoanProduct','class'=>'form-control input-sm']) !!}
{!! Form::submit('Search',['id'=>'search','class'=>'btn btn-primary btn-xs','style'=>'font-size:15px;']) !!}
{!! Form::close() !!}
{{--End Filtering Group --}}

Periodic Collection Component Wise Report


@if($productId==1)
@foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @if($serchingProductId !=null) @php //fieldOfficer $curentFieldOficerId = isset($fieldOfficerIds[0]) ? $fieldOfficerIds[0] : 0; //Total $savingsDepositeTotal = array(); $interestSavingTotal = array(); $savingsRefundTotal = array(); $additionalFeeCollectionTotal = 0; $disbusmentTotal = 0; $regularRecevableTotal = 0; $regularTotal = 0; $dueTotal = 0; $advancetotal = 0; $rebateTotal = 0; $loanReceivePrincipleTotal = 0; $loanReceiveServiceTotal = 0; $totalTotal = 0; $insClimeTotal = 0; $fieldOfficerKey=0; @endphp @foreach ($fieldOfficerIds as $fieldOfficerId) @php $employeeId = DB::table('hr_emp_general_info')->where('id',$fieldOfficerId)->select('emp_id','emp_name_english')->first(); $samityInfos = DB::table('mfn_samity')->where('branchId',$branchSelected)->where('fieldOfficerId',$fieldOfficerId)->whereIn('id',$allSamityUniqueArray)->select('name','id','code')->get(); $sumLoanProduct = 0; foreach ($samityInfos as $samityId) { $fromCollectionNew = $fromCollection->where('samityIdFk',$samityId->id)->pluck('productIdFk')->toArray(); $fromSavingsDepositeNew = $fromSavingsDeposite->where('samityIdFk',$samityId->id)->pluck('primaryProductIdFk')->toArray(); $fromLoanNew = $fromLoan->where('samityIdFk',$samityId->id)->pluck('productIdFk')->toArray(); $fromSavingsWithdrowNew = $fromSavingsWithdrow->where('samityIdFk',$samityId->id)->pluck('primaryProductIdFk')->toArray(); $loanProductFormSamity = array_unique(array_merge($fromCollectionNew,$fromSavingsDepositeNew,$fromLoanNew,$fromSavingsWithdrowNew)); $loanPro =$loanProductsName->whereIn('id',$loanProductFormSamity)->pluck('id')->toArray(); $keyProduct=0; $sumLoanProduct = $sumLoanProduct + count($loanPro); } $countRow = $sumLoanProduct; //Sub Total $savingsDepositeSubTotal =array(); $interestSavingSubTotal =array(); $savingsRefundSubTotal =array(); $additionalFeeCollectionSubTotal = 0; $disbusmentSubTotal = 0; $regularRecevableSubTotal = 0; $regularSubTotal = 0; $dueSubTotal = 0; $advanceSubtotal = 0; $rebateSubTotal = 0; $loanReceivePrincipleSubTotal = 0; $loanReceiveServiceSubTotal = 0; $totalSubTotal = 0; $insClimeSubTotal = 0; $samityKey =0; @endphp @foreach ($samityInfos as $samityInfo) @php $fromCollectionNew = $fromCollection->where('samityIdFk',$samityInfo->id)->pluck('productIdFk')->toArray(); $fromSavingsDepositeNew = $fromSavingsDeposite->where('samityIdFk',$samityInfo->id)->pluck('primaryProductIdFk')->toArray(); $fromLoanNew = $fromLoan->where('samityIdFk',$samityInfo->id)->pluck('productIdFk')->toArray(); $fromSavingsWithdrowNew = $fromSavingsWithdrow->where('samityIdFk',$samityInfo->id)->pluck('primaryProductIdFk')->toArray(); $loanProductsUniqueArray = array_unique(array_merge($fromCollectionNew,$fromSavingsDepositeNew,$fromLoanNew,$fromSavingsWithdrowNew)); $loanProducts =$loanProductsName->whereIn('id',$loanProductsUniqueArray)->pluck('id')->toArray(); $keyProduct = 0; @endphp @foreach ($loanProducts as $loanProduct) @php if ($curentFieldOficerId!= $fieldOfficerId) { $curentFieldOficerId = $fieldOfficerId; $officerChanged = 1; } else{ $officerChanged = 0; } $productName= DB::table('mfn_loans_product')->where('id',$loanProduct)->value('shortName'); @endphp @if($sumLoanProduct>0) @if(($fieldOfficerKey==0 && $samityKey==0 && $keyProduct==0) || ($officerChanged==1)) @endif @foreach ($savingsProducts as $key=>$savingsProduct) @php $savingDeposite = DB::table('mfn_savings_deposit')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('productIdFk',$savingsProduct->id)->where('depositDate','>=',$startDate)->where('depositDate','<=',$endDate)->sum('amount'); if(isset($savingsDepositeSubTotal[$key])){ $savingsDepositeSubTotal[$key]=$savingsDepositeSubTotal[$key]+$savingDeposite; }else{ $savingsDepositeSubTotal[$key]= $savingDeposite; } @endphp @endforeach @foreach($savingsProducts as $interestSavingKey=>$savingsProduct) @php $memberId = DB::table('mfn_member_information')->where('samityId',$samityInfo->id)->where('primaryProductId',$loanProduct)->value('id'); $InterestSaving = DB::table('mfn_savings_interest')->where('memberIdFk',$memberId)->where('date','>=',$startDate)->where('date','<=',$endDate)->sum('interestAmount'); if(isset($interestSavingSubTotal[$interestSavingKey])){ $interestSavingSubTotal[$interestSavingKey]=$interestSavingSubTotal[$interestSavingKey]+$InterestSaving; }else{ $interestSavingSubTotal[$interestSavingKey]= $InterestSaving; } @endphp @endforeach @foreach($savingsProducts as $savingRefundKey=>$savingsProduct) @php $savingWithdraw = DB::table('mfn_savings_withdraw')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('productIdFk',$savingsProduct->id)->where('withdrawDate','>=',$startDate)->where('withdrawDate','<=',$endDate)->sum('amount'); if(isset($savingsRefundSubTotal[$savingRefundKey])){ $savingsRefundSubTotal[$savingRefundKey]=$savingsRefundSubTotal[$savingRefundKey]+$savingWithdraw; }else{ $savingsRefundSubTotal[$savingRefundKey]= $savingWithdraw; } @endphp @endforeach @php $disbusmentAmount = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('loanAmount'); $aditionalFree = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('additionalFee'); $loanId = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id) ->where('productIdFk',$loanProduct)->value('id'); $receivableAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceiveInstamentAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isCompleted',0)->where('isPartiallyPaid',0)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceivePaidAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isPartiallyPaid',1)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceivePaidAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isPartiallyPaid',1)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('partiallyPaidAmount'); $regularDueAmount = $regularReceivePaidAmount - $regularReceivePaidAmount; $regularReceiveCollection = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('amount'); $advance = $regularReceiveCollection - $receivableAmount ; if($advance<0){ $advance = 0; } $dueAmount = $regularReceiveInstamentAmount + $regularDueAmount; if($dueAmount<0){ $dueAmount = 0; } $receivePrincipleAmount = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('principalAmount'); $receiveServiceChargeAmount = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('interestAmount'); $totalAmount = $receivePrincipleAmount + $receiveServiceChargeAmount; $insurenceClime = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('insuranceAmount'); $loanRebates = DB::table('mfn_loan_rebates')->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('date','>=',$startDate)->where('date','<=',$endDate)->sum('amount'); // Sub Total $additionalFeeCollectionSubTotal = $additionalFeeCollectionSubTotal + $aditionalFree; $disbusmentSubTotal = $disbusmentSubTotal + $disbusmentAmount; $regularRecevableSubTotal = $regularRecevableSubTotal + $receivableAmount; $regularSubTotal = $regularSubTotal + $regularReceiveCollection; $dueSubTotal = $dueSubTotal + $dueAmount; $advanceSubtotal = $advanceSubtotal + $advance; $rebateSubTotal = $rebateSubTotal + $loanRebates; $loanReceivePrincipleSubTotal = $loanReceivePrincipleSubTotal + $receivePrincipleAmount; $loanReceiveServiceSubTotal = $loanReceiveServiceSubTotal + $receiveServiceChargeAmount ; $totalSubTotal = $totalSubTotal + $totalAmount; $insClimeSubTotal = $insClimeSubTotal + $insurenceClime; @endphp @endif @php $keyProduct++; @endphp @endforeach @php $samityKey++; @endphp @endforeach @if(count($samityInfos) && $sumLoanProduct>0) @foreach ($savingsProducts as $key=>$savingsProduct) @php if(isset($savingsDepositeTotal[$key])) { $savingsDepositeTotal[$key]=$savingsDepositeTotal[$key]+$savingsDepositeSubTotal[$key]; }else{ $savingsDepositeTotal[$key]=$savingsDepositeSubTotal[$key]; } @endphp @endforeach @foreach ($savingsProducts as $interestSavingKey=>$savingsProduct) @php if(isset($interestSavingTotal[$interestSavingKey])) { $interestSavingTotal[$interestSavingKey]=$interestSavingTotal[$interestSavingKey]+$interestSavingSubTotal[$interestSavingKey]; }else{ $interestSavingTotal[$interestSavingKey]=$interestSavingSubTotal[$interestSavingKey]; } @endphp @endforeach @foreach ($savingsProducts as $savingRefundKey=>$savingsProduct) @php if(isset($savingsRefundTotal[$savingRefundKey])) { $savingsRefundTotal[$savingRefundKey]=$savingsRefundTotal[$savingRefundKey]+$savingsRefundSubTotal[$savingRefundKey]; }else{ $savingsRefundTotal[$savingRefundKey]=$savingsRefundSubTotal[$savingRefundKey]; } @endphp @endforeach @endif @php //Total $additionalFeeCollectionTotal = $additionalFeeCollectionTotal + $additionalFeeCollectionSubTotal; $disbusmentTotal +=$disbusmentSubTotal; $regularRecevableTotal += $regularRecevableSubTotal ; $regularTotal +=$regularSubTotal; $dueTotal +=$dueSubTotal; $advancetotal +=$advanceSubtotal ; $rebateTotal +=$rebateSubTotal; $loanReceivePrincipleTotal +=$loanReceivePrincipleSubTotal ; $loanReceiveServiceTotal +=$loanReceiveServiceSubTotal; $insClimeTotal +=$insClimeSubTotal; $totalTotal +=$totalSubTotal; if(count($samityInfos)>0){ $fieldOfficerKey++; } @endphp @endforeach @foreach ($savingsProducts as $key=>$savingsProduct) @if(isset($savingsDepositeTotal[$key])) @else @endif @endforeach @foreach ($savingsProducts as $interestSavingKey=>$savingsProduct) @if(isset($interestSavingTotal[$interestSavingKey])) @else @endif @endforeach @foreach ($savingsProducts as $savingRefundKey=>$savingsProduct) @if(isset($savingsRefundTotal[$savingRefundKey])) @else @endif @endforeach @endif
Field Worker Samity Component Savings Collection Interest On Savings Savings Refund Additional
Fee
Collection
Disbursement
Amount
Regular
Recoverable
Loan Collection Ins.
Claim
ID Name ID Name{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}Regular Due Advance Rebate Total Collection
Loan Received
(Principle)
Loan Received
(Service Charge)
Total
{{$employeeId->emp_id}} {{$employeeId->emp_name_english}} {{$samityInfo->code}} {{$samityInfo->name}} {{$productName}} {{number_format($savingDeposite,2)}}{{number_format($InterestSaving,2)}}{{number_format($savingWithdraw,2)}}{{number_format($aditionalFree,2)}} {{number_format($disbusmentAmount,2)}} {{number_format($receivableAmount,2)}} {{number_format($regularReceiveCollection,2)}} {{number_format($dueAmount,2)}} {{number_format($advance,2)}} {{number_format($loanRebates,2)}} {{number_format($receivePrincipleAmount,2)}} {{number_format($receiveServiceChargeAmount,2)}} {{number_format($totalAmount,2)}} {{number_format($insurenceClime,2)}}
Sub Total {{number_format($savingsDepositeSubTotal[$key],2)}}{{number_format($interestSavingSubTotal[$interestSavingKey],2)}}{{number_format($savingsRefundSubTotal[$savingRefundKey],2)}}{{number_format($additionalFeeCollectionSubTotal,2)}} {{number_format($disbusmentSubTotal,2)}} {{number_format($regularRecevableSubTotal,2)}} {{number_format($regularSubTotal,2)}} {{number_format($dueSubTotal,2)}} {{number_format($advanceSubtotal,2)}} {{number_format($rebateSubTotal,2)}} {{number_format($loanReceivePrincipleSubTotal,2)}} {{number_format($loanReceiveServiceSubTotal,2)}} {{number_format($totalSubTotal,2)}} {{number_format($insClimeSubTotal,2)}}
Total {{number_format($savingsDepositeTotal[$key],2)}} {{number_format(0,2)}} {{number_format($interestSavingTotal[$interestSavingKey],2)}} {{number_format(0,2)}} {{number_format($savingsRefundTotal[$savingRefundKey],2)}} {{number_format(0,2)}}{{number_format($additionalFeeCollectionTotal,2)}} {{number_format($disbusmentTotal,2)}} {{number_format($regularRecevableTotal,2)}} {{number_format($regularTotal,2)}} {{number_format($dueTotal,2)}} {{number_format($advancetotal,2)}} {{number_format($rebateTotal,2)}} {{number_format($loanReceivePrincipleTotal,2)}} {{number_format($loanReceiveServiceTotal,2)}} {{number_format($totalTotal,2)}} {{number_format($insClimeTotal,2)}}
@endif @if($productId==2)
@foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @php $curentFieldOficerId = isset($fieldOfficerIds[0]) ? $fieldOfficerIds[0] : 0; //Total $savingsDepositeTotal = array(); $interestSavingTotal = array(); $savingsRefundTotal = array(); $additionalFeeCollectionTotal = 0; $disbusmentTotal = 0; $regularRecevableTotal = 0; $regularTotal = 0; $dueTotal = 0; $advancetotal = 0; $rebateTotal = 0; $loanReceivePrincipleTotal = 0; $loanReceiveServiceTotal = 0; $totalTotal = 0; $insClimeTotal = 0; $fieldOfficerKey=0; @endphp @if($serchingProductId !=null) @foreach ($fieldOfficerIds as $fieldOfficerId) @php $employeeId = DB::table('hr_emp_general_info')->where('id',$fieldOfficerId)->select('emp_id','emp_name_english')->first(); $samityInfos = DB::table('mfn_samity')->where('branchId',$branchSelected)->where('fieldOfficerId',$fieldOfficerId)->whereIn('id',$allSamityUniqueArray)->select('name','id','code')->get(); $sumLoanProduct = 0; foreach ($samityInfos as $samityId) { $fromCollectionNew = $fromCollection->where('samityIdFk',$samityId->id)->pluck('productIdFk')->toArray(); $fromSavingsDepositeNew = $fromSavingsDeposite->where('samityIdFk',$samityId->id)->pluck('primaryProductIdFk')->toArray(); $fromLoanNew = $fromLoan->where('samityIdFk',$samityId->id)->pluck('productIdFk')->toArray(); $fromSavingsWithdrowNew = $fromSavingsWithdrow->where('samityIdFk',$samityId->id)->pluck('primaryProductIdFk')->toArray(); $loanProductFormSamity = array_unique(array_merge($fromCollectionNew,$fromSavingsDepositeNew,$fromLoanNew,$fromSavingsWithdrowNew)); $loanPro = $loanProductsName->whereIn('id',$loanProductFormSamity)->pluck('id')->toArray(); $keyProduct=0; $sumLoanProduct = $sumLoanProduct + count($loanPro); } $countRow = $sumLoanProduct; //Sub Total $savingsDepositeSubTotal =array(); $interestSavingSubTotal =array(); $savingsRefundSubTotal =array(); $additionalFeeCollectionSubTotal = 0; $disbusmentSubTotal = 0; $regularRecevableSubTotal = 0; $regularSubTotal = 0; $dueSubTotal = 0; $advanceSubtotal = 0; $rebateSubTotal = 0; $loanReceivePrincipleSubTotal = 0; $loanReceiveServiceSubTotal = 0; $totalSubTotal = 0; $insClimeSubTotal = 0; $samityKey =0; @endphp @foreach ($samityInfos as $samityInfo) @php $fromCollectionNew = $fromCollection->where('samityIdFk',$samityInfo->id)->pluck('productIdFk')->toArray(); $fromSavingsDepositeNew = $fromSavingsDeposite->where('samityIdFk',$samityInfo->id)->pluck('primaryProductIdFk')->toArray(); $fromLoanNew = $fromLoan->where('samityIdFk',$samityInfo->id)->pluck('productIdFk')->toArray(); $fromSavingsWithdrowNew = $fromSavingsWithdrow->where('samityIdFk',$samityInfo->id)->pluck('primaryProductIdFk')->toArray(); $loanProductsUniqueArray = array_unique(array_merge($fromCollectionNew,$fromSavingsDepositeNew,$fromLoanNew,$fromSavingsWithdrowNew)); $loanProducts =$loanProductsName->whereIn('id',$loanProductsUniqueArray)->pluck('id')->toArray(); $keyProduct=0; @endphp @foreach ($loanProducts as $loanProduct) @php if ($curentFieldOficerId!= $fieldOfficerId) { $curentFieldOficerId = $fieldOfficerId; $officerChanged = 1; } else{ $officerChanged = 0; } $productName= DB::table('mfn_loans_product')->where('id',$loanProduct)->value('productCategoryId'); $productCategory = DB::table('mfn_loans_product_category')->where('id',$productName)->value('shortName'); @endphp @if($sumLoanProduct>0) @if(($fieldOfficerKey==0 && $samityKey==0 && $keyProduct==0) || ($officerChanged==1)) @endif @foreach ($savingsProducts as $key=>$savingsProduct) @php $savingDeposite = DB::table('mfn_savings_deposit')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('productIdFk',$savingsProduct->id)->where('depositDate','>=',$startDate)->where('depositDate','<=',$endDate)->sum('amount'); if(isset($savingsDepositeSubTotal[$key])){ $savingsDepositeSubTotal[$key]=$savingsDepositeSubTotal[$key]+$savingDeposite; }else{ $savingsDepositeSubTotal[$key]= $savingDeposite; } @endphp @endforeach @foreach($savingsProducts as $interestSavingKey=>$savingsProduct) @php $memberId = DB::table('mfn_member_information')->where('samityId',$samityInfo->id)->where('primaryProductId',$loanProduct)->value('id'); $InterestSaving = DB::table('mfn_savings_interest')->where('memberIdFk',$memberId)->where('date','>=',$startDate)->where('date','<=',$endDate)->sum('interestAmount'); if(isset($interestSavingSubTotal[$interestSavingKey])){ $interestSavingSubTotal[$interestSavingKey]=$interestSavingSubTotal[$interestSavingKey]+$InterestSaving; }else{ $interestSavingSubTotal[$interestSavingKey]= $InterestSaving; } @endphp @endforeach @foreach($savingsProducts as $savingRefundKey=>$savingsProduct) @php $savingWithdraw = DB::table('mfn_savings_withdraw')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('productIdFk',$savingsProduct->id)->where('withdrawDate','>=',$startDate)->where('withdrawDate','<=',$endDate)->sum('amount'); if(isset($savingsRefundSubTotal[$savingRefundKey])){ $savingsRefundSubTotal[$savingRefundKey]=$savingsRefundSubTotal[$savingRefundKey]+$savingWithdraw; }else{ $savingsRefundSubTotal[$savingRefundKey]= $savingWithdraw; } @endphp @endforeach @php $disbusmentAmount = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('totalRepayAmount'); $aditionalFree = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('additionalFee'); $loanId = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->value('id'); $receivableAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceiveInstamentAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isCompleted',0)->where('isPartiallyPaid',0)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceivePaidAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isPartiallyPaid',1)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $regularReceivePaidAmount = DB::table('mfn_loan_schedule')->where('loanIdFk',$loanId)->where('isPartiallyPaid',1)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('partiallyPaidAmount'); $regularDueAmount = $regularReceivePaidAmount - $regularReceivePaidAmount; $regularReceiveCollection = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('amount'); $advance = $regularReceiveCollection - $receivableAmount ; if($advance<0){ $advance = 0; } $dueAmount = $regularReceiveInstamentAmount + $regularDueAmount; if($dueAmount<0){ $dueAmount = 0; } $receivePrincipleAmount = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('principalAmount'); $receiveServiceChargeAmount = DB::table('mfn_loan_collection')->where('softDel',0)->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('loanIdFk',$loanId)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('interestAmount'); $totalAmount = $receivePrincipleAmount + $receiveServiceChargeAmount; $insurenceClime = DB::table('mfn_loan')->where('samityIdFk',$samityInfo->id)->where('productIdFk',$loanProduct)->where('disbursementDate','>=',$startDate)->where('disbursementDate','<=',$endDate)->sum('insuranceAmount'); $loanRebates = DB::table('mfn_loan_rebates')->where('samityIdFk',$samityInfo->id)->where('primaryProductIdFk',$loanProduct)->where('date','>=',$startDate)->where('date','<=',$endDate)->sum('amount'); // Sub Total $additionalFeeCollectionSubTotal = $additionalFeeCollectionSubTotal + $aditionalFree; $disbusmentSubTotal = $disbusmentSubTotal + $disbusmentAmount; $regularRecevableSubTotal = $regularRecevableSubTotal + $receivableAmount; $regularSubTotal = $regularSubTotal + $regularReceiveCollection; $dueSubTotal = $dueSubTotal + $dueAmount; $advanceSubtotal = $advanceSubtotal + $advance; $rebateSubTotal = $rebateSubTotal + $loanRebates; $loanReceivePrincipleSubTotal = $loanReceivePrincipleSubTotal + $receivePrincipleAmount; $loanReceiveServiceSubTotal = $loanReceiveServiceSubTotal + $receiveServiceChargeAmount ; $totalSubTotal = $totalSubTotal + $totalAmount; $insClimeSubTotal = $insClimeSubTotal + $insurenceClime; @endphp @endif @php $keyProduct++; @endphp @endforeach @php $samityKey++; @endphp @endforeach @if(count($samityInfos) && $sumLoanProduct>0) @foreach ($savingsProducts as $key=>$savingsProduct) @php if(isset($savingsDepositeTotal[$key])){ $savingsDepositeTotal[$key]=$savingsDepositeTotal[$key]+$savingsDepositeSubTotal[$key]; }else{ $savingsDepositeTotal[$key]=$savingsDepositeSubTotal[$key]; } @endphp @endforeach @foreach ($savingsProducts as $interestSavingKey=>$savingsProduct) @php if(isset($interestSavingTotal[$interestSavingKey])){ $interestSavingTotal[$interestSavingKey]=$interestSavingTotal[$interestSavingKey]+$interestSavingSubTotal[$interestSavingKey]; }else{ $interestSavingTotal[$interestSavingKey]=$interestSavingSubTotal[$interestSavingKey]; } @endphp @endforeach @foreach ($savingsProducts as $savingRefundKey=>$savingsProduct) @php if(isset($savingsRefundTotal[$savingRefundKey])){ $savingsRefundTotal[$savingRefundKey]=$savingsRefundTotal[$savingRefundKey]+$savingsRefundSubTotal[$savingRefundKey]; }else{ $savingsRefundTotal[$savingRefundKey]=$savingsRefundSubTotal[$savingRefundKey]; } @endphp @endforeach @endif @php //Total $additionalFeeCollectionTotal = $additionalFeeCollectionTotal + $additionalFeeCollectionSubTotal; $disbusmentTotal +=$disbusmentSubTotal; $regularRecevableTotal += $regularRecevableSubTotal ; $regularTotal +=$regularSubTotal; $dueTotal +=$dueSubTotal; $advancetotal +=$advanceSubtotal ; $rebateTotal +=$rebateSubTotal; $loanReceivePrincipleTotal +=$loanReceivePrincipleSubTotal ; $loanReceiveServiceTotal +=$loanReceiveServiceSubTotal; $insClimeTotal +=$insClimeSubTotal; $totalTotal +=$totalSubTotal; if(count($samityInfos)>0){ $fieldOfficerKey++; } @endphp @endforeach @foreach ($savingsProducts as $key=>$savingsProduct) @if(isset($savingsDepositeTotal[$key])) @else @endif @endforeach @foreach ($savingsProducts as $interestSavingKey=>$savingsProduct) @if(isset($interestSavingTotal[$interestSavingKey])) @else @endif @endforeach @foreach ($savingsProducts as $savingRefundKey=>$savingsProduct) @if(isset($savingsRefundTotal[$savingRefundKey])) @else @endif @endforeach @endif
Field Worker Samity Component Savings Collection Interest On Savings Savings Refund Additional
Fee
Collection
Disbursement
Amount
Regular
Recoverable
Loan Collection Ins.
Claim
ID Name ID Name{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}Regular Due Advance Rebate Total Collection
Loan Received
(Principle)
Loan Received
(Service Charge)
Total
{{$employeeId->emp_id}} {{$employeeId->emp_name_english}}{{$samityInfo->code}} {{$samityInfo->name}} {{$productCategory}}{{number_format($savingDeposite,2)}}{{number_format($InterestSaving,2)}}{{number_format($savingWithdraw,2)}}{{number_format($aditionalFree,2)}} {{number_format($disbusmentAmount,2)}} {{number_format($receivableAmount,2)}} {{number_format($regularReceiveCollection,2)}} {{number_format($dueAmount,2)}} {{number_format($advance,2)}} {{number_format($loanRebates,2)}} {{number_format($receivePrincipleAmount,2)}} {{number_format($receiveServiceChargeAmount,2)}} {{number_format($totalAmount,2)}} {{number_format($insurenceClime,2)}}
Sub Total {{number_format($savingsDepositeSubTotal[$key],2)}} {{number_format($interestSavingSubTotal[$interestSavingKey],2)}}{{number_format($savingsRefundSubTotal[$savingRefundKey],2)}}{{number_format($additionalFeeCollectionSubTotal,2)}} {{number_format($disbusmentSubTotal,2)}} {{number_format($regularRecevableSubTotal,2)}} {{number_format($regularSubTotal,2)}} {{number_format($dueSubTotal,2)}} {{number_format($advanceSubtotal,2)}} {{number_format($rebateSubTotal,2)}} {{number_format($loanReceivePrincipleSubTotal,2)}} {{number_format($loanReceiveServiceSubTotal,2)}} {{number_format($totalSubTotal,2)}} {{number_format($insClimeSubTotal,2)}}
Total{{number_format($savingsDepositeTotal[$key],2)}}{{number_format(0,2)}}{{number_format($interestSavingTotal[$interestSavingKey],2)}}{{number_format(0,2)}}{{number_format($savingsRefundTotal[$savingRefundKey],2)}}{{number_format(0,2)}}{{number_format($additionalFeeCollectionTotal,2)}} {{number_format($disbusmentTotal,2)}} {{number_format($regularRecevableTotal,2)}} {{number_format($regularTotal,2)}} {{number_format($dueTotal,2)}} {{number_format($advancetotal,2)}} {{number_format($rebateTotal,2)}} {{number_format($loanReceivePrincipleTotal,2)}} {{number_format($loanReceiveServiceTotal,2)}} {{number_format($totalTotal,2)}} {{number_format($insClimeTotal,2)}}
@endif