Adedd formid as unique id for reservations
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -20,3 +20,6 @@ test_data/*
|
||||
|
||||
# ignore secrets
|
||||
secrets.yaml
|
||||
|
||||
# ignore db
|
||||
alpinebits.db
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ResRetrieveRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<ReservationsList>
|
||||
<HotelReservation CreateDateTime="2025-09-29T07:21:12.768928+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="6b34fe24ac2ff811"/>
|
||||
<HotelReservation CreateDateTime="2025-09-29T07:33:12.122570+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="e084006b-ae83-4e4d-b2f5-074118cdb3b1"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
|
||||
@@ -26,6 +26,7 @@ class Reservation(Base):
|
||||
__tablename__ = 'reservations'
|
||||
id = Column(Integer, primary_key=True)
|
||||
customer_id = Column(Integer, ForeignKey('customers.id'))
|
||||
form_id = Column(String, unique=True)
|
||||
start_date = Column(Date)
|
||||
end_date = Column(Date)
|
||||
num_adults = Column(Integer)
|
||||
|
||||
@@ -46,6 +46,10 @@ def main():
|
||||
os.makedirs(db_dir, exist_ok=True)
|
||||
# The DB file will be created by SQLAlchemy if it doesn't exist, but ensure directory exists
|
||||
|
||||
# for now we delete the existing DB for clean testing
|
||||
if os.path.exists(db_path):
|
||||
os.remove(db_path)
|
||||
print(f"Deleted existing SQLite DB at {db_path} for clean testing.")
|
||||
# Init DB
|
||||
init_db(config)
|
||||
|
||||
@@ -144,6 +148,7 @@ def main():
|
||||
|
||||
db_reservation = DBReservation(
|
||||
customer_id=db_customer.id,
|
||||
form_id=data.get("formId"),
|
||||
start_date=date.fromisoformat(start_date) if start_date else None,
|
||||
end_date=date.fromisoformat(end_date) if end_date else None,
|
||||
num_adults=num_adults,
|
||||
@@ -159,9 +164,12 @@ def main():
|
||||
# Success - use None instead of object() for cleaner XML output
|
||||
success = None
|
||||
|
||||
# UniqueID
|
||||
# UniqueID, we are using the formid as a stable unique id
|
||||
form_id = data.get("formId")
|
||||
|
||||
# hardcoding the type to 14 is allowed because 15 is only for cancellations and we don't handle those
|
||||
unique_id = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.UniqueId(
|
||||
type_value=ab.UniqueIdType2.VALUE_14, id="6b34fe24ac2ff811"
|
||||
type_value=ab.UniqueIdType2.VALUE_14, id=form_id
|
||||
)
|
||||
|
||||
time_span = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay.TimeSpan(
|
||||
|
||||
Reference in New Issue
Block a user