2 Commits

Author SHA1 Message Date
Jonas Linter
a343013eed Added a try block so that one guestrequest failing doesn't blow up the entire thing 2025-09-30 14:29:37 +02:00
Jonas Linter
7380fa4378 Fixed missing offer comment causing validation error 2025-09-30 14:24:45 +02:00

View File

@@ -672,6 +672,8 @@ def create_xml_from_db(list: list[Tuple[Reservation, Customer]]):
for reservation, customer in list: for reservation, customer in list:
_LOGGER.info(f"Creating XML for reservation {reservation.form_id} and customer {customer.given_name}") _LOGGER.info(f"Creating XML for reservation {reservation.form_id} and customer {customer.given_name}")
try:
phone_numbers = [(customer.phone, PhoneTechType.MOBILE)] if customer.phone is not None else [] phone_numbers = [(customer.phone, PhoneTechType.MOBILE)] if customer.phone is not None else []
customer_data = CustomerData( customer_data = CustomerData(
given_name=customer.given_name, given_name=customer.given_name,
@@ -745,6 +747,9 @@ def create_xml_from_db(list: list[Tuple[Reservation, Customer]]):
hotel_name=reservation.hotel_name, hotel_name=reservation.hotel_name,
) )
# Comments # Comments
offer_comment = None
if reservation.offer is not None:
offer_comment = CommentData( offer_comment = CommentData(
name=CommentName2.ADDITIONAL_INFO, name=CommentName2.ADDITIONAL_INFO,
text="Angebot/Offerta", text="Angebot/Offerta",
@@ -776,6 +781,10 @@ def create_xml_from_db(list: list[Tuple[Reservation, Customer]]):
comments_xml = None comments_xml = None
if comments: if comments:
for c in comments:
_LOGGER.info(f"Creating comment: name={c.name}, text={c.text}, list_items={len(c.list_items)}")
comments_data = CommentsData(comments=comments) comments_data = CommentsData(comments=comments)
comments_xml = alpine_bits_factory.create(comments_data, OtaMessageType.RETRIEVE) comments_xml = alpine_bits_factory.create(comments_data, OtaMessageType.RETRIEVE)
@@ -801,6 +810,9 @@ def create_xml_from_db(list: list[Tuple[Reservation, Customer]]):
reservations_list.append(hotel_reservation) reservations_list.append(hotel_reservation)
except Exception as e:
_LOGGER.error(f"Error creating XML for reservation {reservation.form_id} and customer {customer.given_name}: {e}")
retrieved_reservations = OtaResRetrieveRs.ReservationsList( retrieved_reservations = OtaResRetrieveRs.ReservationsList(
hotel_reservation=reservations_list hotel_reservation=reservations_list
) )