[Bug #1326] Fix issue calculating properly hours to allocate

The issue was introduced in commit a998367bec
while trying to fix a different problem in interpolation function.

The patch has been reverted and both issues fixed now.

Once the patch was reverted, the number of remaining hours was wrong calculated
as if it was 0 it returns the allocated hours instead of 0.

FEA: ItEr76S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-01-04 13:42:28 +01:00
parent ca5b86841b
commit 23d8c3b972

View file

@ -85,13 +85,22 @@ public enum StretchesFunctionTypeEnum {
// must be distributed.
int[] assignedHours = getAssignedHours(allocation, startInclusive, newEndDate);
int[] remindingHours = distributeRemainder(allocation, startInclusive, totalHours, assignedHours);
allocateDaysFrom(allocation, asEffortDuration(remindingHours),
int[] hoursToAllocate = sum(assignedHours, remindingHours);
allocateDaysFrom(allocation, asEffortDuration(hoursToAllocate),
startInclusive);
assignedHours = getAssignedHours(allocation, startInclusive, newEndDate);
Validate.isTrue(sum(assignedHours) == totalHours);
}
private int[] sum(int[] assignedHours, int[] remindingHours) {
Validate.isTrue(assignedHours.length == remindingHours.length);
for (int i = 0; i < assignedHours.length; i++) {
assignedHours[i] += remindingHours[i];
}
return assignedHours;
}
private int[] getAssignedHours(ResourceAllocation<?> allocation,
LocalDate startInclusive, LocalDate endExclusive) {
@ -127,7 +136,7 @@ public enum StretchesFunctionTypeEnum {
int[] reallyAssigned) {
final int remainder = totalHours - sum(reallyAssigned);
if (remainder == 0) {
return reallyAssigned;
return new int[reallyAssigned.length];
}
return distributeRemainder(reallyAssigned, remainder);
}