Use per-day available_rooms from forecasting API (overflow excluded)
Switch from a single total_rooms scalar to rm.available_rooms per day, now that the forecasting public API returns it from daily_occupancy. Fixes worksheet Avail column showing 80 (total physical beds) instead of the correct occupancy-reportable room count. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fc903564fb
commit
822ce2f970
1 changed files with 10 additions and 8 deletions
|
|
@ -53,7 +53,7 @@ async function fetchMonthFromApi(year, month, lastDayNum) {
|
||||||
for (const d of revData.data) revMap[d.date] = d
|
for (const d of revData.data) revMap[d.date] = d
|
||||||
const roomsMap = {}
|
const roomsMap = {}
|
||||||
for (const d of roomsData.data) roomsMap[d.date] = d
|
for (const d of roomsData.data) roomsMap[d.date] = d
|
||||||
return { revMap, roomsMap, available: roomsData.total_rooms }
|
return { revMap, roomsMap }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function directorsForecastRoutes(fastify) {
|
export async function directorsForecastRoutes(fastify) {
|
||||||
|
|
@ -71,7 +71,7 @@ export async function directorsForecastRoutes(fastify) {
|
||||||
const today = new Date().toISOString().split('T')[0]
|
const today = new Date().toISOString().split('T')[0]
|
||||||
const sessionRate = 135
|
const sessionRate = 135
|
||||||
|
|
||||||
const [{ session, overrideMap }, { revMap, roomsMap, available }] = await Promise.all([
|
const [{ session, overrideMap }, { revMap, roomsMap }] = await Promise.all([
|
||||||
getSessionAndOverrides(year, month),
|
getSessionAndOverrides(year, month),
|
||||||
fetchMonthFromApi(year, month, lastDayNum),
|
fetchMonthFromApi(year, month, lastDayNum),
|
||||||
])
|
])
|
||||||
|
|
@ -89,6 +89,7 @@ export async function directorsForecastRoutes(fastify) {
|
||||||
const isToday = dateStr === today
|
const isToday = dateStr === today
|
||||||
const dow = new Date(dateStr + 'T00:00:00').getDay()
|
const dow = new Date(dateStr + 'T00:00:00').getDay()
|
||||||
|
|
||||||
|
const available = rm.available_rooms ?? 0
|
||||||
const otbRooms = rm.otb_rooms ?? 0
|
const otbRooms = rm.otb_rooms ?? 0
|
||||||
const otbNetRev = rev.accom?.otb ?? 0
|
const otbNetRev = rev.accom?.otb ?? 0
|
||||||
const avgRateNet = otbRooms > 0 ? otbNetRev / otbRooms : null
|
const avgRateNet = otbRooms > 0 ? otbNetRev / otbRooms : null
|
||||||
|
|
@ -187,7 +188,7 @@ export async function directorsForecastRoutes(fastify) {
|
||||||
const month = parseInt(request.params.month)
|
const month = parseInt(request.params.month)
|
||||||
const lastDayNum = new Date(year, month, 0).getDate()
|
const lastDayNum = new Date(year, month, 0).getDate()
|
||||||
|
|
||||||
const [{ session, overrideMap }, { revMap, roomsMap, available }] = await Promise.all([
|
const [{ session, overrideMap }, { revMap, roomsMap }] = await Promise.all([
|
||||||
getSessionAndOverrides(year, month),
|
getSessionAndOverrides(year, month),
|
||||||
fetchMonthFromApi(year, month, lastDayNum),
|
fetchMonthFromApi(year, month, lastDayNum),
|
||||||
])
|
])
|
||||||
|
|
@ -214,6 +215,7 @@ export async function directorsForecastRoutes(fastify) {
|
||||||
const ovr = overrideMap[dateStr] || {}
|
const ovr = overrideMap[dateStr] || {}
|
||||||
|
|
||||||
const isPast = rev.is_past ?? false
|
const isPast = rev.is_past ?? false
|
||||||
|
const available = rm.available_rooms ?? 0
|
||||||
const otbRooms = rm.otb_rooms ?? 0
|
const otbRooms = rm.otb_rooms ?? 0
|
||||||
const otbNetRev = rev.accom?.otb ?? 0
|
const otbNetRev = rev.accom?.otb ?? 0
|
||||||
const pickupRooms = ovr.pickup_rooms != null ? parseInt(ovr.pickup_rooms) : 0
|
const pickupRooms = ovr.pickup_rooms != null ? parseInt(ovr.pickup_rooms) : 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue