ti2-tourplan 1.0.60 → 1.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3305,84 +3305,6 @@ exports[`search tests searchItineraries 1`] = `
3305
3305
  Object {
3306
3306
  "bookings": Array [
3307
3307
  Object {
3308
- "AccountingDetails": Object {
3309
- "AmountDue": 0,
3310
- "CreditsTotal": 0,
3311
- "FutureBilling": 187795,
3312
- "InvoicedTotal": 0,
3313
- "ReceivedTotal": 0,
3314
- },
3315
- "AgentRef": "2356674/1",
3316
- "BookingId": 316559,
3317
- "BookingStatus": "Quotation",
3318
- "BookingType": "F",
3319
- "BookingUpdateCount": 2,
3320
- "CanAddServices": "Y",
3321
- "CanCancel": "Y",
3322
- "Consult": "",
3323
- "Currency": "GBP",
3324
- "Dialogue": "",
3325
- "Email": "",
3326
- "EnteredDate": "2024-09-12",
3327
- "IsInternetBooking": "Y",
3328
- "Name": "2356674/1 Sean Conta",
3329
- "QB": "Q",
3330
- "ReadOnly": "N",
3331
- "Ref": "ALFI393706",
3332
- "Remarks": "",
3333
- "Services": Array [
3334
- Object {
3335
- "CanAccept": "N",
3336
- "CanUpdate": "N",
3337
- "CancelDeleteStatus": "D",
3338
- "Comment": "Deluxe King Room",
3339
- "CostedInBooking": "Y",
3340
- "Date": "2025-08-13",
3341
- "Description": "Bed and Full Buffet Breakfast",
3342
- "LinePrice": 187795,
3343
- "LocationCode": "LON",
3344
- "Opt": "LONHOSANLONBFBDLX",
3345
- "OptionNumber": 77490,
3346
- "Remarks": "Passenger Notes: NA.
3347
- Service Notes: NA.",
3348
- "RoomConfigs": Object {
3349
- "RoomConfig": Object {
3350
- "Adults": 1,
3351
- "Children": 0,
3352
- "Infants": 0,
3353
- "PaxList": Object {
3354
- "PaxDetails": Object {
3355
- "Forename": "Sean",
3356
- "PaxType": "A",
3357
- "PersonId": 628199,
3358
- "Surname": "Conta",
3359
- "Title": "Mr",
3360
- },
3361
- },
3362
- "RoomType": "DB",
3363
- },
3364
- },
3365
- "SCU": "night",
3366
- "SCUqty": 4,
3367
- "SequenceNumber": 10,
3368
- "ServiceExtras": Object {
3369
- "ServiceExtra": Object {
3370
- "ChargeBasis": "Room",
3371
- "Description": "Extra Bed",
3372
- "IsCompulsory": "N",
3373
- "IsPricePerPerson": "N",
3374
- "Quantity": 1,
3375
- "SequenceNumber": 1,
3376
- },
3377
- },
3378
- "ServiceLineId": 745684,
3379
- "ServiceLineUpdateCount": 1,
3380
- "SupplierName": "Sanderson",
3381
- "paxList": Array [],
3382
- },
3383
- ],
3384
- "TotalPrice": 187795,
3385
- "TravelDate": "2025-08-13",
3386
3308
  "agentRef": "2356674/1",
3387
3309
  "bookingId": "316559",
3388
3310
  "bookingStatus": "Quotation",
package/index.js CHANGED
@@ -597,54 +597,54 @@ class BuyerPlugin {
597
597
  }
598
598
  */
599
599
  const SCheckPass = Boolean(SCheck);
600
- const ACheckPass = (() => {
601
- /*
602
- FROM TP DOCS:
603
- Each integer in the list gives the availability for one of the days in the range requested,
604
- from the start date through to the end date. The integer values are to be interpreted as
605
- follows:
606
- Greater than 0 means that inventory is available, with the integer specifying the
607
- number of units available. For options with a service type of Y , the inventory is in
608
- units of rooms. For other service types, the inventory is in units of pax.
609
- -1 Not available.
610
- -2 Available on free sell.
611
- -3 Available on request.
612
- Note: A return value of 0 or something less than -3 is impossible.
613
- */
614
- const optAvail = parseInt(R.pathOr('-4', ['OptAvail'], ACheck), 10);
615
- if (optAvail === -1) {
616
- return {
617
- available: false,
618
- };
619
- }
620
- if (optAvail === -2) {
621
- return {
622
- available: true,
623
- type: 'free sell',
624
- };
625
- }
626
- if (optAvail === -3) {
627
- return {
628
- available: true,
629
- type: 'on request',
630
- };
631
- }
632
- if (optAvail > 0) {
633
- return {
634
- available: true,
635
- type: 'inventory',
636
- quantity: optAvail,
637
- };
638
- }
639
- return {
640
- available: false,
641
- };
642
- })();
600
+ // const ACheckPass = (() => {
601
+ // /*
602
+ // FROM TP DOCS:
603
+ // Each integer in the list gives the availability for one of the days in the range requested,
604
+ // from the start date through to the end date. The integer values are to be interpreted as
605
+ // follows:
606
+ // Greater than 0 means that inventory is available, with the integer specifying the
607
+ // number of units available. For options with a service type of Y , the inventory is in
608
+ // units of rooms. For other service types, the inventory is in units of pax.
609
+ // -1 Not available.
610
+ // -2 Available on free sell.
611
+ // -3 Available on request.
612
+ // Note: A return value of 0 or something less than -3 is impossible.
613
+ // */
614
+ // const optAvail = parseInt(R.pathOr('-4', ['OptAvail'], ACheck), 10);
615
+ // if (optAvail === -1) {
616
+ // return {
617
+ // available: false,
618
+ // };
619
+ // }
620
+ // if (optAvail === -2) {
621
+ // return {
622
+ // available: true,
623
+ // type: 'free sell',
624
+ // };
625
+ // }
626
+ // if (optAvail === -3) {
627
+ // return {
628
+ // available: true,
629
+ // type: 'on request',
630
+ // };
631
+ // }
632
+ // if (optAvail > 0) {
633
+ // return {
634
+ // available: true,
635
+ // type: 'inventory',
636
+ // quantity: optAvail,
637
+ // };
638
+ // }
639
+ // return {
640
+ // available: false,
641
+ // };
642
+ // })();
643
643
  let OptStayResults = R.pathOr([], ['OptStayResults'], SCheck);
644
644
  if (!Array.isArray(OptStayResults)) OptStayResults = [OptStayResults];
645
645
  return {
646
- bookable: Boolean(SCheckPass || ACheckPass.available),
647
- type: ACheckPass.type,
646
+ bookable: Boolean(SCheckPass),
647
+ type: 'inventory',
648
648
  rates: OptStayResults.map(rate => {
649
649
  let externalRateText = R.pathOr('', ['ExternalRateDetails', 'ExtOptionDescr'], rate);
650
650
  const extRatePlanDescr = R.pathOr('', ['ExternalRateDetails', 'ExtRatePlanDescr'], rate);
@@ -659,124 +659,6 @@ class BuyerPlugin {
659
659
  };
660
660
  }
661
661
 
662
-
663
- // TODO: safe to deprecate 7-14 days after release date
664
- async searchQuote({
665
- axios,
666
- token: {
667
- hostConnectEndpoint,
668
- hostConnectAgentID,
669
- hostConnectAgentPassword,
670
- },
671
- payload: {
672
- quoteName,
673
- rateId,
674
- quoteId,
675
- // existingQuoteId,
676
- // existingLineId,
677
- optionId,
678
- startDate,
679
- reference,
680
- /*
681
- paxConfigs: [{ roomType: 'DB', adults: 2 }, { roomType: 'TW', children: 2 }]
682
- */
683
- paxConfigs,
684
- /*
685
- The number of second charge units required (second charge units are discussed
686
- in the OptionInfo section). Should only be specified for options that have SCUs.
687
- Defaults to 1.
688
- */
689
- chargeUnitQuanity,
690
- extras,
691
- puInfo,
692
- doInfo,
693
- notes,
694
- QB,
695
- directHeaderPayload,
696
- directLinePayload,
697
- customFieldValues = [],
698
- },
699
- }) {
700
- const cfvPerService = customFieldValues.filter(f => f.isPerService && f.value)
701
- .reduce((acc, f) => {
702
- if (f.type === 'extended-option') {
703
- acc[f.id] = f.value.value || f.value;
704
- } else {
705
- acc[f.id] = f.value;
706
- }
707
- return acc;
708
- }, {});
709
- const model = {
710
- AddServiceRequest: {
711
- AgentID: hostConnectAgentID,
712
- Password: hostConnectAgentPassword,
713
- ...(quoteId ? {
714
- ExistingBookingInfo: { BookingId: quoteId },
715
- } : {
716
- NewBookingInfo: {
717
- Name: this.escapeInvalidXmlChars(quoteName),
718
- QB: QB || 'Q',
719
- ...(directHeaderPayload || {}),
720
- },
721
- }),
722
- ...(puInfo && (puInfo.time || puInfo.location || puInfo.flightDetails) ? {
723
- ...(puInfo.time && puInfo.time.replace(/\D/g, '') ? {
724
- puTime: puInfo.time.replace(/\D/g, ''),
725
- } : {}),
726
- puRemark: this.escapeInvalidXmlChars(`${puInfo.location ? `Location: ${puInfo.location || 'NA'},` : ''}
727
- ${puInfo.flightDetails ? `Flight: ${puInfo.flightDetails || 'NA'},` : ''}
728
- `),
729
- } : {}),
730
- ...(doInfo && (doInfo.time || doInfo.location || doInfo.flightDetails) ? {
731
- // only get numbers from doInfo.time
732
- ...(doInfo.time && doInfo.time.replace(/\D/g, '') ? {
733
- doTime: doInfo.time.replace(/\D/g, ''),
734
- } : {}),
735
- doRemark: this.escapeInvalidXmlChars(`${doInfo.location ? `Location: ${doInfo.location || 'NA'},` : ''}
736
- ${doInfo.flightDetails ? `Flight: ${doInfo.flightDetails || 'NA'},` : ''}
737
- `),
738
- } : {}),
739
- ...(extras && extras.filter(e => e.selectedExtra && e.selectedExtra.id).length ? {
740
- ExtraQuantities: {
741
- ExtraQuantityItem: extras.filter(e => e.selectedExtra && e.selectedExtra.id).map(e => ({
742
- SequenceNumber: e.selectedExtra.id,
743
- ExtraQuantity: e.quantity,
744
- })),
745
- },
746
- } : {}),
747
- Remarks: this.escapeInvalidXmlChars(notes).slice(0, 220),
748
- Opt: optionId,
749
- DateFrom: startDate,
750
- RateId: rateId || 'Default',
751
- SCUqty: (() => {
752
- const num = parseInt(chargeUnitQuanity, 10);
753
- if (isNaN(num) || num < 1) return 1;
754
- return num;
755
- })(),
756
- AgentRef: reference,
757
- RoomConfigs: this.getRoomConfigs(paxConfigs),
758
- ...(directLinePayload || {}),
759
- ...(cfvPerService || {}),
760
- },
761
- };
762
- const replyObj = await this.callTourplan({
763
- model,
764
- endpoint: hostConnectEndpoint,
765
- axios,
766
- xmlOptions: hostConnectXmlOptions,
767
- });
768
- return {
769
- message: R.path(['AddServiceReply', 'Status'], replyObj)
770
- === 'NO' ? 'Service cannot be added to quote for the requested date/stay. (e.g. no rates, block out period, on request, minimum stay etc.)' : '',
771
- quote: {
772
- id: R.path(['AddServiceReply', 'BookingId'], replyObj) || quoteId,
773
- reference: R.path(['AddServiceReply', 'Ref'], replyObj),
774
- linePrice: R.path(['AddServiceReply', 'Services', 'Service', 'LinePrice'], replyObj),
775
- lineId: R.path(['AddServiceReply', 'ServiceLineId'], replyObj),
776
- },
777
- };
778
- }
779
-
780
662
  async addServiceToItinerary({
781
663
  axios,
782
664
  token: {
@@ -1008,47 +890,27 @@ class BuyerPlugin {
1008
890
  const replyObjs = await Promise.all(allSearches);
1009
891
  const bookingHeaders = R.flatten(replyObjs.map(o => R.pathOr([], ['ListBookingsReply', 'BookingHeaders', 'BookingHeader'], o)));
1010
892
  const bookings = await Promise.map(bookingHeaders, async bookingHeader => {
1011
- const getBookingPayload = getPayload('GetBookingRequest', {
1012
- BookingId: R.prop('BookingId', bookingHeader),
1013
- ReturnAccountInfo: 'Y',
1014
- ReturnRoomConfigs: 'Y',
1015
- });
1016
- const bookingReply = await this.callTourplan(getBookingPayload);
1017
- const booking = R.path(['GetBookingReply'], bookingReply);
1018
- const newBooking = await translateItineraryBooking({
1019
- rootValue: booking,
1020
- typeDefs: itineraryBookingTypeDefs,
1021
- query: itineraryBookingQuery,
1022
- });
1023
- // TODO: safe to deprecate 7-14 days after release date
1024
- let Services = R.pathOr([], ['Services', 'Service'], booking);
1025
- if (!Array.isArray(Services)) Services = [Services];
1026
- Services = Services.map(s => {
1027
- let actualRoomConfigs = s.RoomConfigs.RoomConfig;
1028
- if (!Array.isArray(actualRoomConfigs)) actualRoomConfigs = [actualRoomConfigs];
1029
- const paxList = actualRoomConfigs.reduce((acc, roomConfig) => {
1030
- const paxDetails = R.pathOr([], ['PaxList', 'PaxDetails'], roomConfig);
1031
- if (!Array.isArray(paxDetails)) return acc;
1032
- return [...acc, ...paxDetails];
1033
- }, [])
1034
- .map(p => ({
1035
- personId: R.path(['PersonId'], p),
1036
- firstName: R.path(['Forename'], p),
1037
- lastName: R.path(['Surname'], p),
1038
- }));
1039
- return {
1040
- ...s,
1041
- paxList,
1042
- };
1043
- });
1044
- return {
1045
- ...newBooking,
1046
- ...booking,
1047
- Services,
1048
- };
893
+ try {
894
+ const getBookingPayload = getPayload('GetBookingRequest', {
895
+ BookingId: R.prop('BookingId', bookingHeader),
896
+ ReturnAccountInfo: 'Y',
897
+ ReturnRoomConfigs: 'Y',
898
+ });
899
+ const bookingReply = await this.callTourplan(getBookingPayload);
900
+ const booking = R.path(['GetBookingReply'], bookingReply);
901
+ const newBooking = await translateItineraryBooking({
902
+ rootValue: booking,
903
+ typeDefs: itineraryBookingTypeDefs,
904
+ query: itineraryBookingQuery,
905
+ });
906
+ return newBooking;
907
+ } catch (err) {
908
+ console.log('error in searchBooking', err);
909
+ return null;
910
+ }
1049
911
  }, { concurrency: 10 });
1050
912
  return {
1051
- bookings,
913
+ bookings: bookings.filter(b => b),
1052
914
  };
1053
915
  }
1054
916
  }
package/index.test.js CHANGED
@@ -235,7 +235,7 @@ describe('search tests', () => {
235
235
  expect(retVal.rates.length).toBeGreaterThan(0);
236
236
  expect(retVal.type).toBe('inventory');
237
237
  });
238
- it('searchAvailabilityForItinerary - bookable - on request', async () => {
238
+ it.skip('searchAvailabilityForItinerary - bookable - on request', async () => {
239
239
  axios.mockImplementation(getFixture);
240
240
  const retVal = await app.searchAvailabilityForItinerary({
241
241
  axios,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {