Unverified Commit 937ad689 authored by rbonthala-nisum-com's avatar rbonthala-nisum-com Committed by GitHub

Merge pull request #9 from nisum-inc/feature/MT-72_On_billability_status_change

MT-72_On_billability_status_change and capture the new status start date
parents 385ab5c4 fd47236e
...@@ -81,6 +81,17 @@ public class ProjectTeamController { ...@@ -81,6 +81,17 @@ public class ProjectTeamController {
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
//MT-72
@RequestMapping(value = "/getEmployeeProjectInfo", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getEmployeeProjectInfo(
@RequestParam("empId") String empId) throws MyTimeException {
List<ProjectTeamMate> projectInfo = projectService.getProjectInfo(empId);
return new ResponseEntity<>(projectInfo, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET, @RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers() public ResponseEntity<List<EmployeeRoles>> getManagers()
......
...@@ -45,6 +45,8 @@ public class ProjectTeamMate implements Serializable { ...@@ -45,6 +45,8 @@ public class ProjectTeamMate implements Serializable {
private Date startDate; private Date startDate;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date endDate; private Date endDate;
@DateTimeFormat(iso = ISO.DATE)
private Date newBillingStartDate;
private boolean active; private boolean active;
} }
...@@ -34,6 +34,9 @@ public interface ProjectService { ...@@ -34,6 +34,9 @@ public interface ProjectService {
List<ProjectTeamMate> getTeamDetails(String empId); List<ProjectTeamMate> getTeamDetails(String empId);
//MT-72
List<ProjectTeamMate> getProjectInfo(String empId);
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate) public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate)
throws MyTimeException; throws MyTimeException;
......
...@@ -13,6 +13,7 @@ import org.apache.commons.lang.time.DateUtils; ...@@ -13,6 +13,7 @@ import org.apache.commons.lang.time.DateUtils;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -138,6 +139,17 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -138,6 +139,17 @@ public class ProjectServiceImpl implements ProjectService {
} }
//MT-72
@Override
public List<ProjectTeamMate> getProjectInfo(String empId) {
Query query = new Query(Criteria.where("employeeId").is(empId));
query.limit(1);
query.with(new Sort(Sort.Direction.DESC, "startDate"));
List<ProjectTeamMate> projectTeamMate = mongoTemplate.find(query, ProjectTeamMate.class);
return projectTeamMate;
}
@Override @Override
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate) public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate)
throws MyTimeException { throws MyTimeException {
...@@ -146,8 +158,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -146,8 +158,7 @@ public class ProjectServiceImpl implements ProjectService {
pT.getEmployeeId()); pT.getEmployeeId());
for (BillingDetails b : listBD) { for (BillingDetails b : listBD) {
Date d = pT.getStartDate() != null ? pT.getStartDate() : new Date(); Date d = pT.getStartDate() != null ? pT.getStartDate() : new Date();
d.setDate(d.getDate() - 1); b.setBillingEndDate(DateUtils.truncate(DateUtils.addDays(d, -1), Calendar.DATE));
b.setBillingEndDate(DateUtils.truncate(d, Calendar.DATE));
b.setActive(false); b.setActive(false);
updateEmployeeBilling(b); updateEmployeeBilling(b);
} }
...@@ -161,7 +172,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -161,7 +172,7 @@ public class ProjectServiceImpl implements ProjectService {
billings.setActive(true); billings.setActive(true);
billings.setBillingStartDate(pT.getStartDate() == null billings.setBillingStartDate(pT.getStartDate() == null
? DateUtils.truncate(new Date(), Calendar.DATE) ? DateUtils.truncate(new Date(), Calendar.DATE)
: DateUtils.truncate(pT.getStartDate(), Calendar.DATE)); : DateUtils.truncate(pT.getNewBillingStartDate(), Calendar.DATE));
if (pT.getEndDate() != null) { if (pT.getEndDate() != null) {
billings.setBillingEndDate( billings.setBillingEndDate(
DateUtils.truncate(pT.getEndDate(), Calendar.DATE)); DateUtils.truncate(pT.getEndDate(), Calendar.DATE));
...@@ -179,9 +190,8 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -179,9 +190,8 @@ public class ProjectServiceImpl implements ProjectService {
for (ProjectTeamMate pteamMate : activeBenchProject) { for (ProjectTeamMate pteamMate : activeBenchProject) {
Date d = pT.getStartDate() != null ? pT.getStartDate() Date d = pT.getStartDate() != null ? pT.getStartDate()
: new Date(); : new Date();
d.setDate(d.getDate() - 1);
pteamMate.setActive(false); pteamMate.setActive(false);
pteamMate.setEndDate(d); pteamMate.setEndDate(DateUtils.truncate(DateUtils.addDays(d, -1), Calendar.DATE));
projectTeamMatesRepo.save(pteamMate); projectTeamMatesRepo.save(pteamMate);
} }
} }
...@@ -208,7 +218,9 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -208,7 +218,9 @@ public class ProjectServiceImpl implements ProjectService {
projectTeamMate.getProjectId()); projectTeamMate.getProjectId());
if (listBD != null && !listBD.isEmpty()) { if (listBD != null && !listBD.isEmpty()) {
BillingDetails billingDetails = listBD.get(0); BillingDetails billingDetails = listBD.get(0);
Date d = new Date(); /* Date d = new Date();
d.setDate(d.getDate() - 1);*/
Date d = projectTeamMate.getNewBillingStartDate();
d.setDate(d.getDate() - 1); d.setDate(d.getDate() - 1);
billingDetails.setBillingEndDate( billingDetails.setBillingEndDate(
DateUtils.truncate(d, Calendar.DATE)); DateUtils.truncate(d, Calendar.DATE));
...@@ -224,7 +236,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -224,7 +236,7 @@ public class ProjectServiceImpl implements ProjectService {
billings.setBillableStatus(projectTeamMate.getBillableStatus()); billings.setBillableStatus(projectTeamMate.getBillableStatus());
billings.setActive(true); billings.setActive(true);
billings.setBillingStartDate( billings.setBillingStartDate(
DateUtils.truncate(new Date(), Calendar.DATE)); DateUtils.truncate(projectTeamMate.getNewBillingStartDate(), Calendar.DATE));
billings.setBillingEndDate(DateUtils billings.setBillingEndDate(DateUtils
.truncate(projectTeamMate.getEndDate(), Calendar.DATE)); .truncate(projectTeamMate.getEndDate(), Calendar.DATE));
billings.setCreateDate(new Date()); billings.setCreateDate(new Date());
......
...@@ -19,6 +19,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -19,6 +19,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
"mobileNumber":"", "mobileNumber":"",
"startDate":"", "startDate":"",
"endDate":"", "endDate":"",
"newBillingStartDate":"",
"action":"" "action":""
}; };
$scope.employees = []; $scope.employees = [];
...@@ -92,6 +93,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -92,6 +93,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.parentData.mobileNumber = row.entity.mobileNumber; $scope.parentData.mobileNumber = row.entity.mobileNumber;
$scope.parentData.startDate = row.entity.startDate; $scope.parentData.startDate = row.entity.startDate;
$scope.parentData.endDate = row.entity.endDate; $scope.parentData.endDate = row.entity.endDate;
$scope.parentData.newBillingStartDate = row.entity.newBillingStartDate;
if(action == "Update"){ if(action == "Update"){
$scope.updateEmployee(action, $scope.parentData); $scope.updateEmployee(action, $scope.parentData);
...@@ -296,11 +298,17 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -296,11 +298,17 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.alertMsg = ""; $scope.alertMsg = "";
$scope.isDisabled = false; $scope.isDisabled = false;
$scope.result = ""; $scope.result = "";
$scope.employeeList = employees; $scope.employeeList = employees;
$scope.projectList = []; $scope.projectList = [];
//MT-72
$scope.projectInfoList = [];
$scope.newBillingStartDate;
$scope.employeeModel; $scope.employeeModel;
$scope.projectModel; $scope.projectModel;
$scope.objectId = ""; $scope.objectId = "";
$scope.getProjects = function(){ $scope.getProjects = function(){
$http({ $http({
method : "GET", method : "GET",
...@@ -311,6 +319,13 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -311,6 +319,13 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.projectList = []; $scope.projectList = [];
}); });
}; };
$scope.currentBillabilityDateChange = function(){
$scope.startDate = $scope.newBillingStartDate ;
}
if(dataToPass.action == "Add"){ if(dataToPass.action == "Add"){
$scope.empId = ""; $scope.empId = "";
$scope.empName = ""; $scope.empName = "";
...@@ -320,6 +335,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -320,6 +335,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.startDate; $scope.startDate;
$scope.endDate; $scope.endDate;
$scope.empEmail = ""; $scope.empEmail = "";
$scope.newBillingStartDate;
$scope.projectStartDate;
$scope.isDisabled = false; $scope.isDisabled = false;
}else if(dataToPass.action == "Update"){ }else if(dataToPass.action == "Update"){
$scope.id = dataToPass.id; $scope.id = dataToPass.id;
...@@ -339,6 +356,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -339,6 +356,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.designation = dataToPass.designation; $scope.designation = dataToPass.designation;
$scope.startDate = new Date(dataToPass.startDate); $scope.startDate = new Date(dataToPass.startDate);
$scope.endDate = new Date(dataToPass.endDate); $scope.endDate = new Date(dataToPass.endDate);
$scope.newBillingStartDate = new Date(dataToPass.newBillingStartDate);
$scope.isDisabled = true; $scope.isDisabled = true;
$scope.projectModel = { $scope.projectModel = {
'projectName': dataToPass.projectName, 'projectName': dataToPass.projectName,
...@@ -408,7 +426,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -408,7 +426,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
$scope.addBilling = function() { $scope.addBilling = function() {
var record = {"employeeId": $scope.employeeId, "employeeName":$scope.employeeName, "projectId": $scope.projectId, var record = {"employeeId": $scope.employeeId, "employeeName":$scope.employeeName, "projectId": $scope.projectId,
"projectName": $scope.projectName, "billingStartDate":$scope.fromDate,"billingEndDate": $scope.toDate,"active":true}; "projectName": $scope.projectName, "billingStartDate":$scope.fromDate,"billingEndDate": $scope.toDate,"active":true,"newBillingStartDate" :$scope.newBillingStartDate};
addOrUpdateBilling(record,"Add") addOrUpdateBilling(record,"Add")
}; };
...@@ -583,6 +601,16 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -583,6 +601,16 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
$scope.getEmployeeSelected = function(){ $scope.getEmployeeSelected = function(){
if ($scope.employeeModel !== undefined) { if ($scope.employeeModel !== undefined) {
//MT-72
$http({
method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeeProjectInfo?empId="+$scope.employeeModel.employeeId
}).then(function mySuccess(response) {
$scope.projectInfoList = response.data;
}, function myError(response) {
$scope.projectInfoList = [];
});
$scope.employee=$scope.employeeModel; $scope.employee=$scope.employeeModel;
return $scope.employeeModel.employeeName; return $scope.employeeModel.employeeName;
} else { } else {
...@@ -628,16 +656,21 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -628,16 +656,21 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.alertMsg = "Please select a billable status"; $scope.alertMsg = "Please select a billable status";
document.getElementById('empBillableStatus').focus(); document.getElementById('empBillableStatus').focus();
}else if($scope.startDate == undefined) { }else if($scope.startDate == undefined) {
$scope.alertMsg = "Please select Start Date"; $scope.alertMsg = "Please select Assignment Start Date";
document.getElementById('startDate').focus(); document.getElementById('startDate').focus();
}else if($scope.newBillingStartDate == undefined) {
$scope.alertMsg = "Please select Current Billability Start Date";
document.getElementById('newBillingStartDate').focus();
}else if($scope.endDate == undefined) { }else if($scope.endDate == undefined) {
$scope.alertMsg = "Please select End Date"; $scope.alertMsg = "Please select Assignment End Date";
document.getElementById('endDate').focus(); document.getElementById('endDate').focus();
}else if($scope.newBillingStartDate > $scope.endDate){
$scope.alertMsg = "Assignment End Date should be less than Current Billability Start Date ";
} }
else { else {
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "role": employeeModel.role, "designation":employeeModel.designation,"shift": employeeModel.shift,"projectId":projectModel.projectId,"projectName":projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"mobileNumber":employeeModel.mobileNumber,"active":true,"billableStatus":$scope.empBillableStatus,"startDate":$scope.startDate,"endDate":$scope.endDate}; var record = {"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "role": employeeModel.role, "designation":employeeModel.designation,"shift": employeeModel.shift,"projectId":projectModel.projectId,"projectName":projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"mobileNumber":employeeModel.mobileNumber,"active":true,"billableStatus":$scope.empBillableStatus,"startDate":$scope.startDate,"endDate":$scope.endDate,"newBillingStartDate":$scope.newBillingStartDate};
addOrUpdateRole(record, $scope.templateTitle); addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500); $timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
...@@ -657,11 +690,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -657,11 +690,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.alertMsg = "Please select Start Date"; $scope.alertMsg = "Please select Start Date";
document.getElementById('startDate').focus(); document.getElementById('startDate').focus();
}else if($scope.endDate == undefined) { }else if($scope.endDate == undefined) {
$scope.alertMsg = "Please select End Date"; $scope.alertMsg = "Please select new Billing Date ";
document.getElementById('endDate').focus(); document.getElementById('endDate').focus();
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"id":$scope.id,"employeeId":$scope.employeeId, "employeeName":$scope.employeeName, "emailId": $scope.emailId, "role": $scope.role, "shift": $scope.shift,"projectId":$scope.projectModel.projectId,"projectName":$scope.projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"designation":$scope.empDesignation,"billableStatus":$scope.empBillableStatus,"experience":$scope.experience,"mobileNumber":$scope.mobileNumber,"startDate":$scope.startDate,"endDate":$scope.endDate}; var record = {"id":$scope.id,"employeeId":$scope.employeeId, "employeeName":$scope.employeeName, "emailId": $scope.emailId, "role": $scope.role, "shift": $scope.shift,"projectId":$scope.projectModel.projectId,"projectName":$scope.projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"designation":$scope.empDesignation,"billableStatus":$scope.empBillableStatus,"experience":$scope.experience,"mobileNumber":$scope.mobileNumber,"startDate":$scope.startDate,"endDate":$scope.endDate,"newBillingStartDate":$scope.newBillingStartDate};
addOrUpdateRole(record, $scope.templateTitle); addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500); $timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment