tripstorekrabi-shared 1.12.6 → 1.12.7
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 +11 -0
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -113,6 +113,7 @@ export function calculateTotalPrice(data, product, mode = "retail") {
|
|
|
113
113
|
total += calculateStartEndPointPrice(data, findStartingPoint(product, data.startingPointId, false), mode === "retail" || mode === "partner");
|
|
114
114
|
total += calculateStartEndPointPrice(data, findEndPoint(product, data.endPointId, false), mode === "retail" || mode === "partner");
|
|
115
115
|
total += calculateNationalParkFee(data, product);
|
|
116
|
+
total += calculateExtraPayments(data, mode === "retail" || mode === "partner");
|
|
116
117
|
total += calculateAddOnsPrice(data, product, mode === "retail" || mode === "partner");
|
|
117
118
|
return total;
|
|
118
119
|
}
|
|
@@ -121,6 +122,16 @@ export function calculateNationalParkFee(data, product) {
|
|
|
121
122
|
return data.nationalParkFee === "Already paid" && product.nationalPark ? product.nationalPark.pricing.adult * data.adults + product.nationalPark.pricing.child * data.children : 0;
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
export function calculateExtraPayments(data, selling = true) {
|
|
126
|
+
let total = 0;
|
|
127
|
+
if (data.extraPayments) {
|
|
128
|
+
for (const extraPayment of Object.values(data.extraPayments)) {
|
|
129
|
+
total += selling ? extraPayment.receivedAmount : extraPayment.operatorPrice;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return total;
|
|
133
|
+
}
|
|
134
|
+
|
|
124
135
|
export function calculateAddOnsPrice(data, product, selling = true) {
|
|
125
136
|
let total = 0;
|
|
126
137
|
if (data.addOns) {
|