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 {
if (resource != null) {
if(resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.Engaged_STATUS)){
if(resourceReq.getBillingEndDate().compareTo(new Date())<0){
resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);//update Status of allocation
Resource resourceBench = new Resource();
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
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);
Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&&
!latestAllocation.getBillingStartDate().after(resourceReq.getBillingEndDate())) {
respMap.put("statusCode", 811);
respMap.put("message", "Resource is already allocated after "+latestAllocation.getBillingStartDate());
}else{
if (resourceReq.getBillingEndDate().compareTo(new Date()) < 0) {
resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);//update Status of allocation
Resource resourceBench = new Resource();
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
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{
respMap.put("statusCode", 801);
respMap.put("statusCode", 811);
respMap.put("message", "Resource is already released from you, And you can't update this allocation");
//>>>>>>> Stashed changes
}
} else {
respMap.put("statusCode", 801);
respMap.put("statusCode", 811);
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