[Bug #1202] Managed division by zero calculating template averages

It's valid to return a 0 value when the the template has never been asigned, so
there are 0 items to calculate the average used time.

Based in previous patch by Lorenzo Tilve Álvaro <ltilve@igalia.com>:
24b0cf6db5

FEA: ItEr75S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2011-10-06 18:23:51 +02:00
parent 961b24c566
commit 8d05620aff

View file

@ -291,7 +291,8 @@ public class OrderElementDAO extends IntegrationEntityDAO<OrderElement>
public EffortDuration calculateAverageWorkedHours(
final List<OrderElement> list) {
EffortDuration sum = sumWorkedHours(list);
return EffortDuration.average(sum, list.size());
return (list.size() == 0) ? EffortDuration.zero() : EffortDuration
.average(sum, list.size());
}
private BigDecimal average(BigDecimal divisor, BigDecimal sum) {