ti2-tourplan 1.0.38 → 1.0.40

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.
package/index.js CHANGED
@@ -214,10 +214,10 @@ class Plugin {
214
214
  Child: 'C',
215
215
  Infant: 'I',
216
216
  }[p.passengerType] || 'A',
217
- Title: p.salutation,
218
217
  };
218
+ if (p.salutation) PaxDetails.Title = p.salutation;
219
219
  if (p.dob) PaxDetails.DateOfBirth = p.dob;
220
- if (!isNaN(p.age)) {
220
+ if (!R.isNil(p.age) && !isNaN(p.age)) {
221
221
  if (!(p.passengerType === 'Adult' && p.age === 0)) {
222
222
  PaxDetails.Age = p.age;
223
223
  }
@@ -525,7 +525,11 @@ class Plugin {
525
525
  Opt: optionId,
526
526
  Info: 'S',
527
527
  DateFrom: startDate,
528
- DateTo: startDate,
528
+ SCUqty: (() => {
529
+ const num = parseInt(chargeUnitQuanity, 10);
530
+ if (isNaN(num) || num < 1) return 1;
531
+ return num;
532
+ })(),
529
533
  RoomConfigs: this.getPaxConfigs(paxConfigs, true),
530
534
  AgentID: hostConnectAgentID,
531
535
  Password: hostConnectAgentPassword,
@@ -690,7 +694,11 @@ class Plugin {
690
694
  Opt: optionId,
691
695
  DateFrom: startDate,
692
696
  RateId: 'Default',
693
- SCUqty: chargeUnitQuanity || 1,
697
+ SCUqty: (() => {
698
+ const num = parseInt(chargeUnitQuanity, 10);
699
+ if (isNaN(num) || num < 1) return 1;
700
+ return num;
701
+ })(),
694
702
  AgentRef: reference,
695
703
  RoomConfigs: this.getPaxConfigs(paxConfigs),
696
704
  },
@@ -703,7 +711,7 @@ class Plugin {
703
711
  });
704
712
  return {
705
713
  message: R.path(['AddServiceReply', 'Status'], replyObj)
706
- === 'NO' ? 'Service cannot be added to quote' : '',
714
+ === 'NO' ? 'Service cannot be added to quote (could be due to no rates)' : '',
707
715
  quote: {
708
716
  id: R.path(['AddServiceReply', 'BookingId'], replyObj),
709
717
  reference: R.path(['AddServiceReply', 'Ref'], replyObj),
@@ -740,6 +748,7 @@ class Plugin {
740
748
  purchaseDateStart,
741
749
  purchaseDateEnd,
742
750
  bookingId,
751
+ name,
743
752
  },
744
753
  }) {
745
754
  const getPayload = (RequestType, RequestInput) => ({
@@ -758,11 +767,18 @@ class Plugin {
758
767
  EnteredDateFrom: purchaseDateStart || moment().subtract(6, 'month').format('YYYY-MM-DD'),
759
768
  EnteredDateTo: purchaseDateEnd || moment().format('YYYY-MM-DD'),
760
769
  });
761
- const allSearches = bookingId
762
- ? ['BookingId', 'Ref', 'AgentRef'].map(async key => {
770
+ let searchCriterias = [];
771
+ if (bookingId) {
772
+ searchCriterias = ['BookingId', 'Ref', 'AgentRef'].map(key => ({ [key]: bookingId }));
773
+ }
774
+ if (name) {
775
+ searchCriterias.push({ NameContains: name });
776
+ }
777
+ const allSearches = searchCriterias.length
778
+ ? searchCriterias.map(async keyObj => {
763
779
  let reply;
764
780
  try {
765
- reply = await this.callTourplan(getPayload('ListBookingsRequest', { [key]: bookingId }));
781
+ reply = await this.callTourplan(getPayload('ListBookingsRequest', keyObj));
766
782
  } catch (err) {
767
783
  if (err.includes && err.includes('Request failed with status code')) {
768
784
  throw Error(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -124,14 +124,14 @@ const translateTPOption = ({ optionsGroupedBySupplierId, supplierData }) => {
124
124
  }
125
125
  if (R.path(['OptGeneral', 'SType'], option) === 'Y' || R.path(['OptGeneral', 'SType'], option) === 'P') {
126
126
  return ['Single', 'Twin', 'Double', 'Quad']
127
- .map(([unitId, unitName]) => ({
127
+ .map((unitId) => ({
128
128
  unitId,
129
- unitName,
129
+ unitName: unitId,
130
130
  pricing: [],
131
131
  restrictions: {
132
- allowed: R.path(['OptGeneral', `${unitName}_Avail`], option) === 'Y',
133
- paxCount: R.path(['OptGeneral', `${unitName}_Max`], option)
134
- || R.path(['OptGeneral', `${unitName}_Ad_Max`], option),
132
+ allowed: R.path(['OptGeneral', `${unitId}_Avail`], option) === 'Y',
133
+ paxCount: R.path(['OptGeneral', `${unitId}_Max`], option)
134
+ || R.path(['OptGeneral', `${unitId}_Ad_Max`], option),
135
135
  },
136
136
  }));
137
137
  }