Require guest identity and signature before checkout
All checks were successful
build-and-deploy / build-deploy (push) Successful in 36s

This commit is contained in:
androidlover5842
2026-02-05 09:56:32 +05:30
parent cb6fb94bf7
commit f46893e0c3
2 changed files with 32 additions and 1 deletions

View File

@@ -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?,