{{-- div for Company --}} @php $company = DB::table('gnr_company')->where('id', Auth::user()->company_id_fk)->select('name','address')->first(); @endphp {{$company->name}}
{{$company->address}}
PERIODIC COLLECTION REPORT COMPONENT WISE
@foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @foreach ($savingsProducts as $savingsProduct) @endforeach @php $savingsCollectionSubTotalArray = array(); $savingsInterestSubTotalArray = array(); $savingsRefundArSubTotalray = array(); $savingsCollectionSubTotalCounter = 0; $savingsCollectionSubCounter = 0; $savingsInterestSubTotalCounter = 0; $savingsInterestSubCounter = 0; $savingsCollectionTotalArray = array(); $savingsInterestTotalArray = array(); $savingsRefundArTotalray = array(); $savingsCollectionTotalArray = array(); for ($i = 0; $i < sizeof($savingsProducts)*3; $i++) { ++$savingsCollectionSubTotalCounter; $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = 0; $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] = 0; } foreach ($savingsProducts as $key => $sProducts) { ++$savingsInterestSubTotalCounter; $savingsInterestSubTotalArray[$savingsInterestSubTotalCounter] = 0; } $savingsCollectionSubTotalCounter = 0; $savingsCollectionSubCounter = 0; $savingsInterestSubCounter = 0; $savingsInterestSubTotalCounter = 0; $additionalFeeCalculationSubTotal = 0; $additionalFeeCalculationTotal = 0; $disbursementAmountSubTotal = 0; $disbursementAmountTotal = 0; $regularRecoverableSubTotal = 0; $regularRecoverableTotal = 0; $regularLoanCollectionSubTotal = 0; $regularLoanCollectionTotal = 0; $dueLoanCollectionSubTotal = 0; $dueLoanCollectionTotal = 0; $advanceLoanCollectionSubTotal = 0; $advanceLoanCollectionTotal = 0; $rebateLoanCollectionSubTotal = 0; $rebateLoanCollectionTotal = 0; $LoanReceivedSubTotal = 0; $LoanReceivedTotal = 0; $LoanReceivedInterestSubTotal = 0; $LoanReceivedInterestTotal = 0; $totalLoanCollectionSubTotal = 0; $totalLoanCollectionTotal = 0; $installmentClaimedSubTotal = 0; $installmentClaimedTotal = 0; $totalPeriodicSavingsCollection = 0; $totalPeriodicSavingsSubTotalCollection = 0; $processingFeeTotal = 0; $passbookFeeTotal = 0; $AdmissionFeeTotal = 0; @endphp {{-- CHECKING FIELD OFFICER EXIST OR NOT --}} @if (sizeof($fieldOfficersInfos) > 0) {{-- FIELD OFFICER LOOP START --}} @foreach ($fieldOfficersInfos as $fieldOfficer) @php // SAMITY CALCULATION $samityInfos = DB::table('mfn_samity') ->where([['fieldOfficerId', $fieldOfficer->id], ['branchId', $branchId]]) ->select('id', 'name', 'code') ->get(); // dd($samityInfos); $printFieldOfficer = 0; $subTotalCounter = 0; $processingFeeSubTotal = 0; $passbookFeeSubTotal = 0; $AdmissionFeeSubTotal = 0; @endphp {{-- SAMITY LOOP START --}} @foreach ($samityInfos as $samity) @php // ++$printFieldOfficer; // $subTotalCounter = 1; $printSamity = 0; // IF SEARCH OPTION IS SELECTED AS 'Loan Product' if ($searchLoanProduct == 'LoanProduct') { // IF CATEGORY AND PRODUCT SELECTED AS 'ALL' if ($searchProCategory == 'All' and $searchProduct == 'All') { // PRODUCT CALCULATION $productInfos = DB::table('mfn_member_information') ->where([['samityId', $samity->id], ['softDel', '=', '0']]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('primaryProductId') ->groupBy('primaryProductId') ->pluck('primaryProductId') ->toArray(); // dd($memberInformation); } // IF CATEGORY NOT SELECTED AS 'ALL' BUT PRODUCT SELECTED AS 'ALL' elseif ($searchProCategory != 'All' and $searchProduct == 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_member_information.softDel', '=', '0'], ['mfn_loans_product.productCategoryId', $searchProCategory]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('mfn_member_information.primaryProductId') ->groupBy('mfn_member_information.primaryProductId') ->pluck('mfn_member_information.primaryProductId') ->toArray(); } // IF CATEGORY SELECTED AS 'ALL' BUT PRODUCT NOT SELECTED AS 'ALL' elseif ($searchProCategory == 'All' and $searchProduct != 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->where([['samityId', $samity->id], ['softDel', '=', '0'], ['primaryProductId', $searchProduct]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('primaryProductId') ->groupBy('primaryProductId') ->pluck('primaryProductId') ->toArray(); } // IF CATEGORY AND PRODUCT BOTH NOT SELECTED AS 'ALL' elseif ($searchProCategory != 'All' and $searchProduct != 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->where([['samityId', $samity->id], ['softDel', '=', '0'], ['primaryProductId', $searchProduct]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('primaryProductId') ->groupBy('primaryProductId') ->pluck('primaryProductId') ->toArray(); } } // IF SEARCH OPTION IS SELECTED AS 'Loan Product Category' else { // IF CATEGORY AND PRODUCT SELECTED AS 'ALL' if ($searchProCategory == 'All' and $searchProduct == 'All') { // PRODUCT CALCULATION $productInfos = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_member_information.softDel', '=', '0']]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('mfn_loans_product.productCategoryId') ->groupBy('mfn_loans_product.productCategoryId') ->pluck('mfn_loans_product.productCategoryId') ->toArray(); } // IF CATEGORY NOT SELECTED AS 'ALL' BUT PRODUCT SELECTED AS 'ALL' elseif ($searchProCategory != 'All' and $searchProduct == 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_member_information.softDel', '=', '0'], ['mfn_loans_product.productCategoryId', $searchProCategory]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('mfn_loans_product.productCategoryId') ->groupBy('mfn_loans_product.productCategoryId') ->pluck('mfn_loans_product.productCategoryId') ->toArray(); } // IF CATEGORY SELECTED AS 'ALL' BUT PRODUCT NOT SELECTED AS 'ALL' elseif ($searchProCategory == 'All' and $searchProduct != 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_member_information.softDel', '=', '0'], ['mfn_member_information.primaryProductId', $searchProduct]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('mfn_loans_product.productCategoryId') ->groupBy('mfn_loans_product.productCategoryId') ->pluck('mfn_loans_product.productCategoryId') ->toArray(); } // IF CATEGORY AND PRODUCT BOTH NOT SELECTED AS 'ALL' elseif ($searchProCategory != 'All' and $searchProduct != 'All') { // PRODUCT CALCULATION... $productInfos = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_member_information.softDel', '=', '0'], ['mfn_member_information.primaryProductId', $searchProduct]]) // ->where(function ($query) use ($endDate) { // $query->where('closingDate', '>=', $endDate) // ->orWhere('closingDate', '=', '0000-00-00') // ->orWhere('closingDate', '=', ''); // }) ->select('mfn_loans_product.productCategoryId') ->groupBy('mfn_loans_product.productCategoryId') ->pluck('mfn_loans_product.productCategoryId') ->toArray(); } } // dd($productInfos); @endphp {{-- PRODUCT LOOP START --}} @foreach ($productInfos as $product) @php $savingsCollectionSubTotalCounter = 0; @endphp @php ++$printFieldOfficer; $subTotalCounter = 1; ++$printSamity; // IF SEARCH OPTION IS SELECTED AS 'Loan Product' if ($searchLoanProduct == 'LoanProduct') { // GET THE PROPER MEMBER INFORMATION $memberInformation = DB::table('mfn_member_information') ->where([['samityId', $samity->id], ['primaryProductId', $product], ['softDel', '=', 0]]) // ->where(function ($query) use ($endDate) { // $query->where([['closingDate', '<=', $endDate]]) // ->orWhere([['closingDate', '=', '0000-00-00']]) // ->orWhere([['closingDate', '=', null]]); // }) ->pluck('id') ->toArray(); } // IF SEARCH OPTION IS SELECTED AS 'Loan Product Category' else { // GET THE PROPER MEMBER INFORMATION $memberInformation = DB::table('mfn_member_information') ->join('mfn_loans_product', 'mfn_member_information.primaryProductId', '=', 'mfn_loans_product.id') ->where([['mfn_member_information.samityId', $samity->id], ['mfn_loans_product.productCategoryId', $product], ['mfn_member_information.softDel', '=', 0]]) // ->where(function ($query) use ($endDate) { // $query->where([['closingDate', '<=', $endDate]]) // ->orWhere([['closingDate', '=', '0000-00-00']]) // ->orWhere([['closingDate', '=', null]]); // }) ->pluck('mfn_member_information.id') ->toArray(); } // dd($memberInformation); if ($samity->id == 744) { // dd($memberInformation); } @endphp {{-- CHECK FIELD OFFICER TO PRINT ONLY SINGLE TIME --}} @if ($printFieldOfficer == 1) {{-- ROWSPAN LOOP START --}} @foreach ($rowByFieldOfficer as $keyF => $rowspan) {{-- CHECK FIELD OFFICER ID FOR PROPER ROWSPAN --}} @if ($fieldOfficer->id == $keyF) @endif @endforeach @endif {{-- CHECK SAMITY TO PRINT ONLY SINGLE TIME --}} @if ($printSamity == 1) @endif @php $totalCollectionAmount = 0; $totalCollectionAmountArray = array(); // GET THE PROPER SAVINGS ACCOUNT INFORMATION foreach ($savingsProducts as $key => $savings) { $savingsInformation = DB::table('mfn_savings_account') ->where([['savingsProductIdFk', $savings->id], ['softDel', '=', 0]]) // ->where(function ($query) use ($endDate) { // $query->where([['closingDate', '>=', $endDate]]) // ->orWhere([['closingDate', '=', '0000-00-00']]) // ->orWhere([['closingDate', '=', null]]); // }) ->whereIn('memberIdFk', $memberInformation) ->pluck('id') ->toArray(); $savingsAccCollection[$savings->id] = DB::table('mfn_savings_deposit') ->where([['depositDate', '>=', $startDate], ['depositDate', '<=', $endDate], ['softDel', '=', 0]]) ->where('isTransferred', '=', 0) ->whereIn('accountIdFk', $savingsInformation) ->sum('amount'); $savingsInterest[$savings->id] = DB::table('mfn_savings_interest') ->where([['status', '=', 1], ['effectiveDate', '>=', $startDate], ['effectiveDate', '<=', $endDate]]) ->whereIn('accIdFk', $savingsInformation) ->sum('interestAmount'); $savingsRefund[$savings->id] = DB::table('mfn_savings_withdraw') ->where([['softDel', '=', 0], ['withdrawDate', '>=', $startDate], ['withdrawDate', '<=', $endDate]]) ->where('isTransferred', '=', 0) ->whereIn('accountIdFk', $savingsInformation) ->sum('amount'); } @endphp {{-- PRINT ALL OF THE SAVINGS ACCOUNT INFORMATION --}} @foreach ($savingsAccCollection as $total) @if ($total > 0) @else @endif @php ++$savingsCollectionSubTotalCounter; if ($savingsCollectionSubCounter == 0) { // $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = $total; $savingsCollectionSubCounter = 1; } $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] + $total; $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] + $total; $totalPeriodicSavingsCollection += $total; @endphp @endforeach @foreach ($savingsInterest as $interest) @if ($interest > 0) @else @endif @php ++$savingsCollectionSubTotalCounter; $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] + $interest; $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] + $interest; @endphp @endforeach @foreach ($savingsRefund as $refund) @if ($refund > 0) @else @endif @php ++$savingsCollectionSubTotalCounter; $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] + $refund; $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] = $savingsCollectionTotalArray[$savingsCollectionSubTotalCounter] + $refund; @endphp @endforeach {{-- PRINT LOAN ADDITIONAL + INSURANCE FEE --}} @php $additionalFeeCalculationSubTotal = $additionalFeeCalculationSubTotal + $additionalFee; @endphp {{-- DISBURSED LOAN AMOUNT --}} @php $disbursementAmountSubTotal = $disbursementAmountSubTotal + $disbursedLoanAmount; @endphp {{-- PRINT RECOVERABLE LOAN AMOUNT --}} @php $regularRecoverableSubTotal = $regularRecoverableSubTotal + $recoverableLoanAmount; @endphp {{-- PRINT REGULAR LOAN COLLECTION AMOUNT --}} @php $regularLoanCollectionSubTotal = $regularLoanCollectionSubTotal + $regularLoanCollection; @endphp {{-- PRINT DUE LOAN COLLECTION AMOUNT --}} @php $dueLoanCollectionSubTotal = $dueLoanCollectionSubTotal + $dueAmount; @endphp {{-- PRINT ADVANCE LOAN COLLECTION AMOUNT --}} @php $advanceLoanCollectionSubTotal = $advanceLoanCollectionSubTotal + $advanceAmount; @endphp {{-- PRINT LOAN REBATE AMOUNT --}} @php $rebateLoanCollectionSubTotal = $rebateLoanCollectionSubTotal + $rebateAmount; @endphp {{-- PRINT PRINCIPLE LOAN COLLECTION AMOUNT --}} @php $LoanReceivedSubTotal = $LoanReceivedSubTotal + $principleLoanCollection; @endphp {{-- PRINT INTEREST AMOUNT OF LOAN COLLECTION AMOUNT --}} @php $LoanReceivedInterestSubTotal = $LoanReceivedInterestSubTotal + $interestAmountOfLoanCollection; @endphp {{-- PRINT TOTAL LOAN COLLECTION AMOUNT --}} {{-- PRINT TOTAL LOAN INSURANCE CLAIMED [ NOT INSTALLMENT CLAIMED $installmentClaimed ]--}} @php $installmentClaimedSubTotal = $installmentClaimedSubTotal + $insuranceAmount; @endphp @endforeach @endforeach @php // dd($savingsCollectionSubTotalArray); @endphp @if ($subTotalCounter == 1) @foreach ($savingsCollectionSubTotalArray as $savingsCollectionSubTotal) @if ($savingsCollectionSubTotal > 0) @else @endif @endforeach @php $savingsCollectionSubCounter = 0; $savingsCollectionSubTotalCounter = 0; for ($i = 0; $i < sizeof($savingsProducts)*3; $i++) { ++$savingsCollectionSubTotalCounter; $savingsCollectionSubTotalArray[$savingsCollectionSubTotalCounter] = 0; } $savingsCollectionSubTotalCounter = 0; $savingsCollectionSubCounter = 0; @endphp {{-- ADDITIONAL FEE CALCULATION SUB TOTAL --}} @php $additionalFeeCalculationTotal = $additionalFeeCalculationTotal + $additionalFeeCalculationSubTotal; $additionalFeeCalculationSubTotal = 0; @endphp {{-- DISBURSEMENT AMOUNT SUB TOTAL --}} @php $disbursementAmountTotal = $disbursementAmountTotal + $disbursementAmountSubTotal; $disbursementAmountSubTotal = 0; @endphp {{-- REGULAR RECOVERABLE AMOUNT SUB TOTAL --}} @php $regularRecoverableTotal = $regularRecoverableTotal + $regularRecoverableSubTotal; $regularRecoverableSubTotal = 0; @endphp {{-- REGULAR LOAN COLLECTION AMOUNT SUB TOTAL --}} @php $regularLoanCollectionTotal = $regularLoanCollectionTotal + $regularLoanCollectionSubTotal; $regularLoanCollectionSubTotal = 0; @endphp {{-- DUE LOAN COLLECTION AMOUNT SUB TOTAL --}} @php $dueLoanCollectionTotal = $dueLoanCollectionTotal + $dueLoanCollectionSubTotal; $dueLoanCollectionSubTotal = 0; @endphp {{-- ADVANCE LOAN COLLECTION LOAN AMOUNT SUB TOTAL --}} @php $advanceLoanCollectionTotal = $advanceLoanCollectionTotal + $advanceLoanCollectionSubTotal; $advanceLoanCollectionSubTotal = 0; @endphp {{-- REBATE LOAN COLLECTION AMOUNT SUB TOTAL --}} @php $rebateLoanCollectionTotal = $rebateLoanCollectionTotal + $rebateLoanCollectionSubTotal; $rebateLoanCollectionSubTotal = 0; @endphp {{-- RECIEVED LOAN PRINCIPAL AMOUNT COLLECTION SUB TOTAL --}} @php $LoanReceivedTotal = $LoanReceivedTotal + $LoanReceivedSubTotal; $totalLoanCollectionSubTotal = $totalLoanCollectionSubTotal + $LoanReceivedSubTotal; $LoanReceivedSubTotal = 0; @endphp {{-- RECIEVED LOAN INTEREST AMOUNT COLLECTION SUB TOTAL --}} @php $LoanReceivedInterestTotal = $LoanReceivedInterestTotal + $LoanReceivedInterestSubTotal; $totalLoanCollectionSubTotal = $totalLoanCollectionSubTotal + $LoanReceivedInterestSubTotal; $LoanReceivedInterestSubTotal = 0; @endphp {{-- TOTAL LOAN COLLECTION AMOUNT SUB TOTAL --}} @php $totalLoanCollectionTotal = $totalLoanCollectionTotal + $totalLoanCollectionSubTotal; $totalLoanCollectionSubTotal = 0; @endphp {{-- INSTALLMENT CLAIMED SUB TOTAL --}} @php $installmentClaimedTotal = $installmentClaimedTotal + $installmentClaimedSubTotal; $installmentClaimedSubTotal = 0; $processingFeeTotal += $processingFeeSubTotal; $passbookFeeTotal += $passbookFeeSubTotal; $AdmissionFeeTotal += $AdmissionFeeSubTotal; @endphp @endif @endforeach @endif @foreach ($savingsCollectionTotalArray as $savingsCollectionTotal) @if ($savingsCollectionTotal > 0) @else @endif @endforeach {{-- ADDITIONAL FEE CALCULATION TOTAL --}} {{-- DISBURSEMENT AMOUNT TOTAL --}} {{-- REGULAR RECOVERABLE AMOUNT TOTAL --}} {{-- REGULAR LOAN COLLECTION AMOUNT TOTAL --}} {{-- DUE COLLECTION AMOUNT TOTAL --}} {{-- ADVANCE LOAN COLLECTION AMOUNT TOTAL --}} {{-- REBATE LOAN COLLECTION AMOUNT TOTAL --}} {{-- RECIEVED LOAN PRINCIPAL AMOUNT COLLECTION TOTAL --}} {{-- RECIEVED LOAN INTEREST AMOUNT COLLECTION TOTAL --}} {{-- TOTAL LOAN COLLECTION AMOUNT TOTAL --}} {{-- INSTALLMENT CLAIMED TOTAL --}} @php //echo "Savings Collection : ".$totalPeriodicSavingsCollection." || Sub Total : ".$totalPeriodicSavingsSubTotalCollection; //dd($savingsCollectionTotalArray); @endphp
Field Worker Samity Component Savings Collection Interest On Savings Savings Refund Additional
Fee
Collection
Disbursement
Amount
Regular
Recoverable
Loan Collection Ins.
Claim
Processing
Fee
Passbook
Fee
Admission
Fee
ID Name ID Name{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}{{$savingsProduct->shortName}}Regular Due Advance Rebate Total Collection
Loan Received
(Principle)
Loan Received
(Service Charge)
Total
{{ $fieldOfficer->emp_id }} {{ $fieldOfficer->emp_name_english }} {{$samity->code}} {{$samity->name}} {{-- FETCH THE PRODUCT NAME FROM DATABASE --}} @php $dueAmount = 0; $advanceAmount = 0; // IF SEARCH OPTION IS SELECTED AS 'Loan Product' if ($searchLoanProduct == 'LoanProduct') { $productName = DB::table('mfn_loans_product') ->where('id', $product) ->pluck('shortName') ->toArray(); // GET ADDITIONAL FEE + INSURANCE AMOUNT AS ADDITIONAL FEE INFORMATION $additionalFee = DB::table('mfn_loan') ->where([['primaryProductIdFk', $product], ['disbursementDate', '>=', $startDate], ['disbursementDate', '<=', $endDate], ['samityIdFk', $samity->id], ['softDel', '=', 0]]) ->sum('additionalFee'); $insuranceAmount = DB::table('mfn_loan') ->where([['primaryProductIdFk', $product], ['disbursementDate', '>=', $startDate], ['disbursementDate', '<=', $endDate], ['samityIdFk', $samity->id], ['softDel', '=', 0]]) ->sum('insuranceAmount'); // GET LOAN DISBURSEMENT INFORMATION $disbursedLoanAmount = DB::table('mfn_loan') ->where([['primaryProductIdFk', $product], ['disbursementDate', '>=', $startDate], ['disbursementDate', '<=', $endDate], ['samityIdFk', $samity->id], ['softDel', '=', 0]]) ->sum('loanAmount'); // GET LOAN RECOVERABLE INFORMATION $recoverableLoanIds = DB::table('mfn_loan') ->where([['primaryProductIdFk', $product], ['softDel', '=', 0], ['samityIdFk', $samity->id]]) ->pluck('id') ->toArray(); $recoverableLoanAmount = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '>=', $startDate], ['scheduleDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); // LOAN COLLECTION START // REGULAR LOAN COLLECTION AMOUNT $regularLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); // REGULAR DUE COLLECTION AMOUNT $collectionAmountAtTheTimeOfstartDate = DB::table('mfn_loan_collection') ->where([['collectionDate', '<', $startDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); $scheduleAmountAtTheTimeOfstartDate = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '<', $startDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); $collectionAmountAtTheTimeOfendtDate = DB::table('mfn_loan_collection') ->where([['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); $scheduleAmountAtTheTimeOfendtDate = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); // FIND OUT THE DUE AND ADVANCE AMOUNT if (($collectionAmountAtTheTimeOfstartDate == $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate == $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = 0; } elseif (($collectionAmountAtTheTimeOfstartDate < $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate <= $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = $regularLoanCollection; $regularLoanCollection = 0; $advanceAmount = 0; } elseif (($collectionAmountAtTheTimeOfstartDate > $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate > $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = $regularLoanCollection; $regularLoanCollection = 0; } elseif (($collectionAmountAtTheTimeOfstartDate > $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate == $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = 0; } // LOAN REBATE AMOUNT $rebateAmount = DB::table('mfn_loan_rebates') ->where('softDel',0) ->where([['date', '>=', $startDate], ['date', '<=', $startDate]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); // TOTAL COLLECTION // PRINCIPLE LOAN RICIEVED $principleLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('principalAmount'); $interestAmountOfLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('interestAmount'); // TOTAL INSTALLMENT CLAIMED $installmentClaimed = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->count('id'); } // IF SEARCH OPTION IS SELECTED AS 'Loan Product Ctegory' else { $productName = DB::table('mfn_loans_product_category') ->where('id', $product) ->pluck('shortName') ->toArray(); // GET ADDITIONAL FEE + INSURANCE AMOUNT AS ADDITIONAL FEE INFORMATION $additionalFee = DB::table('mfn_loan') ->join('mfn_loans_product', 'mfn_loan.primaryProductIdFk', '=', 'mfn_loans_product.id') ->where([['mfn_loans_product.productCategoryId', $product], ['mfn_loan.disbursementDate', '>=', $startDate], ['mfn_loan.disbursementDate', '<=', $endDate], ['mfn_loan.samityIdFk', $samity->id], ['mfn_loan.softDel', '=', 0]]) ->sum('mfn_loan.additionalFee'); $insuranceAmount = DB::table('mfn_loan') ->join('mfn_loans_product', 'mfn_loan.primaryProductIdFk', '=', 'mfn_loans_product.id') ->where([['mfn_loans_product.productCategoryId', $product], ['mfn_loan.disbursementDate', '>=', $startDate], ['mfn_loan.disbursementDate', '<=', $endDate], ['mfn_loan.samityIdFk', $samity->id], ['mfn_loan.softDel', '=', 0]]) ->sum('mfn_loan.insuranceAmount'); // GET LOAN DISBURSEMENT INFORMATION $disbursedLoanAmount = DB::table('mfn_loan') ->join('mfn_loans_product', 'mfn_loan.primaryProductIdFk', '=', 'mfn_loans_product.id') ->where([['mfn_loans_product.productCategoryId', $product], ['mfn_loan.disbursementDate', '>=', $startDate], ['mfn_loan.disbursementDate', '<=', $endDate], ['mfn_loan.samityIdFk', $samity->id], ['mfn_loan.softDel', '=', 0]]) ->sum('mfn_loan.loanAmount'); // GET LOAN RECOVERABLE INFORMATION $recoverableLoanIds = DB::table('mfn_loan') ->join('mfn_loans_product', 'mfn_loan.primaryProductIdFk', '=', 'mfn_loans_product.id') ->where([['mfn_loans_product.productCategoryId', $product], ['mfn_loan.samityIdFk', $samity->id], ['mfn_loan.softDel', '=', 0]]) ->pluck('mfn_loan.id') ->toArray(); $recoverableLoanAmount = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '>=', $startDate], ['scheduleDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); // LOAN COLLECTION START // REGULAR LOAN COLLECTION AMOUNT $regularLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); // REGULAR DUE COLLECTION AMOUNT $collectionAmountAtTheTimeOfstartDate = DB::table('mfn_loan_collection') ->where([['collectionDate', '<', $startDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); $scheduleAmountAtTheTimeOfstartDate = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '<', $startDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); $collectionAmountAtTheTimeOfendtDate = DB::table('mfn_loan_collection') ->where([['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); $scheduleAmountAtTheTimeOfendtDate = DB::table('mfn_loan_schedule') ->where([['scheduleDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('installmentAmount'); // FIND OUT THE DUE AND ADVANCE AMOUNT if (($collectionAmountAtTheTimeOfstartDate == $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate == $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = 0; $condition = 1; } elseif (($collectionAmountAtTheTimeOfstartDate < $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate <= $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = $regularLoanCollection; $regularLoanCollection = 0; $advanceAmount = 0; $condition = 2; } elseif (($collectionAmountAtTheTimeOfstartDate > $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate > $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = $regularLoanCollection; $regularLoanCollection = 0; $condition = 3; } elseif (($collectionAmountAtTheTimeOfstartDate > $scheduleAmountAtTheTimeOfstartDate) and ($collectionAmountAtTheTimeOfendtDate == $scheduleAmountAtTheTimeOfendtDate)) { $dueAmount = 0; $advanceAmount = 0; $condition = 4; } // LOAN REBATE AMOUNT $rebateAmount = DB::table('mfn_loan_rebates') ->where('softDel',0) ->where([['date', '>=', $startDate], ['date', '<=', $startDate]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('amount'); // TOTAL COLLECTION // PRINCIPLE LOAN RICIEVED $principleLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('principalAmount'); $interestAmountOfLoanCollection = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->sum('interestAmount'); // TOTAL LOAN INSTALLMENT CLAIMED $installmentClaimed = DB::table('mfn_loan_collection') ->where([['collectionDate', '>=', $startDate], ['collectionDate', '<=', $endDate], ['softDel', '=', 0]]) ->whereIn('loanIdFk', $recoverableLoanIds) ->count('id'); } @endphp {{$productName[0]}} {{number_format($total, 2)}} - {{number_format($interest, 2)}} - {{ number_format($refund, 2) }} - @if (($additionalFee) > 0) {{number_format($additionalFee, 2)}} @else - @endif @if ($disbursedLoanAmount > 0) {{number_format($disbursedLoanAmount, 2)}} @else - @endif @if ($recoverableLoanAmount > 0) {{number_format($recoverableLoanAmount, 2)}} @else - @endif @if ($regularLoanCollection > 0) {{number_format($regularLoanCollection, 2)}} @else - @endif @if ($dueAmount > 0) {{number_format($dueAmount, 2)}} @else - @endif @if ($advanceAmount > 0) {{number_format($advanceAmount, 2)}} @else - @endif @if ($rebateAmount > 0) {{number_format($rebateAmount, 2)}} @else - @endif @if ($principleLoanCollection > 0) {{number_format($principleLoanCollection, 2)}} @else - @endif @if ($interestAmountOfLoanCollection > 0) {{number_format($interestAmountOfLoanCollection, 2)}} @else - @endif @if (($principleLoanCollection + $interestAmountOfLoanCollection) > 0) {{number_format($principleLoanCollection + $interestAmountOfLoanCollection, 2)}} @else - @endif @if ( $insuranceAmount > 0) {{$insuranceAmount}} @else - @endif @if (isset($processingFees[$samity->id]) && $processingFees[$samity->id]->total_processingFee > 0 && $processingFees[$samity->id]->primaryProductIdFk == $product) {{$processingFees[$samity->id]->total_processingFee}} @php $processingFeeSubTotal+= $processingFees[$samity->id]->total_processingFee; @endphp @else - @endif @if (isset($memberFees[$samity->id]) && $memberFees[$samity->id]->total_passbookFee > 0 && $memberFees[$samity->id]->primaryProductId == $product) {{$memberFees[$samity->id]->total_passbookFee}} @php $passbookFeeSubTotal += $memberFees[$samity->id]->total_passbookFee; @endphp @else - @endif @if (isset($memberFees[$samity->id]) && $memberFees[$samity->id]->total_admissionFee > 0 && $memberFees[$samity->id]->primaryProductId == $product) {{$memberFees[$samity->id]->total_admissionFee}} @php $AdmissionFeeSubTotal+= $memberFees[$samity->id]->total_admissionFee; @endphp @else - @endif
Sub Total {{number_format($savingsCollectionSubTotal, 2)}} - @if ($additionalFeeCalculationSubTotal > 0) {{number_format($additionalFeeCalculationSubTotal, 2)}} @else - @endif @if ($disbursementAmountSubTotal > 0) {{number_format($disbursementAmountSubTotal, 2)}} @else - @endif @if ($regularRecoverableSubTotal > 0) {{number_format($regularRecoverableSubTotal, 2)}} @else - @endif @if ($regularLoanCollectionSubTotal > 0) {{number_format($regularLoanCollectionSubTotal, 2)}} @else - @endif @if ($dueLoanCollectionSubTotal > 0) {{number_format($dueLoanCollectionSubTotal, 2)}} @else - @endif @if ($advanceLoanCollectionSubTotal > 0) {{number_format($advanceLoanCollectionSubTotal, 2)}} @else - @endif @if ($rebateLoanCollectionSubTotal > 0) {{number_format($rebateLoanCollectionSubTotal, 2)}} @else - @endif @if ($LoanReceivedSubTotal > 0) {{number_format($LoanReceivedSubTotal, 2)}} @else - @endif @if ($LoanReceivedInterestSubTotal > 0) {{number_format($LoanReceivedInterestSubTotal, 2)}} @else - @endif @if ($totalLoanCollectionSubTotal > 0) {{number_format($totalLoanCollectionSubTotal, 2)}} @else - @endif @if ($installmentClaimedSubTotal > 0) {{$installmentClaimedSubTotal}} @else - @endif {{$processingFeeSubTotal > 0 ? $processingFeeSubTotal : '-' }} {{$passbookFeeSubTotal > 0 ? $passbookFeeSubTotal : '-' }} {{$AdmissionFeeSubTotal > 0 ? $AdmissionFeeSubTotal : '-' }}
Total {{number_format($savingsCollectionTotal, 2)}} - @if ($additionalFeeCalculationTotal > 0) {{number_format($additionalFeeCalculationTotal, 2)}} @else - @endif @if ($disbursementAmountTotal > 0) {{number_format($disbursementAmountTotal, 2)}} @else - @endif @if ($regularRecoverableTotal > 0) {{number_format($regularRecoverableTotal, 2)}} @else - @endif @if ($regularLoanCollectionTotal > 0) {{number_format($regularLoanCollectionTotal, 2)}} @else - @endif @if ($dueLoanCollectionTotal > 0) {{number_format($dueLoanCollectionTotal, 2)}} @else - @endif @if ($advanceLoanCollectionTotal > 0) {{number_format($advanceLoanCollectionTotal, 2)}} @else - @endif @if ($rebateLoanCollectionTotal > 0) {{number_format($rebateLoanCollectionTotal, 2)}} @else - @endif @if ($LoanReceivedTotal > 0) {{number_format($LoanReceivedTotal, 2)}} @else - @endif @if ($LoanReceivedInterestTotal > 0) {{number_format($LoanReceivedInterestTotal, 2)}} @else - @endif @if ($totalLoanCollectionTotal > 0) {{number_format($totalLoanCollectionTotal, 2)}} @else @endif @if ($installmentClaimedTotal > 0) {{$installmentClaimedTotal}} @else - @endif {{$processingFeeTotal>0 ? $processingFeeTotal : '-'}} {{$passbookFeeTotal>0 ? $passbookFeeTotal : '-'}} {{$AdmissionFeeTotal>0 ? $AdmissionFeeTotal : '-'}}