From edbf0dae6d1386457fd87b59b161f35e2fff99ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Fri, 12 Aug 2011 12:35:40 +0200 Subject: [PATCH] [Bug #1138] Fix bug In the case that the interval was the same as the task and the start was in the middle of a day, some hours were being losed. FEA: ItEr75S04BugFixing --- .../planner/entities/ResourceAllocation.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java index 0c13b4e50..b5a08c87e 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/ResourceAllocation.java @@ -2002,6 +2002,8 @@ public abstract class ResourceAllocation extends List assignments, final IntraDayDate startInclusive, final IntraDayDate endExclusive) { + final IntraDayDate allocationStart = getIntraDayStartDate(); + return EffortDuration.sum(assignments, new IEffortFrom() { @@ -2030,6 +2032,28 @@ public abstract class ResourceAllocation extends result = new PartialDay(result.getStart(), endExclusive); } + return adjustPartialDayToAllocationStart(result); + } + + // if the start of the allocation is in the middle of a day, + // its work also starts later; so the PartialDay must be + // moved to earlier so it doesn't limit the duration more + // that it should + private PartialDay adjustPartialDayToAllocationStart( + PartialDay day) { + PartialDay result = day; + if (allocationStart.areSameDay(day.getDate())) { + EffortDuration substractingAtStart = day.getStart() + .getEffortDuration(); + EffortDuration newSubstractionAtStart = substractingAtStart + .minus(EffortDuration + .min(substractingAtStart, + allocationStart + .getEffortDuration())); + IntraDayDate newStart = IntraDayDate.create( + day.getDate(), newSubstractionAtStart); + result = new PartialDay(newStart, day.getEnd()); + } return result; } });