ae.sys_data_sh
Sihot system data interface
This portion is very old and needs refactoring and much more unit tests.
The sys record data classes provided by this portion are based on client
and server components (to communicate with the Sihot PMS system)
provided by the ae.sys_core_sh
portion of the ae namespace package.
- TODO:
split into several small modules.
enhance type annotation.
add much more unit tests.
Module Attributes
default map for ClientFromSihot.elem_fld_map instance. |
|
reservation map |
Functions
|
add config/command line options. |
|
fetch the client data record from Sihot for the client specified by its Sihot object id. |
|
complete reservation data row (rec) with default values. |
|
convert date string sent by the Sihot system into a datetime.date value. |
|
convert datetime.date value into a date string in the format of the Sihot system. |
|
split date range into manageable chunks respecting the passed maximum days length and yield them back. |
|
convert list of element names to element path. |
|
determine all reservation ids for a reservation with the passed GDS number. |
|
determine the Sihot object id of a reservation identified by the GDS number. |
|
determine hotel and reservation ids. |
|
using RESERVATION-GET oc from KERNEL interface (see 7.3 in SIHOT KERNEL interface doc). |
|
determine the number of PAX of the passed reservation record. |
|
print the current config options values to the console. |
|
determine all reservation ids for a reservation with the passed reservation number. |
|
determine the Sihot object id of a reservation identified by their reservation number. |
|
search reservations with the criteria specified by the parameters. |
Classes
|
helper base class for bulk data fetches. |
|
build xml and send to the Sihot system to fetch a client record. |
|
extended xml parser converting client data directly into a sys data Record structure. |
|
search client. |
|
extended xml builder class to send/push client data to Sihot. |
|
extended xml builder base class. |
|
extended xml parser converting data directly into a sys data Record structure. |
|
WIP/NotUsed/NoTests: the problem is with GUEST-SEARCH is that there is no way to bulk fetch all guests because the search criteria is not providing range search to split in slices. |
|
reservation bulk fetch. |
|
fetch reservation. |
|
extended xml parser converting reservation data directly into a sys data Record structure. |
|
search reservation. |
|
helper class to send reservation records to Sihot. |
|
extended xml builder to send reservation data to Sihot. |
- convert_date_from_sh(xml_string)[source]
convert date string sent by the Sihot system into a datetime.date value.
- Return type:
- convert_date_onto_sh(date)[source]
convert datetime.date value into a date string in the format of the Sihot system.
- Return type:
- SH_CLIENT_MAP = (('OBJID', 'ShId', None, <function <lambda>>), ('MATCHCODE', 'AcuId'), ('T-SALUTATION', 'Salutation'), ('T-TITLE', 'Title'), ('T-GUEST', 'GuestType', '1'), ('NAME-1', 'Surname'), ('NAME-2', 'Forename'), ('STREET', 'Street'), ('PO-BOX', 'POBox'), ('ZIP', 'Postal'), ('CITY', 'City'), ('T-COUNTRY-CODE', 'Country'), ('T-STATE', 'State', None, <function <lambda>>), ('T-LANGUAGE', 'Language'), ('T-NATION', 'Nationality', None, <function <lambda>>), ('COMMENT', 'Comment'), ('COMMUNICATION/', None, None, <function <lambda>>), ('PHONE-1', 'Phone'), ('PHONE-2', 'WorkPhone'), ('FAX-1', 'Fax'), ('EMAIL-1', 'Email'), ('EMAIL-2', 'EmailB'), ('MOBIL-1', 'MobilePhone'), ('MOBIL-2', 'MobilePhoneB'), ('/COMMUNICATION', None, None, <function <lambda>>), ('ADD-DATA/', None, None, <function <lambda>>), ('T-PERSON-GROUP', None, '1A'), ('D-BIRTHDAY', 'DOB', None, None, <function <lambda>>, <function <lambda>>), ('INTERNET-PASSWORD', 'Password'), ('MATCH-ADM', 'RciId'), ('MATCH-SM', 'SfId'), ('/ADD-DATA', None, None, <function <lambda>>))
default map for ClientFromSihot.elem_fld_map instance. as read-only constant by AcuClientToSihot using the SIHOT KERNEL interface because SiHOT WEB V9 has missing fields: initials (CD_INIT1/2) and profession (CD_INDUSTRY1/2).
- SH_RES_MAP = (('SIHOT-Document.ID', 'ResHotelId'), ('ARESLIST/',), ('RESERVATION/',), ('RESERVATION.RES-HOTEL', 'ResHotelId'), ('RESERVATION.RES-NR', 'ResId', None, <function <lambda>>), ('RESERVATION.SUB-NR', 'ResSubId', None, <function <lambda>>), ('RESERVATION.OBJID', 'ResObjId', None, <function <lambda>>), ('GDSNO', 'ResGdsNo'), ('RESERVATION.GUEST-ID', 'ShId'), ('RESERVATION.GUEST-OBJID', 'ShId'), ('RESERVATION.MATCHCODE', 'AcuId'), ('RESERVATION.NAME', 'Surname'), ('VOUCHERNUMBER', 'ResVoucherNo', None, <function <lambda>>), ('EXT-KEY', 'ResGroupNo', None, <function <lambda>>), ('FLAGS', None, 'IGNORE-OVERBOOKING'), ('RT', 'ResStatus'), ('CAT', 'ResRoomCat'), ('PCAT', 'ResPriceCat', None, <function <lambda>>), ('ALLOTMENT-EXT-NO', 'ResAllotmentNo', '', <function <lambda>>), ('PAYMENT-INST', 'ResAccount', None, <function <lambda>>), ('SALES-DATE', 'ResBooked', None, <function <lambda>>, <function <lambda>>, <function <lambda>>), ('RATE-SEGMENT', 'ResRateSegment', None, <function <lambda>>, ''), ('RATE/', None, None, <function <lambda>>), ('RATE.R', 'ResBoard', None, <function <lambda>>), ('RATE.ISDEFAULT', None, 'Y', <function <lambda>>), ('/RATE', None, None, <function <lambda>>), ('RATE/', None, None, <function <lambda>>), ('RATE.R', 'ResRateBoard', None, <function <lambda>>), ('RATE.ISDEFAULT', None, 'Y', <function <lambda>>), ('RATE.DAYS/', None, None, <function <lambda>>), ('RATE.DAYS.D', ('ResRates', 0, 'RateDay'), None, <function <lambda>>, <function <lambda>>, <function <lambda>>), ('RATE.DAYS.PRICE', ('ResRates', 0, 'RateAmount'), None, <function <lambda>>), ('RATE./DAYS', None, None, <function <lambda>>), ('/RATE', None, None, <function <lambda>>), ('RATE/', None, None, <function <lambda>>), ('RATE.R', None, 'GSC', <function <lambda>>), ('RATE.ISDEFAULT', None, 'N', <function <lambda>>), ('/RATE', None, None, <function <lambda>>), ('RESCHANNELLIST/', None, None, <function <lambda>>), ('RESCHANNEL/', None, None, <function <lambda>>), ('RESCHANNEL.IDX', None, 1, <function <lambda>>), ('RESCHANNEL.MATCHCODE', None, 'RCI', <function <lambda>>), ('RESCHANNEL.ISPRICEOWNER', None, 1, <function <lambda>>), ('RESCHANNEL.IDX', None, 1, <function <lambda>>), ('RESCHANNEL.MATCHCODE', None, 'MAR01', <function <lambda>>), ('RESCHANNEL.ISPRICEOWNER', None, 1, <function <lambda>>), ('RESCHANNEL.IDX', None, 2, <function <lambda>>), ('RESCHANNEL.MATCHCODE', None, 'TSP', <function <lambda>>), ('RESCHANNEL.ISPRICEOWNER', None, 1, <function <lambda>>), ('/RESCHANNEL', None, None, <function <lambda>>), ('/RESCHANNELLIST', None, None, <function <lambda>>), ('ARR', 'ResArrival', None, None, <function <lambda>>, <function <lambda>>), ('DEP', 'ResDeparture', None, None, <function <lambda>>, <function <lambda>>), ('NOROOMS', None, 1), ('NOPAX', 'ResAdults', None, None, <function <lambda>>, <function <lambda>>), ('NOCHILDS', 'ResChildren', None, <function <lambda>>, <function <lambda>>, <function <lambda>>), ('TEC-COMMENT', 'ResLongNote', None, <function <lambda>>), ('COMMENT', 'ResNote', None, <function <lambda>>), ('MARKETCODE-NO', 'ResMktSegment', None, <function <lambda>>), ('MARKETCODE', 'ResMktSegment'), ('SOURCE', 'ResSource', None, <function <lambda>>), ('NN', 'ResMktGroupNN', None, <function <lambda>>), ('CHANNEL', 'ResMktGroup', None, <function <lambda>>), ('EXT-REFERENCE', 'ResFlightArrComment', None, <function <lambda>>), ('ARR-TIME', 'ResFlightETA'), ('PICKUP-TIME-ARRIVAL', 'ResFlightETA', None, <function <lambda>>), ('PICKUP-TYPE-ARRIVAL', None, 1, <function <lambda>>), ('PERSON/', None, None, <function <lambda>>), ('PERSON.GUEST-ID', ('ResPersons', 0, 'PersShId'), None, <function <lambda>>), ('PERSON.MATCHCODE', ('ResPersons', 0, 'PersAcuId'), None, <function <lambda>>), ('PERSON.NAME', ('ResPersons', 0, 'PersSurname'), None, <function <lambda>>), ('PERSON.NAME2', ('ResPersons', 0, 'PersForename'), None, <function <lambda>>), ('PERSON.AUTO-GENERATED', ('ResPersons', 0, 'AutoGen'), '1', <function <lambda>>), ('PERSON.ROOM-SEQ', ('ResPersons', 0, 'RoomSeq'), None, <function <lambda>>), ('PERSON.ROOM-PERS-SEQ', ('ResPersons', 0, 'RoomPersSeq'), None, <function <lambda>>), ('PERSON.PERS-TYPE', ('ResPersons', 0, 'TypeOfPerson'), None, <function <lambda>>), ('PERSON.RN', ('ResPersons', 0, 'RoomNo'), None, <function <lambda>>), ('PERSON.DOB', ('ResPersons', 0, 'PersDOB'), None, <function <lambda>>, <function <lambda>>, <function <lambda>>), ('PERSON.COUNTRY-CODE', ('ResPersons', 0, 'PersCountry'), None, <function <lambda>>), ('PERSON.EMAIL', ('ResPersons', 0, 'PersEmail'), None, <function <lambda>>), ('PERSON.LANG', ('ResPersons', 0, 'PersLanguage'), None, <function <lambda>>), ('PERSON.PHONE', ('ResPersons', 0, 'PersPhone'), None, <function <lambda>>), ('PERSON.PERS-RATE.R', ('ResPersons', 0, 'Board'), None, <function <lambda>>), ('PERSON.PICKUP-COMMENT-ARRIVAL', ('ResPersons', 0, 'FlightArrComment'), None, <function <lambda>>), ('PERSON.PICKUP-TIME-ARRIVAL', ('ResPersons', 0, 'FlightETA'), None, <function <lambda>>), ('PERSON.PICKUP-COMMENT-DEPARTURE', ('ResPersons', 0, 'FlightDepComment'), None, <function <lambda>>), ('PERSON.PICKUP-TIME-DEPARTURE', ('ResPersons', 0, 'FlightETD'), None, <function <lambda>>), ('/PERSON', None, None, <function <lambda>>), ('/RESERVATION',), ('/ARESLIST',))
reservation map
- add_sh_options(cae, client_port=0, add_kernel_port=False, add_maps_and_kernel_usage=False)[source]
add config/command line options.
- client_data(cae, obj_id)[source]
fetch the client data record from Sihot for the client specified by its Sihot object id.
- Parameters:
cae¶ (
ConsoleApp
) – app instance.
- Return type:
- Returns:
client record data structure.
- complete_res_data(rec)[source]
complete reservation data row (rec) with default values.
- Parameters:
- Return type:
- Returns:
completed reservation data Record instance.
- un-changed fields:
ResRoomNo, ResNote, ResLongNote, ResFlightArrComment (flight no…), ResAllotmentNo, ResVoucherNo.
- mandatory fields:
ShId or AcuId or Surname (to specify the orderer of the reservation), ResHotelId, ResArrival, ResDeparture, ResRoomCat, ResMktSegment, ResGdsNo, ResAdults, ResChildren.
- optional fields:
ResPersons0PersSurname and ResPersons0PersForename (surname and forename) ResPersons1PersSurname and ResPersons1PersForename ( … )
- optional auto-populated fields:
see the default values - specified in default_values dict underneath.
- date_range_chunks(date_from, date_till, fetch_max_days)[source]
split date range into manageable chunks respecting the passed maximum days length and yield them back.
- gds_no_to_ids(cae, hotel_id, gds_no)[source]
determine all reservation ids for a reservation with the passed GDS number.
- gds_no_to_obj_id(cae, hotel_id, gds_no)[source]
determine the Sihot object id of a reservation identified by the GDS number.
- Return type:
- res_no_to_ids(cae, hotel_id, res_id, sub_id)[source]
determine all reservation ids for a reservation with the passed reservation number.
- res_no_to_obj_id(cae, hotel_id, res_id, sub_id)[source]
determine the Sihot object id of a reservation identified by their reservation number.
- Return type:
- res_search(cae, date_from, date_till=None, mkt_sources=None, mkt_groups=None, max_los=28, search_flags='', search_scope='', chunk_pause=1)[source]
search reservations with the criteria specified by the parameters.
- Parameters:
cae¶ – instance of the application environment specifying searched Sihot server.
date_till¶ (
Optional
[date
]) – date of last day of included arrivals.mkt_sources¶ (
Optional
[List
[str
]]) – list of market source codes.mkt_groups¶ (
Optional
[List
[str
]]) – list of market group codes.search_flags¶ (
str
) – string with search flag words (separated with semicolon).search_scope¶ (
str
) – string with search scope words (separated with semicolon).chunk_pause¶ (
int
) – integer with seconds to pause between fetch of date range chunks.
- Return type:
- Returns:
string with error message if error or Records/list of Sihot reservations (Record instances).
- obj_id_to_res_no(cae, obj_id)[source]
using RESERVATION-GET oc from KERNEL interface (see 7.3 in SIHOT KERNEL interface doc).
- Parameters:
cae¶ (
ConsoleApp
) – Console App Environment instance.
- Return type:
- Returns:
reservation ids as tuple of (hotel_id, res_id, sub_id, gds_no) or (None, “error”) if not found
- class FldMapXmlParser(cae, elem_map)[source]
Bases:
SihotXmlParser
extended xml parser converting data directly into a sys data Record structure.
- class ClientFromSihot(cae, elem_map=(('OBJID', 'ShId', None, <function <lambda>>), ('MATCHCODE', 'AcuId'), ('T-SALUTATION', 'Salutation'), ('T-TITLE', 'Title'), ('T-GUEST', 'GuestType', '1'), ('NAME-1', 'Surname'), ('NAME-2', 'Forename'), ('STREET', 'Street'), ('PO-BOX', 'POBox'), ('ZIP', 'Postal'), ('CITY', 'City'), ('T-COUNTRY-CODE', 'Country'), ('T-STATE', 'State', None, <function <lambda>>), ('T-LANGUAGE', 'Language'), ('T-NATION', 'Nationality', None, <function <lambda>>), ('COMMENT', 'Comment'), ('COMMUNICATION/', None, None, <function <lambda>>), ('PHONE-1', 'Phone'), ('PHONE-2', 'WorkPhone'), ('FAX-1', 'Fax'), ('EMAIL-1', 'Email'), ('EMAIL-2', 'EmailB'), ('MOBIL-1', 'MobilePhone'), ('MOBIL-2', 'MobilePhoneB'), ('/COMMUNICATION', None, None, <function <lambda>>), ('ADD-DATA/', None, None, <function <lambda>>), ('T-PERSON-GROUP', None, '1A'), ('D-BIRTHDAY', 'DOB', None, None, <function <lambda>>, <function <lambda>>), ('INTERNET-PASSWORD', 'Password'), ('MATCH-ADM', 'RciId'), ('MATCH-SM', 'SfId'), ('/ADD-DATA', None, None, <function <lambda>>)))[source]
Bases:
FldMapXmlParser
extended xml parser converting client data directly into a sys data Record structure.
- __init__(cae, elem_map=(('OBJID', 'ShId', None, <function <lambda>>), ('MATCHCODE', 'AcuId'), ('T-SALUTATION', 'Salutation'), ('T-TITLE', 'Title'), ('T-GUEST', 'GuestType', '1'), ('NAME-1', 'Surname'), ('NAME-2', 'Forename'), ('STREET', 'Street'), ('PO-BOX', 'POBox'), ('ZIP', 'Postal'), ('CITY', 'City'), ('T-COUNTRY-CODE', 'Country'), ('T-STATE', 'State', None, <function <lambda>>), ('T-LANGUAGE', 'Language'), ('T-NATION', 'Nationality', None, <function <lambda>>), ('COMMENT', 'Comment'), ('COMMUNICATION/', None, None, <function <lambda>>), ('PHONE-1', 'Phone'), ('PHONE-2', 'WorkPhone'), ('FAX-1', 'Fax'), ('EMAIL-1', 'Email'), ('EMAIL-2', 'EmailB'), ('MOBIL-1', 'MobilePhone'), ('MOBIL-2', 'MobilePhoneB'), ('/COMMUNICATION', None, None, <function <lambda>>), ('ADD-DATA/', None, None, <function <lambda>>), ('T-PERSON-GROUP', None, '1A'), ('D-BIRTHDAY', 'DOB', None, None, <function <lambda>>, <function <lambda>>), ('INTERNET-PASSWORD', 'Password'), ('MATCH-ADM', 'RciId'), ('MATCH-SM', 'SfId'), ('/ADD-DATA', None, None, <function <lambda>>)))[source]
- class ResFromSihot(cae)[source]
Bases:
FldMapXmlParser
extended xml parser converting reservation data directly into a sys data Record structure.
- class ClientFetch(cae)[source]
Bases:
SihotXmlBuilder
build xml and send to the Sihot system to fetch a client record.
- __init__(cae)[source]
create an instance of this class.
- Parameters:
cae¶ (
ConsoleApp
) – instance of the runningConsoleApp
app.use_kernel¶ – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- fetch_client(obj_id, field_names=())[source]
return Record with guest data OR str with error message in case of error.
-
response:
Optional
[SihotXmlParser
]
- class ClientSearch(cae)[source]
Bases:
SihotXmlBuilder
search client.
- __init__(cae)[source]
create an instance of this class.
- Parameters:
cae¶ – instance of the running
ConsoleApp
app.use_kernel¶ – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- search_clients(matchcode='', exact_matchcode=True, name='', forename='', surname='', guest_no='', email='', guest_type='', flags='FIND-ALSO-DELETED-GUESTS', order_by='', limit=0, field_names=('ShId',), **kwargs)[source]
invoke the client search.
- client_id_by_matchcode(matchcode)[source]
determine client id for a client identified by its match code.
-
response:
Optional
[SihotXmlParser
]
- class ResFetch(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilder
fetch reservation.
- fetch_res(ho_id, gds_no='', res_id='', sub_id='', scope='USEISODATE')[source]
invoke request and fetch of reservation data.
- fetch_by_gds_no(ho_id, gds_no, scope='USEISODATE')[source]
fetch reservation identified by their GDS number.
- fetch_by_res_id(ho_id, res_id, sub_id, scope='USEISODATE')[source]
fetch reservation identified by their reservation number and sub-number.
-
response:
Optional
[SihotXmlParser
]
- class ResSearch(cae, use_kernel=False)[source]
Bases:
SihotXmlBuilder
search reservation.
- search_res(hotel_id='', from_date=datetime.date(2024, 3, 19), to_date=datetime.date(2024, 3, 19), matchcode='', name='', gds_no='', flags='', scope='', guest_id='')[source]
invoke search of reservation.
-
response:
Optional
[SihotXmlParser
]
- class FldMapXmlBuilder(cae, use_kernel=False, elem_map=None)[source]
Bases:
SihotXmlBuilder
extended xml builder base class.
- __init__(cae, use_kernel=False, elem_map=None)[source]
create an instance of this class.
- Parameters:
cae¶ (
ConsoleApp
) – instance of the runningConsoleApp
app.use_kernel¶ (
bool
) – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- prepare_map_xml(rec, include_empty_values=True)[source]
prepare and return xml string.
- Return type:
-
response:
Optional
[SihotXmlParser
]
- class ClientToSihot(cae)[source]
Bases:
FldMapXmlBuilder
extended xml builder class to send/push client data to Sihot.
- __init__(cae)[source]
create an instance of this class.
- Parameters:
cae¶ – instance of the running
ConsoleApp
app.use_kernel¶ – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- _send_person_to_sihot(rec, first_person='')[source]
send client data of one person to Sihot, passing AcuId of first person to send 2nd person.
- Return type:
-
response:
Optional
[SihotXmlParser
]
- class ResToSihot(cae)[source]
Bases:
FldMapXmlBuilder
extended xml builder to send reservation data to Sihot.
- __init__(cae)[source]
create an instance of this class.
- Parameters:
cae¶ (
ConsoleApp
) – instance of the runningConsoleApp
app.use_kernel¶ – pass True to use the Sihot kernel interface (False==use Sihot sxml interface).
- send_res_to_sihot(rec, ensure_client_mode=0)[source]
send reservation to Sihot system.
- Return type:
- res_id_desc(rec, err_msg, separator='\\n\\n', indent=8)[source]
extended reservation ids log and debug message data.
- Return type:
-
response:
Optional
[SihotXmlParser
]
- class BulkFetcherBase(cae, add_kernel_port=True)[source]
Bases:
object
helper base class for bulk data fetches.
- class GuestBulkFetcher(cae, add_kernel_port=True)[source]
Bases:
BulkFetcherBase
WIP/NotUsed/NoTests: the problem is with GUEST-SEARCH is that there is no way to bulk fetch all guests because the search criteria is not providing range search to split in slices. Fetching all 600k clients is resulting in a timeout error after 30 minutes (see Sihot interface SDF_SH_TIMEOUT/’shTimeout’ option value)
- class ResBulkFetcher(cae, allow_future_arrivals=True)[source]
Bases:
BulkFetcherBase
reservation bulk fetch.
- class ResSender(cae)[source]
Bases:
ResToSihot
helper class to send reservation records to Sihot.
-
response:
Optional
[SihotXmlParser
]
-
response: