Disallow checkoutAt in bulk check-in stays
All checks were successful
build-and-deploy / build-deploy (push) Successful in 35s

This commit is contained in:
androidlover5842
2026-02-02 09:01:38 +05:30
parent e3563dd259
commit 247d6e4961
2 changed files with 3 additions and 13 deletions

View File

@@ -340,17 +340,9 @@ class BookingFlow(
val now = OffsetDateTime.now()
val checkInTimes = mutableListOf<OffsetDateTime>()
val checkOutTimes = mutableListOf<OffsetDateTime>()
request.stays.forEach { stay ->
val checkInAt = parseOffset(stay.checkInAt) ?: now
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 newStay = RoomStay(
property = booking.property,
@@ -368,12 +360,8 @@ class BookingFlow(
}
val bookingCheckInAt = checkInTimes.minOrNull() ?: now
val bookingExpectedCheckout = checkOutTimes.maxOrNull()
booking.status = BookingStatus.CHECKED_IN
booking.checkinAt = bookingCheckInAt
if (bookingExpectedCheckout != null) {
booking.expectedCheckoutAt = bookingExpectedCheckout
}
booking.transportMode = request.transportMode?.let {
val mode = parseTransportMode(it)
if (!isTransportModeAllowed(booking.property, mode)) {

View File

@@ -1,17 +1,19 @@
package com.android.trisolarisserver.controller.dto.booking
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import java.util.UUID
@JsonIgnoreProperties(ignoreUnknown = false)
data class BookingCheckInStayRequest(
val roomId: UUID,
val checkInAt: String? = null,
val checkOutAt: String? = null,
val nightlyRate: Long? = null,
val rateSource: String? = null,
val ratePlanCode: String? = null,
val currency: String? = null
)
@JsonIgnoreProperties(ignoreUnknown = false)
data class BookingBulkCheckInRequest(
val stays: List<BookingCheckInStayRequest>,
val transportMode: String? = null,