Fix booking snapshot lazy loading
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -18,14 +18,14 @@ class BookingSnapshotBuilder(
|
||||
private val guestVehicleRepo: GuestVehicleRepo
|
||||
) {
|
||||
fun build(propertyId: UUID, bookingId: UUID): BookingDetailResponse {
|
||||
val booking = bookingRepo.findById(bookingId).orElseThrow {
|
||||
val booking = bookingRepo.findDetailedById(bookingId).orElseThrow {
|
||||
ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found")
|
||||
}
|
||||
if (booking.property.id != propertyId) {
|
||||
throw ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found for property")
|
||||
}
|
||||
|
||||
val stays = roomStayRepo.findByBookingId(bookingId)
|
||||
val stays = roomStayRepo.findByBookingIdWithRoom(bookingId)
|
||||
val activeRooms = stays.filter { it.toAt == null }
|
||||
val roomsToShow = activeRooms.ifEmpty { stays }
|
||||
val roomNumbers = roomsToShow.map { it.room.roomNumber }
|
||||
|
||||
Reference in New Issue
Block a user