diff --git a/src/main/java/mate/sep23/group3/car/sharing/service/impl/RentalServiceImpl.java b/src/main/java/mate/sep23/group3/car/sharing/service/impl/RentalServiceImpl.java index a1c3a0e..47af1f9 100644 --- a/src/main/java/mate/sep23/group3/car/sharing/service/impl/RentalServiceImpl.java +++ b/src/main/java/mate/sep23/group3/car/sharing/service/impl/RentalServiceImpl.java @@ -1,6 +1,7 @@ package mate.sep23.group3.car.sharing.service.impl; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.List; import lombok.RequiredArgsConstructor; @@ -28,6 +29,7 @@ @Service @RequiredArgsConstructor public class RentalServiceImpl implements RentalService { + private static final int ADD_MINUTES_TO_RETURN_DATE = 30; private static final String CAN_NOT_FIND_RENTAL_BY_ID_MESSAGE = "Can't find rental by ID: "; private static final String CAN_NOT_FIND_CAR_BY_ID_MESSAGE = @@ -116,7 +118,9 @@ private Rental setUpRental(RentalRequestDto requestDto, Long userId) { if (carInventory > 0) { Rental rental = new Rental(); rental.setRentalDate(LocalDateTime.now()); - rental.setReturnDate(requestDto.getReturnDate()); + rental.setReturnDate(requestDto.getReturnDate().with(LocalTime.of( + rental.getRentalDate().getHour(), + rental.getRentalDate().getMinute()).plusMinutes(ADD_MINUTES_TO_RETURN_DATE))); car.setInventory(carInventory - 1); rental.setCar(car); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index bd33cbd..e3dcde8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -24,4 +24,3 @@ jwt.expiration=300000 jwt.secret=hello/csadf65JKHGsdfKd/111222333444556677asfKuyGudJKIUYTeK management.endpoint.health.show-details=always -