From af2d856b327030733638ebc5bbc8d6fcae7bbb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Tue, 21 Aug 2012 17:49:11 +0200 Subject: [PATCH] Prevent losing precision in TaskElementAdapter.calculateLimitDateByHours() FEA: ItEr76S04BugFixing --- .../libreplan/web/planner/TaskElementAdapter.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java index 751dcfd2e..0a83dc99b 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java @@ -21,7 +21,7 @@ package org.libreplan.web.planner; -import static org.libreplan.business.workingday.EffortDuration.hours; +import static org.libreplan.business.workingday.EffortDuration.fromHoursAsBigDecimal; import static org.libreplan.business.workingday.EffortDuration.min; import static org.libreplan.business.workingday.EffortDuration.seconds; import static org.libreplan.business.workingday.EffortDuration.zero; @@ -564,7 +564,7 @@ public class TaskElementAdapter { GanttDate result = null; if (!(taskElement instanceof TaskGroup)) { result = calculateLimitDateByHours(assignedEffort - .toHoursAsDecimalWithScale(2).intValue()); + .toHoursAsDecimalWithScale(2)); } if (result == null) { @@ -746,8 +746,8 @@ public class TaskElementAdapter { } // Calculate date according to advanceHours or advancePercentage - final Integer advanceHours = advancePercentage.multiply( - hours).intValue(); + final BigDecimal advanceHours = advancePercentage + .multiply(hours); GanttDate result = calculateLimitDateByHours(advanceHours); if (result == null) { result = calculateLimitDateByPercentage(advancePercentage); @@ -826,11 +826,11 @@ public class TaskElementAdapter { return toGantt(end); } - private GanttDate calculateLimitDateByHours(Integer hours) { - if (hours == null || hours == 0) { + private GanttDate calculateLimitDateByHours(BigDecimal hours) { + if (hours == null || hours.compareTo(BigDecimal.ZERO) == 0) { return null; } - EffortDuration hoursLeft = hours(hours); + EffortDuration hoursLeft = fromHoursAsBigDecimal(hours); IntraDayDate result = null; EffortDuration effortLastDayNotZero = zero();