2820 lines
112 KiB
JavaScript
Executable File
2820 lines
112 KiB
JavaScript
Executable File
'use strict';
|
|
/**
|
|
* 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", "SweetAlert", function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,installmentService,SweetAlert) {
|
|
$scope.myModel = {
|
|
"studentName": "",
|
|
"mobileNumber": "",
|
|
"universityName":"",
|
|
"courseName":""
|
|
};
|
|
// bill date restrict
|
|
$scope.futureDate=new Date();
|
|
// end
|
|
$rootScope.userType = JSON.parse(localStorage.getItem('localObj')).localType;
|
|
/*
|
|
* updateModel default value
|
|
* */
|
|
|
|
$scope.updateModel = {
|
|
"feesType": "",
|
|
"date": "",
|
|
"billNo": "",
|
|
"billAmount": "",
|
|
"paymentOn": "",
|
|
"internalComments":"",
|
|
"studComments":"",
|
|
"statusCode":""
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
* set model
|
|
* */
|
|
$scope.setModel = {
|
|
"feesType": "",
|
|
};
|
|
|
|
/*
|
|
* get payment options
|
|
* */
|
|
|
|
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"
|
|
},
|
|
{
|
|
"paymentOn":"Credit/Debit Card"
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
// sorting function for table params
|
|
$scope.sort = function(keyname){
|
|
$scope.sortKey = keyname; //set the sortKey to the param passed
|
|
$scope.reverse = !$scope.reverse; //if true make it false and vice versa
|
|
}
|
|
|
|
/*
|
|
* init function
|
|
* created by kms
|
|
* */
|
|
$scope.init = function () {
|
|
var getUniv = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getUniversityCourseForFees/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getUniv).then(function (response) {
|
|
if (response.data.status==200 && response.data.universityStatus) {
|
|
$scope.university=response.data.univerSityDetails;
|
|
|
|
|
|
} else {
|
|
$scope.university="";
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
/*
|
|
* get student details
|
|
* created by kms
|
|
* */
|
|
$scope.studentInfo="";
|
|
$scope.getStudentDetails = function (form,myModel) {
|
|
if(myModel.universityName == null || myModel.universityName == '' || myModel.universityName == undefined){
|
|
$scope.univId = "";
|
|
}
|
|
else{
|
|
$scope.univId = myModel.universityName.universityID;
|
|
}
|
|
var firstError = null;
|
|
if (form.$invalid) {
|
|
|
|
var field = null, firstError = null;
|
|
for (field in form) {
|
|
if (field[0] != '$') {
|
|
if (firstError === null && !form[field].$valid) {
|
|
firstError = form[field].$name;
|
|
}
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
|
|
} else {
|
|
var getStudent = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentListFees/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studentName: myModel.studentName,
|
|
mobileNumber: myModel.mobileNumber,
|
|
university: $scope.univId,
|
|
course:myModel.courseName,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
branchId: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
requestedDept: JSON.parse(localStorage.getItem('localObj')).localType,
|
|
}
|
|
};
|
|
$http(getStudent).then(function (response) {
|
|
if (response.data.status==200 && response.data.studentStatus) {
|
|
$scope.studentInfo=response.data.details;
|
|
|
|
} else {
|
|
$scope.studentInfo="";
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 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;
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* 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;
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* 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,type) {
|
|
if(details.SessionName!=undefined && details.SessionName!=''){
|
|
$scope.sessionDetails=[];
|
|
$scope.sessionDetailsTo=[];
|
|
if(type==1){
|
|
$scope.setModel.feesType.ToSessionName="";
|
|
}
|
|
else{
|
|
$scope.setModel.feesType.ToSessionName=details.ToSessionName;
|
|
}
|
|
|
|
if(details.ProgramType=='Y001' && details.SNo=='1'){
|
|
// 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.sessionDetails.push({
|
|
"SessionName":svalues.SessionName +'('+svalues.SessionDate+')',
|
|
"SessionID":svalues.SessionID,
|
|
});
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
}
|
|
else if(details.ProgramType=='Y001' && details.SNo!='1'){
|
|
|
|
if($scope.feesStructureInfo[0].SessionName!=''){
|
|
// get session details
|
|
var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[details.SNo-2].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{
|
|
// 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,
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
}
|
|
}
|
|
else{
|
|
|
|
if(details.ProgramType=='Y001' && details.SNo!='1'){
|
|
|
|
$scope.sessionDetails=[];
|
|
$scope.sessionDetailsTo=[];
|
|
if(type==1){
|
|
$scope.setModel.feesType.ToSessionName="";
|
|
}
|
|
else{
|
|
$scope.setModel.feesType.ToSessionName=details.ToSessionName;
|
|
}
|
|
|
|
if($scope.feesStructureInfo[0].SessionName!=''){
|
|
// get session details
|
|
var found = $filter('getById')($scope.masterSessionDetails, $scope.feesStructureInfo[details.SNo-2].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(details.SessionName=='' || details.SessionName==null || details.SessionName==undefined){
|
|
angular.forEach($scope.masterSessionDetails,function (svalues,skey) {
|
|
|
|
if(svalues.IsActive=='1' ){
|
|
$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
|
|
* */
|
|
$scope.saveFees = function (myModel, form,updateModel, loading) {
|
|
if(isNaN(updateModel.date)){
|
|
$scope.billDate = updateModel.date;
|
|
|
|
}
|
|
else{
|
|
$scope.getdate=new Date(updateModel.date).toDateString();
|
|
|
|
$scope.billDate = $filter('date')(new Date($scope.getdate), 'dd-MM-yyyy');
|
|
}
|
|
var firstError = null;
|
|
if (form.$invalid) {
|
|
var field = null, firstError = null;
|
|
for (field in form) {
|
|
if (field[0] != '$') {
|
|
if (firstError === null && !form[field].$valid) {
|
|
firstError = form[field].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
} else {
|
|
$scope.ldloading = {};
|
|
|
|
$scope.ldloading[loading.replace('-', '_')] = true;
|
|
|
|
|
|
var updateFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateFeesDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studID: myModel.StudentID,
|
|
courseID:myModel.CourseID,
|
|
courseAmount:updateModel.feesType.ActualFees,
|
|
feesID: updateModel.feesType.FeesID,
|
|
feesName: updateModel.feesType.Sem_Year,
|
|
billNO: updateModel.billNo,
|
|
billDate: $scope.billDate,
|
|
billAmount:updateModel.billAmount,
|
|
modeOfPayment: updateModel.paymentOn.paymentOn,
|
|
commentsForStudent: updateModel.studComments,
|
|
internalComments: updateModel.internalComments,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
mobileNumber: myModel.MobileNumber,
|
|
studentName: myModel.Firstname,
|
|
university: myModel.UniversityName,
|
|
course: myModel.CourseName,
|
|
//statusCode: updateModel.statusCode,
|
|
requestedBranch : JSON.parse(localStorage.getItem('localObj')).localBranchID
|
|
|
|
|
|
}
|
|
};
|
|
$http(updateFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.paidStatus) {
|
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
|
swal("Success!", "Updated successfully.", "success");
|
|
/*$scope.updateModel = {
|
|
"feesType": "",
|
|
"date": "",
|
|
"billNo": "",
|
|
"billAmount": "",
|
|
"paymentOn": "",
|
|
"internalComments":"",
|
|
"studComments":"",
|
|
"statusCode":""
|
|
|
|
};*/
|
|
form.$setPristine(true);
|
|
$scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
|
|
|
|
|
|
} else {
|
|
$scope.ldloading[loading.replace('-', '_')] = false;
|
|
swal("Failed!", response.data.message, "error");
|
|
//$scope.getStudentFeesStructure(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
}
|
|
|
|
});
|
|
}
|
|
};
|
|
/*
|
|
* set fees for student
|
|
* */
|
|
$scope.submitFeesForStudent = function (myModel, form,updateModel, loading) {
|
|
var firstError = null;
|
|
if (form.$invalid) {
|
|
var field = null, firstError = null;
|
|
for (field in form) {
|
|
if (field[0] != '$') {
|
|
if (firstError === null && !form[field].$valid) {
|
|
firstError = form[field].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
swal("", "Please check session details/installment details", "warning");
|
|
} else {
|
|
|
|
/* 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=false;
|
|
swal("Please check total/installment amount ");
|
|
}
|
|
else if(parseInt($scope.setTotalAmount)==checkTotamt){
|
|
var statusUpdate=true;
|
|
|
|
}
|
|
}
|
|
else{
|
|
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(statusUpdate==true){
|
|
$scope.setSessionTo="";
|
|
|
|
if(updateModel.ProgramType=='P001' || updateModel.ProgramType=='P002'){
|
|
$scope.setSessionTo=updateModel.ToSessionName;
|
|
}
|
|
|
|
|
|
$scope.ldloading5 = {};
|
|
|
|
$scope.ldloading5[loading.replace('-', '_')] = true;
|
|
|
|
|
|
var updateFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'setFeesForStudent/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
studID: myModel.StudentID,
|
|
courseID:myModel.CourseID,
|
|
courseAmount:updateModel.ActualFees,
|
|
feesID: updateModel.ID,
|
|
STFWR:updateModel.STFOrWR,
|
|
waiver: updateModel.Waiver,
|
|
other: updateModel.Others,
|
|
session: updateModel.SessionName,
|
|
sessionTo: $scope.setSessionTo,
|
|
rollNo: updateModel.RollNo,
|
|
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID,
|
|
installmentItems:$rootScope.updateMoreItems,
|
|
batchCode:updateModel.BatchCode,
|
|
|
|
}
|
|
};
|
|
$http(updateFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.setStatus) {
|
|
$scope.ldloading5[loading.replace('-', '_')] = false;
|
|
swal("Success!", "Fees set successfully.", "success");
|
|
|
|
$scope.getStudentSetFees(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
/*$scope.setModel = {
|
|
"feesType": "",
|
|
};*/
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
$rootScope.updateMoreItems=[];
|
|
$scope.setTotalAmount='';
|
|
form.$setPristine(true);
|
|
|
|
} else {
|
|
$scope.ldloading5[loading.replace('-', '_')] = false;
|
|
swal("Failed!", response.data.message, "error");
|
|
$rootScope.updateMoreItems.splice($scope.updateMoreItems.length-1);
|
|
// $scope.getStudentSetFees(myModel.ID,myModel.CourseID,myModel.StudentID);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
};
|
|
/*
|
|
* Global method for get student fees structure
|
|
* created by kms
|
|
* */
|
|
$scope.studentFeesInfo="";
|
|
$scope.getStudentFeesStructure = function(ID,courseID,studeID){
|
|
$scope.updateModel = {
|
|
"feesType": "",
|
|
|
|
};
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
var getFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentFeesStructure/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
ID:ID,
|
|
courseID: courseID,
|
|
studentID: studeID,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(getFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.feesStatus) {
|
|
$scope.studentFeesInfo=response.data.feesDetails;
|
|
$scope.existStudentFeesDetails = response.data.getExistStudentFeesDetails;
|
|
$scope.getFeesUpdateStatus = response.data.getFeesUpdateStatus;
|
|
|
|
$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 {
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
swal("Warning!", response.data.message, "warning");
|
|
$scope.editId=-1;
|
|
|
|
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
/*
|
|
* get student set fees details
|
|
* */
|
|
$scope.feesStructureInfo="";
|
|
$scope.BatchDetails=[];
|
|
$scope.masterSessionDetails="";
|
|
$scope.sessionDetails=[];
|
|
$scope.getStudentSetFees = function (ID,courseID,studeID) {
|
|
$scope.BatchDetails=[];
|
|
$scope.sessionDetails=[];
|
|
$scope.sessionDetailsTo=[];
|
|
$scope.feesStructureInfo="";
|
|
$scope.myModelInstallemt.ID="";
|
|
$scope.myModelInstallemt.name="";
|
|
$scope.myModelInstallemt.amount="";
|
|
$scope.myModelInstallemt.date="";
|
|
$rootScope.lastInstallemtDate="";
|
|
$rootScope.updateMoreItems=[];
|
|
var setFees = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentFeesAssign/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
ID:ID,
|
|
courseID: courseID,
|
|
studentID: studeID,
|
|
requestedtBy: JSON.parse(localStorage.getItem('localObj')).localUserID
|
|
}
|
|
};
|
|
$http(setFees).then(function (response) {
|
|
if (response.data.status==200 && response.data.feesStatus) {
|
|
|
|
$scope.masterSessionDetails = response.data.sessionDetails;
|
|
|
|
$scope.feesStructureInfo=response.data.feesDetails;
|
|
$scope.setModel = {
|
|
"feesType": $scope.feesStructureInfo[0],
|
|
};
|
|
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.obj = $scope.feesStructureInfo[0].batchDetails.find(x => x.IsDefault == true);
|
|
if($scope.obj==undefined || $scope.obj=='' || $scope.obj==null){
|
|
$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));
|
|
|
|
}
|
|
else{
|
|
|
|
$scope.setModel.feesType.BatchCode = $scope.obj.BatchCode;
|
|
$scope.BatchDate = new Date($scope.obj.BatchDate.substring(6,10)+'-'+$scope.obj.BatchDate.substring(3,5)+'-'+$scope.obj.BatchDate.substring(0,2));
|
|
|
|
|
|
}
|
|
|
|
$scope.calculateInstallemnts($scope.feesStructureInfo[0],$scope.setTotalAmount,0,'1');
|
|
|
|
// get session details
|
|
angular.forEach($scope.masterSessionDetails,function (svalues,skey) {
|
|
if(svalues.IsActive=='1'){
|
|
$scope.sessionDetails.push({
|
|
"SessionName":svalues.SessionName +'('+svalues.SessionDate+')',
|
|
"SessionID":svalues.SessionID,
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
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; 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.ExistSessionDate="";
|
|
// 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.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,
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$scope.setModel.feesType.SessionName=$scope.feesStructureInfo[0].SessionName;
|
|
$scope.setModel.feesType.ToSessionName=$scope.feesStructureInfo[0].ToSessionName;
|
|
$scope.dateValidations();
|
|
|
|
}
|
|
} else {
|
|
$scope.feesStructureInfo="";
|
|
$scope.setModel = {
|
|
"feesType": "",
|
|
};
|
|
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
/*
|
|
* change batch details
|
|
* createdcby kms
|
|
* */
|
|
$scope.changeBatch = function (Details) {
|
|
|
|
if(Details.InstallmentDetails != ''){
|
|
$scope.setFeesTotalAmount(Details,'2','2','1',Details.STFOrWR);
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems=[];
|
|
$scope.setModel.feesType.Others = '';
|
|
|
|
$scope.setFeesTotalAmount(Details,'1','1','1',Details.STFOrWR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$scope.cancel = function () {
|
|
$scope.editId=-1;
|
|
$scope.studentFeesInfo="";
|
|
$scope.existStudentFeesDetails="";
|
|
$scope.getFeesUpdateStatus="";
|
|
|
|
$scope.viewId=-1;
|
|
}
|
|
/*
|
|
* get add more installment array
|
|
* created by kms
|
|
* */
|
|
|
|
$scope.myModelInstallemt = {
|
|
"ID":"",
|
|
"amount":"",
|
|
"name":"",
|
|
"date":"",
|
|
|
|
|
|
};
|
|
$rootScope.updateMoreItems=[];
|
|
$rootScope.clickMoreItems = function (form,setModel) {
|
|
$scope.convertGetDate='';
|
|
var firstError = null;
|
|
if (form.$invalid) {
|
|
var field = null, firstError = null;
|
|
for (field in form) {
|
|
if (field[0] != '$') {
|
|
if (firstError === null && !form[field].$valid) {
|
|
firstError = form[field].$stop_name;
|
|
}
|
|
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
swal("", "Please check session details/installment details", "warning");
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
if(isNaN($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate)){
|
|
$scope.pushDueDate= $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate;
|
|
}
|
|
else{
|
|
$scope.convertGetDate=new Date($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].DueDate).toDateString();
|
|
$scope.pushDueDate = $filter('date')(new Date($scope.convertGetDate), 'dd-MM-yyyy');
|
|
|
|
}
|
|
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: MoreInsAmt,
|
|
DueDate: $scope.pushDueDate
|
|
});
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems.push({
|
|
ID:"",
|
|
Name: model.name,
|
|
Amount: MoreInsAmt,
|
|
DueDate: $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();
|
|
}
|
|
|
|
}
|
|
/*
|
|
* 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;
|
|
|
|
$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;
|
|
/*$scope.setModel.feesType.SessionName=model.SessionName;
|
|
$scope.setModel.feesType.ToSessionName=model.ToSessionName;*/
|
|
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.obj = model.batchDetails.find(x => x.IsDefault == true);
|
|
if($scope.obj==undefined || $scope.obj=='' || $scope.obj==null){
|
|
$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));
|
|
|
|
}
|
|
else{
|
|
|
|
|
|
$scope.setModel.feesType.BatchCode = $scope.obj.BatchCode;
|
|
$scope.BatchDate = new Date($scope.obj.BatchDate.substring(6,10)+'-'+$scope.obj.BatchDate.substring(3,5)+'-'+$scope.obj.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','1',model.STFOrWR);
|
|
}
|
|
else{
|
|
$scope.setFeesTotalAmount(model,'3','1','1',model.STFOrWR);
|
|
|
|
}
|
|
|
|
// form.$setPristine(true);
|
|
|
|
|
|
}
|
|
$scope.setTotalAmount='';
|
|
/*
|
|
* get set fees total amount
|
|
* */
|
|
$scope.setFeesTotalAmount = function (values,type,type1,checkPermission,beforeSTF) {
|
|
|
|
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;
|
|
}
|
|
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 = "Not applicable";
|
|
$scope.setModel.feesType.SessionName = "Not applicable";
|
|
$rootScope.updateMoreItems=[];
|
|
|
|
}
|
|
|
|
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,checkPermission);
|
|
$scope.calculateDueAmount(values,$scope.setTotalAmount,$scope.othersFees,$scope.stfFees,'2',beforeSTF);
|
|
|
|
}
|
|
else{
|
|
// $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission);
|
|
$scope.calculateDueAmount(values,$scope.setTotalAmount,$scope.othersFees,$scope.stfFees,'2',beforeSTF);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
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,checkPermission);
|
|
$scope.calculateDueAmount(values,$scope.setTotalAmount,$scope.othersFees,$scope.stfFees,'2',beforeSTF);
|
|
|
|
}
|
|
else{
|
|
// $scope.calculateInstallemntsExist(values,$scope.setTotalAmount,$scope.othersFees,type,type1,checkPermission);
|
|
$scope.calculateDueAmount(values,$scope.setTotalAmount,$scope.othersFees,$scope.stfFees,'2',beforeSTF);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* 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);
|
|
|
|
|
|
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 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 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;*/
|
|
|
|
}
|
|
|
|
}
|
|
$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 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
* calculate exist installment
|
|
* created by kms
|
|
* */
|
|
$scope.calculateInstallemntsExist = function (model,totAmt,other,type,type1,checkPermission) {
|
|
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 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);
|
|
}
|
|
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;
|
|
}
|
|
|
|
});
|
|
|
|
}*/
|
|
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
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(exBatchDate<inDate && moment(inDate).diff(exBatchDate, '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==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
|
|
* */
|
|
$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();
|
|
|
|
}
|
|
$scope.changeInstallemtAmt = function (old,present,index,values,totAmt,other) {
|
|
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;
|
|
}
|
|
if(parseInt(currentValue)<=parseInt($scope.setTotalAmount)){
|
|
|
|
if(currentValue<=pastValue){
|
|
var diffVal1=parseInt(pastValue)-parseInt(currentValue);
|
|
$rootScope.updateMoreItems[index+1].Amount=parseInt($rootScope.updateMoreItems[index+1].Amount)+parseInt(diffVal1);
|
|
|
|
}
|
|
else if(pastValue<currentValue){
|
|
var diffVal2=parseInt(currentValue)-parseInt(pastValue);
|
|
|
|
if(diffVal2>$rootScope.updateMoreItems[index+1].Amount){
|
|
$rootScope.updateMoreItems[index+1].Amount=parseInt(diffVal2)-parseInt($rootScope.updateMoreItems[index+1].Amount);
|
|
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems[index+1].Amount=parseInt($rootScope.updateMoreItems[index+1].Amount)-parseInt(diffVal2);
|
|
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
|
|
var diffVal3=parseInt(currentValue)-parseInt(pastValue);
|
|
// alert(diffVal3);
|
|
|
|
if(diffVal3>$rootScope.updateMoreItems[index].Amount){
|
|
$rootScope.updateMoreItems[index].Amount=parseInt(diffVal3)-parseInt($rootScope.updateMoreItems[index].Amount);
|
|
|
|
}
|
|
else{
|
|
$rootScope.updateMoreItems[index].Amount=parseInt($rootScope.updateMoreItems[index].Amount)-parseInt(diffVal3);
|
|
|
|
}
|
|
}
|
|
$scope.calculateDueAmount(values,totAmt,other,values.STFOrWR,'2',values.STFOrWR);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/*while changing installment date/amount calculate fine amount
|
|
* created by kms
|
|
* */
|
|
$scope.calculateDueAmount = function (values,totAmt,other,STFOrWR,checkPermission,beforeSTF) {
|
|
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(isNaN(parseInt(values.ActualFees))){
|
|
var gettotAmt = 0;
|
|
}
|
|
else{
|
|
var gettotAmt = values.ActualFees;
|
|
}
|
|
if(isNaN(parseInt(other))){
|
|
var getother = 0;
|
|
}
|
|
else{
|
|
var getother = other;
|
|
}
|
|
if(isNaN(parseInt(STFOrWR))){
|
|
var getSTFOrWR = 0;
|
|
}
|
|
else{
|
|
var getSTFOrWR = STFOrWR;
|
|
}
|
|
if(isNaN(parseInt(beforeSTF))){
|
|
var getBeforeSTFOrWR = 0;
|
|
}
|
|
else{
|
|
var getBeforeSTFOrWR = beforeSTF;
|
|
}
|
|
var lastInstallAmt;
|
|
if(parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) > parseInt(getBeforeSTFOrWR)){
|
|
lastInstallAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) - parseInt(getBeforeSTFOrWR);
|
|
}
|
|
else{
|
|
lastInstallAmt = parseInt(getBeforeSTFOrWR) - parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount);
|
|
}
|
|
if(parseInt(lastInstallAmt) > parseInt(getother)){
|
|
lastInstallAmt = parseInt(lastInstallAmt) - parseInt(getother); }
|
|
else{
|
|
lastInstallAmt = parseInt(getother) - parseInt(lastInstallAmt);
|
|
}
|
|
|
|
|
|
|
|
|
|
var exBatchDate = moment($scope.BatchDate);
|
|
|
|
if($rootScope.updateMoreItems.length>0){
|
|
var existLoop=0;
|
|
var exitPayAmt=0;
|
|
var finalFineAmt=0;
|
|
angular.forEach($rootScope.updateMoreItems,function (item,position) {
|
|
var exDatenew1;
|
|
var exDatenew2;
|
|
// var exitPayAmt=parseInt(totAmt-other);
|
|
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) {
|
|
$scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR));
|
|
$scope.setModel.feesType.Others = 0;
|
|
finalFineAmt=0;
|
|
|
|
}
|
|
|
|
else if(exDatenew1 > exBatchDate && existLoop==0){
|
|
|
|
// exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt);
|
|
angular.forEach($rootScope.updateMoreItems,function (listVal,listKey) {
|
|
if(listKey>=position){
|
|
|
|
exitPayAmt = parseInt(exitPayAmt)+parseInt($rootScope.updateMoreItems[listKey].Amount);
|
|
}
|
|
|
|
})
|
|
if(exitPayAmt>getBeforeSTFOrWR){
|
|
exitPayAmt = parseInt(exitPayAmt) - parseInt(getBeforeSTFOrWR);
|
|
}
|
|
else{
|
|
exitPayAmt = parseInt(getBeforeSTFOrWR) - parseInt(exitPayAmt);
|
|
|
|
}
|
|
|
|
if(exitPayAmt>getother){
|
|
exitPayAmt = parseInt(exitPayAmt) - parseInt(getother) + parseInt(getSTFOrWR);
|
|
}
|
|
else{
|
|
exitPayAmt = parseInt(getother) - parseInt(exitPayAmt) + parseInt(getSTFOrWR);
|
|
|
|
}
|
|
existLoop=1;
|
|
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);
|
|
finalFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11);
|
|
$scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR) + parseInt(todatlFineAmt));
|
|
$scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// $rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) + parseInt(finalFineAmt) - parseInt(getother);
|
|
$rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt(lastInstallAmt) + parseInt(getSTFOrWR) + parseInt(finalFineAmt);
|
|
|
|
|
|
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(exBatchDate<inDate && moment(inDate).diff(exBatchDate, '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==false) {
|
|
|
|
angular.forEach($rootScope.updateMoreItems,function (updateV,updateK) {
|
|
$rootScope.updateMoreItems[updateK].DueDate=$filter('date')(new Date(inBatchDate), 'dd-MM-yyyy');
|
|
|
|
|
|
});
|
|
|
|
$scope.dueDetailsRollup(gettotAmt,other,checkPermission,STFOrWR,lastInstallAmt,beforeSTF);
|
|
}
|
|
|
|
})
|
|
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
$scope.dateValidations();
|
|
|
|
}
|
|
|
|
/*
|
|
* roll back after installment date No
|
|
* created by kms
|
|
* */
|
|
|
|
$scope.dueDetailsRollup = function (totAmt,other,checkPermission,STFOrWR,lastInstallAmt,beforeSTF) {
|
|
if(isNaN(parseInt(totAmt))){
|
|
var gettotAmt = 0;
|
|
}
|
|
else{
|
|
var gettotAmt = totAmt;
|
|
}
|
|
if(isNaN(parseInt(other))){
|
|
var getother = 0;
|
|
}
|
|
else{
|
|
var getother = other;
|
|
}
|
|
if(isNaN(parseInt(STFOrWR))){
|
|
var getSTFOrWR = 0;
|
|
}
|
|
else{
|
|
var getSTFOrWR = STFOrWR;
|
|
}
|
|
if(isNaN(parseInt(beforeSTF))){
|
|
var getBeforeSTFOrWR = 0;
|
|
}
|
|
else{
|
|
var getBeforeSTFOrWR = beforeSTF;
|
|
}
|
|
var lastInstallAmt;
|
|
if(parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) > parseInt(getBeforeSTFOrWR)){
|
|
lastInstallAmt = parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount) - parseInt(getBeforeSTFOrWR);
|
|
}
|
|
else{
|
|
lastInstallAmt = parseInt(getBeforeSTFOrWR) - parseInt($rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount);
|
|
}
|
|
if(parseInt(lastInstallAmt) > parseInt(getother)){
|
|
lastInstallAmt = parseInt(lastInstallAmt) - parseInt(getother); }
|
|
else{
|
|
lastInstallAmt = parseInt(getother) - parseInt(lastInstallAmt);
|
|
}
|
|
var exBatchDate = moment($scope.BatchDate);
|
|
if($rootScope.updateMoreItems.length>0){
|
|
var existLoop=0;
|
|
var exitPayAmt=0;
|
|
var finalFineAmt=0;
|
|
angular.forEach($rootScope.updateMoreItems,function (item,position) {
|
|
var exDatenew1;
|
|
var exDatenew2;
|
|
// var exitPayAmt=parseInt(totAmt-other);
|
|
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) {
|
|
$scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR));
|
|
$scope.setModel.feesType.Others = 0;
|
|
finalFineAmt=0;
|
|
}
|
|
|
|
else if(exDatenew1 > exBatchDate && existLoop==0){
|
|
|
|
// exitPayAmt=parseInt(exitPayAmt)-parseInt(existTotAmt);
|
|
angular.forEach($rootScope.updateMoreItems,function (listVal,listKey) {
|
|
if(listKey>=position){
|
|
|
|
exitPayAmt = parseInt(exitPayAmt)+parseInt($rootScope.updateMoreItems[listKey].Amount);
|
|
}
|
|
|
|
})
|
|
if(exitPayAmt>getBeforeSTFOrWR){
|
|
exitPayAmt = parseInt(exitPayAmt) - parseInt(getBeforeSTFOrWR);
|
|
}
|
|
else{
|
|
exitPayAmt = parseInt(getBeforeSTFOrWR) - parseInt(exitPayAmt);
|
|
|
|
}
|
|
|
|
if(exitPayAmt>getother){
|
|
exitPayAmt = parseInt(exitPayAmt) - parseInt(getother) + parseInt(getSTFOrWR);
|
|
}
|
|
else{
|
|
exitPayAmt = parseInt(getother) - parseInt(exitPayAmt) + parseInt(getSTFOrWR);
|
|
|
|
}
|
|
existLoop=1;
|
|
|
|
|
|
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);
|
|
finalFineAmt = parseInt(fineAmt1) + parseInt(fineAmt11);
|
|
|
|
$scope.setTotalAmount = Math.round(parseInt(gettotAmt) + parseInt(getSTFOrWR) + parseInt(todatlFineAmt));
|
|
$scope.setModel.feesType.Others = Math.round(parseInt(todatlFineAmt));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$rootScope.updateMoreItems[$rootScope.updateMoreItems.length-1].Amount = parseInt(lastInstallAmt) + parseInt(getSTFOrWR) + parseInt(finalFineAmt);
|
|
|
|
|
|
}
|
|
|
|
$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":''
|
|
})
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
// this is for watch function
|
|
|
|
/* $scope.$watch('updateMoreItems', function (newValue, oldValue) {
|
|
for (var i = 0; i < newValue.length; i++) {
|
|
|
|
if (newValue[i].Amount != oldValue[i].Amount) {
|
|
alert();
|
|
var currentValue=0;
|
|
var pastValue=0;
|
|
if(newValue[i].Amount>oldValue[i].Amount){
|
|
currentValue = parseInt(newValue[i].Amount)-oldValue[i].Amount;
|
|
}
|
|
else if(newValue[i].Amount<oldValue[i].Amount){
|
|
pastValue = oldValue[i].Amount-parseInt(newValue[i].Amount);
|
|
|
|
}
|
|
else{
|
|
currentValue=0
|
|
pastValue=0;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}, true);*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}]);
|
|
|
|
/*modal controller
|
|
* */
|
|
app.controller('ModalDemoCtrl', ["$scope", "$modal", "$log", function ($scope, $modal, $log) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Click to View Bill Details';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.FeesName="" ;
|
|
$scope.open = function (values) {
|
|
$scope.FeesName = values;
|
|
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'myModalContent.html',
|
|
controller: 'FeesModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.FeesName;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
|
|
|
|
}]);
|
|
|
|
// Please note that $modalInstance represents a modal window (instance) dependency.
|
|
// It is not the same as the $modal service used above.
|
|
|
|
app.controller('FeesModalInstanceCtrl', ["$scope", "$modalInstance", "items","WordsService", function ($scope, $modalInstance, items,WordsService) {
|
|
|
|
$scope.items = items;
|
|
$scope.selected = {
|
|
item: $scope.items[0]
|
|
};
|
|
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
//show hide function for pdf design
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
$scope.ReceivedBy = "";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchLogo = "";
|
|
$scope.ShowHide = function (pdfValue) {
|
|
$scope.showButton = true;
|
|
$scope.billNo = pdfValue.BillNO;
|
|
$scope.paymentType=pdfValue.ModeOfPayment;
|
|
$scope.billDate=pdfValue.BillDate;
|
|
$scope.amountInWords = WordsService.convertNumberToWords(pdfValue.BillAmount);
|
|
$scope.billAmount = pdfValue.BillAmount;
|
|
$scope.branchName = pdfValue.BranchName;
|
|
$scope.ReceivedBy = pdfValue.ReceivedBy;
|
|
$scope.BranchAddr = pdfValue.Address;
|
|
$scope.BranchLogo = pdfValue.LogoPath;
|
|
|
|
|
|
}
|
|
|
|
$scope.mouseLeave = function(){
|
|
$scope.showButton = false;
|
|
$scope.billNo="";
|
|
$scope.sessionName="";
|
|
$scope.paymentType="";
|
|
$scope.billDate="";
|
|
$scope.amountInWords = "";
|
|
$scope.billAmount = "";
|
|
$scope.branchName = "";
|
|
$scope.ReceivedBy="";
|
|
$scope.BranchAddr = "";
|
|
$scope.BranchLogo = "";
|
|
}
|
|
|
|
}]);
|
|
app.directive('visible', function() {
|
|
|
|
return {
|
|
restrict: 'A',
|
|
|
|
link: function(scope, element, attributes) {
|
|
scope.$watch(attributes.visible, function(value){
|
|
element.css('visibility', value ? 'visible' : 'hidden');
|
|
});
|
|
}
|
|
};
|
|
});
|
|
/*modal controller
|
|
* */
|
|
app.controller('studentModalDemoCtrl', ["$scope", "$rootScope", "$modal", "$log", "API_POINTS", "$http", function ($scope, $rootScope, $modal, $log,apiPoint,$http) {
|
|
//Tooltip for print button
|
|
$scope.dynamicTooltip = 'Student View';
|
|
|
|
|
|
|
|
// $scope.items = ['item1', 'item2', 'item3'];
|
|
|
|
$scope.open = function (studentDetails) {
|
|
|
|
|
|
// get student view details
|
|
var getcourse = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStudentBasicInfo/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
requestedBy :studentDetails.MobileNumber,
|
|
requestedFrom: 3
|
|
}
|
|
};
|
|
$http(getcourse).then(function (response) {
|
|
|
|
if (response.data.status == 200 && response.data.studentStatus== true) {
|
|
$scope.courseEditLoading = false;
|
|
// $scope.studentDetails = response.data.studentDetails;
|
|
$scope.studentDetails = response.data;
|
|
// $scope.courseDetails = response.data.courseDetails;
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentDetailsModal.html',
|
|
controller: 'ModalInstanceCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
items: function () {
|
|
return $scope.studentDetails;
|
|
}
|
|
}
|
|
});
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
|
|
} else {
|
|
swal("Failed!", "This student is not registerd", "warning");
|
|
$scope.courseEditLoading = false;
|
|
$scope.studentDetails = "";
|
|
$scope.courseDetails = "";
|
|
|
|
}
|
|
});
|
|
|
|
|
|
};
|
|
$scope.open1 = function (values,type) {
|
|
|
|
var modalInstance1 = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPaymentModal.html',
|
|
controller: 'ModalInstanceCtrl1',
|
|
// size: size,
|
|
resolve: {
|
|
items1: function () {
|
|
var myvalues =
|
|
{
|
|
"values":values,
|
|
"type":type
|
|
};
|
|
return myvalues;
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
modalInstance1.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
};
|
|
|
|
$scope.printStudentDetails = function (details) {
|
|
$rootScope.pdfItems = details;
|
|
|
|
var printInstance = $modal.open({
|
|
templateUrl: 'assets/views/student/studentPdf.html',
|
|
controller: 'studentModalDemoCtrl',
|
|
});
|
|
};
|
|
|
|
// generate pdf for student view
|
|
$scope.export = function(getName) {
|
|
kendo.drawing.drawDOM($("#exportthis")).then(function(group) {
|
|
kendo.drawing.pdf.saveAs(group, getName+".pdf");
|
|
});
|
|
}
|
|
|
|
|
|
|
|
}]);
|
|
|
|
// Please note that $modalInstance represents a modal window (instance) dependency.
|
|
// It is not the same as the $modal service used above.
|
|
|
|
app.controller('ModalInstanceCtrl', ["$scope", "$modalInstance", "items","WordsService", function ($scope, $modalInstance, items,WordsService) {
|
|
|
|
$scope.items = items;
|
|
$scope.selected = {
|
|
item: $scope.items[0]
|
|
};
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
|
|
}]);
|
|
app.controller('ModalInstanceCtrl1', ["$scope", "$modalInstance", "items1","WordsService", function ($scope, $modalInstance, items1,WordsService) {
|
|
|
|
$scope.items1 = items1.values;
|
|
$scope.selectedtype = items1.type;
|
|
|
|
$scope.ok = function () {
|
|
$modalInstance.close($scope.selected.item);
|
|
};
|
|
|
|
$scope.cancel = function () {
|
|
$modalInstance.dismiss('cancel');
|
|
};
|
|
|
|
|
|
}]);
|
|
app.filter('unique', function() {
|
|
return function(collection, primaryKey, secondaryKey) { //optional secondary key
|
|
var output = [],
|
|
keys = [];
|
|
|
|
angular.forEach(collection, function(item) {
|
|
var key;
|
|
secondaryKey === undefined ? key = item[primaryKey] : key = item[primaryKey][secondaryKey];
|
|
|
|
if(keys.indexOf(key) === -1) {
|
|
keys.push(key);
|
|
output.push(item);
|
|
}
|
|
});
|
|
|
|
return output;
|
|
};
|
|
});
|
|
|
|
app.filter('getById', function() {
|
|
return function(input, id) {
|
|
var i=0, len=input.length;
|
|
for (; i<len; i++) {
|
|
if (+input[i].SessionID == +id) {
|
|
return input[i];
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}); |