@php function getLoanInfo($loans,$schedules,$collections,$expiredLoanIds,$startDate,$endDate,$filServiceCharge){ $regularRecoverable = 0; $recoveryRegular = 0; $recoveryDueCurrent = 0; $recoveryDueExpired = 0; $recoveryAdvance = 0; $thisWeekNewDue = 0; foreach ($loans as $loan) { if ($filServiceCharge==1) { $previousAmountPayable = $schedules->where('loanIdFk',$loan->id)->where('scheduleDate','<',$startDate)->sum('installmentAmount'); $previousAmountPaid = $collections->where('loanIdFk',$loan->id)->where('collectionDate','<',$startDate)->sum('amount'); $thisWeekRecoverable = $schedules->where('loanIdFk',$loan->id)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('installmentAmount'); $thisWeekCollectionAmount = $collections->where('loanIdFk',$loan->id)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('amount'); } else{ $previousAmountPayable = $schedules->where('loanIdFk',$loan->id)->where('scheduleDate','<',$startDate)->sum('principalAmount'); $previousAmountPaid = $collections->where('loanIdFk',$loan->id)->where('collectionDate','<',$startDate)->sum('principalAmount'); $thisWeekRecoverable = $schedules->where('loanIdFk',$loan->id)->where('scheduleDate','>=',$startDate)->where('scheduleDate','<=',$endDate)->sum('principalAmount'); $thisWeekCollectionAmount = $collections->where('loanIdFk',$loan->id)->where('collectionDate','>=',$startDate)->where('collectionDate','<=',$endDate)->sum('principalAmount'); } $previosDueAmount = $previousAmountPayable - $previousAmountPaid; $previousAdvanceAmount = -$previosDueAmount; if ($previousAdvanceAmount>0) { $thisWeekRecoverable -= $previousAdvanceAmount; } $thisWeekRecoverable = $thisWeekRecoverable < 0 ? 0 : $thisWeekRecoverable; if ($previosDueAmount>0) { $dueCollection = $previosDueAmount > $thisWeekCollectionAmount ? $thisWeekCollectionAmount : $previosDueAmount; $regularCollection = ($thisWeekCollectionAmount - $dueCollection)>0 ? ($thisWeekCollectionAmount - $dueCollection) : 0; if ($regularCollection>0) { $regularCollection = $regularCollection > $thisWeekCollectionAmount ? $thisWeekCollectionAmount : $regularCollection; } $advanceCollection = ($thisWeekCollectionAmount - $regularCollection - $dueCollection)>0 ? ($thisWeekCollectionAmount - $regularCollection - $dueCollection) : 0; } else{ $dueCollection = 0; $regularCollection = $thisWeekCollectionAmount > $thisWeekRecoverable ? $thisWeekRecoverable : $thisWeekCollectionAmount; $advanceCollection = ($thisWeekCollectionAmount - $regularCollection)>0 ? ($thisWeekCollectionAmount - $regularCollection) : 0; } $regularRecoverable += $thisWeekRecoverable; $recoveryRegular += $regularCollection; if (in_array($loan->id, $expiredLoanIds)) { $recoveryDueExpired += $dueCollection; } else{ $recoveryDueCurrent += $dueCollection; } $recoveryAdvance += $advanceCollection; $thisWeekNewDue += $thisWeekRecoverable - $regularCollection; } $data = array( 'regularRecoverable' => $regularRecoverable, 'recoveryRegular' => $recoveryRegular, 'recoveryDueCurrent' => $recoveryDueCurrent, 'recoveryDueExpired' => $recoveryDueExpired, 'recoveryAdvance' => $recoveryAdvance, 'thisWeekNewDue' => $thisWeekNewDue ); return $data; } @endphp
{{-- div for Company --}}
Fatal error: Uncaught Error: Class "DB" not found in /home/shikkhaplus/public_html/guk_bk/resources/views/microfin/reports/regularNGeneralReports/fieldOfficerReport/fieldOfficerReport.blade.php:86 Stack trace: #0 {main} thrown in /home/shikkhaplus/public_html/guk_bk/resources/views/microfin/reports/regularNGeneralReports/fieldOfficerReport/fieldOfficerReport.blade.php on line 86