Revert "Sync active room stays when booking expected dates change"
All checks were successful
build-and-deploy / build-deploy (push) Successful in 17s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 17s
This reverts commit 189fdb33de.
This commit is contained in:
@@ -1361,7 +1361,6 @@ ROOM STAYS + CARDS APIS
|
|||||||
What it does:
|
What it does:
|
||||||
|
|
||||||
- Returns active stays with booking and guest details.
|
- Returns active stays with booking and guest details.
|
||||||
- expectedCheckoutAt is resolved per active stay (room_stay.planned_checkout_at), with booking expected checkout as fallback.
|
|
||||||
- Includes per-stay nightlyRate (nullable when rate was not set on room stay).
|
- Includes per-stay nightlyRate (nullable when rate was not set on room stay).
|
||||||
- AGENT-only users are blocked.
|
- AGENT-only users are blocked.
|
||||||
|
|
||||||
@@ -1823,11 +1822,7 @@ BOOKING APIS
|
|||||||
What it does:
|
What it does:
|
||||||
|
|
||||||
- Updates planned dates on booking (expectedCheckInAt, expectedCheckOutAt), not actual checkout.
|
- Updates planned dates on booking (expectedCheckInAt, expectedCheckOutAt), not actual checkout.
|
||||||
- Updates booking-level expected dates.
|
- Updates booking-level expected dates only; does not auto-change room_stay checkout timestamps.
|
||||||
- After validation, auto-syncs linked active room stays (checked-out stays are not modified):
|
|
||||||
- OPEN booking: active stay fromAt is synced to expectedCheckInAt (when provided).
|
|
||||||
- OPEN/CHECKED_IN booking: active stay planned checkout is synced to expectedCheckOutAt (when provided).
|
|
||||||
- Does not auto-close room stays and does not overwrite actual room_stay.to_at timestamps.
|
|
||||||
- For OPEN bookings: can update both expected check-in and expected check-out.
|
- For OPEN bookings: can update both expected check-in and expected check-out.
|
||||||
- For OPEN bookings with linked room stays: each stay start/end must remain inside expected booking window.
|
- For OPEN bookings with linked room stays: each stay start/end must remain inside expected booking window.
|
||||||
- For CHECKED_IN: can update only expectedCheckOutAt (check-in change is blocked).
|
- For CHECKED_IN: can update only expectedCheckOutAt (check-in change is blocked).
|
||||||
|
|||||||
@@ -511,7 +511,6 @@ class BookingFlow(
|
|||||||
room = room,
|
room = room,
|
||||||
fromAt = checkInAt,
|
fromAt = checkInAt,
|
||||||
toAt = null,
|
toAt = null,
|
||||||
plannedCheckoutAt = booking.expectedCheckoutAt,
|
|
||||||
rateSource = parseRateSource(stay.rateSource),
|
rateSource = parseRateSource(stay.rateSource),
|
||||||
nightlyRate = stay.nightlyRate,
|
nightlyRate = stay.nightlyRate,
|
||||||
ratePlanCode = stay.ratePlanCode,
|
ratePlanCode = stay.ratePlanCode,
|
||||||
@@ -580,7 +579,6 @@ class BookingFlow(
|
|||||||
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid date range")
|
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid date range")
|
||||||
}
|
}
|
||||||
validateRoomStayBoundsForExpectedDatesUpdate(booking, expectedIn, expectedOut)
|
validateRoomStayBoundsForExpectedDatesUpdate(booking, expectedIn, expectedOut)
|
||||||
syncActiveRoomStaysWithBookingExpectedDates(booking, expectedIn, expectedOut)
|
|
||||||
|
|
||||||
booking.updatedAt = OffsetDateTime.now()
|
booking.updatedAt = OffsetDateTime.now()
|
||||||
bookingRepo.save(booking)
|
bookingRepo.save(booking)
|
||||||
@@ -639,32 +637,6 @@ class BookingFlow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun syncActiveRoomStaysWithBookingExpectedDates(
|
|
||||||
booking: com.android.trisolarisserver.models.booking.Booking,
|
|
||||||
expectedIn: OffsetDateTime?,
|
|
||||||
expectedOut: OffsetDateTime?
|
|
||||||
) {
|
|
||||||
val bookingId = booking.id ?: return
|
|
||||||
if (expectedIn == null && expectedOut == null) return
|
|
||||||
val activeStays = roomStayRepo.findActiveByBookingId(bookingId)
|
|
||||||
if (activeStays.isEmpty()) return
|
|
||||||
|
|
||||||
var changed = false
|
|
||||||
activeStays.forEach { stay ->
|
|
||||||
if (booking.status == BookingStatus.OPEN && expectedIn != null && stay.fromAt != expectedIn) {
|
|
||||||
stay.fromAt = expectedIn
|
|
||||||
changed = true
|
|
||||||
}
|
|
||||||
if (expectedOut != null && stay.plannedCheckoutAt != expectedOut) {
|
|
||||||
stay.plannedCheckoutAt = expectedOut
|
|
||||||
changed = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changed) {
|
|
||||||
roomStayRepo.saveAll(activeStays)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/{bookingId}/billing-policy")
|
@PostMapping("/{bookingId}/billing-policy")
|
||||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class RoomStays(
|
|||||||
roomTypeName = roomType.name,
|
roomTypeName = roomType.name,
|
||||||
fromAt = stay.fromAt.toString(),
|
fromAt = stay.fromAt.toString(),
|
||||||
checkinAt = booking.checkinAt?.toString(),
|
checkinAt = booking.checkinAt?.toString(),
|
||||||
expectedCheckoutAt = (stay.plannedCheckoutAt ?: booking.expectedCheckoutAt)?.toString(),
|
expectedCheckoutAt = booking.expectedCheckoutAt?.toString(),
|
||||||
nightlyRate = stay.nightlyRate
|
nightlyRate = stay.nightlyRate
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ class RoomStay(
|
|||||||
@Column(name = "to_at", columnDefinition = "timestamptz")
|
@Column(name = "to_at", columnDefinition = "timestamptz")
|
||||||
var toAt: OffsetDateTime? = null, // null = active
|
var toAt: OffsetDateTime? = null, // null = active
|
||||||
|
|
||||||
@Column(name = "planned_checkout_at", columnDefinition = "timestamptz")
|
|
||||||
var plannedCheckoutAt: OffsetDateTime? = null,
|
|
||||||
|
|
||||||
@Column(name = "is_voided", nullable = false)
|
@Column(name = "is_voided", nullable = false)
|
||||||
var isVoided: Boolean = false,
|
var isVoided: Boolean = false,
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ interface RoomStayRepo : JpaRepository<RoomStay, UUID> {
|
|||||||
@Query("""
|
@Query("""
|
||||||
select rs.room.id as roomId,
|
select rs.room.id as roomId,
|
||||||
rs.fromAt as fromAt,
|
rs.fromAt as fromAt,
|
||||||
coalesce(rs.plannedCheckoutAt, b.expectedCheckoutAt) as expectedCheckoutAt
|
b.expectedCheckoutAt as expectedCheckoutAt
|
||||||
from RoomStay rs
|
from RoomStay rs
|
||||||
join rs.booking b
|
join rs.booking b
|
||||||
where rs.property.id = :propertyId
|
where rs.property.id = :propertyId
|
||||||
|
|||||||
Reference in New Issue
Block a user