Commit ec28e0d1 authored by Md Suleman's avatar Md Suleman

updated sub status date issue and some resource allocation sevice modification

parent 6bd109e2
...@@ -5,6 +5,7 @@ import lombok.*; ...@@ -5,6 +5,7 @@ import lombok.*;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
...@@ -23,7 +24,9 @@ public class EmployeeSubStatus { ...@@ -23,7 +24,9 @@ public class EmployeeSubStatus {
@NonNull @NonNull
private String subStatus; private String subStatus;
@NonNull @NonNull
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date fromDate; private Date fromDate;
@NonNull @NonNull
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date toDate; private Date toDate;
} }
...@@ -262,9 +262,9 @@ public class ResourceService implements IResourceService { ...@@ -262,9 +262,9 @@ public class ResourceService implements IResourceService {
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId()); Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining(); Date empDoj = employeeService.getEmployeeById(resource.getEmployeeId()).getDateOfJoining();
if (resource.getBillingStartDate().compareTo(empDoj) < 0) { if (resource.getBillingStartDate().compareTo(empDoj) < 0) {
message = "Resource Billing Start Date (" + resource.getBillingStartDate() + " ) in " message = "Resource Billing Start Date (" + MyTeamDateUtils.getRadableDate().format(resource.getBillingStartDate()) + " ) in "
+ projectService.getProjectByProjectId(resource.getProjectId()).getProjectName() + projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()
+ " project should not be before Date of Joining ( " + empDoj + ")."; + " project should not be before Date of Joining ( " + MyTeamDateUtils.getRadableDate().format(empDoj) + ").";
isValid = false; isValid = false;
respMap.put("statusCode", 814); respMap.put("statusCode", 814);
respMap.put("message", message); respMap.put("message", message);
...@@ -285,7 +285,8 @@ public class ResourceService implements IResourceService { ...@@ -285,7 +285,8 @@ public class ResourceService implements IResourceService {
message = "Resource is already alocated for projects:\n"; message = "Resource is already alocated for projects:\n";
for(Resource resourcel:matchedList){ for(Resource resourcel:matchedList){
Project project = projectService.getProjectByProjectId(resourcel.getProjectId()); Project project = projectService.getProjectByProjectId(resourcel.getProjectId());
message += "Project:"+project.getProjectName()+" From:"+resourcel.getBillingStartDate()+" To:"+resourcel.getBillingEndDate()+"\n"; message += "Project:"+project.getProjectName()+" From:"+MyTeamDateUtils.getRadableDate().format(resourcel.getBillingStartDate())+" To:"
+MyTeamDateUtils.getRadableDate().format(resourcel.getBillingEndDate())+"\n";
} }
respMap.put("statusCode", 815); respMap.put("statusCode", 815);
respMap.put("message", message); respMap.put("message", message);
...@@ -305,7 +306,8 @@ public class ResourceService implements IResourceService { ...@@ -305,7 +306,8 @@ public class ResourceService implements IResourceService {
latestAllocation.getBillingStartDate().compareTo(new Date())>0){ latestAllocation.getBillingStartDate().compareTo(new Date())>0){
isAssigned = false; isAssigned = false;
Project project = projectService.getProjectByProjectId(latestAllocation.getProjectId()); Project project = projectService.getProjectByProjectId(latestAllocation.getProjectId());
message = "Resource is already reserved in "+project.getProjectName()+" project from "+latestAllocation.getBillingStartDate()+" to "+latestAllocation.getBillingEndDate(); message = "Resource is already Reserved in "+project.getProjectName()+" project from "+
MyTeamDateUtils.getRadableDate().format(latestAllocation.getBillingStartDate())+" to "+MyTeamDateUtils.getRadableDate().format(latestAllocation.getBillingEndDate());
}else if(!isDatesAvailableForAllocation(resourceReq)){ }else if(!isDatesAvailableForAllocation(resourceReq)){
message = respMap.get("message").toString(); message = respMap.get("message").toString();
...@@ -345,7 +347,7 @@ public class ResourceService implements IResourceService { ...@@ -345,7 +347,7 @@ public class ResourceService implements IResourceService {
Resource lastAllocation = this.getLatestAllocation(resourceList.stream().filter(a -> a.getBillingEndDate().compareTo(resource.getBillingStartDate())<0 && Resource lastAllocation = this.getLatestAllocation(resourceList.stream().filter(a -> a.getBillingEndDate().compareTo(resource.getBillingStartDate())<0 &&
!a.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList())); !a.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
if(resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED) && resourceReq.getStatus().equals(MyTeamUtils.STATUS_ENGAGED)){ if(resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED) && resourceReq.getStatus().equals(MyTeamUtils.STATUS_ENGAGED)){
if(!lastAllocation.getStatus().equals(MyTeamUtils.STATUS_RELEASED)){ if(lastAllocation != null && !lastAllocation.getStatus().equals(MyTeamUtils.STATUS_RELEASED)){
message = "Resource is not released form last allocation"; message = "Resource is not released form last allocation";
}else{ }else{
isValid = true; isValid = true;
......
...@@ -37,11 +37,15 @@ public class SubStatusService implements ISubStatusService { ...@@ -37,11 +37,15 @@ public class SubStatusService implements ISubStatusService {
@Override @Override
public EmployeeSubStatus updateExistingEmplyeeSubStatus(EmployeeSubStatus employeeSubStatusReq) { public EmployeeSubStatus updateExistingEmplyeeSubStatus(EmployeeSubStatus employeeSubStatusReq) {
employeeSubStatusReq.setFromDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatusReq.getFromDate()));
employeeSubStatusReq.setToDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatusReq.getToDate()));
return employeeSubStatusRepo.save(employeeSubStatusReq); return employeeSubStatusRepo.save(employeeSubStatusReq);
} }
@Override @Override
public EmployeeSubStatus addEmployeeSubStatus(EmployeeSubStatus employeeSubStatus) { public EmployeeSubStatus addEmployeeSubStatus(EmployeeSubStatus employeeSubStatus) {
employeeSubStatus.setFromDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatus.getFromDate()));
employeeSubStatus.setToDate(MyTeamDateUtils.getDayMoreThanDate(employeeSubStatus.getToDate()));
return employeeSubStatusRepo.insert(employeeSubStatus); return employeeSubStatusRepo.insert(employeeSubStatus);
} }
......
...@@ -14,6 +14,10 @@ import java.util.*; ...@@ -14,6 +14,10 @@ import java.util.*;
@Slf4j @Slf4j
public class MyTeamDateUtils { public class MyTeamDateUtils {
public static SimpleDateFormat getRadableDate() {
return new SimpleDateFormat("dd-MMM-yyyy");
}
public static Date getYesterdayDate() { public static Date getYesterdayDate() {
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1); cal.add(Calendar.DATE, -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