Remove booking room-stay preassign API
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s
This commit is contained in:
@@ -19,7 +19,6 @@ import com.android.trisolarisserver.controller.dto.booking.BookingExpectedDatesU
|
||||
import com.android.trisolarisserver.controller.dto.booking.BookingLinkGuestRequest
|
||||
import com.android.trisolarisserver.controller.dto.booking.BookingNoShowRequest
|
||||
import com.android.trisolarisserver.controller.dto.booking.BookingListItem
|
||||
import com.android.trisolarisserver.controller.dto.booking.RoomStayPreAssignRequest
|
||||
import com.android.trisolarisserver.repo.booking.BookingRepo
|
||||
import com.android.trisolarisserver.repo.guest.GuestDocumentRepo
|
||||
import com.android.trisolarisserver.repo.guest.GuestRepo
|
||||
@@ -698,55 +697,6 @@ class BookingFlow(
|
||||
bookingEvents.emit(propertyId, bookingId)
|
||||
}
|
||||
|
||||
@PostMapping("/{bookingId}/room-stays")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@Transactional
|
||||
fun preAssignRoom(
|
||||
@PathVariable propertyId: UUID,
|
||||
@PathVariable bookingId: UUID,
|
||||
@AuthenticationPrincipal principal: MyPrincipal?,
|
||||
@RequestBody request: RoomStayPreAssignRequest
|
||||
) {
|
||||
val actor = requireActor(propertyId, principal)
|
||||
val booking = requireBooking(propertyId, bookingId)
|
||||
if (booking.status == BookingStatus.CANCELLED || booking.status == BookingStatus.NO_SHOW || booking.status == BookingStatus.CHECKED_OUT) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Booking closed")
|
||||
}
|
||||
|
||||
val room = roomRepo.findByIdAndPropertyId(request.roomId, propertyId)
|
||||
?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Room not found")
|
||||
if (!room.active || room.maintenance) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Room not available")
|
||||
}
|
||||
|
||||
val fromAt = parseOffset(request.fromAt)
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "fromAt required")
|
||||
val toAt = parseOffset(request.toAt)
|
||||
?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "toAt required")
|
||||
if (!toAt.isAfter(fromAt)) {
|
||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid date range")
|
||||
}
|
||||
|
||||
if (roomStayRepo.existsOverlap(propertyId, request.roomId, fromAt, toAt)) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Room already reserved/occupied for range")
|
||||
}
|
||||
|
||||
val stay = RoomStay(
|
||||
property = booking.property,
|
||||
booking = booking,
|
||||
room = room,
|
||||
fromAt = fromAt,
|
||||
toAt = toAt,
|
||||
rateSource = parseRateSource(request.rateSource),
|
||||
nightlyRate = request.nightlyRate,
|
||||
ratePlanCode = request.ratePlanCode,
|
||||
currency = request.currency ?: booking.property.currency,
|
||||
createdBy = actor
|
||||
)
|
||||
roomStayRepo.save(stay)
|
||||
bookingEvents.emit(propertyId, bookingId)
|
||||
}
|
||||
|
||||
private fun requireBooking(propertyId: UUID, bookingId: UUID): com.android.trisolarisserver.models.booking.Booking {
|
||||
val booking = bookingRepo.findById(bookingId).orElseThrow {
|
||||
ResponseStatusException(HttpStatus.NOT_FOUND, "Booking not found")
|
||||
|
||||
@@ -150,17 +150,6 @@ data class RoomChangeResponse(
|
||||
val movedAt: String
|
||||
)
|
||||
|
||||
data class RoomStayPreAssignRequest(
|
||||
val roomId: UUID,
|
||||
val fromAt: String,
|
||||
val toAt: String,
|
||||
val nightlyRate: Long? = null,
|
||||
val rateSource: String? = null,
|
||||
val ratePlanCode: String? = null,
|
||||
val currency: String? = null,
|
||||
val notes: String? = null
|
||||
)
|
||||
|
||||
data class RoomStayVoidRequest(
|
||||
val reason: String? = null
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user