tripstorekrabi-shared 1.12.7 → 1.12.9
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 +4 -2
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { getBookingType } from "./utils.js";
|
|
3
3
|
|
|
4
4
|
export const MAX_PAX = 30;
|
|
5
|
+
export const PAY_ON_TOUR = 'Pay on tour';
|
|
6
|
+
export const ALREADY_PAID = "Already paid";
|
|
5
7
|
|
|
6
8
|
export function calculateProductPrice(booking, pricing, mode = "retail") {
|
|
7
9
|
let type = pricing.type;
|
|
@@ -119,14 +121,14 @@ export function calculateTotalPrice(data, product, mode = "retail") {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
export function calculateNationalParkFee(data, product) {
|
|
122
|
-
return data.nationalParkFee ===
|
|
124
|
+
return data.nationalParkFee === ALREADY_PAID && product.nationalPark ? product.nationalPark.pricing.adult * data.adults + product.nationalPark.pricing.child * data.children : 0;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
export function calculateExtraPayments(data, selling = true) {
|
|
126
128
|
let total = 0;
|
|
127
129
|
if (data.extraPayments) {
|
|
128
130
|
for (const extraPayment of Object.values(data.extraPayments)) {
|
|
129
|
-
total += selling ? extraPayment.receivedAmount : extraPayment.operatorPrice;
|
|
131
|
+
total += selling ? (extraPayment.receivedAmount ? extraPayment.receivedAmount : extraPayment.price) : extraPayment.operatorPrice;
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
return total;
|