Unverified Commit 8257ab73 authored by mshaik-nisum-com's avatar mshaik-nisum-com Committed by GitHub

Merge pull request #122 from nisum-inc/FEATURE/UpdateTeamMateMaintainEndDate

UpdateTeamMateMaintainEndDate
parents 6806fd2c 299a19a7
......@@ -342,6 +342,65 @@ public class ProjectServiceImpl implements ProjectService {
@Override
public ProjectTeamMate updateTeammate(ProjectTeamMate projectTeamMate) {
ProjectTeamMate existingTeammate1 = projectTeamMatesRepo.findById(projectTeamMate.getId());
// past or present endDate (Inactive the Resource)
if (projectTeamMate.getEndDate().compareTo(new Date()) <= 0 &&projectTeamMate.getEndDate().compareTo(existingTeammate1.getEndDate())!=0) {
existingTeammate1.setActive(false);
//existingTeammate1.setEndDate(new Date());
existingTeammate1.setEndDate(projectTeamMate.getEndDate());
BillingDetails billingDetails = new BillingDetails();
billingDetails.setBillableStatus("Non-Billable");
List<BillingDetails> listBD = getEmployeeActiveBillingDetails(projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId());
if (listBD != null && !listBD.isEmpty()) {
BillingDetails billingDetailsExisting = listBD.get(0);
/*Date d = new Date();
d.setDate(d.getDate() - 1);
billingDetailsExisting.setBillingEndDate(d);*/
Date actualEndDate=projectTeamMate.getEndDate();
billingDetailsExisting.setBillingEndDate(actualEndDate);
billingDetailsExisting.setActive(false);
updateEmployeeBilling(billingDetailsExisting);
}
//billingDetails.setBillingStartDate(new Date());
Date sd=projectTeamMate.getEndDate();
sd.setDate(sd.getDate()+1);
billingDetails.setBillingStartDate(sd);
billingDetails.setAccount("Nisum India");
billingDetails.setActive(true);
billingDetails.setEmployeeId(existingTeammate1.getEmployeeId());
billingDetails.setEmployeeName(existingTeammate1.getEmployeeName());
billingDetails.setCreateDate(new Date());
billingDetails.setProjectId("Nisum0000");
billingDetails.setProjectName(MyTimeUtils.FREE_POLL);
addEmployeeBillingDetails(billingDetails);
projectTeamMatesRepo.save(existingTeammate1);
ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount("Nisum India");
newBenchAllocation.setBillableStatus("Non-Billable");
newBenchAllocation.setDesignation(existingTeammate1.getDesignation());
newBenchAllocation.setEmailId(existingTeammate1.getEmailId());
newBenchAllocation.setEmployeeId(existingTeammate1.getEmployeeId());
newBenchAllocation.setActive(true);
newBenchAllocation.setEmployeeName(existingTeammate1.getEmployeeName());
newBenchAllocation.setProjectId("Nisum0000");
//newBenchAllocation.setStartDate(new Date());
newBenchAllocation.setStartDate(sd);
Project p = projectRepo.findByProjectId("Nisum0000");
newBenchAllocation.setProjectName(p.getProjectName());
// newBenchAllocation.setManagerId(p.getManagerId());
// newBenchAllocation.setManagerName(p.getManagerName());
projectTeamMatesRepo.save(newBenchAllocation);
updateShiftDetails(existingTeammate1);
return existingTeammate1;
}else
{
ProjectTeamMate existingTeammate = projectTeamMatesRepo
.findByEmployeeIdAndProjectId(projectTeamMate.getEmployeeId(),
......@@ -349,6 +408,7 @@ public class ProjectServiceImpl implements ProjectService {
existingTeammate.setProjectId(projectTeamMate.getProjectId());
existingTeammate.setProjectName(projectTeamMate.getProjectName());
existingTeammate.setRole(projectTeamMate.getRole());
// changing the Billability status
if (existingTeammate.getBillableStatus() == null
|| projectTeamMate.getBillableStatus() != null
&& existingTeammate.getBillableStatus() != null
......@@ -365,6 +425,11 @@ public class ProjectServiceImpl implements ProjectService {
*/
Date d = projectTeamMate.getNewBillingStartDate();
d.setDate(d.getDate() - 1);
if(existingTeammate.getNewBillingStartDate().compareTo(projectTeamMate.getNewBillingStartDate())<=0)
billingDetails.setBillingEndDate(
DateUtils.truncate(projectTeamMate.getNewBillingStartDate(), Calendar.DATE));
else
billingDetails.setBillingEndDate(
DateUtils.truncate(d, Calendar.DATE));
billingDetails.setActive(false);
......@@ -381,7 +446,8 @@ public class ProjectServiceImpl implements ProjectService {
// TODO
Date d = projectTeamMate.getNewBillingStartDate();
d.setDate(d.getDate() + 1);
billings.setBillingStartDate(DateUtils.truncate(d, Calendar.DATE));
//billings.setBillingStartDate(DateUtils.truncate(d, Calendar.DATE));
billings.setBillingStartDate(DateUtils.truncate(projectTeamMate.getStartDate(), Calendar.DATE));
existingTeammate.setNewBillingStartDate(
DateUtils.truncate(d, Calendar.DATE));
billings.setBillingEndDate(DateUtils
......@@ -389,6 +455,19 @@ public class ProjectServiceImpl implements ProjectService {
billings.setCreateDate(new Date());
addEmployeeBillingDetails(billings);
// TODO
}else //without changing the Billability status
{
List<BillingDetails> listBD1 = getEmployeeActiveBillingDetails(
projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId());
if (listBD1 != null && !listBD1.isEmpty()) {
BillingDetails billingDetails = listBD1.get(0);
billingDetails.setBillingEndDate(projectTeamMate.getEndDate());
billingDetails.setBillingStartDate(projectTeamMate.getStartDate());
addEmployeeBillingDetails(billingDetails);
}
existingTeammate.setNewBillingStartDate(projectTeamMate.getNewBillingStartDate());
}
existingTeammate.setBillableStatus(projectTeamMate.getBillableStatus());
......@@ -400,52 +479,9 @@ public class ProjectServiceImpl implements ProjectService {
.findByEmployeeId(teamMate.getEmployeeId());
employeeDB.setShift(teamMate.getShift());
employeeRolesRepo.save(employeeDB);
if (projectTeamMate.getEndDate().compareTo(new Date()) < 0) {
ProjectTeamMate existingTeammate1 = projectTeamMatesRepo.findById(projectTeamMate.getId());
existingTeammate1.setActive(false);
existingTeammate1.setEndDate(new Date());
BillingDetails billingDetails = new BillingDetails();
billingDetails.setBillableStatus("Non-Billable");
billingDetails.setBillingStartDate(new Date());
billingDetails.setAccount("Nisum");
billingDetails.setActive(true);
billingDetails.setEmployeeId(existingTeammate1.getEmployeeId());
billingDetails.setEmployeeName(existingTeammate1.getEmployeeName());
billingDetails.setCreateDate(new Date());
billingDetails.setProjectId("Nisum0000");
billingDetails.setProjectName(MyTimeUtils.FREE_POLL);
addEmployeeBillingDetails(billingDetails);
List<BillingDetails> listBD = getEmployeeActiveBillingDetails(projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId());
if (listBD != null && !listBD.isEmpty()) {
BillingDetails billingDetailsExisting = listBD.get(0);
Date d = new Date();
d.setDate(d.getDate() - 1);
billingDetailsExisting.setBillingEndDate(d);
billingDetailsExisting.setActive(false);
updateEmployeeBilling(billingDetailsExisting);
}
projectTeamMatesRepo.save(existingTeammate1);
ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount("Nisum");
newBenchAllocation.setBillableStatus("Non-Billable");
newBenchAllocation.setDesignation(existingTeammate1.getDesignation());
newBenchAllocation.setEmailId(existingTeammate1.getEmailId());
newBenchAllocation.setEmployeeId(existingTeammate1.getEmployeeId());
newBenchAllocation.setActive(true);
newBenchAllocation.setEmployeeName(existingTeammate1.getEmployeeName());
newBenchAllocation.setProjectId("Nisum0000");
newBenchAllocation.setStartDate(new Date());
Project p = projectRepo.findByProjectId("Nisum0000");
newBenchAllocation.setProjectName(p.getProjectName());
// newBenchAllocation.setManagerId(p.getManagerId());
// newBenchAllocation.setManagerName(p.getManagerName());
projectTeamMatesRepo.save(newBenchAllocation);
updateShiftDetails(existingTeammate1);
}
return teamMate;
}
}
public void updateShiftDetails(ProjectTeamMate existingTeammate) {
......@@ -942,7 +978,7 @@ public class ProjectServiceImpl implements ProjectService {
String toDate = null;
List<ProjectTeamMate> teamMateList = projectTeamMatesRepo.findAll();
for (ProjectTeamMate projectMate : teamMateList) {
if (projectTeamMate.getEmployeeId().equals(projectMate.getEmployeeId()) && projectMate.isActive()
if (projectTeamMate.getEmployeeId().equals(projectMate.getEmployeeId()) && (projectMate.getEndDate().compareTo(new Date())>0)
&& !projectMate.getProjectId().equals("Nisum0000")) {
if (++count == 1)
{
......
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