From 7e0295166c2a01b29c3bb235b3439a2c42b3610a Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Tue, 18 Sep 2012 19:01:46 +0200 Subject: [PATCH] Bug #1529: Avoid exception in Cost tab in project details The problem is that SumChargedEffort is null when it shouldn't, so the order is marked to be recalculated if this is the case. This is a workaround for the issue described in the bug #1529, while we're not able to reproduce the problem. FEA: ItEr77S04BugFixing --- .../web/orders/AssignedHoursToOrderElementModel.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedHoursToOrderElementModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedHoursToOrderElementModel.java index 2bf1a2128..73c630a77 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedHoursToOrderElementModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedHoursToOrderElementModel.java @@ -197,9 +197,15 @@ public class AssignedHoursToOrderElementModel implements IAssignedHoursToOrderEl if (orderElement.getChildren().isEmpty()) { return EffortDuration.zero(); } - EffortDuration assignedDirectChildren = getTotalAssignedEffort().minus( - this.assignedDirectEffort); - return assignedDirectChildren; + EffortDuration totalAssignedEffort = getTotalAssignedEffort(); + // FIXME Once we're able to reproduce and fix the cause of bugs like + // #1529, we could remove this if + if (totalAssignedEffort.compareTo(assignedDirectEffort) < 0) { + orderElement.getOrder() + .markAsNeededToRecalculateSumChargedEfforts(); + return EffortDuration.zero(); + } + return totalAssignedEffort.minus(this.assignedDirectEffort); } @Override