Commit fd34d593 authored by Md Suleman's avatar Md Suleman

updated logic to get letest alocation record

parent 88dd77ec
...@@ -51,17 +51,20 @@ public class ResourceService implements IResourceService { ...@@ -51,17 +51,20 @@ public class ResourceService implements IResourceService {
private Resource getLatestAllocation(List<Resource> resourceAllocList){ private Resource getLatestAllocation(List<Resource> resourceAllocList){
Resource latestAlloc = resourceAllocList.get(0); Resource latestAlloc = null;
for (Resource resource:resourceAllocList){ if(!resourceAllocList.isEmpty()) {
if(latestAlloc.getBillingEndDate().before(resource.getBillingEndDate())) latestAlloc = resourceAllocList.get(0);
for (Resource resource : resourceAllocList) {
if (latestAlloc.getBillingEndDate().before(resource.getBillingEndDate()))
latestAlloc = resource; latestAlloc = resource;
} }
}
return latestAlloc; return latestAlloc;
} }
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException { public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId()); List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
Resource prevAllocation = this.getLatestAllocation(resourceAllocList); Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) { if (prevAllocation != null) {
if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) { if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
......
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