course details changes done

This commit is contained in:
gandhimathi 2018-02-22 17:45:32 +05:30
parent 93e191b336
commit b1c9f03929

View File

@ -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,619 @@ 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');
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":''
})
}