tripstorekrabi-shared 1.13.38 → 1.13.40
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 -9
- package/product.js +2 -2
package/package.json
CHANGED
package/price.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { getBookingType } from "./utils.js";
|
|
2
2
|
|
|
3
|
-
export const SELLING_PAYMENT_MODE = 0;
|
|
4
|
-
export const PARTNER_PAYMENT_MODE = 1;
|
|
5
|
-
export const OPERATOR_PAYMENT_MODE = 2;
|
|
6
3
|
export const MAX_PAX = 30;
|
|
7
4
|
export const PAY_ON_TOUR = 'Pay on tour';
|
|
8
5
|
export const ALREADY_PAID = "Already paid";
|
|
@@ -20,6 +17,10 @@ export const EXTRA_PAYMENT_CATEGORIES = [STARTING_POINT_EXTRA_PAYMENT,
|
|
|
20
17
|
ADD_ON_EXTRA_PAYMENT,
|
|
21
18
|
OTHER_EXTRA_PAYMENT];
|
|
22
19
|
|
|
20
|
+
const SELLING_PAYMENT_MODE = 0;
|
|
21
|
+
const PARTNER_PAYMENT_MODE = 1;
|
|
22
|
+
const OPERATOR_PAYMENT_MODE = 2;
|
|
23
|
+
|
|
23
24
|
export function calculateProductSellingPrice(booking, pricing) {
|
|
24
25
|
return calculateProductPrice(booking, pricing, { paymentMode: SELLING_PAYMENT_MODE });
|
|
25
26
|
}
|
|
@@ -32,7 +33,7 @@ export function calculateProductOperatorPrice(booking, pricing) {
|
|
|
32
33
|
return calculateProductPrice(booking, pricing, { paymentMode: OPERATOR_PAYMENT_MODE });
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
function calculateProductPrice(booking, pricing, options = { paymentMode: SELLING_PAYMENT_MODE }) {
|
|
36
37
|
function calculateRetailPrice(commissionRate, price) {
|
|
37
38
|
return Math.floor(
|
|
38
39
|
(price * 100) /
|
|
@@ -246,14 +247,14 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
|
|
|
246
247
|
{
|
|
247
248
|
category: STARTING_POINT_EXTRA_PAYMENT,
|
|
248
249
|
description: startingPoint.name,
|
|
249
|
-
price: calculateStartEndPointPrice(booking, startingPoint,
|
|
250
|
-
operatorPrice: calculateStartEndPointPrice(booking, startingPoint,
|
|
250
|
+
price: calculateStartEndPointPrice(booking, startingPoint, { paymentMode: SELLING_PAYMENT_MODE }),
|
|
251
|
+
operatorPrice: calculateStartEndPointPrice(booking, startingPoint, { paymentMode: OPERATOR_PAYMENT_MODE }),
|
|
251
252
|
},
|
|
252
253
|
{
|
|
253
254
|
category: END_POINT_EXTRA_PAYMENT,
|
|
254
255
|
description: endPoint.name,
|
|
255
|
-
price: calculateStartEndPointPrice(booking, endPoint,
|
|
256
|
-
operatorPrice: calculateStartEndPointPrice(booking, endPoint,
|
|
256
|
+
price: calculateStartEndPointPrice(booking, endPoint, { paymentMode: SELLING_PAYMENT_MODE }),
|
|
257
|
+
operatorPrice: calculateStartEndPointPrice(booking, endPoint, { paymentMode: OPERATOR_PAYMENT_MODE }),
|
|
257
258
|
},
|
|
258
259
|
{
|
|
259
260
|
category: NATIONAL_PARK_FEE_EXTRA_PAYMENT,
|
|
@@ -288,7 +289,19 @@ export function calculateAddOnsPrice(booking, product, options = { paymentMode:
|
|
|
288
289
|
return total;
|
|
289
290
|
}
|
|
290
291
|
|
|
291
|
-
export function
|
|
292
|
+
export function calculateStartEndPointSellingPrice(people, startEndPoint) {
|
|
293
|
+
return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: SELLING_PAYMENT_MODE });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function calculateStartEndPointOperatorPrice(people, startEndPoint) {
|
|
297
|
+
return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: OPERATOR_PAYMENT_MODE });
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function calculateStartEndPointPartnerNetPrice(people, startEndPoint) {
|
|
301
|
+
return calculateStartEndPointPrice(people, startEndPoint, { paymentMode: PARTNER_PAYMENT_MODE });
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function calculateStartEndPointPrice(people, startEndPoint, options = { paymentMode: SELLING_PAYMENT_MODE }) {
|
|
292
305
|
let pricing = startEndPoint?.pricing;
|
|
293
306
|
let isSelling = options.paymentMode in [SELLING_PAYMENT_MODE, PARTNER_PAYMENT_MODE];
|
|
294
307
|
if (pricing) {
|
package/product.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { calculateProductSellingPrice, countMinPeople } from "./price.js";
|
|
2
2
|
|
|
3
3
|
const MATCH_HTML_REGEXP = /(<([^>]+)>)/ig;
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ export function buildIndex(id, product) {
|
|
|
12
12
|
heroPhoto: product.heroPhoto,
|
|
13
13
|
operator: product.operator.default.name,
|
|
14
14
|
url: product.url,
|
|
15
|
-
price:
|
|
15
|
+
price: calculateProductSellingPrice({ adults: countMinPeople(product.pricing), children: 0, infants: 0 }, product.pricing) / countMinPeople(product.pricing),
|
|
16
16
|
priceType: product.pricing.type,
|
|
17
17
|
availability: product.availability
|
|
18
18
|
};
|