tripstorekrabi-shared 1.6.4 → 1.7.0
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 +4 -1
- package/price.js +5 -5
- package/utils.js +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Shared library for Trip Store Krabi",
|
|
5
5
|
"author": "Stefan Sommer",
|
|
6
6
|
"repository": {
|
|
@@ -15,5 +15,8 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"dayjs": "^1.10.8"
|
|
17
17
|
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"deploy": "npm publish"
|
|
20
|
+
},
|
|
18
21
|
"type": "module"
|
|
19
22
|
}
|
package/price.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { getBookingType } from "./utils.js";
|
|
3
3
|
|
|
4
|
-
export const MAX_PAX =
|
|
4
|
+
export const MAX_PAX = 30;
|
|
5
5
|
|
|
6
6
|
export function calculateProductPrice(booking, pricing, selling = true) {
|
|
7
7
|
let type = pricing.type;
|
|
@@ -15,9 +15,9 @@ export function calculateProductPrice(booking, pricing, selling = true) {
|
|
|
15
15
|
} else {
|
|
16
16
|
let bookingType = getBookingType(booking.referenceNumber);
|
|
17
17
|
|
|
18
|
-
if (volume[bookingType]
|
|
18
|
+
if (volume[bookingType]) {
|
|
19
19
|
let customPricing = volume[bookingType];
|
|
20
|
-
total = booking.adults * (selling ? customPricing.adult.partnerNetPrice : customPricing.adult.operatorNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? booking.children * (selling ? customPricing.child.partnerNetPrice : customPricing.child.operatorNetPrice) : 0);
|
|
20
|
+
total = booking.adults * (selling ? customPricing.adult.partnerNetPrice : customPricing.adult.operatorNetPrice ?? volume.adult.operatorNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? booking.children * (selling ? customPricing.child.partnerNetPrice : customPricing.child.operatorNetPrice ?? volume.child.operatorNetPrice) : 0);
|
|
21
21
|
} else {
|
|
22
22
|
total = booking.adults * (selling ? volume.adult.sellingPrice : volume.adult.operatorNetPrice) + (pricing.ageBands.child.active && volume.child && booking.children ? booking.children * (selling ? volume.child.sellingPrice : volume.child.operatorNetPrice) : 0);
|
|
23
23
|
}
|
|
@@ -32,9 +32,9 @@ export function calculateProductPrice(booking, pricing, selling = true) {
|
|
|
32
32
|
} else {
|
|
33
33
|
let bookingType = getBookingType(booking.referenceNumber);
|
|
34
34
|
|
|
35
|
-
if (volume[bookingType]
|
|
35
|
+
if (volume[bookingType]) {
|
|
36
36
|
let customPricing = volume[bookingType];
|
|
37
|
-
total = selling ? customPricing.partnerNetPrice : customPricing.operatorNetPrice;
|
|
37
|
+
total = selling ? customPricing.partnerNetPrice : customPricing.operatorNetPrice ?? volume.operatorNetPrice;
|
|
38
38
|
} else {
|
|
39
39
|
total = (selling ? volume.sellingPrice : volume.operatorNetPrice);
|
|
40
40
|
}
|
package/utils.js
CHANGED
|
@@ -307,7 +307,7 @@ export function getBookingSummary(booking, options = {}) {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
if (booking.productDescription && booking.operator && booking.departureDate && booking.schedule && booking.leadTraveller) {
|
|
310
|
-
let departureDate = dayjs(booking.departureDate.toDate()).format("DD.MM.YYYY");
|
|
310
|
+
let departureDate = dayjs(booking.departureDate.toDate()).tz("Asia/Bangkok").format("DD.MM.YYYY");
|
|
311
311
|
summary += booking.productDescription + ", " + departureDate + ", " + booking.operator + ", " + booking.adults + ", " + booking.children + ", "
|
|
312
312
|
+ booking.infants + ", " + booking.leadTraveller;
|
|
313
313
|
|
|
@@ -438,10 +438,10 @@ export function validatePickupTime(pickupTime, schedule = "", context) {
|
|
|
438
438
|
return checkTime(from, departureTime, context);
|
|
439
439
|
}
|
|
440
440
|
} else if (pickupTime.indexOf("-") != -1) {
|
|
441
|
-
return context.createError({ message: `Invalid pickup time format, use spaces around the dash: ${pickupTime.replace(/ /g, '').replace("-", " - ")}
|
|
441
|
+
return context.createError({ message: `Invalid pickup time format, use spaces around the dash: ${pickupTime.replace(/ /g, '').replace("-", " - ")}`, path: context.path, });
|
|
442
442
|
} else {
|
|
443
443
|
if (!SCHEDULE_PATTERN.test(pickupTime)) {
|
|
444
|
-
return context.createError({ message: "Invalid pickup time format: for example use '09:00' or '08:45 - 09:00'" });
|
|
444
|
+
return context.createError({ message: "Invalid pickup time format: for example use '09:00' or '08:45 - 09:00'", path: context.path, });
|
|
445
445
|
} else {
|
|
446
446
|
return checkTime(pickupTime, departureTime, context);
|
|
447
447
|
}
|
|
@@ -460,7 +460,7 @@ function checkTime(pickupTimeValue, departureTimeValue, context) {
|
|
|
460
460
|
let departureTimeValues = departureTimeValue.split(":");
|
|
461
461
|
let departureTime = dayjs().hour(departureTimeValues[0]).minute(departureTimeValues[1]).second(0);
|
|
462
462
|
|
|
463
|
-
return pickupTime.isSameOrBefore(departureTime) ? true : context.createError({ message: "Pickup time must be before or equals departure time" });
|
|
463
|
+
return pickupTime.isSameOrBefore(departureTime) ? true : context.createError({ message: "Pickup time must be before or equals departure time", path: context.path, });
|
|
464
464
|
} catch (e) {
|
|
465
465
|
return false;
|
|
466
466
|
}
|