tripstorekrabi-shared 1.21.4 → 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 +11 -13
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
|
@@ -730,26 +730,24 @@ 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
|
|