Commit ade1a202 authored by Prayas Jain's avatar Prayas Jain

Added delete functionality

parent c1fa3b8d
......@@ -50,7 +50,6 @@ public class ResourceService implements IResourceService {
public HashMap<String, Object> respMap = new HashMap<>();
private Resource getLatestAllocation(List<Resource> resourceAllocList) {
Resource latestAlloc = null;
if (!resourceAllocList.isEmpty()) {
......@@ -71,13 +70,14 @@ public class ResourceService implements IResourceService {
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
Resource prevAllocation = getLatestAllocation(resourceAllocationList.stream().filter(r -> isAllocationActiveToday(r)).collect(Collectors.toList()));
Resource prevAllocation = getLatestAllocation(
resourceAllocationList.stream().filter(r -> isAllocationActiveToday(r)).collect(Collectors.toList()));
Resource resourcePers = null;
if(prevAllocation != null){
if (prevAllocation != null) {
prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
this.updateExistedResource(prevAllocation); //updateLatestProjectAllocationToEnd
resourcePers = resourceRepo.save(resourceReq); //createNewProjectAllocationtoStart
this.updateExistedResource(prevAllocation); // updateLatestProjectAllocationToEnd
resourcePers = resourceRepo.save(resourceReq); // createNewProjectAllocationtoStart
}
return resourcePers;
}
......@@ -96,7 +96,6 @@ public class ResourceService implements IResourceService {
return isExists;
}
public void updateResourceDetails(Resource resourceReq, String loginEmpId) throws MyTeamException {
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
......@@ -127,30 +126,35 @@ public class ResourceService implements IResourceService {
Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) {
if(!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.RELEASED_STATUS)){
Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if (!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.RELEASED_STATUS)) {
Resource latestAllocation = this
.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&&
!latestAllocation.getBillingStartDate().after(resourceReq.getBillingEndDate())) {
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{
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
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.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);
}
}else{
} else {
respMap.put("statusCode", 811);
respMap.put("message", "Resource is already released from you, And you can't update this allocation");
}
......@@ -186,7 +190,8 @@ public class ResourceService implements IResourceService {
public boolean validateAllocationAgainstPrevAllocation(Resource resourceReq) {
boolean isValid = true;
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),
resourceReq.getProjectId());
Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) {
if (!prevAllocation.getBillingStartDate().before(resourceReq.getBillingStartDate())) {
......@@ -203,7 +208,8 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId) throws MyTeamException {
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId)
throws MyTeamException {
boolean isValid = true;
......@@ -226,7 +232,10 @@ public class ResourceService implements IResourceService {
log.info("ResourceALloc Req::" + resource);
log.info("" + project.getProjectEndDate().toString());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
// if
// (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())||
// !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate()))
// {
if (!(resource.getBillingEndDate().compareTo(project.getProjectEndDate()) <= 0)) {
log.info("Billing end date should be on or before Project End Date.");
respMap.put("statusCode", 813);
......@@ -238,7 +247,6 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean validateBillingStartDateAgainstDOJ(Resource resource) {
String message = "";
boolean isValid = true;
......@@ -256,51 +264,58 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean isResourceAvailable(Resource resourceReq) {
boolean isAssigned = true;
String message = "";
List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()); //getting all allocations of employee
Resource resourceLatestRecord = getLatestAllocation(resourceAllocList.stream().
filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList())); //getting latest allocation of employee in bench project
if (resourceLatestRecord != null && !isAllocationActiveToday(resourceLatestRecord)){
Resource latestProjectResource = getLatestAllocation(resourceAllocList.stream().
filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
if(!resourceReq.getProjectId().equalsIgnoreCase(latestProjectResource.getProjectId())) {
List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()); // getting all
// allocations
// of employee
Resource resourceLatestRecord = getLatestAllocation(
resourceAllocList.stream().filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList())); // getting latest allocation of employee in bench project
if (resourceLatestRecord != null && !isAllocationActiveToday(resourceLatestRecord)) {
Resource latestProjectResource = getLatestAllocation(resourceAllocList.stream()
.filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList()));
if (!resourceReq.getProjectId().equalsIgnoreCase(latestProjectResource.getProjectId())) {
message = "Resource " + latestProjectResource.getEmployeeId() + " already Assigned to the "
+ projectService.getProjectByProjectId(latestProjectResource.getProjectId()).getProjectName()
+ " Project" + " from " + latestProjectResource.getBillingStartDate() + "to " + latestProjectResource.getBillingEndDate();
+ " Project" + " from " + latestProjectResource.getBillingStartDate() + "to "
+ latestProjectResource.getBillingEndDate();
isAssigned = false;
respMap.put("statusCode", 815);
respMap.put("message", message);
}
}else{
if(!validateResourceBillingEndDateAgainstBench(resourceReq)){
} else {
if (!validateResourceBillingEndDateAgainstBench(resourceReq)) {
isAssigned = false;
}
}
return isAssigned;
}
public boolean validateResourceBillingEndDateAgainstBench(Resource resourceReq){
public boolean validateResourceBillingEndDateAgainstBench(Resource resourceReq) {
boolean isValid = true;
String message = "";
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),MyTeamUtils.BENCH_PROJECT_ID);
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),
MyTeamUtils.BENCH_PROJECT_ID);
Resource resourceBenchLatestRecord = getLatestAllocation(resourceAllocList.stream().
filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
Resource resourceBenchLatestRecord = getLatestAllocation(
resourceAllocList.stream().filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList()));
if(!isAllocationActiveToday(resourceBenchLatestRecord)){
if (!isAllocationActiveToday(resourceBenchLatestRecord)) {
isValid = false;
message = "Resource is not available for allocation";
}else if(!(resourceReq.getBillingEndDate().before(resourceBenchLatestRecord.getBillingEndDate()) &&
resourceReq.getBillingStartDate().after(resourceBenchLatestRecord.getBillingStartDate()))){
message = "Resource is available from "+resourceBenchLatestRecord.getBillingStartDate()+" to "+resourceBenchLatestRecord.getBillingEndDate();
} else if (!(resourceReq.getBillingEndDate().before(resourceBenchLatestRecord.getBillingEndDate())
&& resourceReq.getBillingStartDate().after(resourceBenchLatestRecord.getBillingStartDate()))) {
message = "Resource is available from " + resourceBenchLatestRecord.getBillingStartDate() + " to "
+ resourceBenchLatestRecord.getBillingEndDate();
isValid = false;
}
respMap.put("statusCode", 810);
......@@ -308,30 +323,38 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean isAllocationActiveToday(Resource resource){
public boolean isAllocationActiveToday(Resource resource) {
boolean isActive = true;
if(resource.getBillingStartDate().compareTo(new Date()) <=0 &&
resource.getBillingEndDate().compareTo(new Date())>=0){
if (resource.getBillingStartDate().compareTo(new Date()) <= 0
&& resource.getBillingEndDate().compareTo(new Date()) >= 0) {
isActive = true;
}else{
} else {
isActive = false;
}
return isActive;
}
public void deleteResource(Resource resourceReq, String loginEmpId) {
resourceRepo.delete(resourceReq);
}
public void deleteAndUpdateAllocation(Resource resourceReq,String loginEmpId){
public void deleteAndUpdateAllocation(Resource resourceReq, String loginEmpId) {
List<Resource> empAllAllocations = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
Resource latestAllocation = this.getLatestAllocation(empAllAllocations.stream().filter(r -> !r.getId().equals(resourceReq.getId())).collect(Collectors.toList()));
if(latestAllocation != null && latestAllocation.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)){
latestAllocation.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
Resource latestAllocation = this.getLatestAllocation(empAllAllocations.stream()
.filter(r -> !r.getId().equals(resourceReq.getId())).collect(Collectors.toList()));
Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) {
if (latestAllocation != null
&& latestAllocation.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)) {
latestAllocation.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
this.updateExistedResource(latestAllocation);
this.deleteResource(resourceReq,loginEmpId);
}
this.deleteResource(resourceReq, loginEmpId);
}else {
respMap.put("statusCode", 811);
respMap.put("message", "Record Not Found");
}
}
......@@ -340,7 +363,6 @@ public class ResourceService implements IResourceService {
return resourceRepo.findAll();
}
public List<ResourceVO> getAllResourcesVO() {
return getAllResources().stream().map(resource -> {
......@@ -373,7 +395,8 @@ public class ResourceService implements IResourceService {
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
// Account
// account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
......@@ -414,7 +437,6 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
public List<ResourceVO> prepareProjectTeamMembersList(String projectId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
......@@ -454,7 +476,6 @@ public class ResourceService implements IResourceService {
return resourceRepo.findByProjectId(projectId);
}
@Override
public List<Resource> getAllResourcesForAllActiveProjects() {
List<Resource> resourceList = new ArrayList<>();
......@@ -466,7 +487,6 @@ public class ResourceService implements IResourceService {
return resourceList;
}
@Override
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>();
......@@ -478,7 +498,8 @@ public class ResourceService implements IResourceService {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO
.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setResourceRole(resource.getResourceRole());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
......@@ -491,12 +512,12 @@ public class ResourceService implements IResourceService {
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
// Active
if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) >= 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
resourcesList.add(resourceVO);
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) < 0) {
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus())
&& billingEndDate.compareTo(new Date()) < 0) {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
resourcesList.add(resourceVO);
} else if (statusFlag.equals(MyTeamUtils.BOTH))
......@@ -508,7 +529,6 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
@Override
public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId) {
......@@ -520,7 +540,8 @@ public class ResourceService implements IResourceService {
List<Resource> resourcesAllocatedList = resourceRepo.findByEmployeeId(empId);
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty()
&& MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
for (Resource resourceAlloc : resourcesAllocatedList) {
project = projectService.getProjectByProjectId(resourceAlloc.getProjectId());
......@@ -555,7 +576,6 @@ public class ResourceService implements IResourceService {
return myProjectList;
}
@Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>();
......@@ -575,15 +595,17 @@ public class ResourceService implements IResourceService {
}
@Override
public List<ResourceVO> getBillingsForEmployee(String empId) {
List<ResourceVO> finalList = new ArrayList<>();
List<Resource> resourcesList = resourceRepo.findByEmployeeId(empId);
if (resourcesList != null && resourcesList.size() > 0) {
log.info("The resources billing list before sorting::" + resourcesList);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<Resource> sortedList = resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
// return
// billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<Resource> sortedList = resourcesList.stream()
.sorted(Comparator.comparing(Resource::getBillingStartDate).reversed())
.collect(Collectors.toList());
finalList = convertResourcesToResourcesVO(sortedList);
}
......@@ -597,13 +619,14 @@ public class ResourceService implements IResourceService {
if (resourcesList == null || resourcesList.size() == 0) {
return resourcesList;
} else {
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
// return
// billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed())
.collect(Collectors.toList());
}
}
@Override
public List<Employee> getUnAssignedEmployees() {
......@@ -625,7 +648,6 @@ public class ResourceService implements IResourceService {
return notAssignedEmployees;
}
public void deleteResourcesUnderProject(String projectId) {
Query query = new Query(Criteria.where("projectId").is(projectId));
List<Resource> list = mongoTemplate.find(query, Resource.class);
......@@ -633,7 +655,6 @@ public class ResourceService implements IResourceService {
resourceRepo.delete(list);
}
private List<ResourceVO> convertResourcesToResourcesVO(List<Resource> resourcesList) {
List<ResourceVO> finalList = new ArrayList<>();
......@@ -668,7 +689,8 @@ public class ResourceService implements IResourceService {
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
// Account
// account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
......@@ -687,7 +709,6 @@ public class ResourceService implements IResourceService {
return finalList;
}
@Override
public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException {
Resource resourcePersisted = null;
......@@ -697,17 +718,18 @@ public class ResourceService implements IResourceService {
resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setResourceRole(employee.getRole());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);
resourceBench.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date());
resourceBench
.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date());
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourceBench.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourcePersisted = addResource(resourceBench, loginEmpId);
return resourcePersisted;
}
@Override
public List<EmployeeShiftsVO> getResourcesForShift(String shift) {
List<Resource> resourcesListPers = null;
......@@ -742,13 +764,14 @@ public class ResourceService implements IResourceService {
if (employee != null) {
if (shift.equalsIgnoreCase(employee.getShift()))
resourcesList.add(shiftsVO);
else if (employee.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
else if (employee.getShift() == null
&& Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
resourcesList.add(shiftsVO);
}
}
}//for
} // for
}
}
......@@ -762,7 +785,6 @@ public class ResourceService implements IResourceService {
}
@Override
public List<Resource> getResourcesByBillingStatus(String resourceStatus) {
return resourceRepo.findByBillableStatus(resourceStatus);
......@@ -782,12 +804,14 @@ public class ResourceService implements IResourceService {
for (Resource resource : resourcesList) {
ReserveReportsVO reserveReportsVO = new ReserveReportsVO();
reserveReportsVO.setEmployeeId(resource.getEmployeeId());
reserveReportsVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
reserveReportsVO
.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
reserveReportsVO.setProjectName(project.getProjectName());
reserveReportsVO.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
reserveReportsVO
.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
......@@ -803,11 +827,10 @@ public class ResourceService implements IResourceService {
}
@Override
public List<Resource> getResourceByProjectId(String projectId){
public List<Resource> getResourceByProjectId(String projectId) {
return resourceRepo.findByProjectId(projectId);
}
public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr) {
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
......@@ -845,11 +868,9 @@ public class ResourceService implements IResourceService {
// }catch (Exception e){}
//
return null;
}
public boolean validateResourceAllocationStatus(ResourceAllocationStatus resourceStatus) {
boolean isValidStatus = false;
switch (resourceStatus) {
......@@ -868,7 +889,6 @@ public class ResourceService implements IResourceService {
return isValidStatus;
}
public List<Resource> getResourcesGreaterThanBillingStartDate(Date billingStartDate) {
return resourceRepo.findByBillingStartDateGreaterThan(billingStartDate);
}
......@@ -884,23 +904,26 @@ public class ResourceService implements IResourceService {
Project project = null;
//Setting Current Billing details.
// Setting Current Billing details.
AllocationChangeVO allocationVO = new AllocationChangeVO();
allocationVO.setEmployeeId(resource.getEmployeeId());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
allocationVO.setEmployeeName(
employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setCurrentAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
allocationVO.setCurrentBillingStatus(resource.getBillableStatus());
allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate());
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(), MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()));
Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(),
MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()));
log.info("\n\n\n The prev billing info is::" + prevBilling);
if (prevBilling != null) {
......@@ -908,7 +931,8 @@ public class ResourceService implements IResourceService {
project = projectService.getProjectByProjectId(prevBilling.getProjectId());
if (project != null) {
allocationVO.setPrevProjectName(project.getProjectName());
allocationVO.setPrevAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setPrevAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
allocationVO.setPrevBillingStatus(prevBilling.getBillableStatus());
......@@ -929,13 +953,15 @@ public class ResourceService implements IResourceService {
AllocationChangeVO allocationVO = new AllocationChangeVO();
allocationVO.setEmployeeId(resource.getEmployeeId());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
allocationVO
.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setCurrentAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
......@@ -951,13 +977,13 @@ public class ResourceService implements IResourceService {
return allocationList;
}
@Override
public Set<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus).stream().filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
return resourceRepo.findByBillableStatus(billableStatus).stream()
.filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
}
public Resource sendResourceToOpenPool(Resource resource,String loginId) {
public Resource sendResourceToOpenPool(Resource resource, String loginId) {
Resource existingresource = resourceRepo.findById(resource.getId());
existingresource.setStatus(MyTeamUtils.RELEASED_STATUS);
this.updateExistedResource(existingresource);
......@@ -969,7 +995,8 @@ public class ResourceService implements IResourceService {
benchResource.setEmployeeId(resource.getEmployeeId());
benchResource.setResourceRole(resource.getResourceRole());
benchResource.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resource.getBillingEndDate()));
benchResource.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
benchResource.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
benchResource.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
benchResource.setStatus(MyTeamUtils.RELEASED_STATUS);
benchResource.setAuditFields(loginId, MyTeamUtils.CREATE);
......@@ -981,66 +1008,56 @@ public class ResourceService implements IResourceService {
@Override
public Resource getCurrentAllocation(String employeeId) {
return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource-> isAllocationActiveToday(resource)).findAny().orElse(getLatestResourceByEmpId(employeeId));
return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource -> isAllocationActiveToday(resource))
.findAny().orElse(getLatestResourceByEmpId(employeeId));
}
}
//class
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
if (resourceList != null && resourceList.size() > 0) {
Resource resourceAlloc=resourceList.get(0);
}
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
ResourceVO resourceVO=new ResourceVO();
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
}
return finalResourcesList;
}
*/
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
if (optionalResource.isPresent()) {
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
}
return finalResourcesList;
}
/*
* @Override public List<ResourceVO> getActiveResources(String empId) {
* List<ResourceVO> finalResourcesList = new ArrayList<>();
*
* List<Resource> resourceList = resourceRepo.findByEmployeeId(empId); if
* (resourceList != null && resourceList.size() > 0) {
*
* Resource resourceAlloc=resourceList.get(0); }
*
* for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
*
* ResourceVO resourceVO=new ResourceVO();
* resourceVO.setEmployeeId(resource.getEmployeeId());
*
* Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
* resourceVO.setEmployeeName(employee.getEmployeeName());
* resourceVO.setDesignation(employee.getDesignation());
* resourceVO.setEmailId(employee.getEmailId());
* resourceVO.setMobileNo(employee.getMobileNumber());
*
* resourceVO.setProjectName(projectService.getProjectByProjectId(resource.
* getProjectId()).getProjectName());
*
*
* if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
* finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()))
* ; }
*
*
* } return finalResourcesList; }
*
*/
/*
*
* @Override public List<ResourceVO> getActiveResources(String empId) {
* List<ResourceVO> finalResourcesList = new ArrayList<>(); Employee employee =
* null;
*
* List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
* Optional<Resource> optionalResource = resourceList.stream().filter(resource
* -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny(); if
* (optionalResource.isPresent()) { finalResourcesList =
* prepareProjectTeamMembersList(optionalResource.get().getProjectId()); }
* return finalResourcesList; }
*
*/
......@@ -392,7 +392,6 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
} else if ($scope.result == "Error") {
showAlert('Something went wrong while deleting the role.')
}
}
function AddProjectController($scope, $mdDialog, dataToPass, gridOptionsData, managers, $window, $mdSelect) {
......@@ -1465,7 +1464,6 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}
else {
updateTeamRecord(record, action,row);
$scope.myForm.$setPristine();
}
}
......@@ -1616,8 +1614,6 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
//Startdate: $scope.startDate,
Enddate: $scope.endDate
}
console.log($scope.previousData)
console.log($scope.currentData)
var predata = JSON.stringify($scope.previousData);
var curdata = JSON.stringify($scope.currentData);
if (predata == curdata) {
......@@ -1839,6 +1835,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
row.resourceRole = $scope.parentData.role;
row.billableStatus = $scope.parentData.billableStatus;
}
$scope.previousRow = angular.copy(row);
}
}, function myError(response){
......
......@@ -40,7 +40,7 @@
</div>
<div class="form-group col-lg-9 col-md-9 col-sm-9 col-xs-12"></div>
<div class="row col-lg-12" style="margin-left: 0px;">
<div class="row col-lg-12 no-padding" style="margin-left: 0px;">
<input type="radio" ng-model="status" value="Active" ng-click="getTeamMates()"> Active
<input type="radio" ng-model="status" value="InActive" ng-click="getTeamMates()"> Inactive
<input type="radio" ng-model="status" value="Proposed" ng-click="getTeamMates()"> Proposed
......
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