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