tripstorekrabi-shared 1.24.6 → 1.24.7
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 +12 -3
- package/package.json +4 -4
package/booking.js
CHANGED
|
@@ -23,11 +23,12 @@ export function addBookingFromInvoice(
|
|
|
23
23
|
firestore,
|
|
24
24
|
invoice,
|
|
25
25
|
paymentData,
|
|
26
|
-
comment = ''
|
|
26
|
+
comment = '',
|
|
27
|
+
existingTransaction = null
|
|
27
28
|
) {
|
|
28
29
|
let bookingNumberDoc = firestore.collection('meta').doc('BOOKING_NUMBER');
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
const coreLogic = async (transaction) => {
|
|
31
32
|
const snapshot = await transaction.get(bookingNumberDoc);
|
|
32
33
|
const currentLast = snapshot.get('last') ?? 0;
|
|
33
34
|
|
|
@@ -143,7 +144,15 @@ export function addBookingFromInvoice(
|
|
|
143
144
|
{ last: currentLast + processed },
|
|
144
145
|
{ merge: true }
|
|
145
146
|
);
|
|
146
|
-
|
|
147
|
+
|
|
148
|
+
return processed;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
if (existingTransaction) {
|
|
152
|
+
return coreLogic(existingTransaction);
|
|
153
|
+
} else {
|
|
154
|
+
return firestore.runTransaction(coreLogic);
|
|
155
|
+
}
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
export function getOperatorSignature(agent, operatorName, contact) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tripstorekrabi-shared",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.7",
|
|
4
4
|
"description": "Shared library for Trip Store Krabi",
|
|
5
5
|
"author": "Stefan Sommer <tonprince@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"dayjs": "^1.11.21",
|
|
21
|
-
"libphonenumber-js": "^1.13.
|
|
22
|
-
"nanoid": "^
|
|
23
|
-
"firebase-admin": "^14.
|
|
21
|
+
"libphonenumber-js": "^1.13.10",
|
|
22
|
+
"nanoid": "^6.0.0",
|
|
23
|
+
"firebase-admin": "^14.2.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"deploy": "npm publish"
|