From 6b07e6c7f66044abf43b951032a37f74ba40f80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Tue, 12 Oct 2010 21:51:16 +0200 Subject: [PATCH] [Bug #676] Fix bug The taken effort must be added to the effort taken by the day. Otherwise if the start date is in the middle of the day and the allocation finishes the same day the calculated end is wrong. FEA: ItEr62S05BugFixing --- ...llocatorForSpecifiedResourcesPerDayAndHours.java | 3 ++- .../entities/AllocationUntilFillingHoursTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/allocationalgorithms/AllocatorForSpecifiedResourcesPerDayAndHours.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/allocationalgorithms/AllocatorForSpecifiedResourcesPerDayAndHours.java index e8b390033..fef537923 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/allocationalgorithms/AllocatorForSpecifiedResourcesPerDayAndHours.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/allocationalgorithms/AllocatorForSpecifiedResourcesPerDayAndHours.java @@ -99,7 +99,8 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours { lastDate = current; taken = assignForDay(resourcesPerDayModification, dayStartingAt(current), effortRemaining); - lastDate = IntraDayDate.create(current.getDate(), taken); + lastDate = IntraDayDate.create(current.getDate(), + taken.plus(current.getEffortDuration())); effortRemaining = effortRemaining.minus(taken); } if (resourcesPerDayModification.isDayFilled(lastDate.getDate(), diff --git a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/AllocationUntilFillingHoursTest.java b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/AllocationUntilFillingHoursTest.java index e1ff6a896..61f00bdde 100644 --- a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/AllocationUntilFillingHoursTest.java +++ b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/AllocationUntilFillingHoursTest.java @@ -135,6 +135,19 @@ public class AllocationUntilFillingHoursTest { equalTo(ResourcesPerDay.amount(1))); } + @Test + public void theEndDateIsCalculatedCorrectlyIfTheStartIsInTheMiddleOfADayAndEndsTheSameDay() { + givenStartDate(IntraDayDate.create(new LocalDate(2009, 10, 10), + EffortDuration.hours(2))); + givenSpecificAllocations(ResourcesPerDay.amount(1)); + ResourceAllocation.allocating(allocations).untilAllocating(4); + ResourceAllocation allocation = allocations.get(0) + .getBeingModified(); + assertThat(allocation.getIntraDayEndDate(), + equalTo(IntraDayDate.create(new LocalDate(2009, 10, 10), + EffortDuration.hours(6)))); + } + @Test public void theResourcesPerDayAreKeptCorrectlyCalculatedAfterUpdatingTheEndInterval() { final ResourcesPerDay oneResourcePerDay = ResourcesPerDay.amount(1);