From 5214584b3c8793f5d0e59e2901865207039d8d55 Mon Sep 17 00:00:00 2001 From: androidlover5842 Date: Thu, 29 Jan 2026 09:30:53 +0530 Subject: [PATCH] Compute guest counts server-side on booking create --- .../trisolarisserver/controller/BookingFlow.kt | 15 +++++++++++++-- .../controller/dto/BookingDtos.kt | 2 -- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/BookingFlow.kt b/src/main/kotlin/com/android/trisolarisserver/controller/BookingFlow.kt index 3824407..af59988 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/BookingFlow.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/BookingFlow.kt @@ -79,6 +79,17 @@ class BookingFlow( val shouldCheckIn = !expectedCheckInAt.isBefore(now) val phone = request.guestPhoneE164?.trim()?.takeIf { it.isNotBlank() } 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( property = property, primaryGuest = guest, @@ -94,11 +105,11 @@ class BookingFlow( } mode }, - adultCount = request.adultCount, + adultCount = adultCount, childCount = request.childCount, maleCount = request.maleCount, femaleCount = request.femaleCount, - totalGuestCount = request.totalGuestCount, + totalGuestCount = totalGuestCount, notes = request.notes, createdBy = actor, updatedAt = now diff --git a/src/main/kotlin/com/android/trisolarisserver/controller/dto/BookingDtos.kt b/src/main/kotlin/com/android/trisolarisserver/controller/dto/BookingDtos.kt index c8c4a62..6c027f2 100644 --- a/src/main/kotlin/com/android/trisolarisserver/controller/dto/BookingDtos.kt +++ b/src/main/kotlin/com/android/trisolarisserver/controller/dto/BookingDtos.kt @@ -19,11 +19,9 @@ data class BookingCreateRequest( val expectedCheckOutAt: String, val guestPhoneE164: String? = null, val transportMode: String? = null, - val adultCount: Int? = null, val childCount: Int? = null, val maleCount: Int? = null, val femaleCount: Int? = null, - val totalGuestCount: Int? = null, val notes: String? = null )