Skip to content

Commit

Permalink
refactor: Invoice 생성 위치 이동 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
astraum committed Jun 9, 2022
1 parent 5930685 commit 4227aac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public ReservationElement make(ReservationRequest reservationRequest) {
Accommodation accommodation = retrieveAccommodation(
reservationRequest.getAccommodationId());

Invoice invoice = Invoice.calculate(accommodation.getPrice(),
reservationRequest.getLengthOfStay());

Reservation reservation = reservationRequest.toReservation(invoice, accommodation,
Reservation reservation = reservationRequest.toReservation(accommodation,
customer);

reservation = reservationRepository.save(reservation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public Integer getLengthOfStay() {
return Math.toIntExact(ChronoUnit.DAYS.between(checkInDate, checkOutDate));
}

public Reservation toReservation(Invoice invoice, Accommodation accommodation,
public Reservation toReservation(Accommodation accommodation,
Customer customer) {
return Reservation.builder()
.checkInDate(checkInDate)
.checkOutDate(checkOutDate)
.numberOfGuest(numberOfGuest)
.numberOfInfant(numberOfInfant)
.invoice(invoice)
.invoice(Invoice.calculate(accommodation.getPrice(), getLengthOfStay()))
.accommodation(accommodation)
.customer(customer)
.build();
Expand Down

0 comments on commit 4227aac

Please sign in to comment.