From 475f5c7c0f5e525e97e71e3b5ec066425fd7931d Mon Sep 17 00:00:00 2001 From: Diego Pino Garcia Date: Mon, 7 Mar 2011 18:19:33 +0100 Subject: [PATCH] [Bug #908] Total amount of allocated hours miscalculated in lineal interpolation (Streches function) As the end is exclusive, it's needed to increment the endDate in one day for the last Stretch FEA: ItEr72S04BugFixing --- .../business/planner/entities/StretchesFunction.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java index 640855aec..ad74736c7 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java @@ -255,11 +255,15 @@ public class StretchesFunction extends AssignmentFunction { } private void apply(ResourceAllocation resourceAllocation, - LocalDate startInclusive, LocalDate endExclusive, + LocalDate startInclusive, LocalDate taskEnd, int intervalHours) { + // End has to be exclusive on last Stretch + LocalDate endDate = getEnd(); + if (endDate.equals(taskEnd)) { + endDate = endDate.plusDays(1); + } resourceAllocation.withPreviousAssociatedResources() - .onIntervalWithinTask(getStartFor(startInclusive), - getEnd()) + .onIntervalWithinTask(getStartFor(startInclusive), endDate) .allocateHours(intervalHours); } @@ -279,7 +283,7 @@ public class StretchesFunction extends AssignmentFunction { interval.apply(allocation, allocationStart, allocationEnd, hoursPerInterval[i++]); } - + Validate.isTrue(totalHours == allocation.getAssignedHours()); } private static int[] getHoursPerInterval(