From b4de7e098ed5f8c62c0604d65cab75a7d7642cbb Mon Sep 17 00:00:00 2001 From: Diego Pino Garcia Date: Mon, 27 Dec 2010 12:04:10 +0100 Subject: [PATCH] Fix bug in getHoursInGapUntilAllocatingAndGoingToTheEnd(), don't add 0 hour days if the total number of hours to allocate were already completed FEA: ItEr66OTS08CorreccionsRecursosLimitantesItEr65OTS04 --- .../business/planner/limiting/entities/Gap.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/limiting/entities/Gap.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/limiting/entities/Gap.java index 568afc800..6f5aae921 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/limiting/entities/Gap.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/limiting/entities/Gap.java @@ -184,9 +184,15 @@ public class Gap implements Comparable { while (daysUntilEnd.hasNext()) { PartialDay each = daysUntilEnd.next(); int hoursAtDay = calendar.getCapacityOn(each).roundToHours(); - int hours = Math.min(hoursAtDay, total); + int hours = Math.min(hoursAtDay, total); total -= hours; - result.add(hours); + + // Don't add hours when total and hours are zero (it'd be like + // adding an extra 0 hour day when total is completed) + if (total != 0 || hours != 0) { + result.add(hours); + } + if (total == 0 && DateAndHour.from(each.getDate()) .compareTo(allocationEnd) >= 0) {