tripstorekrabi-shared 1.13.64 → 1.13.65
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
|
@@ -311,6 +311,34 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
export function getActiveExtraPayments(extraPayments) {
|
|
315
|
+
return extraPayments
|
|
316
|
+
.filter(([id, item]) => !item.disabled)
|
|
317
|
+
.sort(([id1, item1], [id2, item2]) =>
|
|
318
|
+
item1.description.localeCompare(item2.description)
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function getExtraPaymentsOperatorPrice(extraPayments) {
|
|
323
|
+
return getActiveExtraPayments(extraPayments).reduce(
|
|
324
|
+
(prev, curr) => {
|
|
325
|
+
let price;
|
|
326
|
+
let item = curr[1];
|
|
327
|
+
if (item.paymentMethod === PAY_ON_TOUR) {
|
|
328
|
+
let ourCommission = item.price - item.operatorPrice;
|
|
329
|
+
if (ourCommission > 0) {
|
|
330
|
+
price = -ourCommission;
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
price = item.operatorPrice;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return prev + price;
|
|
337
|
+
},
|
|
338
|
+
0
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
314
342
|
export function calculateAddOnsPrice(booking, product, options = { mode: SELLING_MODE }) {
|
|
315
343
|
let total = 0;
|
|
316
344
|
let isSelling = options.mode in [SELLING_MODE, PARTNER_MODE];
|