tripstorekrabi-shared 1.13.70 → 1.13.72
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/booking.js +30 -5
- package/package.json +1 -1
- package/utils.js +6 -5
package/booking.js
CHANGED
|
@@ -3,6 +3,7 @@ import advancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|
|
3
3
|
import utc from 'dayjs/plugin/utc.js';
|
|
4
4
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
5
5
|
import { PAY_ON_TOUR, calculateTotalOperatorPrice } from './price.js';
|
|
6
|
+
import { nanoid } from 'nanoid';
|
|
6
7
|
|
|
7
8
|
dayjs.extend(advancedFormat);
|
|
8
9
|
dayjs.extend(utc);
|
|
@@ -28,8 +29,6 @@ export function addBookingFromInvoice(
|
|
|
28
29
|
return bookingNumberDoc.get().then(async (snapshot) => {
|
|
29
30
|
let nextBookingNumber = (snapshot.get('last') ?? 0) + 1;
|
|
30
31
|
let processed = 0;
|
|
31
|
-
comment =
|
|
32
|
-
[comment, invoice.comment].filter((item) => item).join(', ') ?? '';
|
|
33
32
|
|
|
34
33
|
for (let i = 0; i < invoice.items.length; i++) {
|
|
35
34
|
let item = invoice.items[i];
|
|
@@ -48,10 +47,37 @@ export function addBookingFromInvoice(
|
|
|
48
47
|
productDescription = item.description;
|
|
49
48
|
}
|
|
50
49
|
|
|
50
|
+
let notes = {};
|
|
51
|
+
if (item.dietary) {
|
|
52
|
+
notes[nanoid()] = {
|
|
53
|
+
description: item.dietary.trim(),
|
|
54
|
+
visibility: [CUSTOMER_NOTE, OPERATOR_NOTE],
|
|
55
|
+
lastModified: dayjs().toDate(),
|
|
56
|
+
lastModifiedBy: 'Trip Store Krabi Next',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (comment) {
|
|
61
|
+
notes[nanoid()] = {
|
|
62
|
+
description: comment.trim(),
|
|
63
|
+
visibility: [],
|
|
64
|
+
lastModified: dayjs().toDate(),
|
|
65
|
+
lastModifiedBy: 'Trip Store Krabi Next',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (invoice.comment) {
|
|
70
|
+
notes[nanoid()] = {
|
|
71
|
+
description: invoice.comment.trim(),
|
|
72
|
+
visibility: [],
|
|
73
|
+
lastModified: dayjs().toDate(),
|
|
74
|
+
lastModifiedBy: 'Trip Store Krabi Next',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
51
78
|
let data = {
|
|
52
79
|
referenceNumber: 'TSK' + (nextBookingNumber + processed),
|
|
53
|
-
|
|
54
|
-
specialRequirements: item.dietary?.toUpperCase() ?? '',
|
|
80
|
+
notes,
|
|
55
81
|
productDescription,
|
|
56
82
|
productRef: hasProduct
|
|
57
83
|
? firestore.collection('products').doc(item.productId)
|
|
@@ -77,7 +103,6 @@ export function addBookingFromInvoice(
|
|
|
77
103
|
roomNumber: item.roomNumber ?? '',
|
|
78
104
|
flight: item.flight ?? null,
|
|
79
105
|
train: item.train ?? null,
|
|
80
|
-
comment,
|
|
81
106
|
customerPaymentStatus: 'Paid',
|
|
82
107
|
operatorPaymentStatus: 'Pending',
|
|
83
108
|
extraPayments: {},
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -5,6 +5,7 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
|
|
5
5
|
import utc from 'dayjs/plugin/utc.js';
|
|
6
6
|
import timezone from 'dayjs/plugin/timezone.js';
|
|
7
7
|
import { findEndPoint, findStartingPoint } from './price.js';
|
|
8
|
+
import { CUSTOMER_NOTE } from './booking.js';
|
|
8
9
|
|
|
9
10
|
dayjs.extend(customParseFormat);
|
|
10
11
|
dayjs.extend(advancedFormat);
|
|
@@ -602,13 +603,13 @@ export function createVoucherRequest(booking, product) {
|
|
|
602
603
|
let request = {
|
|
603
604
|
booking: {
|
|
604
605
|
referenceNumber: booking.referenceNumber,
|
|
605
|
-
specialRequirements: booking.
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
specialRequirements: Object.values(booking.notes ?? {})
|
|
607
|
+
.filter((item) => item.visibility.includes(CUSTOMER_NOTE))
|
|
608
|
+
.map((item) => item.description)
|
|
609
|
+
.join(', '),
|
|
608
610
|
nationalParkFee:
|
|
609
611
|
product && product.nationalPark
|
|
610
|
-
? 'NATIONAL PARK ENTRANCE FEE: ' +
|
|
611
|
-
booking.nationalParkFee.toUpperCase()
|
|
612
|
+
? 'NATIONAL PARK ENTRANCE FEE: ' + booking.nationalParkFee
|
|
612
613
|
: '',
|
|
613
614
|
productDescription: booking.productDescription,
|
|
614
615
|
leadTraveller: booking.leadTraveller,
|