From d7aea5d25d2b836fdd8fe601003609339effdffe Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 9 Mar 2018 13:09:52 +0530 Subject: [PATCH] course details changes done --- .../assets/js/controllers/feesStatusCtrl.js | 1299 ++++++++++++----- 1 file changed, 917 insertions(+), 382 deletions(-) diff --git a/Apollo/assets/js/controllers/feesStatusCtrl.js b/Apollo/assets/js/controllers/feesStatusCtrl.js index 78fb3383..e88b50bc 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", "installmentService", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,installmentService) { +app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", "installmentService", "SweetAlert", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,installmentService,SweetAlert) { $scope.myModel = { "studentName": "", "mobileNumber": "", @@ -31,6 +31,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n + /* * set model * */ @@ -67,6 +68,9 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n { "paymentOn":"WAIVER" }, + { + "paymentOn":"Credit/Debit Card" + } ]; @@ -161,51 +165,52 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }); } - } + } - /* - * get update fees details for student - * created by kms - * */ + /* + * get update fees details for student + * created by kms + * */ $scope.editId=-1; - $scope.updateFees = function (p) { - $scope.viewId=-1 - $scope.getStudentFeesStructure(p.ID,p.CourseID,p.StudentID); - $scope.editId=p.ID; + $scope.updateFees = function (p) { + $scope.viewId=-1 + $scope.getStudentFeesStructure(p.ID,p.CourseID,p.StudentID); + $scope.editId=p.ID; - } + } - /* - * set fees for student - * */ - $scope.viewId=-1; - $scope.setFees = function (p) { - $scope.BatchDate =''; + /* + * set fees for student + * */ + $scope.viewId=-1; + $scope.setFees = function (p) { + $scope.BatchDate =''; - $scope.editId=-1; - $scope.getStudentSetFees(p.ID,p.CourseID,p.StudentID); - $scope.viewId=p.ID; + $scope.editId=-1; + $scope.getStudentSetFees(p.ID,p.CourseID,p.StudentID); + $scope.viewId=p.ID; - } + } - /* - * update total fees amount after change value - * created by kms - * */ - $scope.changeTotalFees = function (model) { - $scope.updateModel.billAmount = model.BalanceAmount; + /* + * update total fees amount after change value + * created by kms + * */ + $scope.changeTotalFees = function (model) { + $scope.updateModel.billAmount = model.BalanceAmount; + $scope.updateModel.date = $filter('date')(new Date(), 'dd-MM-yyyy'); - } + } - /* - * change session details - * created by kms - * */ - $scope.changeSessions = function (details) { - if(details.SessionName!=undefined && details.SessionName!=''){ + /* + * change session details + * created by kms + * */ + $scope.changeSessions = function (details) { + if(details.SessionName!=undefined && details.SessionName!=''){ $scope.sessionDetails=[]; $scope.sessionDetailsTo=[]; $scope.setModel.feesType.ToSessionName=""; @@ -250,18 +255,18 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } else{ - angular.forEach($scope.masterSessionDetails,function (svalues,skey) { + angular.forEach($scope.masterSessionDetails,function (svalues,skey) { - if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ - $scope.sessionDetails.push({ - "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', - "SessionID":svalues.SessionID, - }); + if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ + $scope.sessionDetails.push({ + "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', + "SessionID":svalues.SessionID, + }); - } + } - }); + }); } @@ -294,91 +299,91 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }); } - } - else{ + } + else{ - if(details.ProgramType=='Y001' && details.SNo!='1'){ - $scope.sessionDetails=[]; - $scope.sessionDetailsTo=[]; - $scope.setModel.feesType.ToSessionName=""; + if(details.ProgramType=='Y001' && details.SNo!='1'){ + $scope.sessionDetails=[]; + $scope.sessionDetailsTo=[]; + $scope.setModel.feesType.ToSessionName=""; - if($scope.feesStructureInfo[0].SessionName!=''){ - // get session details - var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[0].SessionName); - $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); - - angular.forEach($scope.masterSessionDetails,function (svalues,skey) { - - if((svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID) && $scope.ExistSessionDate <= new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ - $scope.sessionDetails.push({ - "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', - "SessionID":svalues.SessionID, - }); - - } - - - }); - } - else{ - - angular.forEach($scope.masterSessionDetails,function (svalues,skey) { - - if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ - $scope.sessionDetails.push({ - "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', - "SessionID":svalues.SessionID, - }); - - } - - - }); - - } - - - - } - else{ + if($scope.feesStructureInfo[0].SessionName!=''){ // get session details - var found = $filter('getById')($scope.masterSessionDetails, details.SessionName); + var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[0].SessionName); $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); angular.forEach($scope.masterSessionDetails,function (svalues,skey) { - if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ + if((svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID) && $scope.ExistSessionDate <= new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', "SessionID":svalues.SessionID, }); - if($scope.ExistSessionDate <= new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ - - - $scope.sessionDetailsTo.push({ - "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', - "SessionID":svalues.SessionID, - }); - } } }); } + else{ + + angular.forEach($scope.masterSessionDetails,function (svalues,skey) { + + if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID){ + $scope.sessionDetails.push({ + "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', + "SessionID":svalues.SessionID, + }); + + } + + + }); + + } + + } + else{ + // get session details + var found = $filter('getById')($scope.masterSessionDetails, details.SessionName); + $scope.ExistSessionDate = new Date(found.SessionDate.substring(6,10)+'-'+found.SessionDate.substring(3,5)+'-'+found.SessionDate.substring(0,2)); + + angular.forEach($scope.masterSessionDetails,function (svalues,skey) { + + if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ + $scope.sessionDetails.push({ + "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', + "SessionID":svalues.SessionID, + }); + + if($scope.ExistSessionDate <= new Date(svalues.SessionDate.substring(6,10)+'-'+svalues.SessionDate.substring(3,5)+'-'+svalues.SessionDate.substring(0,2))){ + $scope.sessionDetailsTo.push({ + "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', + "SessionID":svalues.SessionID, + }); + } + } + + + }); + } } - /* - * save fees details for student - * created by kms - * */ + } + + + + /* + * save fees details for student + * created by kms + * */ $scope.saveFees = function (myModel, form,updateModel, loading) { if(isNaN(updateModel.date)){ $scope.billDate = updateModel.date; @@ -488,70 +493,78 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n angular.element('.ng-invalid[name=' + firstError + ']').focus(); } else { - /* if(isNaN(installment.date)){ - $scope.pushDueDate1= $rootScope.lastInstallemtDate; + /* 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){ + $rootScope.updateMoreItems.push({ + ID: installment.ID, + Name: installment.name, + Amount: installment.amount, + DueDate: $scope.pushDueDate1 + }); + } + else{ + $rootScope.updateMoreItems.push({ + ID: "", + Name: installment.name, + Amount: installment.amount, + DueDate: $scope.pushDueDate1 + }); + }*/ + + if(updateModel.Sem_Year!='TC' && updateModel.Sem_Year!='PC' && updateModel.Sem_Year!='DC' && updateModel.Sem_Year!='MC' && updateModel.Sem_Year!='OTHER'){ + var checkTotamt=0; + + angular.forEach($rootScope.updateMoreItems, function (value, key) { + checkTotamt=parseInt(checkTotamt)+parseInt(value.Amount); + + if(isNaN(value.DueDate)){ + $scope.correctDate=''; + } + else{ + + $scope.convertGetDate2=new Date(value.DueDate).toDateString(); + $scope.pushDueDate2 = $filter('date')(new Date($scope.convertGetDate2), 'dd-MM-yyyy'); + $rootScope.updateMoreItems[key].DueDate=$scope.pushDueDate2; + } + }); + if(parseInt($scope.setTotalAmount)checkTotamt){ + var statusUpdate=false; + swal("Please check total/installment amount "); + } + else if(parseInt($scope.setTotalAmount)==checkTotamt){ + var statusUpdate=true; + + } } else{ - $scope.convertGetDate1=new Date(installment.date).toDateString(); - $scope.pushDueDate1 = $filter('date')(new Date($scope.convertGetDate1), 'dd-MM-yyyy'); + if(updateModel.Valid=='1'){ + var statusUpdate=true; + } + else{ + var statusUpdate=false; + swal("", "Course fees are not paid so unable to set course fees", "warning"); + + } - }*/ - /* if(installment.ID !='' && installment.ID !==null && installment.ID !=undefined){ - $rootScope.updateMoreItems.push({ - ID: installment.ID, - Name: installment.name, - Amount: installment.amount, - DueDate: $scope.pushDueDate1 - }); } - else{ - $rootScope.updateMoreItems.push({ - ID: "", - Name: installment.name, - Amount: installment.amount, - DueDate: $scope.pushDueDate1 - }); - }*/ - - if(updateModel.Sem_Year!='TC' && updateModel.Sem_Year!='PC' && updateModel.Sem_Year!='DC' && updateModel.Sem_Year!='MC' && updateModel.Sem_Year!='OTHER'){ - var checkTotamt=0; - - angular.forEach($rootScope.updateMoreItems, function (value, key) { - checkTotamt=parseInt(checkTotamt)+parseInt(value.Amount); - - if(isNaN(value.DueDate)){ - $scope.correctDate=''; - } - else{ - - $scope.convertGetDate2=new Date(value.DueDate).toDateString(); - $scope.pushDueDate2 = $filter('date')(new Date($scope.convertGetDate2), 'dd-MM-yyyy'); - $rootScope.updateMoreItems[key].DueDate=$scope.pushDueDate2; - } - }); - if(parseInt($scope.setTotalAmount)checkTotamt){ - var statusUpdate=false; - swal("Please check total/installment amount "); - } - else if(parseInt($scope.setTotalAmount)==checkTotamt){ - var statusUpdate=true; - - } - } - else{ - var statusUpdate=true; - } if(statusUpdate==true){ $scope.setSessionTo=""; - if(updateModel.ProgramType=='P001' || updateModel.ProgramType=='P002'){ - $scope.setSessionTo=updateModel.ToSessionName; - } + if(updateModel.ProgramType=='P001' || updateModel.ProgramType=='P002'){ + $scope.setSessionTo=updateModel.ToSessionName; + } $scope.ldloading5 = {}; @@ -646,8 +659,12 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $scope.updateModel = { "feesType": $scope.studentFeesInfo[0], + "billAmount":$scope.studentFeesInfo[0].BalanceAmount, + "date":$filter('date')(new Date(), 'dd-MM-yyyy') }; + /* $scope.billCurrentDate=$filter('date')(new Date(), 'dd-MM-yyyy'); + alert($scope.billCurrentDate);*/ } else { @@ -735,22 +752,22 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } - else { + else { - /* $scope.myModelInstallemt.ID=$scope.feesStructureInfo[0].InstallmentDetails[$scope.feesStructureInfo[0].InstallmentDetails.length-1].ID; + /* $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;*/ + $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; i++){ $rootScope.updateMoreItems.push($scope.feesStructureInfo[0].InstallmentDetails[i]); - $scope.getDateArray.push({ + $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)) - }); + "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)) + }); @@ -763,7 +780,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n angular.forEach($scope.masterSessionDetails,function (svalues,skey) { - if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ + if(svalues.IsActive=='1' || $scope.feesStructureInfo[0].SessionName==svalues.SessionID || $scope.feesStructureInfo[0].ToSessionName==svalues.SessionID){ $scope.sessionDetails.push({ "SessionName":svalues.SessionName +'('+svalues.SessionDate+')', "SessionID":svalues.SessionID, @@ -785,10 +802,9 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $scope.setModel.feesType.SessionName=$scope.feesStructureInfo[0].SessionName; $scope.setModel.feesType.SessionNameTo=$scope.feesStructureInfo[0].ToSessionName; - + $scope.dateValidations(); } - $scope.dateValidations(); } else { $scope.feesStructureInfo=""; $scope.setModel = { @@ -807,16 +823,16 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n * */ $scope.changeBatch = function (Details) { - if(Details.InstallmentDetails != ''){ - $scope.setFeesTotalAmount(Details,'2','2'); - } - else{ - $rootScope.updateMoreItems=[]; - $scope.setModel.feesType.Others = ''; + if(Details.InstallmentDetails != ''){ + $scope.setFeesTotalAmount(Details,'2','2','1'); + } + else{ + $rootScope.updateMoreItems=[]; + $scope.setModel.feesType.Others = ''; - $scope.setFeesTotalAmount(Details,'1','1'); + $scope.setFeesTotalAmount(Details,'1','1','1'); - } + } } @@ -901,10 +917,10 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }*/ - /* $scope.myModelInstallemt.ID=""; - $scope.myModelInstallemt.name=installmentService.installmentWords($rootScope.updateMoreItems.length+1); - $scope.myModelInstallemt.amount=parseInt(afterMoreInsAmt); - $scope.myModelInstallemt.date=$scope.pushDueDate;*/ + /* $scope.myModelInstallemt.ID=""; + $scope.myModelInstallemt.name=installmentService.installmentWords($rootScope.updateMoreItems.length+1); + $scope.myModelInstallemt.amount=parseInt(afterMoreInsAmt); + $scope.myModelInstallemt.date=$scope.pushDueDate;*/ $scope.dateValidations(); } @@ -955,10 +971,10 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $rootScope.lastInstallemtDate="";*/ $rootScope.updateMoreItems=[]; } - $scope.setFeesTotalAmount(model,'1','2'); + $scope.setFeesTotalAmount(model,'1','2','1'); } else{ - $scope.setFeesTotalAmount(model,'3','1'); + $scope.setFeesTotalAmount(model,'3','1','1'); } @@ -970,9 +986,14 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n /* * get set fees total amount * */ - $scope.setFeesTotalAmount = function (values,type,type1) { + $scope.setFeesTotalAmount = function (values,type,type1,checkPermission) { 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.Valid=='0'){ + swal("", "Course fees are not paid so unable to set course fees", "warning"); + + } if(values.ActualFees=='' || values.ActualFees==null || values.ActualFees==undefined){ $scope.actFees=0; } @@ -1047,11 +1068,11 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $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); + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission); } else{ - $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission); } } @@ -1089,11 +1110,11 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $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); + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission); } else{ - $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1); + $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission); } @@ -1112,136 +1133,404 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n * */ $scope.calculateInstallemnts =function (model,totAmt,other,type) { - // $scope.setTotalAmount=totAmt; + // $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 cDate = moment(); + var bDate = moment($scope.BatchDate); + var startPayableAmt = parseInt(totAmt); - 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'); + if(cDate > bDate && moment(cDate).diff(bDate, 'days')>30){ + SweetAlert.swal({ + title: "", + text: "The selected installment date is crossing the maximum allowed period. Do you want to continue (Yes/No). If yes you need to get approval from the higher authorities", + type: "info", + showCancelButton: true, + confirmButtonColor: "#eea236", confirmButtonText: "Yes", + cancelButtonText: "No", + closeOnConfirm: true, + closeOnCancel: true + }, + function (isConfirm) { + if (isConfirm) { + for (var i = 1; i <= 2; i++) { + if (i == 1) { + /* if (cDate <= bDate) { - 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'); + 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'); - } - else { - $scope.insSecondDate = $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 { - var dayDiff = moment().diff(bDate, 'days'); - var todatlFineAmt = 0; - var fineAmt1 = 0; - var fineAmt11 = 0; - var countDays = 0; - for (var k = 1; k <= dayDiff; k++) { + } + else { + $scope.insSecondDate = $filter('date')(new Date(cDate), 'dd-MM-yyyy'); - if (k <= 90) { - - if (startPayableAmt <= 10000) { - fineAmt1 = 300; - } - - else if ((startPayableAmt > 10000) && (startPayableAmt <= 20000)) { - fineAmt1 = 600; - } - else if (startPayableAmt > 20000) { - fineAmt1 = 900; - } - - } - else { - countDays = countDays+1; - - if (countDays<30) { - if(countDays==1){ - fineAmt11 = parseInt(fineAmt11)+300; } } - else{ - countDays=0; + else {*/ + var dayDiff = moment().diff(bDate, 'days'); + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt11 = 0; + var countDays = 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 > 20000) { + fineAmt1 = 900; + } + + } + else { + countDays = countDays+1; + + if (countDays<30) { + if(countDays==1){ + fineAmt11 = parseInt(fineAmt11)+300; + } + + } + else{ + countDays=0; + + } + } + + } + // todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); + todatlFineAmt = parseInt(fineAmt1) + 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(); + } + else { + 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 tempCurrentDate = moment(bDate).add(30, 'days'); + $scope.insSecondDate = moment($scope.BatchDate).subtract(30, 'days'); + var dayDiff = moment(tempCurrentDate).diff(bDate, 'days'); + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt11 = 0; + var countDays = 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 > 20000) { + fineAmt1 = 900; + } + + } + else { + countDays = countDays+1; + + if (countDays<30) { + if(countDays==1){ + fineAmt11 = parseInt(fineAmt11)+300; + } + + } + else{ + countDays=0; + + } + } + + } + // todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); + todatlFineAmt = parseInt(fineAmt1) + 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(tempCurrentDate), 'dd-MM-yyyy'); + $scope.insSecondDate = $filter('date')(new Date(tempCurrentDate), '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;*/ + } } - // todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); - todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11); + $scope.dateValidations(); - 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)); - } + } + } + ); + } - } + else{ + for (var i = 1; i <= 2; i++) { + if (i == 1) { + if (cDate <= bDate) { - 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'); + 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'); } - $scope.updateMoreItems.push({ - ID: "", - Name: installmentService.installmentWords(i), - Amount: percentage, - DueDate: $scope.insFirstDate - }); - } else { + var dayDiff = moment().diff(bDate, 'days'); + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt11 = 0; + var countDays = 0; + for (var k = 1; k <= dayDiff; k++) { + if (k <= 90) { - 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;*/ + if (startPayableAmt <= 10000) { + fineAmt1 = 300; + } + + else if ((startPayableAmt > 10000) && (startPayableAmt <= 20000)) { + fineAmt1 = 600; + } + else if (startPayableAmt > 20000) { + fineAmt1 = 900; + } + + } + else { + countDays = countDays+1; + + if (countDays<30) { + if(countDays==1){ + fineAmt11 = parseInt(fineAmt11)+300; + } + + } + else{ + countDays=0; + + } + } + + } + // todatlFineAmt = parseInt(fineAmt1) + parseInt(fineAmt2) + parseInt(fineAmt3) + parseInt(fineAmt4) + parseInt(fineAmt5) + parseInt(fineAmt6) + parseInt(fineAmt7) + parseInt(fineAmt8) + parseInt(fineAmt9) + parseInt(fineAmt10) + parseInt(fineAmt11); + todatlFineAmt = parseInt(fineAmt1) + 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(); + } + $scope.dateValidations(); + + } + + @@ -1252,63 +1541,62 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n * calculate exist installment * created by kms * */ - $scope.calculateInstallemntsExist = function (model,totAmt,other,type,type1) { + $scope.calculateInstallemntsExist = function (model,totAmt,other,type,type1,checkPermission) { var exBatchDate = moment($scope.BatchDate); - if(type==2 || type==1){ + if(type==2 || type==1){ if($rootScope.updateMoreItems.length>0){ var existLoop=0; var existTotAmt=0 - angular.forEach($rootScope.updateMoreItems,function (item,position) { - var exDatenew1; - var exDatenew2; - var exitPayAmt=parseInt(totAmt-other); - /* if(isNaN(moment($rootScope.updateMoreItems[position].DueDate))){ - exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); - exDatenew1 = moment(exDatenew1); + angular.forEach($rootScope.updateMoreItems,function (item,position) { + var exDatenew1; + var exDatenew2; + var exitPayAmt=parseInt(totAmt-other); + /* if(isNaN(moment($rootScope.updateMoreItems[position].DueDate))){ + exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); + exDatenew1 = moment(exDatenew1); - }*/ - if($rootScope.updateMoreItems[position].DueDate.length<=10){ - exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); - exDatenew1 = moment(exDatenew1); + }*/ + if($rootScope.updateMoreItems[position].DueDate.length<=10){ + exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); + exDatenew1 = moment(exDatenew1); + } + else{ + exDatenew1 = moment($rootScope.updateMoreItems[position].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{ - exDatenew1 = moment($rootScope.updateMoreItems[position].DueDate); - } - - if (exDatenew1 <= exBatchDate) { - - if(type=='1'){ - $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); - // $scope.setModel.feesType.Others = Math.round(parseInt(other)); + if(other==0){ $scope.setModel.feesType.Others = ''; - + $scope.setTotalAmount = Math.round(parseInt(totAmt)-parseInt(other)); } 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 = ''; - } - + $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); - if(position==0){ + } - $rootScope.updateMoreItems[position].Amount = existPercentage; + var existPercentage = Math.round($scope.setTotalAmount * 70 / 100); + existPercentage = Math.round(existPercentage / 10) * 10; + exitPayAmt = parseInt($scope.setTotalAmount)-parseInt(existPercentage); + if(position==0){ + + $rootScope.updateMoreItems[position].Amount = existPercentage; + + } + else if(position==1){ + $rootScope.updateMoreItems[position].Amount = exitPayAmt; + } - } - else if(position==1){ - $rootScope.updateMoreItems[position].Amount = exitPayAmt; - } @@ -1328,14 +1616,14 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n existTotAmt = parseInt(existTotAmt)+parseInt($rootScope.updateMoreItems[position].Amount); - } + } - else if(exDatenew1 > exBatchDate && existLoop==0){ + else if(exDatenew1 > exBatchDate && existLoop==0){ - exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); + exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); - var dayDiff = exDatenew1.diff(exBatchDate, 'days'); - dayDiff = dayDiff+1; + var dayDiff = exDatenew1.diff(exBatchDate, 'days'); + dayDiff = dayDiff+1; var todatlFineAmt = 0; var fineAmt1 = 0; var fineAmt11 = 0; @@ -1392,66 +1680,312 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } - if($rootScope.updateMoreItems[position-1]!=undefined){ + if($rootScope.updateMoreItems[position-1]!=undefined){ - existLoop=1; - 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; + existLoop=1; + 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; - } + 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{ - existLoop=1; - 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; + } + else{ + existLoop=1; + 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; - } + 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; + } - }); + }); - } + } - } + } + } + }); + + + if(checkPermission=='1'){ + + + + // check batch date for confirmation + angular.forEach($rootScope.updateMoreItems,function (list,keyV) { + var inDate; + var inBatchDate=moment(exBatchDate).add('30','days') + if(list.DueDate.length<=10){ + inDate = new Date(list.DueDate.substring(6,10)+'-'+list.DueDate.substring(3,5)+'-'+list.DueDate.substring(0,2)); + inDate = moment(inDate); + } + else{ + inDate = moment(list.DueDate).add('1','days'); + } + if(exBatchDate30){ + SweetAlert.swal({ + title: "", + text: "The selected installment date is crossing the maximum allowed period. Do you want to continue (Yes/No). If yes you need to get approval from the higher authorities", + type: "info", + showCancelButton: true, + confirmButtonColor: "#eea236",confirmButtonText: "Yes", + cancelButtonText: "No", + closeOnConfirm: true, + closeOnCancel: true }, + function(isConfirm) { + if (isConfirm==false) { + + angular.forEach($rootScope.updateMoreItems,function (updateV,updateK) { + $rootScope.updateMoreItems[updateK].DueDate=$filter('date')(new Date(inBatchDate), 'dd-MM-yyyy'); + + }); + + $scope.rollBackFeesDetails(model,totAmt,other,type,type1); + } + + }) + + + } + }); + } + + } + } + + $scope.dateValidations(); + } + + /* + * this function used to roll back the details if no + * */ + /* + * calculate exist installment + * created by kms + * */ + $scope.rollBackFeesDetails = function (model,totAmt,other,type,type1) { + var exBatchDate = moment($scope.BatchDate); + if(type==2 || type==1){ + if($rootScope.updateMoreItems.length>0){ + var existLoop=0; + var existTotAmt=0 + angular.forEach($rootScope.updateMoreItems,function (item,position) { + var exDatenew1; + var exitPayAmt=parseInt(totAmt-other); + /* if(isNaN(moment($rootScope.updateMoreItems[position].DueDate))){ + exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); + exDatenew1 = moment(exDatenew1); + + }*/ + if($rootScope.updateMoreItems[position].DueDate.length<=10){ + exDatenew1 = new Date($rootScope.updateMoreItems[position].DueDate.substring(6,10)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(3,5)+'-'+$rootScope.updateMoreItems[position].DueDate.substring(0,2)); + exDatenew1 = moment(exDatenew1); + + } + else{ + + exDatenew1 = moment($rootScope.updateMoreItems[position].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); + if(position==0){ + + $rootScope.updateMoreItems[position].Amount = existPercentage; + + } + else if(position==1){ + $rootScope.updateMoreItems[position].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; + } + + }); + + } + existTotAmt = parseInt(existTotAmt)+parseInt($rootScope.updateMoreItems[position].Amount); + + + } + + else if(exDatenew1 > exBatchDate && existLoop==0){ + + + exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt); + + var dayDiff = exDatenew1.diff(exBatchDate, 'days'); + dayDiff = dayDiff+1; + + var todatlFineAmt = 0; + var fineAmt1 = 0; + var fineAmt11 = 0; + var countDays = 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 > 20000) { + fineAmt1 = 900; + } + + } + else { + countDays = countDays+1; + + if (countDays<30) { + if(countDays==1){ + fineAmt11 = parseInt(fineAmt11)+300; + } + + } + else{ + countDays=0; + + } + } } - }); + todatlFineAmt = parseInt(fineAmt1) + 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)); + } + + } + + if($rootScope.updateMoreItems[position-1]!=undefined){ + + existLoop=1; + 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; + } + + }); + + } + + } + else{ + existLoop=1; + 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(); } @@ -1488,6 +2022,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n "Date":'' }) + return true; } @@ -1523,14 +2058,14 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $scope.changeInstallemtAmt = function (old,present,index) { if($rootScope.updateMoreItems[index+1]!=undefined){ - var currentValue=present; - var pastValue=old; - if(currentValue==undefined || currentValue==''){ - var currentValue=0; - } - if(pastValue==undefined || pastValue==''){ - pastValue=0; - } + var currentValue=present; + var pastValue=old; + if(currentValue==undefined || currentValue==''){ + var currentValue=0; + } + if(pastValue==undefined || pastValue==''){ + pastValue=0; + } if(parseInt(currentValue)<=parseInt($scope.setTotalAmount)){ if(currentValue<=pastValue){ @@ -1576,8 +2111,8 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n }]); - /*modal controller - * */ +/*modal controller +* */ app.controller('ModalDemoCtrl', ["$scope", "$modal", "$log", function ($scope, $modal, $log) { //Tooltip for print button $scope.dynamicTooltip = 'Click to View Bill Details';