tripstorekrabi-shared 1.13.22 → 1.13.24
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 +28 -0
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -134,6 +134,20 @@ export function getTotalAmountToBeReceived(booking) {
|
|
|
134
134
|
return total;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
export function calculatePartnerNetPrice(booking, product) {
|
|
138
|
+
return getExtraPaymentsPaidWithPartner(
|
|
139
|
+
booking,
|
|
140
|
+
product
|
|
141
|
+
).reduce(
|
|
142
|
+
(prev, curr) => prev + curr.price,
|
|
143
|
+
calculateProductPrice(
|
|
144
|
+
booking,
|
|
145
|
+
product.pricing,
|
|
146
|
+
'partner'
|
|
147
|
+
)
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
137
151
|
export function calculateTotalPrice(booking, product, mode = "retail") {
|
|
138
152
|
let total = calculateProductPrice(booking, product.pricing, mode);
|
|
139
153
|
total += calculateStartEndPointPrice(booking, findStartingPoint(product, booking.startingPointId, false), mode === "retail" || mode === "partner");
|
|
@@ -180,6 +194,19 @@ export function calculateExtraPayments(booking, selling = true, calculationMode
|
|
|
180
194
|
export function getExtraPaymentsPaidWithPartner(booking, product) {
|
|
181
195
|
let startingPoint = findStartingPoint(product, booking.startingPointId);
|
|
182
196
|
let endPoint = findEndPoint(product, booking.endPointId);
|
|
197
|
+
let addOnDefs = product.addOns ?? {};
|
|
198
|
+
let addOns = Object.keys(booking.addOns).filter((id) => addOnDefs[id] != null).map(([id, addOn]) => {
|
|
199
|
+
let addOnDef = addOnDefs[id];
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
category: ADD_ON_EXTRA_PAYMENT,
|
|
203
|
+
description: addOnDef.title,
|
|
204
|
+
price: addOn.adults * addOnDef.pricing.adult.sellingPrice +
|
|
205
|
+
(addOn.children ?? 0) * addOnDef.pricing.child.sellingPrice,
|
|
206
|
+
operatorPrice: addOn.adults * addOnDef.pricing.adult.operatorNetPrice +
|
|
207
|
+
(addOn.children ?? 0) * addOnDef.pricing.child.operatorNetPrice
|
|
208
|
+
}
|
|
209
|
+
});
|
|
183
210
|
|
|
184
211
|
return [
|
|
185
212
|
{
|
|
@@ -200,6 +227,7 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
|
|
|
200
227
|
price: calculateNationalParkFee(booking, product),
|
|
201
228
|
operatorPrice: calculateNationalParkFee(booking, product),
|
|
202
229
|
},
|
|
230
|
+
...addOns
|
|
203
231
|
].filter(
|
|
204
232
|
(item) =>
|
|
205
233
|
(item.price > 0 || item.operatoPrice > 0) &&
|