Commit cb8450a9 authored by Md Suleman's avatar Md Suleman

updated resource service for updating the allocation by adding one more validation

parent e6847920
...@@ -134,29 +134,35 @@ public class ResourceService implements IResourceService { ...@@ -134,29 +134,35 @@ public class ResourceService implements IResourceService {
if (resource != null) { if (resource != null) {
if(resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.Engaged_STATUS)){ if(resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.Engaged_STATUS)){
if(resourceReq.getBillingEndDate().compareTo(new Date())<0){ Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);//update Status of allocation
Resource resourceBench = new Resource(); if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&&
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID); !latestAllocation.getBillingStartDate().after(resourceReq.getBillingEndDate())) {
resourceBench.setEmployeeId(resourceReq.getEmployeeId()); respMap.put("statusCode", 811);
resourceBench.setResourceRole(resourceReq.getResourceRole()); respMap.put("message", "Resource is already allocated after "+latestAllocation.getBillingStartDate());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);//add alocation status as Released }else{
resourceBench.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate())); if (resourceReq.getBillingEndDate().compareTo(new Date()) < 0) {
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate()); resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);//update Status of allocation
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); Resource resourceBench = new Resource();
resourceBench.setAuditFields(loginEmpId, MyTeamUtils.CREATE); resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
resourceRepo.save(resourceBench); resourceBench.setEmployeeId(resourceReq.getEmployeeId());
resourceBench.setResourceRole(resourceReq.getResourceRole());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);//add alocation status as Released
resourceBench.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
resourceRepo.save(resourceBench);
}
this.updateExistedResource(resourceReq);
} }
this.updateExistedResource(resourceReq);
}else{ }else{
respMap.put("statusCode", 801); respMap.put("statusCode", 811);
respMap.put("message", "Resource is already released from you, And you can't update this allocation"); respMap.put("message", "Resource is already released from you, And you can't update this allocation");
//>>>>>>> Stashed changes
} }
} else { } else {
respMap.put("statusCode", 801); respMap.put("statusCode", 811);
respMap.put("message", "Record Not Found"); respMap.put("message", "Record Not Found");
} }
......
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