tripstorekrabi-shared 1.20.0 → 1.20.2
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 +3 -3
- package/price.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Shared library for Trip Store Krabi",
|
|
5
5
|
"author": "Stefan Sommer <tonprince@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"dayjs": "^1.11.13",
|
|
19
|
-
"libphonenumber-js": "^1.
|
|
20
|
-
"nanoid": "^5.
|
|
19
|
+
"libphonenumber-js": "^1.12.6",
|
|
20
|
+
"nanoid": "^5.1.5"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"deploy": "npm publish"
|
package/price.js
CHANGED
|
@@ -50,7 +50,7 @@ function calculateSellingPrice(commissionRate, price) {
|
|
|
50
50
|
|
|
51
51
|
function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE }) {
|
|
52
52
|
if (pricing.promotion) {
|
|
53
|
-
let departureDate = booking.departureDate instanceof Date ? dayjs(booking.departureDate) : typeof booking.departureDate
|
|
53
|
+
let departureDate = booking.departureDate instanceof Date ? dayjs(booking.departureDate) : typeof booking.departureDate?.toDate === 'function' ? dayjs(booking.departureDate.toDate()) : null;
|
|
54
54
|
let startDate = pricing.promotion.startDate instanceof Date ? pricing.promotion.startDate : typeof pricing.promotion.startDate.toDate === 'function' ? pricing.promotion.startDate.toDate() : null;
|
|
55
55
|
let endDate = pricing.promotion.endDate instanceof Date ? pricing.promotion.endDate : typeof pricing.promotion.endDate.toDate === 'function' ? pricing.promotion.endDate.toDate() : null;
|
|
56
56
|
|
|
@@ -141,7 +141,7 @@ function calculateProductPrice(booking, pricing, options = { mode: SELLING_MODE
|
|
|
141
141
|
|
|
142
142
|
export function findVolume(people, pricing) {
|
|
143
143
|
let total = people.adults + people.children ?? 0;
|
|
144
|
-
return pricing.volumes.sort((v1, v2) => v1.max - v2.max).find((item, i) => {
|
|
144
|
+
return [...pricing.volumes].sort((v1, v2) => v1.max - v2.max).find((item, i) => {
|
|
145
145
|
if (total <= item.max) {
|
|
146
146
|
return true;
|
|
147
147
|
} else if (i === pricing.volumes.length - 1) {
|
|
@@ -322,7 +322,7 @@ export function getExtraPaymentsPaidWithPartner(booking, product) {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
export function getActiveExtraPayments(extraPayments) {
|
|
325
|
-
return extraPayments
|
|
325
|
+
return [...extraPayments]
|
|
326
326
|
.filter(([id, item]) => !item.disabled)
|
|
327
327
|
.sort(([id1, item1], [id2, item2]) =>
|
|
328
328
|
item1.description.localeCompare(item2.description)
|