Fix available_rooms to use is_included flag from room category settings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4e783bd508
commit
d8ad753a62
1 changed files with 7 additions and 6 deletions
|
|
@ -53,14 +53,15 @@ async def get_rooms_forecast(
|
|||
row = result.fetchone()
|
||||
fallback_total_rooms = int(row.config_value) if row and row.config_value else 30
|
||||
|
||||
# Pre-fetch available rooms per day excluding overflow (category_id='5') and maintenance rooms
|
||||
# Pre-fetch available rooms per day using is_included flag from room categories settings
|
||||
occ_result = await db.execute(
|
||||
text("""
|
||||
SELECT date, SUM(available - COALESCE(maintenance, 0)) AS available_rooms
|
||||
FROM newbook_occupancy_report_data
|
||||
WHERE date >= :start_date AND date <= :end_date
|
||||
AND category_id != '5'
|
||||
GROUP BY date
|
||||
SELECT o.date, SUM(COALESCE(o.available, 0) - COALESCE(o.maintenance, 0)) AS available_rooms
|
||||
FROM newbook_occupancy_report_data o
|
||||
JOIN newbook_room_categories c ON o.category_id = c.site_id
|
||||
WHERE o.date >= :start_date AND o.date <= :end_date
|
||||
AND c.is_included = true
|
||||
GROUP BY o.date
|
||||
"""),
|
||||
{"start_date": start, "end_date": end}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue