Skip to content

Commit

Permalink
when create rental, returnDate time sets 30 minutes after rentalDate …
Browse files Browse the repository at this point in the history
…time
  • Loading branch information
dima-semeniuk committed Jan 17, 2024
1 parent 9afc7cb commit 082541c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jwt.expiration=300000
jwt.secret=hello/csadf65JKHGsdfKd/111222333444556677asfKuyGudJKIUYTeK

management.endpoint.health.show-details=always

0 comments on commit 082541c

Please sign in to comment.