Fix current OTB overcounting Departed and Unconfirmed bookings
Guests who check out early keep their original departure_date in NewBook, so Departed status with departure_date > stay_date were being counted as live OTB — inflating room count above physical capacity. Unconfirmed bookings are also provisional so excluded from live OTB. Prior-year queries retain all statuses since historical bookings will legitimately be in Departed state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
455396c965
commit
2912745300
1 changed files with 5 additions and 2 deletions
|
|
@ -91,13 +91,15 @@ async def get_current_otb_revenue(db, stay_date: date) -> Decimal:
|
|||
return Decimal('0')
|
||||
|
||||
# Query actual bookings for real-time OTB revenue
|
||||
# Exclude 'Departed' — guests who checked out early retain their original departure_date
|
||||
# so would be double-counted; exclude 'Unconfirmed' for same reason on live OTB
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT raw_json
|
||||
FROM newbook_bookings_data
|
||||
WHERE arrival_date <= :stay_date
|
||||
AND departure_date > :stay_date
|
||||
AND status IN ('Unconfirmed', 'Confirmed', 'Arrived', 'Departed')
|
||||
AND status IN ('Confirmed', 'Arrived')
|
||||
AND category_id = ANY(:categories)
|
||||
"""),
|
||||
{
|
||||
|
|
@ -304,13 +306,14 @@ async def get_current_otb_rooms_by_category(db, stay_date: date) -> Dict[str, in
|
|||
return {}
|
||||
|
||||
# Query actual bookings for real-time OTB count
|
||||
# Exclude 'Departed' — early checkouts keep their original departure_date so would inflate count
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT category_id, COUNT(*) as room_count
|
||||
FROM newbook_bookings_data
|
||||
WHERE arrival_date <= :stay_date
|
||||
AND departure_date > :stay_date
|
||||
AND status IN ('Unconfirmed', 'Confirmed', 'Arrived', 'Departed')
|
||||
AND status IN ('Confirmed', 'Arrived')
|
||||
AND category_id = ANY(:categories)
|
||||
GROUP BY category_id
|
||||
"""),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue