Require guest identity and signature before checkout
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s
This commit is contained in:
@@ -651,6 +651,7 @@ class BookingFlow(
|
||||
}
|
||||
val now = OffsetDateTime.now()
|
||||
val checkOutAt = parseOffset(request.checkOutAt) ?: now
|
||||
validateCheckoutPrerequisites(booking, checkOutAt)
|
||||
|
||||
val stays = roomStayRepo.findActiveByBookingId(bookingId)
|
||||
if (stays.any { !isCheckoutAmountValid(it) || !isMinimumStayDurationValid(it, checkOutAt) }) {
|
||||
@@ -723,6 +724,7 @@ class BookingFlow(
|
||||
|
||||
val now = OffsetDateTime.now()
|
||||
val checkOutAt = parseOffset(request.checkOutAt) ?: now
|
||||
validateCheckoutPrerequisites(booking, checkOutAt)
|
||||
if (!isCheckoutAmountValid(stay)) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Room stay amount is outside allowed range")
|
||||
}
|
||||
@@ -1060,6 +1062,29 @@ class BookingFlow(
|
||||
return java.time.Duration.between(stay.fromAt, checkOutAt).toMinutes() >= 60
|
||||
}
|
||||
|
||||
private fun validateCheckoutPrerequisites(
|
||||
booking: com.android.trisolarisserver.models.booking.Booking,
|
||||
checkOutAt: OffsetDateTime
|
||||
) {
|
||||
val guest = booking.primaryGuest
|
||||
?: throw ResponseStatusException(HttpStatus.CONFLICT, "Primary guest required before checkout")
|
||||
if (guest.name.isNullOrBlank()) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Guest name required before checkout")
|
||||
}
|
||||
if (guest.phoneE164.isNullOrBlank()) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Guest phone required before checkout")
|
||||
}
|
||||
if (guest.signaturePath.isNullOrBlank()) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Guest signature required before checkout")
|
||||
}
|
||||
|
||||
val checkInAt = booking.checkinAt ?: booking.expectedCheckinAt
|
||||
?: throw ResponseStatusException(HttpStatus.CONFLICT, "Check-in time missing for booking")
|
||||
if (!checkOutAt.isAfter(checkInAt)) {
|
||||
throw ResponseStatusException(HttpStatus.CONFLICT, "checkOutAt must be after checkInAt")
|
||||
}
|
||||
}
|
||||
|
||||
private fun ensureLedgerToleranceForCheckout(
|
||||
bookingId: UUID,
|
||||
timezone: String?,
|
||||
|
||||
Reference in New Issue
Block a user