Now can allocate some hours from end of the task to some date
This commit is contained in:
parent
9d0bc64dd9
commit
8596aeef8a
4 changed files with 37 additions and 1 deletions
|
|
@ -34,4 +34,6 @@ public interface IAllocatable extends IAllocateResourcesPerDay {
|
|||
|
||||
public IAllocateHoursOnInterval fromStartUntil(LocalDate endExclusive);
|
||||
|
||||
public IAllocateHoursOnInterval fromEndUntil(LocalDate start);
|
||||
|
||||
}
|
||||
|
|
@ -592,10 +592,28 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllocateHoursOnInterval fromEndUntil(final LocalDate start) {
|
||||
return new IAllocateHoursOnInterval() {
|
||||
|
||||
@Override
|
||||
public void allocateHours(int hours) {
|
||||
allocate(IntraDayDate.startOfDay(start),
|
||||
task.getIntraDayEndDate(), hours(hours));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void allocate(LocalDate end, EffortDuration durationToAssign) {
|
||||
IntraDayDate startInclusive = getStartAfterConsolidated();
|
||||
IntraDayDate endExclusive = IntraDayDate.startOfDay(end);
|
||||
allocate(startInclusive, endExclusive, durationToAssign);
|
||||
}
|
||||
|
||||
private void allocate(IntraDayDate startInclusive,
|
||||
IntraDayDate endExclusive, EffortDuration durationToAssign) {
|
||||
List<T> assignmentsCreated = createAssignments(startInclusive,
|
||||
IntraDayDate.startOfDay(end), durationToAssign);
|
||||
endExclusive, durationToAssign);
|
||||
resetAssignmentsTo(assignmentsCreated);
|
||||
updateResourcesPerDay();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ public class SpecificResourceAllocation extends
|
|||
return new SpecificAssignmentsAllocation().fromStartUntil(endExclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllocateHoursOnInterval fromEndUntil(LocalDate start) {
|
||||
return new SpecificAssignmentsAllocation().fromEndUntil(start);
|
||||
}
|
||||
|
||||
private final class SpecificAssignmentsAllocation extends
|
||||
AssignmentsAllocation {
|
||||
|
||||
|
|
|
|||
|
|
@ -305,6 +305,17 @@ public class SpecificResourceAllocationTest {
|
|||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canAssignFromEndUntilStart() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
givenSpecificResourceAllocation(start, 4);
|
||||
specificResourceAllocation.fromEndUntil(start).allocateHours(32);
|
||||
assertThat(specificResourceAllocation.getAssignments(),
|
||||
haveHours(8, 8, 8, 8));
|
||||
assertThat(specificResourceAllocation.getResourcesPerDay(),
|
||||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canBeNotifiedWhenADayAssignmentIsRemoved() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue