tripstorekrabi-shared 1.13.4 → 1.13.6
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 +22 -12
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -111,31 +111,41 @@ export function countMaxPeople(pricing) {
|
|
|
111
111
|
return volume ? volume.reduce((p, v) => p > v ? p : v) : MAX_PAX;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
export function getTotalAmountToBeReceived(booking) {
|
|
115
|
+
return booking.partnerNetPrice + calculateExtraPayments(booking, true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getTotalOperatorNetPrice(booking) {
|
|
119
|
+
return booking.operatorNetPrice + calculateExtraPayments(booking, false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function calculateTotalPrice(booking, product, mode = "retail") {
|
|
123
|
+
let total = calculateProductPrice(booking, product.pricing, mode);
|
|
124
|
+
total += calculateStartEndPointPrice(booking, findStartingPoint(product, booking.startingPointId, false), mode === "retail" || mode === "partner");
|
|
125
|
+
total += calculateStartEndPointPrice(booking, findEndPoint(product, booking.endPointId, false), mode === "retail" || mode === "partner");
|
|
126
|
+
total += calculateNationalParkFee(booking, product);
|
|
127
|
+
total += calculateAddOnsPrice(booking, product, mode === "retail" || mode === "partner");
|
|
118
128
|
return total;
|
|
119
129
|
}
|
|
120
130
|
|
|
121
|
-
export function calculateNationalParkFee(
|
|
122
|
-
return
|
|
131
|
+
export function calculateNationalParkFee(booking, product) {
|
|
132
|
+
return booking.nationalParkFee === ALREADY_PAID && product.nationalPark ? product.nationalPark.pricing.adult * booking.adults + product.nationalPark.pricing.child * booking.children : 0;
|
|
123
133
|
}
|
|
124
134
|
|
|
125
|
-
export function calculateExtraPayments(
|
|
135
|
+
export function calculateExtraPayments(booking, selling = true) {
|
|
126
136
|
let total = 0;
|
|
127
|
-
if (
|
|
128
|
-
for (const extraPayment of Object.values(
|
|
137
|
+
if (booking.extraPayments) {
|
|
138
|
+
for (const extraPayment of Object.values(booking.extraPayments).filter((item) => !item.disabled && item.paymentMethod !== PAY_ON_TOUR)) {
|
|
129
139
|
total += selling ? (extraPayment.receivedAmount ? extraPayment.receivedAmount : extraPayment.price) : extraPayment.operatorPrice;
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
return total;
|
|
133
143
|
}
|
|
134
144
|
|
|
135
|
-
export function calculateAddOnsPrice(
|
|
145
|
+
export function calculateAddOnsPrice(booking, product, selling = true) {
|
|
136
146
|
let total = 0;
|
|
137
|
-
if (
|
|
138
|
-
for (const [id, addOn] of Object.entries(
|
|
147
|
+
if (booking.addOns) {
|
|
148
|
+
for (const [id, addOn] of Object.entries(booking.addOns)) {
|
|
139
149
|
let addOnDef = findAddOn(id, product.addOns);
|
|
140
150
|
if (addOnDef) {
|
|
141
151
|
total += addOn.adults * (selling ? addOnDef.pricing.adult
|