Bug #1502: Fix NPE in deviation indicator
It has been reviewed the behavior of "Estimation deviation on completed tasks" chart in order to fulfill the next requirements: * No hours reported: The task is not taken into account * No allocation: It uses the estimated hours * No estimated hours: The task is not taken into account FEA: ItEr76S04BugFixing
This commit is contained in:
parent
c1f9ca8804
commit
cf95c33b2c
1 changed files with 15 additions and 9 deletions
|
|
@ -28,6 +28,7 @@ package org.libreplan.business.planner.entities.visitors;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.libreplan.business.orders.entities.SumChargedEffort;
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
import org.libreplan.business.planner.entities.TaskElement;
|
||||
import org.libreplan.business.planner.entities.TaskGroup;
|
||||
|
|
@ -52,15 +53,20 @@ public class CalculateFinishedTasksEstimationDeviationVisitor extends TaskElemen
|
|||
|
||||
public void visit(Task task) {
|
||||
if (task.isFinished()) {
|
||||
int allocatedHours = task.getAssignedHours();
|
||||
if (allocatedHours > 0) {
|
||||
EffortDuration spentEffort = task.getOrderElement()
|
||||
.getSumChargedEffort().getTotalChargedEffort();
|
||||
deviations.add(new Double(
|
||||
((1.0*spentEffort.getHours() -
|
||||
allocatedHours)/allocatedHours)*100));
|
||||
} else {
|
||||
deviations.add(new Double(0.0));
|
||||
int hours = task.getAssignedHours();
|
||||
if (hours == 0) {
|
||||
hours = task.getOrderElement().getWorkHours();
|
||||
}
|
||||
if (hours != 0) {
|
||||
SumChargedEffort sumChargedEffort = task.getOrderElement()
|
||||
.getSumChargedEffort();
|
||||
EffortDuration spentEffort = sumChargedEffort == null ? EffortDuration
|
||||
.zero() : sumChargedEffort.getTotalChargedEffort();
|
||||
if (!spentEffort.isZero()) {
|
||||
deviations
|
||||
.add(new Double(
|
||||
((1.0 * spentEffort.getHours() - hours) / hours) * 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue