ti2-tourplan 1.0.50 → 1.0.51

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.
Files changed (2) hide show
  1. package/index.js +29 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -590,11 +590,22 @@ class Plugin {
590
590
  RateText: 'Std'
591
591
  }
592
592
  },
593
- RateId: 'Default',
593
+ RateId: '$NZD2016b81f44793096,4,DOUB,C5 A1INF KGB DOUB RONL',
594
594
  RateName: 'Std-Mon Sun',
595
595
  RateText: 'Std',
596
596
  SaleFrom: '2023-12-20',
597
- TotalPrice: '51175'
597
+ TotalPrice: '51175',
598
+ ExternalRateDetails: {
599
+ ExtSupplierId: 'NZ000021',
600
+ ExtOptionId: 'DOUB',
601
+ ExtOptionDescr: 'Superior Room, 1 King Bed',
602
+ ExtRatePlanCode: 'C5 A1INF KGB DOUB RONL',
603
+ ExtRatePlanDescr: 'Room Only',
604
+ ExtGuarantee: 'N',
605
+ },
606
+ RoomList: {
607
+ RoomType: 'DB',
608
+ }
598
609
  },
599
610
  OptionNumber: '70461'
600
611
  }
@@ -602,8 +613,21 @@ class Plugin {
602
613
  }
603
614
  */
604
615
  const optionInfoReply = R.path(['OptionInfoReply'], replyObj);
616
+ let OptStayResults = R.pathOr([], ['Option', 'OptStayResults'], optionInfoReply);
617
+ if (!Array.isArray(OptStayResults)) OptStayResults = [OptStayResults];
605
618
  return {
606
619
  bookable: Boolean(optionInfoReply),
620
+ rates: OptStayResults.map(rate => {
621
+ let externalRateText = R.pathOr('', ['ExternalRateDetails', 'ExtOptionDescr'], rate);
622
+ const extRatePlanDescr = R.pathOr('', ['ExternalRateDetails', 'ExtRatePlanDescr'], rate);
623
+ if (extRatePlanDescr && !externalRateText.includes(extRatePlanDescr)) {
624
+ externalRateText = `${externalRateText} (${extRatePlanDescr})`;
625
+ }
626
+ return {
627
+ rateId: R.path(['RateId'], rate),
628
+ externalRateText,
629
+ };
630
+ }),
607
631
  };
608
632
  // THE BELOW CODE is for A check, might still need it on user's future request
609
633
  // const optAvail = parseInt(R.pathOr('-4', ['OptionInfoReply', 'Option', 'OptAvail'], replyObj), 10);
@@ -679,6 +703,7 @@ class Plugin {
679
703
  puInfo,
680
704
  doInfo,
681
705
  notes,
706
+ directHeaderPayload,
682
707
  },
683
708
  }) {
684
709
  const model = {
@@ -691,11 +716,9 @@ class Plugin {
691
716
  NewBookingInfo: {
692
717
  Name: this.escapeInvalidXmlChars(quoteName),
693
718
  QB: 'Q',
719
+ ...(directHeaderPayload || {}),
694
720
  },
695
721
  }),
696
- ...(rateId ? {
697
- RateId: rateId,
698
- } : {}),
699
722
  ...(puInfo && (puInfo.time || puInfo.location || puInfo.flightDetails) ? {
700
723
  ...(puInfo.time && puInfo.time.replace(/\D/g, '') ? {
701
724
  puTime: puInfo.time.replace(/\D/g, ''),
@@ -724,7 +747,7 @@ class Plugin {
724
747
  Remarks: this.escapeInvalidXmlChars(notes).slice(0, 220),
725
748
  Opt: optionId,
726
749
  DateFrom: startDate,
727
- RateId: 'Default',
750
+ RateId: rateId || 'Default',
728
751
  SCUqty: (() => {
729
752
  const num = parseInt(chargeUnitQuanity, 10);
730
753
  if (isNaN(num) || num < 1) return 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.50",
3
+ "version": "1.0.51",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {