From d561f6dd2ccef2172cb88fd3f1d318de9ae78df4 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 13 Jun 2018 11:35:03 +0530 Subject: [PATCH] course fees edit changes in fees status --- .../assets/js/controllers/feesStatusCtrl.js | 79 +++++++++++++++---- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/Apollo/assets/js/controllers/feesStatusCtrl.js b/Apollo/assets/js/controllers/feesStatusCtrl.js index b964c820..e44dd0c8 100755 --- a/Apollo/assets/js/controllers/feesStatusCtrl.js +++ b/Apollo/assets/js/controllers/feesStatusCtrl.js @@ -957,17 +957,17 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n if(Details.InstallmentDetails != ''){ - $scope.setFeesTotalAmount(Details,'2',Details); + $scope.setFeesTotalAmount(Details,'2',Details,'1'); } else{ /*$scope.$watch('setModel.feesType.BatchCode', function(newValue, oldValue) { if(newValue!=oldValue){ $rootScope.updateMoreItems=[]; - $scope.setFeesTotalAmount(Details,'1',Details); + $scope.setFeesTotalAmount(Details,'1',Details,'1'); } });*/ - $scope.setFeesTotalAmount(Details,'1',Details); + $scope.setFeesTotalAmount(Details,'1',Details,'1'); } @@ -1134,10 +1134,10 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n $rootScope.lastInstallemtDate="";*/ $rootScope.updateMoreItems=[]; } - $scope.setFeesTotalAmount(model,'1',model); + $scope.setFeesTotalAmount(model,'1',model,'1'); } else{ - $scope.setFeesTotalAmount(model,'3',model); + $scope.setFeesTotalAmount(model,'3',model,'1'); } @@ -1149,7 +1149,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n /* * get set fees total amount * */ - $scope.setFeesTotalAmount = function (values,type,beforeValues) { + $scope.setFeesTotalAmount = function (values,type,beforeValues,from) { 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'){ @@ -1189,6 +1189,12 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } else{ + if($scope.setTotalAmount=='' || $scope.setTotalAmount==null || $scope.setTotalAmount==0){ + $scope.beforeSetTotalAmount=0; + } + else{ + $scope.beforeSetTotalAmount=$scope.setTotalAmount; + } 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)); @@ -1225,16 +1231,25 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } $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); } else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ - $scope.calculateDueAmount(values,beforeValues); + if(from=='1'){ + $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); + } + else{ + $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); + } } else{ - $scope.calculateDueAmount(values,beforeValues); + if(from=='1'){ + $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); + } + else{ + $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); + } } } @@ -1266,17 +1281,26 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n 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); } else if(values.InstallmentDetails=='' && $rootScope.updateMoreItems.length<=2){ - $scope.calculateDueAmount(values,beforeValues); + if(from=='1'){ + $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); + } + else{ + $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); + } } else{ - $scope.calculateDueAmount(values,beforeValues); + if(from=='1'){ + $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); + } + else{ + $scope.calculateDueAmount($scope.beforeSetTotalAmount,$scope.setTotalAmount); + } } @@ -1840,7 +1864,7 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n } } - $scope.calculateDueAmount(values,values); + $scope.calculateDueAmount($scope.setTotalAmount,$scope.setTotalAmount); } @@ -1851,8 +1875,31 @@ app.controller('feesStatusCtrl', ["$scope","$rootScope","toaster", "$filter", "n /*while changing installment date/amount calculate fine amount * created by kms * */ - $scope.calculateDueAmount = function (values,beforeValues) { - if(values.ActualFees=='' || values.ActualFees==undefined){ + $scope.calculateDueAmount = function (beforeTot,afterTot) { + if(parseInt(beforeTot)0){ + if(parseInt($scope.finalTotAmt)>0){ + $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) + parseInt($scope.finalTotAmt); + + } + else{ + if(parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount)