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 {
private Resource getLatestAllocation(List<Resource> resourceAllocList){
Resource latestAlloc = resourceAllocList.get(0);
for (Resource resource:resourceAllocList){
if(latestAlloc.getBillingEndDate().before(resource.getBillingEndDate()))
Resource latestAlloc = null;
if(!resourceAllocList.isEmpty()) {
latestAlloc = resourceAllocList.get(0);
for (Resource resource : resourceAllocList) {
if (latestAlloc.getBillingEndDate().before(resource.getBillingEndDate()))
latestAlloc = resource;
}
}
return latestAlloc;
}
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) {
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