tripstorekrabi-shared 1.21.3 → 1.21.5
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/package.json +1 -1
- package/price.js +10 -10
- package/utils.js +19 -21
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CUSTOM_MEETING_POINT, TELL_HOTEL_LATER_STARTING_POINT,
|
|
1
|
+
import { CUSTOM_MEETING_POINT, TELL_HOTEL_LATER_STARTING_POINT, getBookingSourceKey } from "./utils.js";
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import isBetween from 'dayjs/plugin/isBetween.js';
|
|
4
4
|
|
|
@@ -68,13 +68,13 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
|
|
|
68
68
|
console.error(`No volume price found for the total amount of ${booking.adults + booking.children} people`);
|
|
69
69
|
return undefined;
|
|
70
70
|
} else {
|
|
71
|
-
let
|
|
71
|
+
let bookingSourceKey = getBookingSourceKey(booking.referenceNumber);
|
|
72
72
|
|
|
73
|
-
if (volume[
|
|
74
|
-
let customPricing = volume[
|
|
73
|
+
if (volume[bookingSourceKey]) {
|
|
74
|
+
let customPricing = volume[bookingSourceKey];
|
|
75
75
|
|
|
76
76
|
if (options.mode === SELLING_MODE) {
|
|
77
|
-
let commissionRate = pricing.commissionRates?.[
|
|
77
|
+
let commissionRate = pricing.commissionRates?.[bookingSourceKey];
|
|
78
78
|
|
|
79
79
|
if (commissionRate && commissionRate > 0) {
|
|
80
80
|
total = booking.adults * calculateSellingPrice(commissionRate, customPricing.adult.partnerNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? (booking.children * calculateSellingPrice(commissionRate, customPricing.child.partnerNetPrice)) : 0);
|
|
@@ -102,13 +102,13 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
|
|
|
102
102
|
console.error(`No volume price found for the total amount of ${booking.adults + booking.children} people`);
|
|
103
103
|
return undefined;
|
|
104
104
|
} else {
|
|
105
|
-
let
|
|
105
|
+
let bookingSourceKey = getBookingSourceKey(booking.otaPartnerRef);
|
|
106
106
|
|
|
107
|
-
if (volume[
|
|
108
|
-
let customPricing = volume[
|
|
107
|
+
if (volume[bookingSourceKey]) {
|
|
108
|
+
let customPricing = volume[bookingSourceKey];
|
|
109
109
|
|
|
110
110
|
if (options.mode === SELLING_MODE) {
|
|
111
|
-
let commissionRate = pricing.commissionRates?.[
|
|
111
|
+
let commissionRate = pricing.commissionRates?.[bookingSourceKey];
|
|
112
112
|
|
|
113
113
|
if (commissionRate && commissionRate > 0) {
|
|
114
114
|
total = calculateSellingPrice(commissionRate, customPricing.partnerNetPrice);
|
|
@@ -139,7 +139,7 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
export function findVolume(people, pricing) {
|
|
142
|
-
let total = people.adults + people.children ?? 0;
|
|
142
|
+
let total = (people.adults ?? 0) + (people.children ?? 0);
|
|
143
143
|
return [...pricing.volumes].sort((v1, v2) => v1.max - v2.max).find((item, i) => {
|
|
144
144
|
if (total <= item.max) {
|
|
145
145
|
return true;
|
package/utils.js
CHANGED
|
@@ -695,61 +695,59 @@ export function createVoucherRequest(booking, product) {
|
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
export function isGYGBooking(otaPartnerRef) {
|
|
698
|
-
return otaPartnerRef
|
|
698
|
+
return otaPartnerRef?.id === GYG_AGENCY_ID;
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
export function isViatorBooking(otaPartnerRef) {
|
|
702
|
-
return otaPartnerRef
|
|
702
|
+
return otaPartnerRef?.id === VIATOR_AGENCY_ID;
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
export function isExpediaBooking(otaPartnerRef) {
|
|
706
|
-
return otaPartnerRef
|
|
706
|
+
return otaPartnerRef?.id === EXP_AGENCY_ID;
|
|
707
707
|
}
|
|
708
708
|
|
|
709
709
|
export function isKlookBooking(otaPartnerRef) {
|
|
710
|
-
return otaPartnerRef
|
|
710
|
+
return otaPartnerRef?.id === KLK_AGENCY_ID;
|
|
711
711
|
}
|
|
712
712
|
|
|
713
713
|
export function isMusementBooking(otaPartnerRef) {
|
|
714
|
-
return otaPartnerRef
|
|
714
|
+
return otaPartnerRef?.id === MUS_AGENCY_ID;
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
export function isTiqetsBooking(otaPartnerRef) {
|
|
718
|
-
return otaPartnerRef
|
|
718
|
+
return otaPartnerRef?.id === TIQ_AGENCY_ID;
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
export function isCivitatisBooking(otaPartnerRef) {
|
|
722
|
-
return otaPartnerRef
|
|
722
|
+
return otaPartnerRef?.id === CIV_AGENCY_ID;
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
export function isCuriosidad(otaPartnerRef) {
|
|
726
|
-
return otaPartnerRef
|
|
726
|
+
return otaPartnerRef?.id === CUR_AGENCY_ID
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
export function isTSKBooking(otaPartnerRef) {
|
|
730
730
|
return !otaPartnerRef || otaPartnerRef.id === TRIPSTORE_AGENCY_ID;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
export function
|
|
734
|
-
if (
|
|
735
|
-
return '';
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if (isGYGBooking(referenceNumber)) {
|
|
733
|
+
export function getBookingSourceKey(otaPartnerRef) {
|
|
734
|
+
if (isGYGBooking(otaPartnerRef)) {
|
|
739
735
|
return 'gyg';
|
|
740
|
-
} else if (isViatorBooking(
|
|
736
|
+
} else if (isViatorBooking(otaPartnerRef)) {
|
|
741
737
|
return 'br';
|
|
742
|
-
} else if (isExpediaBooking(
|
|
738
|
+
} else if (isExpediaBooking(otaPartnerRef)) {
|
|
743
739
|
return 'exp';
|
|
744
|
-
} else if (isKlookBooking(
|
|
740
|
+
} else if (isKlookBooking(otaPartnerRef)) {
|
|
745
741
|
return 'klk';
|
|
746
|
-
} else if (isMusementBooking(
|
|
742
|
+
} else if (isMusementBooking(otaPartnerRef)) {
|
|
747
743
|
return 'mus';
|
|
748
|
-
} else if (isTiqetsBooking(
|
|
744
|
+
} else if (isTiqetsBooking(otaPartnerRef)) {
|
|
749
745
|
return 'tiq';
|
|
750
|
-
} else if (isCuriosidad(
|
|
746
|
+
} else if (isCuriosidad(otaPartnerRef)) {
|
|
751
747
|
return 'cur';
|
|
752
|
-
} else if (
|
|
748
|
+
} else if (isCivitatisBooking(otaPartnerRef)) {
|
|
749
|
+
return 'civ';
|
|
750
|
+
} else if (isTSKBooking(otaPartnerRef)) {
|
|
753
751
|
return 'tsk';
|
|
754
752
|
}
|
|
755
753
|
|