[Bug #1138] Fix bug

In the case that the interval was the same as the task and the start
was in the middle of a day, some hours were being losed.

FEA: ItEr75S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-08-12 12:35:40 +02:00
parent 2d96c15d73
commit edbf0dae6d

View file

@ -2002,6 +2002,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
List<? extends DayAssignment> assignments, List<? extends DayAssignment> assignments,
final IntraDayDate startInclusive, final IntraDayDate endExclusive) { final IntraDayDate startInclusive, final IntraDayDate endExclusive) {
final IntraDayDate allocationStart = getIntraDayStartDate();
return EffortDuration.sum(assignments, return EffortDuration.sum(assignments,
new IEffortFrom<DayAssignment>() { new IEffortFrom<DayAssignment>() {
@ -2030,6 +2032,28 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
result = new PartialDay(result.getStart(), result = new PartialDay(result.getStart(),
endExclusive); endExclusive);
} }
return adjustPartialDayToAllocationStart(result);
}
// if the start of the allocation is in the middle of a day,
// its work also starts later; so the PartialDay must be
// moved to earlier so it doesn't limit the duration more
// that it should
private PartialDay adjustPartialDayToAllocationStart(
PartialDay day) {
PartialDay result = day;
if (allocationStart.areSameDay(day.getDate())) {
EffortDuration substractingAtStart = day.getStart()
.getEffortDuration();
EffortDuration newSubstractionAtStart = substractingAtStart
.minus(EffortDuration
.min(substractingAtStart,
allocationStart
.getEffortDuration()));
IntraDayDate newStart = IntraDayDate.create(
day.getDate(), newSubstractionAtStart);
result = new PartialDay(newStart, day.getEnd());
}
return result; return result;
} }
}); });