Commit 0310f4ea authored by Md Suleman's avatar Md Suleman

added validation while moving resource to proposed to engage

parent 38550d04
......@@ -143,6 +143,10 @@ public class ResourceService implements IResourceService {
if (resource != null) {
if(!resource.getStatus().equalsIgnoreCase(MyTeamUtils.STATUS_RELEASED)){
if(validateResourceForProposedToEngage(resourceReq)){
this.updateExistedResource(resourceReq);
return;
}
if(isDatesAvailableForAllocation(resourceReq)) {
Resource prevAllocation = getFirstOfListOrNull(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()).stream().
filter(a -> a.getBillingEndDate().compareTo(MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()))==0).collect(Collectors.toList()));
......@@ -156,8 +160,12 @@ public class ResourceService implements IResourceService {
nextAllocation.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
this.updateExistedResource(nextAllocation);
}
// resource.setBillableStatus(resourceReq.getBillableStatus());
// resource.setBillingStartDate(resourceReq.getBillingStartDate());
// resource.setBillingEndDate(resourceReq.getBillingEndDate());
this.updateExistedResource(resourceReq);
}
}else{
respMap.put("statusCode", 811);
respMap.put("message", "Resource is already released from you, And you can't update this allocation");
......@@ -328,6 +336,29 @@ public class ResourceService implements IResourceService {
return isAssigned;
}
public boolean validateResourceForProposedToEngage(Resource resourceReq){
String message = "";
boolean isValid = false;
Resource resource = resourceRepo.findById(resourceReq.getId());
if(resource != null){
List<Resource> resourceList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
Resource lastAllocation = this.getLatestAllocation(resourceList.stream().filter(a -> a.getBillingEndDate().compareTo(resource.getBillingStartDate())<0 &&
!a.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
if(resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED) && resourceReq.getStatus().equals(MyTeamUtils.STATUS_ENGAGED)){
if(!lastAllocation.getStatus().equals(MyTeamUtils.STATUS_RELEASED)){
message = "Resource is not released form last allocation";
}else{
isValid = true;
}
}
respMap.put("statusCode", 810);
respMap.put("message", message);
}
return isValid;
}
public boolean validateResourceBillingEndDateAgainstBench(Resource resourceReq){
boolean isValid = true;
String message = "";
......
......@@ -58,7 +58,7 @@ public class SubStatusService implements ISubStatusService {
@Override
public EmployeeSubStatus endSubStatus(EmployeeSubStatus subStatus){
EmployeeSubStatus currentSubStatus = getCurrentSubStatus(subStatus.getEmployeeID());
if(currentSubStatus.getId().equals(subStatus.getId())){
if(currentSubStatus!=null){
subStatus.setToDate(MyTeamDateUtils.getDayLessThanDate(new Date()));
updateExistingEmplyeeSubStatus(subStatus);
}
......
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