Add forecast occupancy logic for room availability range APIs
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
This commit is contained in:
@@ -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?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user