diff --git a/Apollo/api/application/controllers/Fees_Status_Controller.php b/Apollo/api/application/controllers/Fees_Status_Controller.php index cc26316b..6447a3a8 100755 --- a/Apollo/api/application/controllers/Fees_Status_Controller.php +++ b/Apollo/api/application/controllers/Fees_Status_Controller.php @@ -240,6 +240,7 @@ class Fees_Status_Controller extends REST_Controller { $details['Others'] = $this->post('other'); $details['CreatedBy'] = $this->post('createdBy'); $details['CreatedOn'] = $now->format('Y-m-d H:i:s'); + $details['BatchCode'] = $this->post('batchCode'); $jsonInstallmenData = $this->post('installmentItems'); diff --git a/Apollo/api/application/models/Fees_status_model.php b/Apollo/api/application/models/Fees_status_model.php index 9d22155c..b5662782 100755 --- a/Apollo/api/application/models/Fees_status_model.php +++ b/Apollo/api/application/models/Fees_status_model.php @@ -17,7 +17,7 @@ class Fees_status_model extends CI_Model public function getStudentList($search=null) { if($search['MobileNumber']!='' OR $search['Firstname']!='' OR $search['UniversityID']!='' OR $search['CourseID']!=''){ - $this->db->select('ST.StudentID,ST.MobileNumber,ST.Firstname,ST.Fathername,ST.EmailID,STC.ID,US.UniversityID,US.UniversityName,CU.CourseID,CU.CourseName,BA.BatchCode,BA.BatchName'); + $this->db->select('ST.StudentID,ST.MobileNumber,ST.Firstname,ST.Fathername,ST.EmailID,STC.ID,US.UniversityID,US.UniversityName,CU.CourseID,CU.CourseName,BA.BatchCode,BA.BatchName,BA.BatchDate'); $this->db->from(STUDENTS.' as ST'); $this->db->join(STUDENTCOURSE.' as STC', 'STC.StudentID = ST.StudentID'); $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID'); @@ -408,12 +408,14 @@ class Fees_status_model extends CI_Model } else { $this->db->insert(STUDENTS_FEES_PAID, $feesPaidDetails); if ($this->db->affected_rows() == '1') { + $result['paidStatus'] = true; $result['message'] = "Successfully fees details added"; + $feesPayedID = $this->db->insert_id(); // $entryOfCallTrack = $this->updateInCallTrack($trackDetails); // day book entry - if($feesPaidDetails['ModeOfPayment']=='CASH' AND $feesPaidDetails['BillAmount']!='0'){ - $dayBookEntry = $this->insertDayBookMaster($feesPaidDetails); + if($feesPaidDetails['BillAmount']!='0'){ + $dayBookEntry = $this->insertDayBookMaster($feesPaidDetails,$feesPayedID); } @@ -632,6 +634,7 @@ class Fees_status_model extends CI_Model * created by kms * */ public function getFeesStructureAssign($student=null){ + $this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year'); $this->db->where('CourseID',$student['CourseID']); $this->db->order_by('ProgramType'); @@ -640,7 +643,8 @@ class Fees_status_model extends CI_Model $result_array['feesStatus']=true; foreach ($feesDetails->result() as $row){ - $this->db->select('FeesID,CourseFees, STFOrWR,Waiver,Others,SessionName,RollNo'); + $this->db->select('FeesID,CourseFees, STFOrWR,Waiver,Others,SessionName,RollNo,BatchCode'); + $this->db->where('StudentID',$student['StudentID']); $this->db->where('CourseID',$student['CourseID']); $this->db->where('FeesType',$row->ID); @@ -651,6 +655,7 @@ class Fees_status_model extends CI_Model $fetchData['CourseID']=$row->CourseID; $fetchData['Sem_Year']=$row->Sem_Year; $fetchData['ActualFees']=$existData[0]->CourseFees; + $fetchData['BatchCode']=$existData[0]->BatchCode; $fetchData['STFOrWR']=$existData[0]->STFOrWR; $fetchData['Waiver']=$existData[0]->Waiver; $fetchData['Others']=$existData[0]->Others; @@ -659,6 +664,7 @@ class Fees_status_model extends CI_Model $fetchData['PayableFees']=$existData[0]->CourseFees+$existData[0]->STFOrWR+$existData[0]->Others-$existData[0]->Waiver; // for installment details $InstallemtResult = $this->getInstallmentDetails($existData[0]->FeesID); + if($InstallemtResult != false){ $fetchData['InstallmentDetails']=$InstallemtResult; } @@ -668,6 +674,13 @@ class Fees_status_model extends CI_Model } + $batchDetails = $this->getBatchDetails($existData[0]->BatchCode,$student['CourseID'],$student['StudentID'],$row->ID); + if($batchDetails!=false){ + $fetchData['batchDetails']=$batchDetails; + } + else{ + $fetchData['batchDetails']=""; + } $CourseFeesArray[]=$fetchData; @@ -676,8 +689,10 @@ class Fees_status_model extends CI_Model $fetchData['ExistValue']=0; $fetchData['ID']=$row->ID; $fetchData['CourseID']=$row->CourseID; + $fetchData['Sem_Year']=$row->Sem_Year; $fetchData['ActualFees']=$row->FeesAmount; + $fetchData['BatchCode']=""; $fetchData['STFOrWR']=""; $fetchData['Waiver']=""; $fetchData['Others']=""; @@ -686,6 +701,13 @@ class Fees_status_model extends CI_Model $fetchData['PayableFees']=$row->FeesAmount; // for installment details $fetchData['InstallmentDetails']=""; + $batchDetails = $this->getBatchDetails('',$student['CourseID'],$student['StudentID'],''); + if($batchDetails!=false){ + $fetchData['batchDetails']=$batchDetails; + } + else{ + $fetchData['batchDetails']=""; + } $CourseFeesArray[]=$fetchData; @@ -708,6 +730,7 @@ class Fees_status_model extends CI_Model else{ $result_array['feesStatus']=false; } + return $result_array; } @@ -729,6 +752,68 @@ class Fees_status_model extends CI_Model } + /* + * get batch details + * created by kms + * */ + public function getBatchDetails($batchCode=null,$courseID=null,$studentID=null,$feesType=null){ + if($batchCode=='' OR $batchCode==null){ + $this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,US.UniversityID,US.UniversityName,BA.IsActive'); + $this->db->from(COURSE.' as CU'); + $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID'); + $this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID'); + $this->db->order_by('BA.CreatedOn','DESC'); + $this->db->where('CU.CourseID',$courseID); + $this->db->where('BA.IsActive','1'); + $batchDetails = $this->db->get(); + if($batchDetails->result()){ + + return $batchDetails->result(); + } + else { + return false; + } + } + else{ + + + $this->db->distinct(); + $this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,US.UniversityID,US.UniversityName,BA.IsActive'); + $this->db->from(COURSE.' as CU'); + $this->db->join(STUDENTS_FEES_STATUS.' as STF', 'STF.CourseID = CU.CourseID'); + $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID'); + $this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID'); + $this->db->order_by('BA.CreatedOn','DESC'); + $this->db->where('CU.CourseID',$courseID); + $this->db->where('STF.StudentID',$studentID); + $this->db->where('STF.FeesType',$feesType); + $batchDetails = array(); + + /* $this->db->or_where('BA.IsActive','1'); + $this->db->or_where('STF.BatchCode =',$batchCode);*/ + $existDetails = $this->db->get(); + if($existDetails->result()){ + foreach ($existDetails->result() as $row){ + if($row->IsActive=='1' || $row->BatchCode==$batchCode){ + array_push($batchDetails,$row); + } + + } + } + if($batchDetails){ + + return $batchDetails; + } + else { + return false; + } + + + + } + + } + /* * get default pc,tc,dc,mc,other fees * created by kms @@ -803,6 +888,7 @@ class Fees_status_model extends CI_Model } + $CourseFeesArray1[]=$fetchData; } @@ -948,31 +1034,92 @@ class Fees_status_model extends CI_Model * insert day book master while fees update * created by kms * */ - public function insertDayBookMaster($data=null){ - $insertArray['Date'] = $data['BillDate']; - $insertArray['CreatedBy'] = $data['CreatedBy']; - $insertArray['CreatedOn'] = $data['CreatedOn']; - $insertArray['Description'] = $data['InternalComments']; - $insertArray['Amount'] = $data['BillAmount']; - $insertArray['Status'] = 'Approved'; + public function insertDayBookMaster($data=null,$paymentID){ + if($data['ModeOfPayment']=='CASH'){ + $insertArray['Date'] = $data['BillDate']; + $insertArray['CreatedBy'] = $data['CreatedBy']; + $insertArray['CreatedOn'] = $data['CreatedOn']; + $insertArray['Description'] = $data['InternalComments']; + $insertArray['Amount'] = $data['BillAmount']; + $insertArray['Status'] = 'Approved'; + $insertArray['PaymentStatus'] = false; + $insertArray['FeesPaymentID'] = $paymentID; - $insertArray['BranchCode'] = $data['UpdatedBy']; + $insertArray['BranchCode'] = $data['UpdatedBy']; - $this->db->select('ID,TypeID'); - $this->db->where('TypeID', 'I002'); - $this->db->where('TypeName', 'FEES'); - $getIncome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row(); + $this->db->select('ID,TypeID'); + $this->db->where('TypeID', 'I002'); + $this->db->where('TypeName', 'FEES'); + $getIncome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row(); + + if($getIncome){ + $insertArray['Name'] = $getIncome->TypeID; + $insertArray['Type'] = $getIncome->ID; + $this->db->insert(DAYBOOKMASTER, $insertArray); + return true; + } + else{ + return true; + } - if($getIncome){ - $insertArray['Name'] = $getIncome->TypeID; - $insertArray['Type'] = $getIncome->ID; - $this->db->insert(DAYBOOKMASTER, $insertArray); - return true; } else{ + // this is for income entry + $insertArray['Date'] = $data['BillDate']; + $insertArray['CreatedBy'] = $data['CreatedBy']; + $insertArray['CreatedOn'] = $data['CreatedOn']; + $insertArray['Description'] = $data['InternalComments']; + $insertArray['Amount'] = $data['BillAmount']; + $insertArray['Status'] = 'Approved'; + $insertArray['PaymentStatus'] = false; + $insertArray['FeesPaymentID'] = $paymentID; + + $insertArray['BranchCode'] = $data['UpdatedBy']; + + $this->db->select('ID,TypeID'); + $this->db->where('TypeID', 'I002'); + $this->db->where('TypeName', 'FEES'); + $getIncome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row(); + + if($getIncome){ + $insertArray['Name'] = $getIncome->TypeID; + $insertArray['Type'] = $getIncome->ID; + $this->db->insert(DAYBOOKMASTER, $insertArray); + + } + + + // this is for expense come entry + + $expenseArray['Date'] = $data['BillDate']; + $expenseArray['CreatedBy'] = $data['CreatedBy']; + $expenseArray['CreatedOn'] = $data['CreatedOn']; + $expenseArray['Description'] = $data['InternalComments']; + $expenseArray['Amount'] = $data['BillAmount']; + $expenseArray['Status'] = 'Approved'; + $expenseArray['PaymentStatus'] = false; + $expenseArray['FeesPaymentID'] = $paymentID; + + $expenseArray['BranchCode'] = $data['UpdatedBy']; + + $this->db->select('ID,TypeID'); + $this->db->where('TypeID', 'I001'); + $this->db->where('TypeName', 'FEES'); + $getOutcome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row(); + + if($getOutcome){ + $expenseArray['Name'] = $getOutcome->TypeID; + $expenseArray['Type'] = $getOutcome->ID; + $this->db->insert(DAYBOOKMASTER, $expenseArray); + + } + + return true; + } + } /* * send notification for student diff --git a/Apollo/assets/js/controllers/feesStatusCtrl.js b/Apollo/assets/js/controllers/feesStatusCtrl.js index ad3cc579..b89c7669 100755 --- a/Apollo/assets/js/controllers/feesStatusCtrl.js +++ b/Apollo/assets/js/controllers/feesStatusCtrl.js @@ -3,7 +3,7 @@ * controllers for ng-table * Simple table with sorting and filtering on AngularJS */ -app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state) { +app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", "installmentService", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,installmentService) { $scope.myModel = { "studentName": "", "mobileNumber": "", @@ -11,6 +11,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n "courseName":"" }; + $rootScope.userType = JSON.parse(localStorage.getItem('localObj')).localType; /* * updateModel default value @@ -28,32 +29,49 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }; + + /* * set model * */ $scope.setModel = { "feesType": "", - - }; + /* * get payment options * */ - $scope.paymentOptions = [ - { - "paymentOn":"CASH" - }, - { - "paymentOn":"CHEQUE" - }, - { - "paymentOn":"NEFT" - }, - { - "paymentOn":"CASH DEPOSIT" - } - ]; + if(JSON.parse(localStorage.getItem('localObj')).localType=='R002' && JSON.parse(localStorage.getItem('localObj')).is_DayBookApproval_Access==0){ + $scope.paymentOptions = [ + { + "paymentOn":"CASH" + }, + + ]; + } + else{ + $scope.paymentOptions = [ + { + "paymentOn":"CASH" + }, + { + "paymentOn":"CHEQUE" + }, + { + "paymentOn":"REFERRAL" + }, + { + "paymentOn":"ONLINE TRANSACTION" + }, + { + "paymentOn":"WAIVER" + }, + + ]; + + } + // sorting function for table params $scope.sort = function(keyname){ $scope.sortKey = keyname; //set the sortKey to the param passed @@ -163,6 +181,8 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n * */ $scope.viewId=-1; $scope.setFees = function (p) { + $scope.BatchDate =''; + $scope.editId=-1; $scope.getStudentSetFees(p.ID,p.CourseID,p.StudentID); $scope.viewId=p.ID; @@ -277,9 +297,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n /* * set fees for student * */ - $scope.submitFeesForStudent = function (myModel, form,updateModel, loading,installment) { - - + $scope.submitFeesForStudent = function (myModel, form,updateModel, loading) { var firstError = null; if (form.$invalid) { var field = null, firstError = null; @@ -296,15 +314,15 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } angular.element('.ng-invalid[name=' + firstError + ']').focus(); } else { - if(isNaN(installment.date)){ + /* if(isNaN(installment.date)){ $scope.pushDueDate1= $rootScope.lastInstallemtDate; } else{ $scope.convertGetDate1=new Date(installment.date).toDateString(); $scope.pushDueDate1 = $filter('date')(new Date($scope.convertGetDate1), 'dd-MM-yyyy'); - } - if(installment.ID !='' && installment.ID !==null && installment.ID !=undefined){ + }*/ + /* if(installment.ID !='' && installment.ID !==null && installment.ID !=undefined){ $rootScope.updateMoreItems.push({ ID: installment.ID, Name: installment.name, @@ -319,7 +337,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n Amount: installment.amount, DueDate: $scope.pushDueDate1 }); - } + }*/ angular.forEach($rootScope.updateMoreItems, function (value, key) { if(isNaN(value.DueDate)){ @@ -332,7 +350,6 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $rootScope.updateMoreItems[key].DueDate=$scope.pushDueDate2; } }); - $scope.ldloading5 = {}; $scope.ldloading5[loading.replace('-', '_')] = true; @@ -355,7 +372,8 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n session: updateModel.SessionName, rollNo: updateModel.RollNo, createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID, - installmentItems:$rootScope.updateMoreItems + installmentItems:$rootScope.updateMoreItems, + batchCode:updateModel.BatchCode, } }; @@ -441,7 +459,10 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n * get student set fees details * */ $scope.feesStructureInfo=""; + $scope.BatchDetails=[]; $scope.getStudentSetFees = function (ID,courseID,studeID) { + $scope.BatchDetails=[]; + $scope.feesStructureInfo=""; $scope.myModelInstallemt.ID=""; $scope.myModelInstallemt.name=""; @@ -464,30 +485,56 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }; $http(setFees).then(function (response) { if (response.data.status==200 && response.data.feesStatus) { + $scope.feesStructureInfo=response.data.feesDetails; $scope.setModel = { "feesType": $scope.feesStructureInfo[0], - }; - $scope.setTotalAmount=$scope.feesStructureInfo[0].PayableFees; + angular.forEach($scope.feesStructureInfo[0].batchDetails,function (values,key) { + $scope.BatchDetails.push({ + "BatchCode":values.BatchCode, + "BatchName":values.BatchName + '-'+ values.BatchCode, + "BatchDate":values.BatchDate + }) + }); + $scope.setTotalAmount=$scope.feesStructureInfo[0].PayableFees; $rootScope.updateMoreItems=[]; - if($scope.feesStructureInfo[0].InstallmentDetails != ''){ - $scope.myModelInstallemt.ID=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].ID; + if($scope.feesStructureInfo[0].InstallmentDetails == '') { + $scope.setModel.feesType.BatchCode = $scope.feesStructureInfo[0].batchDetails[0].BatchCode; + $scope.BatchDate = new Date($scope.feesStructureInfo[0].batchDetails[0].BatchDate.substring(6,10)+'-'+$scope.feesStructureInfo[0].batchDetails[0].BatchDate.substring(3,5)+'-'+$scope.feesStructureInfo[0].batchDetails[0].BatchDate.substring(0,2)); + + $scope.calculateInstallemnts($scope.feesStructureInfo[0],$scope.setTotalAmount,0,'1'); + + + } + + + else { + + + /* $scope.myModelInstallemt.ID=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].ID; $scope.myModelInstallemt.name=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].Name; $scope.myModelInstallemt.amount=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].Amount; $scope.myModelInstallemt.date=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].DueDate; - $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date; - for(var i=0; i < $scope.feesStructureInfo[0].InstallmentDetails.length-1; i++){ + $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date;*/ + for(var i=0; i < $scope.feesStructureInfo[0].InstallmentDetails.length; i++){ $rootScope.updateMoreItems.push($scope.feesStructureInfo[0].InstallmentDetails[i]); + $scope.getDateArray.push({ + + "Date":new Date($scope.feesStructureInfo[0].InstallmentDetails[i].DueDate.substring(6,10)+'-'+$scope.feesStructureInfo[0].InstallmentDetails[i].DueDate.substring(3,5)+'-'+$scope.feesStructureInfo[0].InstallmentDetails[i].DueDate.substring(0,2)) + }); + + + } + $scope.setModel.feesType.BatchCode = $scope.feesStructureInfo[0].BatchCode; + } - - - + $scope.dateValidations(); } else { $scope.feesStructureInfo=""; $scope.setModel = { @@ -500,6 +547,15 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } + /* + * change batch details + * createdcby kms + * */ + $scope.changeBatch = function (Details) { + $scope.setFeesTotalAmount(Details,'2','2'); + + } + $scope.cancel = function () { $scope.editId=-1; @@ -523,7 +579,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }; $rootScope.updateMoreItems=[]; - $rootScope.clickMoreItems = function (model,form,setModel) { + $rootScope.clickMoreItems = function (form,setModel) { $scope.convertGetDate=''; var firstError = null; if (form.$invalid) { @@ -544,19 +600,29 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } else { - if(isNaN(model.date)){ - $scope.pushDueDate= $rootScope.lastInstallemtDate; + if(isNaN($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate)){ + $scope.pushDueDate= $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate; } else{ - $scope.convertGetDate=new Date(model.date).toDateString(); + $scope.convertGetDate=new Date($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate).toDateString(); $scope.pushDueDate = $filter('date')(new Date($scope.convertGetDate), 'dd-MM-yyyy'); } - if(model.ID !='' && model.ID !==null && model.ID !=undefined){ + var MoreInsAmt= Math.round($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount * 50 / 100); + var afterMoreInsAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount)-parseInt(MoreInsAmt); + $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = MoreInsAmt; + $rootScope.updateMoreItems.push({ + ID:"", + Name: installmentService.installmentWords($rootScope.updateMoreItems.length+1), + Amount: MoreInsAmt, + DueDate: $scope.pushDueDate + }); + + /*if(model.ID !='' && model.ID !==null && model.ID !=undefined){ $rootScope.updateMoreItems.push({ ID:model.ID, Name: model.name, - Amount: model.amount, + Amount: MoreInsAmt, DueDate: $scope.pushDueDate }); } @@ -564,81 +630,620 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $rootScope.updateMoreItems.push({ ID:"", Name: model.name, - Amount: model.amount, + Amount: MoreInsAmt, DueDate: $scope.pushDueDate }); - } + }*/ - $scope.myModelInstallemt.ID=""; - $scope.myModelInstallemt.name=""; - $scope.myModelInstallemt.amount=""; - $scope.myModelInstallemt.date=""; + /* $scope.myModelInstallemt.ID=""; + $scope.myModelInstallemt.name=installmentService.installmentWords($rootScope.updateMoreItems.length+1); + $scope.myModelInstallemt.amount=parseInt(afterMoreInsAmt); + $scope.myModelInstallemt.date=$scope.pushDueDate;*/ + $scope.dateValidations(); } + } /* * change installment values * */ $scope.changeInstallemt = function (model,form) { + + if(model.Sem_Year!='TC' && model.Sem_Year!='PC' && model.Sem_Year!='DC' && model.Sem_Year!='MC' && model.Sem_Year!='OTHER'){ + $scope.BatchDetails=[]; $rootScope.updateMoreItems=[]; + angular.forEach(model.batchDetails,function (values,key) { + $scope.BatchDetails.push({ + "BatchCode":values.BatchCode, + "BatchName":values.BatchName + '-'+ values.BatchCode, + "BatchDate":values.BatchDate + }) + }); - if(model.InstallmentDetails != ''){ - $scope.myModelInstallemt.ID=model.InstallmentDetails[model.InstallmentDetails.length-1].ID; + if(model.InstallmentDetails != ''){ + /*$scope.myModelInstallemt.ID=model.InstallmentDetails[model.InstallmentDetails.length-1].ID; - $scope.myModelInstallemt.name=model.InstallmentDetails[model.InstallmentDetails.length-1].Name; - $scope.myModelInstallemt.amount=model.InstallmentDetails[model.InstallmentDetails.length-1].Amount; - $scope.myModelInstallemt.date=model.InstallmentDetails[model.InstallmentDetails.length-1].DueDate; - $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date; - for(var i=0; i < model.InstallmentDetails.length-1; i++){ - $rootScope.updateMoreItems.push(model.InstallmentDetails[i]); + $scope.myModelInstallemt.name=model.InstallmentDetails[model.InstallmentDetails.length-1].Name; + $scope.myModelInstallemt.amount=model.InstallmentDetails[model.InstallmentDetails.length-1].Amount; + $scope.myModelInstallemt.date=model.InstallmentDetails[model.InstallmentDetails.length-1].DueDate; + $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date;*/ + for(var i=0; i < model.InstallmentDetails.length; i++){ + $rootScope.updateMoreItems.push(model.InstallmentDetails[i]); + + } + $scope.setModel.feesType.BatchCode = model.BatchCode; + angular.forEach($rootScope.updateMoreItems,function (values,key) { + if(values.DueDate.length>10 || values.DueDate.length==undefined){ + $rootScope.updateMoreItems[key].DueDate = $filter('date')(values.DueDate,'dd-MM-yyyy'); + + } + }); } - } - else{ - $scope.myModelInstallemt.ID=""; - $scope.myModelInstallemt.name=""; - $scope.myModelInstallemt.amount=""; - $scope.myModelInstallemt.date=""; - $rootScope.lastInstallemtDate=""; - } - $scope.setFeesTotalAmount(model); + else{ + $scope.setModel.feesType.BatchCode = $scope.BatchDetails[0].BatchCode; + $scope.BatchDate = new Date($scope.BatchDetails[0].BatchDate.substring(6,10)+'-'+$scope.BatchDetails[0].BatchDate.substring(3,5)+'-'+$scope.BatchDetails[0].BatchDate.substring(0,2)); + + /* $scope.myModelInstallemt.ID=""; + $scope.myModelInstallemt.name=""; + $scope.myModelInstallemt.amount=""; + $scope.myModelInstallemt.date=""; + $rootScope.lastInstallemtDate="";*/ + $rootScope.updateMoreItems=[]; + } + $scope.setFeesTotalAmount(model,'1','2'); + } + else{ + $scope.setFeesTotalAmount(model,'3','1'); + + } form.$setPristine(true); + } $scope.setTotalAmount=''; /* * get set fees total amount * */ - $scope.setFeesTotalAmount = function (values) { - if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ - $scope.actFees=0; - } - else{ - $scope.actFees=values.ActualFees; - } - if(values.Others=='' || values.Others==null || values.Others==undefined){ - $scope.othersFees=0; - } - else{ - $scope.othersFees=values.Others; - } - if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ - $scope.stfFees=0; - } - else{ - $scope.stfFees=values.STFOrWR; - } - if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ - $scope.wiverFees=0; - } - else{ - $scope.wiverFees=values.Waiver; + $scope.setFeesTotalAmount = function (values,type,type1) { + + if(type==3 || values.Sem_Year=='TC' || values.Sem_Year=='PC' || values.Sem_Year=='DC' || values.Sem_Year=='MC' || values.Sem_Year=='OTHER'){ + if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ + $scope.actFees=0; + } + else{ + $scope.actFees=values.ActualFees; + } + if(values.Others=='' || values.Others==null || values.Others==undefined){ + $scope.othersFees=0; + } + else{ + $scope.othersFees=values.Others; + } + if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ + $scope.stfFees=0; + } + else{ + $scope.stfFees=values.STFOrWR; + } + if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ + $scope.wiverFees=0; + } + else{ + $scope.wiverFees=values.Waiver; + } + + $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); + $scope.setModel.feesType.BatchCode = "Nill"; + $rootScope.updateMoreItems=[]; + } - $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); - + else{ + angular.forEach(values.batchDetails,function (values1,key) { + if(values1.BatchCode==values.BatchCode){ + $scope.BatchDate = new Date(values1.BatchDate.substring(6,10)+'-'+values1.BatchDate.substring(3,5)+'-'+values1.BatchDate.substring(0,2)); + + } + + }); + + + if(type=='1'){ + if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ + $scope.actFees=0; + } + else{ + $scope.actFees=values.ActualFees; + } + if(values.Others=='' || values.Others==null || values.Others==undefined){ + $scope.othersFees=0; + } + else{ + $scope.othersFees=values.Others; + } + if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ + $scope.stfFees=0; + } + else{ + $scope.stfFees=values.STFOrWR; + } + if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ + $scope.wiverFees=0; + } + else{ + $scope.wiverFees=values.Waiver; + } + + $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); + + if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length==0){ + $scope.calculateInstallemnts(values,$scope.setTotalAmount,$scope.othersFees,type); + } + else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + + } + else{ + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + + } + } + + + else{ + + if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ + $scope.actFees=0; + } + else{ + $scope.actFees=values.ActualFees; + } + if(values.Others=='' || values.Others==null || values.Others==undefined){ + $scope.othersFees=0; + } + else{ + $scope.othersFees=values.Others; + } + if(values.STFOrWR=='' || values.STFOrWR==null || values.STFOrWR==undefined){ + $scope.stfFees=0; + } + else{ + $scope.stfFees=values.STFOrWR; + } + if(values.Waiver=='' || values.Waiver==null || values.Waiver==undefined){ + $scope.wiverFees=0; + } + else{ + $scope.wiverFees=values.Waiver; + } + + $scope.setTotalAmount= parseInt($scope.actFees) + parseInt($scope.stfFees) + parseInt($scope.othersFees) - parseInt($scope.wiverFees); + if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length==0){ + $scope.calculateInstallemnts(values,$scope.setTotalAmount,$scope.othersFees,type); + } + else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + + } + else{ + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + + } + + } + } + + + + + + } + + /* + * calculate installments + * created by kms + * */ + $scope.calculateInstallemnts =function (model,totAmt,other,type) { + + // $scope.setTotalAmount=totAmt; + $rootScope.updateMoreItems=[]; + + + var cDate = moment(); + var bDate = moment($scope.BatchDate); + + var startPayableAmt = parseInt(totAmt); + for (var i = 1; i <= 2; i++) { + if (i == 1) { + if (cDate <= bDate) { + + + var percentage = Math.round(startPayableAmt * 70 / 100); + percentage = Math.round(percentage / 10) * 10; + startPayableAmt = startPayableAmt - percentage; + $scope.insFirstDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); + + + var dayDiff2 = moment(bDate).diff(cDate, 'days'); + if (dayDiff2 > 30) { + $scope.insSecondDate = moment($scope.BatchDate).subtract(30, 'days'); + $scope.insSecondDate = $filter('date')(new Date($scope.insSecondDate), 'dd-MM-yyyy'); + } + else if (dayDiff2 > 15 && dayDiff2 <= 30) { + $scope.insSecondDate = moment($scope.BatchDate).subtract(15, 'days'); + $scope.insSecondDate = $filter('date')(new Date($scope.insSecondDate), 'dd-MM-yyyy'); + + } + else { + $scope.insSecondDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); + + } + + } + else { + var dayDiff = moment().diff(bDate, 'days'); + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt2 = 0; + var fineAmt3 = 0; + var fineAmt4 = 0; + var fineAmt5 = 0; + var fineAmt6 = 0; + var fineAmt7 = 0; + var fineAmt8 = 0; + var fineAmt9 = 0; + var fineAmt10 = 0; + var fineAmt11 = 0; + for (var k = 1; k <= dayDiff; k++) { + + if (k <= 90) { + + if (startPayableAmt <= 10000) { + fineAmt1 = 300; + } + + else if ((startPayableAmt > 10000) && (startPayableAmt <= 20000)) { + fineAmt1 = 600; + } + else if (startPayableAmt > 30000) { + fineAmt1 = 900; + } + + } + else if (k > 90) { + if (k > 90 && k <= 120) { + fineAmt2 = 300; + + } + else if (k > 120 && k <= 150) { + fineAmt3 = 300; + + } + else if (k > 150 && k <= 180) { + fineAmt4 = 300; + + } + else if (k > 180 && k <= 210) { + fineAmt5 = 300; + + } + else if (k > 210 && k <= 240) { + fineAmt6 = 300; + + } + else if (k > 240 && k <= 270) { + fineAmt7 = 300; + + } + else if (k > 270 && k <= 300) { + fineAmt8 = 300; + + } + else if (k > 300 && k <= 330) { + fineAmt9 = 300; + + } + else if (k > 330 && k <= 360) { + fineAmt10 = 300; + + } + + else { + fineAmt11 = 300; + } + + + } + + } + todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); + if(type=='1'){ + $scope.setTotalAmount = Math.round(parseInt(totAmt) + parseInt(todatlFineAmt)-parseInt(other)); + $scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt)); + } + else{ + $scope.setTotalAmount = Math.round(parseInt(totAmt)); + if(other==0){ + $scope.setModel.feesType.Others = ''; + } + else{ + $scope.setModel.feesType.Others = Math.round(parseInt(other)); + } + + } + + startPayableAmt = parseInt($scope.setTotalAmount); + var percentage = Math.round(startPayableAmt * 70 / 100); + percentage = Math.round(percentage / 10) * 10; + startPayableAmt = startPayableAmt - percentage; + + $scope.insFirstDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); + $scope.insSecondDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); + + } + + $scope.updateMoreItems.push({ + ID: "", + Name: installmentService.installmentWords(i), + Amount: percentage, + DueDate: $scope.insFirstDate + }); + + } + else { + + + startPayableAmt = Math.round(startPayableAmt / 10) * 10; + $scope.updateMoreItems.push({ + ID: "", + Name: installmentService.installmentWords(i), + Amount: startPayableAmt, + DueDate: $scope.insSecondDate + }); + /* $scope.myModelInstallemt.ID = ""; + $scope.myModelInstallemt.name = installmentService.installmentWords(i); + $scope.myModelInstallemt.amount = startPayableAmt; + $scope.myModelInstallemt.date = $scope.insSecondDate; + $rootScope.lastInstallemtDate = $scope.myModelInstallemt.date;*/ + + } + + } + + $scope.dateValidations(); + + + + } + + + /* + * calculate exist installment + * created by kms + * */ + $scope.calculateInstallemntsExist = function (model,totAmt,other,type,type1) { + + + var exBatchDate = moment($scope.BatchDate); + + if(type==2 || type==1){ + if($rootScope.updateMoreItems.length>0){ + var exDatenew1; + var exDatenew2; + var exitPayAmt=parseInt(totAmt-other); + if(isNaN(moment($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate))){ + exDatenew1 = new Date($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate.substring(0,2)); + exDatenew1 = moment(exDatenew1); + + } + else{ + exDatenew1 = moment($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate); + } + + if (exDatenew1 <= exBatchDate) { + + if(type=='1'){ + $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); + // $scope.setModel.feesType.Others = Math.round(parseInt(other)); + $scope.setModel.feesType.Others = ''; + + } + else{ + + if(other==0){ + $scope.setModel.feesType.Others = ''; + $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); + } + else{ + $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); + $scope.setModel.feesType.Others = ''; + } + + } + var existPercentage = Math.round($scope.setTotalAmount * 70 / 100); + existPercentage = Math.round(existPercentage / 10) * 10; + exitPayAmt = parseInt($scope.setTotalAmount)-parseInt(existPercentage); + $rootScope.updateMoreItems[0].Amount = existPercentage; + $rootScope.updateMoreItems[1].Amount = exitPayAmt; + + if($rootScope.updateMoreItems.length>2){ + angular.forEach($rootScope.updateMoreItems,function (values,key) { + if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ + var currentElementAmt = $rootScope.updateMoreItems[key].Amount; + var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); + var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); + $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; + $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; + } + + }); + + } + + + } + else if(exDatenew1 > exBatchDate){ + + var dayDiff = exDatenew1.diff(exBatchDate, 'days'); + dayDiff = dayDiff+1; + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt2 = 0; + var fineAmt3 = 0; + var fineAmt4 = 0; + var fineAmt5 = 0; + var fineAmt6 = 0; + var fineAmt7 = 0; + var fineAmt8 = 0; + var fineAmt9 = 0; + var fineAmt10 = 0; + var fineAmt11 = 0; + for (var k = 1; k <= dayDiff; k++) { + + if (k <= 90) { + + if (exitPayAmt <= 10000) { + fineAmt1 = 300; + } + + else if ((exitPayAmt > 10000) && (exitPayAmt <= 20000)) { + fineAmt1 = 600; + } + else if (exitPayAmt > 30000) { + fineAmt1 = 900; + } + + } + else if (k > 90) { + if (k > 90 && k <= 120) { + fineAmt2 = 300; + + } + else if (k > 120 && k <= 150) { + fineAmt3 = 300; + + } + else if (k > 150 && k <= 180) { + fineAmt4 = 300; + + } + else if (k > 180 && k <= 210) { + fineAmt5 = 300; + + } + else if (k > 210 && k <= 240) { + fineAmt6 = 300; + + } + else if (k > 240 && k <= 270) { + fineAmt7 = 300; + + } + else if (k > 270 && k <= 300) { + fineAmt8 = 300; + + } + else if (k > 300 && k <= 330) { + fineAmt9 = 300; + + } + else if (k > 330 && k <= 360) { + fineAmt10 = 300; + + } + + else { + fineAmt11 = 300; + } + + + } + + } + todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); + if(type1=='2'){ + $scope.setTotalAmount = Math.round(parseInt(totAmt) -parseInt(other) + parseInt(todatlFineAmt)); + $scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt)); + } + else{ + $scope.setTotalAmount = Math.round(parseInt(totAmt)); + if(other==0){ + + $scope.setModel.feesType.Others = ''; + } + else{ + $scope.setModel.feesType.Others = Math.round(parseInt(other)); + } + + } + + exitPayAmt = parseInt($scope.setTotalAmount); + var existPercentage = Math.round(exitPayAmt * 70 / 100); + existPercentage = Math.round(existPercentage / 10) * 10; + exitPayAmt = parseInt(exitPayAmt)-parseInt(existPercentage); + $rootScope.updateMoreItems[0].Amount = existPercentage; + $rootScope.updateMoreItems[1].Amount = exitPayAmt; + + if($rootScope.updateMoreItems.length>2){ + angular.forEach($rootScope.updateMoreItems,function (values,key) { + if(key>=1 && $rootScope.updateMoreItems.length-1!=key){ + var currentElementAmt = $rootScope.updateMoreItems[key].Amount; + var dividePrevElementAmt = Math.round(currentElementAmt * 50 / 100); + var divideNextElementAmt = parseInt(currentElementAmt)-parseInt(dividePrevElementAmt); + $rootScope.updateMoreItems[key].Amount = dividePrevElementAmt; + $rootScope.updateMoreItems[key+1].Amount = dividePrevElementAmt; + } + + }); + + } + } + + } + } + + + $scope.dateValidations(); + + } + $scope.getDateArray = []; + /* + * validate installment date + * */ + $scope.dateValidations = function () { + $scope.getDateArray = []; + + $scope.getDateArray=[ + { + "Date":'' + } + ]; + + angular.forEach($rootScope.updateMoreItems,function (values,key) { + if(values.DueDate.length==10){ + $scope.getDateArray.push({ + + "Date":new Date(values.DueDate.substring(6,10)+'-'+values.DueDate.substring(3,5)+'-'+values.DueDate.substring(0,2)) + }) + } + else{ + $scope.getDateArray.push({ + + "Date":values.DueDate + }) + } + + }); + + $scope.getDateArray.push({ + + "Date":'' + }) + + } diff --git a/Apollo/assets/views/status-update/setFeesForStudent.html b/Apollo/assets/views/status-update/setFeesForStudent.html index aa4f9e46..77f20498 100755 --- a/Apollo/assets/views/status-update/setFeesForStudent.html +++ b/Apollo/assets/views/status-update/setFeesForStudent.html @@ -30,6 +30,36 @@ Fees type is required +