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 6f6b012db..5c2eab504 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 @@ -1922,7 +1922,8 @@ public abstract class ResourceAllocation 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) { diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Stretch.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Stretch.java index 95d3be414..6faf01095 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Stretch.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/Stretch.java @@ -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); }