Bug #1329: Fix issue calculating properly end date of stretches

The problem was that when a task finishes in a complete day, that means, task
end date is the next day with zero effort. In this situation, the stretches
calculation was enlarging 1 day more the task itself which causes the issue
reported in this bug.

FEA: ItEr76S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-01-11 16:25:59 +01:00
parent 6b657a8791
commit 65b24f8099
2 changed files with 8 additions and 5 deletions

View file

@ -1922,7 +1922,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return null;
}
DayAssignment lastAssignment = assignments.get(assignments.size() - 1);
return lastAssignment.getDay().plusDays(1);
return IntraDayDate.create(lastAssignment.getDay(),
lastAssignment.getDuration()).asExclusiveEnd();
}
public boolean isAlreadyFinishedBy(LocalDate date) {

View file

@ -22,6 +22,7 @@
package org.libreplan.business.planner.entities;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@ -46,16 +47,17 @@ public class Stretch {
public static LocalDate getDateByLengthProportion(
ResourceAllocation<?> allocation, BigDecimal lengthProportion) {
int allocationDuration = Days.daysBetween(allocation.getStartDate(),
allocation.getEndDate()).getDays();
int days = lengthProportion.multiply(
BigDecimal.valueOf(allocationDuration)).intValue();
allocation.getIntraDayEndDate().asExclusiveEnd()).getDays();
int days = lengthProportion
.multiply(BigDecimal.valueOf(allocationDuration))
.setScale(0, RoundingMode.HALF_UP).intValue();
return allocation.getStartDate().plusDays(days);
}
public static BigDecimal getLengthProportionByDate(
ResourceAllocation<?> allocation, LocalDate date) {
int allocationDuration = Days.daysBetween(allocation.getStartDate(),
allocation.getEndDate()).getDays();
allocation.getIntraDayEndDate().asExclusiveEnd()).getDays();
int days = Days.daysBetween(allocation.getStartDate(), date).getDays();
return daysProportion(days, allocationDuration);
}