diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java index 2f606e342..73ddd754f 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/IAllocatable.java @@ -88,6 +88,16 @@ public interface IAllocatable extends IAllocateResourcesPerDay { */ public IAllocateEffortOnInterval fromStartUntil(LocalDate endExclusive); + /** + * It allocates the effort specified on the interval from the start, i.e. + * first day not consolidated to the specified end. All previous assignments + * are removed, but the consolidated ones. + * + * @param end + * @return + */ + public IAllocateEffortOnInterval fromStartUntil(IntraDayDate end); + /** * It allocates the effort specified on the interval from the end until the * start. Being the start the maximum of the provided start and the first @@ -99,4 +109,4 @@ public interface IAllocatable extends IAllocateResourcesPerDay { */ public IAllocateEffortOnInterval fromEndUntil(LocalDate start); -} \ No newline at end of file +} diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java index 659e851fb..10a7678f2 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/ResourceAllocation.java @@ -862,6 +862,18 @@ public abstract class ResourceAllocation extends public IAllocateEffortOnInterval fromStartUntil(final LocalDate end) { final AllocationInterval interval = new AllocationInterval( getStartSpecifiedByTask(), IntraDayDate.startOfDay(end)); + return getIAllocateEffortOnInterval(interval); + } + + @Override + public IAllocateEffortOnInterval fromStartUntil(final IntraDayDate end) { + final AllocationInterval interval = new AllocationInterval( + getStartSpecifiedByTask(), end); + return getIAllocateEffortOnInterval(interval); + } + + private IAllocateEffortOnInterval getIAllocateEffortOnInterval( + final AllocationInterval interval) { return new IAllocateEffortOnInterval() { @Override diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java index c443c233f..16b3cc90b 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SpecificResourceAllocation.java @@ -181,6 +181,11 @@ public class SpecificResourceAllocation extends return new SpecificAssignmentsAllocator().fromStartUntil(endExclusive); } + @Override + public IAllocateEffortOnInterval fromStartUntil(IntraDayDate end) { + return new SpecificAssignmentsAllocator().fromStartUntil(end); + } + @Override public IAllocateEffortOnInterval fromEndUntil(LocalDate start) { return new SpecificAssignmentsAllocator().fromEndUntil(start); diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/consolidations/AdvanceConsolidationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/consolidations/AdvanceConsolidationModel.java index 6e101c533..7cbce4ca9 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/consolidations/AdvanceConsolidationModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/consolidations/AdvanceConsolidationModel.java @@ -215,11 +215,11 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel { .getAllResourceAllocations(); withDetachOnDayAssignmentRemoval(allResourceAllocations); - LocalDate endExclusive = LocalDate.fromDateFields(task.getEndDate()); - if (value.getDate().compareTo(endExclusive.minusDays(1)) >= 0) { + IntraDayDate end = task.getIntraDayEndDate(); + if (value.getDate().compareTo(end.getDate().minusDays(1)) >= 0) { reassignExpandingTask(allResourceAllocations); } else { - reassignAll(endExclusive, allResourceAllocations); + reassignAll(end, allResourceAllocations); } } @@ -230,24 +230,24 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel { } } - private void reassignAll(LocalDate endExclusive, + private void reassignAll(IntraDayDate end, Collection> allocations) { for (ResourceAllocation each : allocations) { EffortDuration pendingEffort = consolidation .getNotConsolidated(each.getIntendedTotalAssigment()); - reassign(each, endExclusive, pendingEffort); + reassign(each, end, pendingEffort); } } private void reassign(ResourceAllocation resourceAllocation, - LocalDate endExclusive, EffortDuration pendingEffort) { + IntraDayDate end, EffortDuration pendingEffort) { if (resourceAllocation instanceof SpecificResourceAllocation) { ((SpecificResourceAllocation) resourceAllocation) .allocateWholeAllocationKeepingProportions(pendingEffort, - IntraDayDate.startOfDay(endExclusive)); + end); } else { resourceAllocation.withPreviousAssociatedResources() - .fromStartUntil(endExclusive) + .fromStartUntil(end) .allocate(pendingEffort); } } @@ -327,7 +327,7 @@ public class AdvanceConsolidationModel implements IAdvanceConsolidationModel { .getAllResourceAllocations(); withDetachOnDayAssignmentRemoval(allResourceAllocations); - reassignAll(task.getEndAsLocalDate(), allResourceAllocations); + reassignAll(task.getIntraDayEndDate(), allResourceAllocations); } private void updateConsolidationInAdvanceIfIsNeeded() {