tripstorekrabi-shared 1.13.71 → 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/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: {},
|