Fixed incorrect overlap detection
This commit is contained in:
@@ -300,15 +300,22 @@ class FreeRoomsAction(AlpineBitsAction):
|
||||
# Validate date range
|
||||
start_date, end_date = self._parse_date_range(sac.start, sac.end)
|
||||
|
||||
# Check if this inventory entry has any counts (available rooms)
|
||||
# Entries without counts represent unavailable rooms
|
||||
has_availability = inventory.inv_counts is not None and inventory.inv_counts.inv_count
|
||||
|
||||
# Check for overlap with closing seasons
|
||||
for closing_start, closing_end in closing_season_ranges:
|
||||
if self._date_ranges_overlap(start_date, end_date, closing_start, closing_end):
|
||||
error_message = f"Inventory entry ({start_date} to {end_date}) overlaps with closing season ({closing_start} to {closing_end})"
|
||||
_LOGGER.info(error_message)
|
||||
raise FreeRoomsProcessingError(
|
||||
error_message,
|
||||
HttpStatusCode.BAD_REQUEST,
|
||||
)
|
||||
# Only entries with availability (counts) cannot overlap with closing seasons
|
||||
# Entries without counts (unavailable rooms) can overlap with closing seasons
|
||||
if has_availability:
|
||||
for closing_start, closing_end in closing_season_ranges:
|
||||
if self._date_ranges_overlap(start_date, end_date, closing_start, closing_end):
|
||||
error_message = f"Inventory entry ({start_date} to {end_date}) overlaps with closing season ({closing_start} to {closing_end})"
|
||||
_LOGGER.info(error_message)
|
||||
raise FreeRoomsProcessingError(
|
||||
error_message,
|
||||
HttpStatusCode.BAD_REQUEST,
|
||||
)
|
||||
|
||||
# Check for overlap with other inventory entries for the same room/category
|
||||
inv_code = sac.inv_code.strip() if sac.inv_code else None
|
||||
|
||||
Reference in New Issue
Block a user