Add forecast occupancy logic for room availability range APIs
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s

This commit is contained in:
androidlover5842
2026-02-04 17:22:28 +05:30
parent 0a65e022e0
commit 2950af3332
3 changed files with 59 additions and 2 deletions

View File

@@ -30,6 +30,37 @@ interface RoomStayRepo : JpaRepository<RoomStay, UUID> {
@Param("toAt") toAt: java.time.OffsetDateTime
): List<UUID>
@Query("""
select distinct rs.room.id
from RoomStay rs
where rs.property.id = :propertyId
and rs.isVoided = false
and rs.toAt is not null
and rs.fromAt < :toAt
and rs.toAt > :fromAt
""")
fun findOccupiedRoomIdsBetweenClosed(
@Param("propertyId") propertyId: UUID,
@Param("fromAt") fromAt: java.time.OffsetDateTime,
@Param("toAt") toAt: java.time.OffsetDateTime
): List<UUID>
@Query("""
select rs.room.id as roomId,
rs.fromAt as fromAt,
b.expectedCheckoutAt as expectedCheckoutAt
from RoomStay rs
join rs.booking b
where rs.property.id = :propertyId
and rs.isVoided = false
and rs.toAt is null
and rs.fromAt < :toAt
""")
fun findActiveForecastRows(
@Param("propertyId") propertyId: UUID,
@Param("toAt") toAt: java.time.OffsetDateTime
): List<ActiveRoomStayForecastRow>
@Query("""
select rs
from RoomStay rs
@@ -163,3 +194,9 @@ interface BookingRoomNumberRow {
val bookingId: UUID
val roomNumber: Int
}
interface ActiveRoomStayForecastRow {
val roomId: UUID
val fromAt: java.time.OffsetDateTime
val expectedCheckoutAt: java.time.OffsetDateTime?
}