Disallow checkoutAt in bulk check-in stays
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:
@@ -340,17 +340,9 @@ class BookingFlow(
|
|||||||
|
|
||||||
val now = OffsetDateTime.now()
|
val now = OffsetDateTime.now()
|
||||||
val checkInTimes = mutableListOf<OffsetDateTime>()
|
val checkInTimes = mutableListOf<OffsetDateTime>()
|
||||||
val checkOutTimes = mutableListOf<OffsetDateTime>()
|
|
||||||
request.stays.forEach { stay ->
|
request.stays.forEach { stay ->
|
||||||
val checkInAt = parseOffset(stay.checkInAt) ?: now
|
val checkInAt = parseOffset(stay.checkInAt) ?: now
|
||||||
checkInTimes.add(checkInAt)
|
checkInTimes.add(checkInAt)
|
||||||
val checkOutAt = parseOffset(stay.checkOutAt)
|
|
||||||
if (checkOutAt != null) {
|
|
||||||
if (!checkOutAt.isAfter(checkInAt)) {
|
|
||||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid date range for stay")
|
|
||||||
}
|
|
||||||
checkOutTimes.add(checkOutAt)
|
|
||||||
}
|
|
||||||
val room = rooms.getValue(stay.roomId)
|
val room = rooms.getValue(stay.roomId)
|
||||||
val newStay = RoomStay(
|
val newStay = RoomStay(
|
||||||
property = booking.property,
|
property = booking.property,
|
||||||
@@ -368,12 +360,8 @@ class BookingFlow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val bookingCheckInAt = checkInTimes.minOrNull() ?: now
|
val bookingCheckInAt = checkInTimes.minOrNull() ?: now
|
||||||
val bookingExpectedCheckout = checkOutTimes.maxOrNull()
|
|
||||||
booking.status = BookingStatus.CHECKED_IN
|
booking.status = BookingStatus.CHECKED_IN
|
||||||
booking.checkinAt = bookingCheckInAt
|
booking.checkinAt = bookingCheckInAt
|
||||||
if (bookingExpectedCheckout != null) {
|
|
||||||
booking.expectedCheckoutAt = bookingExpectedCheckout
|
|
||||||
}
|
|
||||||
booking.transportMode = request.transportMode?.let {
|
booking.transportMode = request.transportMode?.let {
|
||||||
val mode = parseTransportMode(it)
|
val mode = parseTransportMode(it)
|
||||||
if (!isTransportModeAllowed(booking.property, mode)) {
|
if (!isTransportModeAllowed(booking.property, mode)) {
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package com.android.trisolarisserver.controller.dto.booking
|
package com.android.trisolarisserver.controller.dto.booking
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = false)
|
||||||
data class BookingCheckInStayRequest(
|
data class BookingCheckInStayRequest(
|
||||||
val roomId: UUID,
|
val roomId: UUID,
|
||||||
val checkInAt: String? = null,
|
val checkInAt: String? = null,
|
||||||
val checkOutAt: String? = null,
|
|
||||||
val nightlyRate: Long? = null,
|
val nightlyRate: Long? = null,
|
||||||
val rateSource: String? = null,
|
val rateSource: String? = null,
|
||||||
val ratePlanCode: String? = null,
|
val ratePlanCode: String? = null,
|
||||||
val currency: String? = null
|
val currency: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = false)
|
||||||
data class BookingBulkCheckInRequest(
|
data class BookingBulkCheckInRequest(
|
||||||
val stays: List<BookingCheckInStayRequest>,
|
val stays: List<BookingCheckInStayRequest>,
|
||||||
val transportMode: String? = null,
|
val transportMode: String? = null,
|
||||||
|
|||||||
Reference in New Issue
Block a user