Compute guest counts server-side on booking create
Some checks failed
build-and-deploy / build-deploy (push) Failing after 29s
Some checks failed
build-and-deploy / build-deploy (push) Failing after 29s
This commit is contained in:
@@ -79,6 +79,17 @@ class BookingFlow(
|
|||||||
val shouldCheckIn = !expectedCheckInAt.isBefore(now)
|
val shouldCheckIn = !expectedCheckInAt.isBefore(now)
|
||||||
val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() }
|
val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() }
|
||||||
val guest = resolveGuestForBooking(propertyId, property, actor, now, phone)
|
val guest = resolveGuestForBooking(propertyId, property, actor, now, phone)
|
||||||
|
val hasGuestCounts = request.maleCount != null || request.femaleCount != null || request.childCount != null
|
||||||
|
val adultCount = if (hasGuestCounts) {
|
||||||
|
(request.maleCount ?: 0) + (request.femaleCount ?: 0)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
val totalGuestCount = if (hasGuestCounts) {
|
||||||
|
adultCount + (request.childCount ?: 0)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
val booking = com.android.trisolarisserver.models.booking.Booking(
|
val booking = com.android.trisolarisserver.models.booking.Booking(
|
||||||
property = property,
|
property = property,
|
||||||
primaryGuest = guest,
|
primaryGuest = guest,
|
||||||
@@ -94,11 +105,11 @@ class BookingFlow(
|
|||||||
}
|
}
|
||||||
mode
|
mode
|
||||||
},
|
},
|
||||||
adultCount = request.adultCount,
|
adultCount = adultCount,
|
||||||
childCount = request.childCount,
|
childCount = request.childCount,
|
||||||
maleCount = request.maleCount,
|
maleCount = request.maleCount,
|
||||||
femaleCount = request.femaleCount,
|
femaleCount = request.femaleCount,
|
||||||
totalGuestCount = request.totalGuestCount,
|
totalGuestCount = totalGuestCount,
|
||||||
notes = request.notes,
|
notes = request.notes,
|
||||||
createdBy = actor,
|
createdBy = actor,
|
||||||
updatedAt = now
|
updatedAt = now
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ data class BookingCreateRequest(
|
|||||||
val expectedCheckOutAt: String,
|
val expectedCheckOutAt: String,
|
||||||
val guestPhoneE164: String? = null,
|
val guestPhoneE164: String? = null,
|
||||||
val transportMode: String? = null,
|
val transportMode: String? = null,
|
||||||
val adultCount: Int? = null,
|
|
||||||
val childCount: Int? = null,
|
val childCount: Int? = null,
|
||||||
val maleCount: Int? = null,
|
val maleCount: Int? = null,
|
||||||
val femaleCount: Int? = null,
|
val femaleCount: Int? = null,
|
||||||
val totalGuestCount: Int? = null,
|
|
||||||
val notes: String? = null
|
val notes: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user