@hyper.software/common-helpers 1.11.7 → 1.11.9
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/lib/services/bookingService/__tests__/bookingInvoiceService.test.js +73 -541
- package/lib/services/bookingService/__tests__/bookingInvoiceService.test.js.map +1 -1
- package/lib/services/bookingService/__tests__/bookingsService.getTotalCost.test.js +1 -1
- package/lib/services/bookingService/__tests__/bookingsService.manualComputeTotalCost.test.js +2 -2
- package/lib/services/bookingService/__tests__/bookingsService.manualComputeTotalCost.test.js.map +1 -1
- package/lib/services/bookingService/bookingInvoiceService.js +10 -9
- package/lib/services/bookingService/bookingInvoiceService.js.map +1 -1
- package/lib/services/bookingService/bookingsService.js +1 -1
- package/lib/services/bookingService/bookingsService.js.map +1 -1
- package/lib/testingData/bookingData.js +35908 -36349
- package/lib/testingData/bookingData.js.map +1 -1
- package/lib/testingData/companyData.js +2 -2
- package/lib/testingData/companyData.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
var bookingInvoiceService_1 = require("../bookingInvoiceService");
|
|
15
15
|
var interfaces_1 = require("../../../interfaces");
|
|
16
|
+
var bookingData_1 = require("../../../testingData/bookingData");
|
|
17
|
+
var companyData_1 = require("../../../testingData/companyData");
|
|
16
18
|
describe('bookingInvoiceService', function () {
|
|
17
19
|
var mockIntl = {
|
|
18
20
|
formatMessage: function (_a, values) {
|
|
@@ -21,546 +23,82 @@ describe('bookingInvoiceService', function () {
|
|
|
21
23
|
return (values === null || values === void 0 ? void 0 : values.ownerName) ? "".concat(id, ": ").concat(values === null || values === void 0 ? void 0 : values.ownerName) : id;
|
|
22
24
|
},
|
|
23
25
|
};
|
|
24
|
-
var mockCompany = {
|
|
25
|
-
id: 'company-1',
|
|
26
|
-
mainUser: { firstName: 'John', lastName: 'Doe' },
|
|
27
|
-
phoneNumbers: ['123456789'],
|
|
28
|
-
legalInformation: { registrationNumber: 'REG123' },
|
|
29
|
-
invoices: {
|
|
30
|
-
salesTax: 19,
|
|
31
|
-
reducedSalesTax: 7,
|
|
32
|
-
invoicePrefix: 'INV',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
26
|
var mockUser = {
|
|
36
27
|
firstName: 'Admin',
|
|
37
28
|
lastName: 'User',
|
|
38
29
|
};
|
|
39
|
-
var mockBooking = {
|
|
40
|
-
checkinDate: '2024-03-20',
|
|
41
|
-
customer: {
|
|
42
|
-
firstName: 'Jane',
|
|
43
|
-
lastName: 'Smith',
|
|
44
|
-
},
|
|
45
|
-
invoices: [
|
|
46
|
-
{
|
|
47
|
-
currentInvoiceId: '001',
|
|
48
|
-
notes: 'Test note',
|
|
49
|
-
paymentMethod: interfaces_1.PAYMENT_METHOD.CASH,
|
|
50
|
-
products: [
|
|
51
|
-
{
|
|
52
|
-
type: 'ACCOMMODATION',
|
|
53
|
-
description: 'Standard Room',
|
|
54
|
-
quantity: 2,
|
|
55
|
-
taxType: interfaces_1.SERVICE_TAX_TYPE.REDUCED_SALES_TAX,
|
|
56
|
-
rate: 100,
|
|
57
|
-
tax: 7,
|
|
58
|
-
total: 214,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
var mockBooking2 = {
|
|
65
|
-
id: 'befcf0c1-aed6-4ca4-803c-2f1fe534af98',
|
|
66
|
-
companyId: 'bc7d6200-f873-11e6-8f7f-6312d0182b41',
|
|
67
|
-
customerId: '43cc94b7-164c-4d21-8677-db194a4a469d',
|
|
68
|
-
checkinDate: null,
|
|
69
|
-
checkoutDate: null,
|
|
70
|
-
code: 'FZJZD1',
|
|
71
|
-
bookingSource: 'BOOKING',
|
|
72
|
-
details: 'Sie haben für diese Buchung eine virtuelle Kreditkarte erhalten.Sie können sie ab dem 2025-07-21 belasten.',
|
|
73
|
-
totalCost: 0,
|
|
74
|
-
isConfirmed: true,
|
|
75
|
-
isCheckedIn: false,
|
|
76
|
-
isCheckedOut: false,
|
|
77
|
-
city: null,
|
|
78
|
-
notificationStatuses: {},
|
|
79
|
-
extra: {
|
|
80
|
-
payment: { isPaid: true, otaComission: 96.6 },
|
|
81
|
-
arrivalTime: null,
|
|
82
|
-
otaBookingId: '4460277987',
|
|
83
|
-
},
|
|
84
|
-
checkinInformation: {},
|
|
85
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
86
|
-
updatedAt: '2022-01-01T15:00:00.000Z',
|
|
87
|
-
deletedAt: null,
|
|
88
|
-
invoices: [
|
|
89
|
-
{
|
|
90
|
-
company: [Object],
|
|
91
|
-
dueDate: null,
|
|
92
|
-
customer: [Object],
|
|
93
|
-
products: [],
|
|
94
|
-
companyId: 'bc7d6200-f873-11e6-8f7f-6312d0182b41',
|
|
95
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
96
|
-
notesText: '',
|
|
97
|
-
notesLabel: null,
|
|
98
|
-
invoiceDate: null,
|
|
99
|
-
adminFullName: '',
|
|
100
|
-
invoicePrefix: '',
|
|
101
|
-
paymentMethod: 'N/A',
|
|
102
|
-
currentInvoiceId: '00004',
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
roomBookings: [
|
|
106
|
-
{
|
|
107
|
-
id: '1c09fe3d-1966-4c1b-bf76-ab1387160a65',
|
|
108
|
-
companyId: 'bc7d6200-f873-11e6-8f7f-6312d0182b41',
|
|
109
|
-
roomId: '3b6b7f4b-7146-476b-94f3-f3c2dab230a3',
|
|
110
|
-
bookingId: 'befcf0c1-aed6-4ca4-803c-2f1fe534af98',
|
|
111
|
-
checkinDate: '2022-07-21T14:00:00.000Z',
|
|
112
|
-
checkoutDate: '2022-07-25T07:00:00.000Z',
|
|
113
|
-
breakfastIncluded: true,
|
|
114
|
-
numberOfAdults: 2,
|
|
115
|
-
numberOfChildren: 1,
|
|
116
|
-
pricePerNight: 201.24,
|
|
117
|
-
integrations: [Object],
|
|
118
|
-
childrenAges: [Array],
|
|
119
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
120
|
-
updatedAt: '2022-01-01T15:00:00.000Z',
|
|
121
|
-
deletedAt: null,
|
|
122
|
-
room: [Object],
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
customer: {
|
|
126
|
-
id: '43cc94b7-164c-4d21-8677-db194a4a469d',
|
|
127
|
-
companyId: 'bc7d6200-f873-11e6-8f7f-6312d0182b41',
|
|
128
|
-
firstName: 'Leuckert',
|
|
129
|
-
lastName: 'Markus',
|
|
130
|
-
phoneNumber: '+49 176 30362638',
|
|
131
|
-
email: 'lmarku.866416@guest.booking.com',
|
|
132
|
-
birthDate: null,
|
|
133
|
-
address: {},
|
|
134
|
-
nationality: null,
|
|
135
|
-
identificationNumber: null,
|
|
136
|
-
identificationDocument: [],
|
|
137
|
-
optedInPromotionalOffers: false,
|
|
138
|
-
notes: null,
|
|
139
|
-
isAnonymized: false,
|
|
140
|
-
customerGroupId: null,
|
|
141
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
142
|
-
updatedAt: '2022-01-01T15:00:00.000Z',
|
|
143
|
-
deletedAt: null,
|
|
144
|
-
customerGroup: null,
|
|
145
|
-
},
|
|
146
|
-
company: {
|
|
147
|
-
id: 'bc7d6200-f873-11e6-8f7f-6312d0182b41',
|
|
148
|
-
partnerId: null,
|
|
149
|
-
parentCompanyId: null,
|
|
150
|
-
mainUserId: 'bc7d3af0-f873-11e6-8f7f-6312d0182b52',
|
|
151
|
-
name: 'Company',
|
|
152
|
-
isEnabled: true,
|
|
153
|
-
subdomain: 'acme',
|
|
154
|
-
language: 'de-DE',
|
|
155
|
-
timezone: 'Europe/Berlin',
|
|
156
|
-
currency: 'EUR',
|
|
157
|
-
email: 'raul.tomescu@visitorapp.co',
|
|
158
|
-
address: {
|
|
159
|
-
city: 'Los Angeles',
|
|
160
|
-
country: 'Germany',
|
|
161
|
-
zipCode: '80538',
|
|
162
|
-
streetName: 'Sunset Avenue',
|
|
163
|
-
streetNumber: '100A',
|
|
164
|
-
},
|
|
165
|
-
checkinTime: {},
|
|
166
|
-
checkoutTime: {},
|
|
167
|
-
pricing: { AIRBNB: 17, BOOKING: 15 },
|
|
168
|
-
amenities: [],
|
|
169
|
-
data: {},
|
|
170
|
-
google: {},
|
|
171
|
-
smartPricing: {},
|
|
172
|
-
integrations: { bnovo: [Object], stripe: [Object] },
|
|
173
|
-
locationDescription: {},
|
|
174
|
-
themeData: {},
|
|
175
|
-
publicInformation: {},
|
|
176
|
-
website: {
|
|
177
|
-
url: 'https://hotel-heller.de',
|
|
178
|
-
shortUrl: 'https://hotel-heller.de',
|
|
179
|
-
},
|
|
180
|
-
socials: {},
|
|
181
|
-
images: [],
|
|
182
|
-
phoneNumbers: [],
|
|
183
|
-
holidays: [],
|
|
184
|
-
owDiscountRules: [],
|
|
185
|
-
bookings: {},
|
|
186
|
-
legalInformation: {},
|
|
187
|
-
bankInformation: {},
|
|
188
|
-
invoices: {},
|
|
189
|
-
npsScore: null,
|
|
190
|
-
trialEndDate: null,
|
|
191
|
-
isPayingCustomer: false,
|
|
192
|
-
includeFeesInFinalCostExternalBookings: false,
|
|
193
|
-
customerDataStoragePeriod: 'ONE_YEAR',
|
|
194
|
-
nextInvoiceId: '00005',
|
|
195
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
196
|
-
updatedAt: '2022-01-01T15:00:00.000Z',
|
|
197
|
-
deletedAt: null,
|
|
198
|
-
mainUser: {
|
|
199
|
-
id: 'bc7d3af0-f873-11e6-8f7f-6312d0182b52',
|
|
200
|
-
partnerId: null,
|
|
201
|
-
isActive: true,
|
|
202
|
-
email: 'mock.user@mockemail.com',
|
|
203
|
-
firstName: 'ADMIN',
|
|
204
|
-
lastName: 'USER',
|
|
205
|
-
profilePhoto: null,
|
|
206
|
-
phoneNumber: null,
|
|
207
|
-
areTermsAccepted: false,
|
|
208
|
-
dateAcceptedTerms: null,
|
|
209
|
-
resetPasswordId: null,
|
|
210
|
-
language: 'en-US',
|
|
211
|
-
createdAt: '2022-01-01T15:00:00.000Z',
|
|
212
|
-
updatedAt: '2022-01-01T15:00:00.000Z',
|
|
213
|
-
deletedAt: null,
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
bookingServices: [],
|
|
217
|
-
};
|
|
218
|
-
var mockBooking3 = {
|
|
219
|
-
id: '06937984-37bc-437e-b281-c167fba95b61',
|
|
220
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
221
|
-
customerId: '43cc94b7-164c-4d21-8677-db194a4a469d',
|
|
222
|
-
checkinDate: '2025-02-15T14:00:00.000Z',
|
|
223
|
-
checkoutDate: '2025-02-20T11:00:00.000Z',
|
|
224
|
-
code: 'TEST123',
|
|
225
|
-
bookingSource: 'DIRECT',
|
|
226
|
-
details: 'Test booking',
|
|
227
|
-
totalCost: 500,
|
|
228
|
-
isConfirmed: true,
|
|
229
|
-
isCheckedIn: false,
|
|
230
|
-
isCheckedOut: false,
|
|
231
|
-
city: 'Berlin',
|
|
232
|
-
notificationStatuses: {},
|
|
233
|
-
extra: {},
|
|
234
|
-
checkinInformation: {},
|
|
235
|
-
createdAt: '2025-01-30T15:00:00.000Z',
|
|
236
|
-
updatedAt: '2025-01-30T15:00:00.000Z',
|
|
237
|
-
deletedAt: null,
|
|
238
|
-
invoices: [],
|
|
239
|
-
roomBookings: [
|
|
240
|
-
{
|
|
241
|
-
id: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
242
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
243
|
-
roomId: '3b6b7f4b-7146-476b-94f3-f3c2dab230a3',
|
|
244
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
245
|
-
checkinDate: '2025-02-15T14:00:00.000Z',
|
|
246
|
-
checkoutDate: '2025-02-20T11:00:00.000Z',
|
|
247
|
-
breakfastIncluded: true,
|
|
248
|
-
numberOfAdults: 2,
|
|
249
|
-
numberOfChildren: 0,
|
|
250
|
-
pricePerNight: 100,
|
|
251
|
-
integrations: {},
|
|
252
|
-
childrenAges: [],
|
|
253
|
-
createdAt: '2025-01-30T15:00:00.000Z',
|
|
254
|
-
updatedAt: '2025-01-30T15:00:00.000Z',
|
|
255
|
-
deletedAt: null,
|
|
256
|
-
room: {
|
|
257
|
-
id: '3b6b7f4b-7146-476b-94f3-f3c2dab230a3',
|
|
258
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
259
|
-
roomTypeId: '41c1d638-ec85-46bf-9067-a355a7f96ae7',
|
|
260
|
-
name: 'Room 101',
|
|
261
|
-
order: 1,
|
|
262
|
-
images: [],
|
|
263
|
-
channels: [],
|
|
264
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
265
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
266
|
-
deletedAt: null,
|
|
267
|
-
roomType: {
|
|
268
|
-
id: '41c1d638-ec85-46bf-9067-a355a7f96ae7',
|
|
269
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
270
|
-
name: 'Standard Room',
|
|
271
|
-
maxNumberOfGuests: 2,
|
|
272
|
-
hasPrivateBathroom: true,
|
|
273
|
-
description: 'A comfortable standard room',
|
|
274
|
-
order: 1,
|
|
275
|
-
images: [],
|
|
276
|
-
beds: [{ type: 'DOUBLE_BED', amount: 1 }],
|
|
277
|
-
breakfastInformation: {
|
|
278
|
-
type: 'OPTIONAL_WITH_EXTRA_COST',
|
|
279
|
-
adultCost: 15,
|
|
280
|
-
childrenCost: 7.5,
|
|
281
|
-
},
|
|
282
|
-
amenities: [],
|
|
283
|
-
integrations: {},
|
|
284
|
-
childrenRates: [],
|
|
285
|
-
childrenTourismTaxRates: [],
|
|
286
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
287
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
288
|
-
deletedAt: null,
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
],
|
|
293
|
-
customer: {
|
|
294
|
-
id: '43cc94b7-164c-4d21-8677-db194a4a469d',
|
|
295
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
296
|
-
firstName: 'John',
|
|
297
|
-
lastName: 'Doe',
|
|
298
|
-
phoneNumber: '+1234567890',
|
|
299
|
-
email: 'john.doe@example.com',
|
|
300
|
-
birthDate: null,
|
|
301
|
-
address: {},
|
|
302
|
-
nationality: null,
|
|
303
|
-
identificationNumber: null,
|
|
304
|
-
identificationDocument: [],
|
|
305
|
-
optedInPromotionalOffers: false,
|
|
306
|
-
notes: null,
|
|
307
|
-
isAnonymized: false,
|
|
308
|
-
customerGroupId: null,
|
|
309
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
310
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
311
|
-
deletedAt: null,
|
|
312
|
-
customerGroup: null,
|
|
313
|
-
},
|
|
314
|
-
roomBookingBookingServices: [
|
|
315
|
-
{
|
|
316
|
-
id: '8893bd57-eab0-4d90-a156-ef67afcfe25f',
|
|
317
|
-
roomBookingId: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
318
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
319
|
-
bookingServiceId: '7783bd57-eab0-4d90-a156-ef67afcfe25f',
|
|
320
|
-
bookingService: {
|
|
321
|
-
id: '7783bd57-eab0-4d90-a156-ef67afcfe25f',
|
|
322
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
323
|
-
serviceId: '8893bd57-eab0-4d90-a156-ef67afcfe25f',
|
|
324
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
325
|
-
roomTypeServiceId: null,
|
|
326
|
-
isActive: true,
|
|
327
|
-
data: {
|
|
328
|
-
name: 'Parking',
|
|
329
|
-
amount: 20,
|
|
330
|
-
taxType: 'NO_TAX',
|
|
331
|
-
sections: ['BOOKING_DETAILS'],
|
|
332
|
-
pricingUnit: 'PER_STAY',
|
|
333
|
-
},
|
|
334
|
-
service: {
|
|
335
|
-
id: '8893bd57-eab0-4d90-a156-ef67afcfe25f',
|
|
336
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
337
|
-
name: 'Parking',
|
|
338
|
-
amount: 20,
|
|
339
|
-
pricingUnit: 'PER_STAY',
|
|
340
|
-
taxType: 'NO_TAX',
|
|
341
|
-
enabledByDefault: true,
|
|
342
|
-
sections: ['BOOKING_DETAILS'],
|
|
343
|
-
startDate: null, // No season
|
|
344
|
-
endDate: null,
|
|
345
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
346
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
347
|
-
deletedAt: null,
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
353
|
-
roomBookingId: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
354
|
-
bookingServiceId: '06735f8c-3f95-5fbb-af1d-15dc7d20ae3f',
|
|
355
|
-
id: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
356
|
-
bookingService: {
|
|
357
|
-
id: '06735f8c-3f95-5fbb-af1d-15dc7d20ae3f',
|
|
358
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
359
|
-
serviceId: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
360
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
361
|
-
roomTypeServiceId: null,
|
|
362
|
-
isActive: true,
|
|
363
|
-
data: {
|
|
364
|
-
name: 'Winter Special',
|
|
365
|
-
amount: 50,
|
|
366
|
-
taxType: 'SALES_TAX',
|
|
367
|
-
sections: ['BOOKING_DETAILS'],
|
|
368
|
-
pricingUnit: 'PER_STAY',
|
|
369
|
-
},
|
|
370
|
-
service: {
|
|
371
|
-
id: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
372
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
373
|
-
name: 'Winter Special',
|
|
374
|
-
amount: 50,
|
|
375
|
-
pricingUnit: 'PER_STAY',
|
|
376
|
-
taxType: 'SALES_TAX',
|
|
377
|
-
enabledByDefault: true,
|
|
378
|
-
sections: ['BOOKING_DETAILS'],
|
|
379
|
-
startDate: '2025-01-01', // In season
|
|
380
|
-
endDate: '2025-03-31',
|
|
381
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
382
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
383
|
-
deletedAt: null,
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
389
|
-
roomBookingId: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
390
|
-
id: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
391
|
-
bookingsServiceId: '06735f8c-3f84-4fbb-af1d-15dc7d20bg4g',
|
|
392
|
-
bookingService: {
|
|
393
|
-
id: '06735f8c-3f84-4fbb-af1d-15dc7d20bg4g',
|
|
394
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
395
|
-
serviceId: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
396
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
397
|
-
roomTypeServiceId: null,
|
|
398
|
-
isActive: true,
|
|
399
|
-
data: {
|
|
400
|
-
name: 'Kurtaxe LS',
|
|
401
|
-
amount: 5,
|
|
402
|
-
taxType: 'NO_TAX',
|
|
403
|
-
sections: ['BOOKING_DETAILS'],
|
|
404
|
-
pricingUnit: 'PER_PERSON_PER_NIGHT',
|
|
405
|
-
},
|
|
406
|
-
service: {
|
|
407
|
-
id: '06735f8c-3f84-4fbb-af1d-15dc7d20ae3f',
|
|
408
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
409
|
-
name: 'Kurtaxe LS',
|
|
410
|
-
amount: 5,
|
|
411
|
-
pricingUnit: 'PER_PERSON_PER_NIGHT',
|
|
412
|
-
taxType: 'NO_TAX',
|
|
413
|
-
enabledByDefault: true,
|
|
414
|
-
sections: ['BOOKING_DETAILS'],
|
|
415
|
-
startDate: '2025-01-01', // In season
|
|
416
|
-
endDate: '2025-03-31',
|
|
417
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
418
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
419
|
-
deletedAt: null,
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
roomBookingId: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
425
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
426
|
-
id: '076b76a4-0f5f-4996-9af1-deb358946235',
|
|
427
|
-
bookingServiceId: '06937984-37bc-437e-b281-c167fba95c72',
|
|
428
|
-
bookingService: {
|
|
429
|
-
id: '06937984-37bc-437e-b281-c167fba95c72',
|
|
430
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
431
|
-
serviceId: '076b76a4-0f5f-4996-9af1-deb358946235',
|
|
432
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
433
|
-
roomTypeServiceId: null,
|
|
434
|
-
isActive: true,
|
|
435
|
-
data: {
|
|
436
|
-
name: 'Summer Special',
|
|
437
|
-
amount: 75,
|
|
438
|
-
taxType: 'SALES_TAX',
|
|
439
|
-
sections: ['BOOKING_DETAILS'],
|
|
440
|
-
pricingUnit: 'PER_STAY',
|
|
441
|
-
},
|
|
442
|
-
service: {
|
|
443
|
-
id: '076b76a4-0f5f-4996-9af1-deb358946235',
|
|
444
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
445
|
-
name: 'Summer Special',
|
|
446
|
-
amount: 75,
|
|
447
|
-
pricingUnit: 'PER_STAY',
|
|
448
|
-
taxType: 'SALES_TAX',
|
|
449
|
-
enabledByDefault: true,
|
|
450
|
-
sections: ['BOOKING_DETAILS'],
|
|
451
|
-
startDate: '2025-06-01', // Out of season
|
|
452
|
-
endDate: '2025-08-31',
|
|
453
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
454
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
455
|
-
deletedAt: null,
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
roomBookingId: 'f3ce8489-16eb-4529-871b-96ad25eeacdd',
|
|
461
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
462
|
-
bookingServiceId: '7db88166-b9c7-43e3-b208-692349f66egh',
|
|
463
|
-
bookingService: {
|
|
464
|
-
id: '7db88166-b9c7-43e3-b208-692349f66egh',
|
|
465
|
-
bookingId: '06937984-37bc-437e-b281-c167fba95b61',
|
|
466
|
-
serviceId: '7db88166-b9c7-43e3-b208-692349f66fcd',
|
|
467
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
468
|
-
roomTypeServiceId: null,
|
|
469
|
-
isActive: false,
|
|
470
|
-
data: {
|
|
471
|
-
name: 'Breakfast Buffet',
|
|
472
|
-
amount: 25,
|
|
473
|
-
taxType: 'REDUCED_SALES_TAX',
|
|
474
|
-
sections: ['BOOKING_DETAILS'],
|
|
475
|
-
pricingUnit: 'PER_PERSON_PER_NIGHT',
|
|
476
|
-
},
|
|
477
|
-
service: {
|
|
478
|
-
id: '7db88166-b9c7-43e3-b208-692349f66fcd',
|
|
479
|
-
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
480
|
-
name: 'Breakfast Buffet',
|
|
481
|
-
amount: 25,
|
|
482
|
-
pricingUnit: 'PER_PERSON_PER_NIGHT',
|
|
483
|
-
taxType: 'REDUCED_SALES_TAX',
|
|
484
|
-
enabledByDefault: false,
|
|
485
|
-
sections: ['BOOKING_DETAILS'],
|
|
486
|
-
startDate: null,
|
|
487
|
-
endDate: null,
|
|
488
|
-
createdAt: '2025-01-01T00:00:00.000Z',
|
|
489
|
-
updatedAt: '2025-01-01T00:00:00.000Z',
|
|
490
|
-
deletedAt: null,
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
},
|
|
494
|
-
],
|
|
495
|
-
company: {
|
|
496
|
-
id: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
497
|
-
partnerId: null,
|
|
498
|
-
parentCompanyId: null,
|
|
499
|
-
mainUserId: 'bc7d3af0-f873-11e6-8f7f-6312d0182b52',
|
|
500
|
-
name: 'Test Company',
|
|
501
|
-
isEnabled: true,
|
|
502
|
-
subdomain: 'test',
|
|
503
|
-
language: 'en-US',
|
|
504
|
-
timezone: 'Europe/Berlin',
|
|
505
|
-
currency: 'EUR',
|
|
506
|
-
email: 'test@example.com',
|
|
507
|
-
address: {
|
|
508
|
-
city: 'Berlin',
|
|
509
|
-
country: 'Germany',
|
|
510
|
-
zipCode: '10115',
|
|
511
|
-
streetName: 'Test Street',
|
|
512
|
-
streetNumber: '123',
|
|
513
|
-
},
|
|
514
|
-
invoices: {
|
|
515
|
-
salesTax: 19,
|
|
516
|
-
reducedSalesTax: 7,
|
|
517
|
-
invoicePrefix: 'INV',
|
|
518
|
-
},
|
|
519
|
-
mainUser: {
|
|
520
|
-
id: 'bc7d3af0-f873-11e6-8f7f-6312d0182b52',
|
|
521
|
-
firstName: 'Admin',
|
|
522
|
-
lastName: 'User',
|
|
523
|
-
},
|
|
524
|
-
},
|
|
525
|
-
};
|
|
526
30
|
it('should return empty array if company or booking is missing', function () {
|
|
527
|
-
expect((0, bookingInvoiceService_1.initialiseInvoiceData)(null, mockUser,
|
|
528
|
-
expect((0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
31
|
+
expect((0, bookingInvoiceService_1.initialiseInvoiceData)(null, mockUser, bookingData_1.booking1, mockIntl)).toEqual([]);
|
|
32
|
+
expect((0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, null, mockIntl)).toEqual([]);
|
|
529
33
|
});
|
|
530
34
|
it('should initialize invoice data with existing invoice', function () {
|
|
531
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
35
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingData_1.booking1, mockIntl);
|
|
532
36
|
expect(result).toHaveLength(1);
|
|
533
37
|
expect(result[0]).toMatchObject({
|
|
534
38
|
adminFullName: 'Admin User',
|
|
535
|
-
registrationNumber: '
|
|
536
|
-
companyId:
|
|
537
|
-
currentInvoiceId: '
|
|
538
|
-
notesText: '
|
|
539
|
-
paymentMethod: '
|
|
39
|
+
registrationNumber: 'H332',
|
|
40
|
+
companyId: bookingData_1.booking1.companyId,
|
|
41
|
+
currentInvoiceId: '01631',
|
|
42
|
+
notesText: '',
|
|
43
|
+
paymentMethod: 'N/A',
|
|
540
44
|
products: expect.arrayContaining([
|
|
541
45
|
expect.objectContaining({
|
|
542
46
|
type: 'ACCOMMODATION',
|
|
543
|
-
description: '
|
|
47
|
+
description: 'Double Room (01.04.2025 - 03.04.2025)',
|
|
48
|
+
rate: 139.25,
|
|
49
|
+
tax: 19.5,
|
|
50
|
+
taxType: 'REDUCED_SALES_TAX',
|
|
51
|
+
total: 298,
|
|
544
52
|
quantity: 2,
|
|
545
53
|
}),
|
|
546
54
|
]),
|
|
547
55
|
});
|
|
548
56
|
});
|
|
549
57
|
it('should initialize invoice data without existing invoice', function () {
|
|
550
|
-
var bookingWithoutInvoice = __assign(__assign({},
|
|
551
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
58
|
+
var bookingWithoutInvoice = __assign(__assign({}, bookingData_1.booking1), { invoices: [] });
|
|
59
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingWithoutInvoice, mockIntl);
|
|
552
60
|
expect(result).toHaveLength(1);
|
|
553
61
|
expect(result[0]).toMatchObject({
|
|
554
62
|
adminFullName: 'Admin User',
|
|
555
|
-
registrationNumber: '
|
|
556
|
-
companyId: '
|
|
63
|
+
registrationNumber: 'H332',
|
|
64
|
+
companyId: 'd82ba143-3b0d-4569-972a-be7c3244901c',
|
|
557
65
|
currentInvoiceId: '',
|
|
558
66
|
notesText: '',
|
|
559
|
-
products: [
|
|
67
|
+
products: expect.arrayContaining([
|
|
68
|
+
expect.objectContaining({
|
|
69
|
+
type: 'ACCOMMODATION',
|
|
70
|
+
description: 'Double Room (01.06.2025 - 04.06.2025)',
|
|
71
|
+
rate: 113.6274,
|
|
72
|
+
tax: 76.9734,
|
|
73
|
+
taxType: 'REDUCED_SALES_TAX',
|
|
74
|
+
total: 1099.62,
|
|
75
|
+
roomBookingId: '03252cfc-7242-47cb-999d-26f96a83e276',
|
|
76
|
+
roomTypeId: '41c1d638-ec85-46bf-9067-a355a7f96ae7',
|
|
77
|
+
quantity: 9,
|
|
78
|
+
}),
|
|
79
|
+
expect.objectContaining({
|
|
80
|
+
type: 'SERVICE',
|
|
81
|
+
description: 'Wine Tour',
|
|
82
|
+
quantity: 6,
|
|
83
|
+
taxType: 'SALES_TAX',
|
|
84
|
+
rate: 21,
|
|
85
|
+
tax: 24,
|
|
86
|
+
total: 150,
|
|
87
|
+
}),
|
|
88
|
+
expect.objectContaining({
|
|
89
|
+
type: 'SERVICE',
|
|
90
|
+
description: 'Special Cleaning Fee',
|
|
91
|
+
quantity: 1,
|
|
92
|
+
taxType: 'SALES_TAX',
|
|
93
|
+
rate: 84,
|
|
94
|
+
tax: 16,
|
|
95
|
+
total: 100,
|
|
96
|
+
}),
|
|
97
|
+
]),
|
|
560
98
|
});
|
|
561
99
|
});
|
|
562
100
|
describe('handling multiple invoices', function () {
|
|
563
|
-
var bookingWithMultipleInvoices = __assign(__assign({},
|
|
101
|
+
var bookingWithMultipleInvoices = __assign(__assign({}, bookingData_1.booking1), { invoices: [
|
|
564
102
|
{
|
|
565
103
|
currentInvoiceId: '001',
|
|
566
104
|
notes: 'First invoice',
|
|
@@ -595,7 +133,7 @@ describe('bookingInvoiceService', function () {
|
|
|
595
133
|
},
|
|
596
134
|
] });
|
|
597
135
|
it('should use first invoice data when multiple invoices exist', function () {
|
|
598
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
136
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingWithMultipleInvoices, mockIntl);
|
|
599
137
|
expect(result).toHaveLength(2);
|
|
600
138
|
expect(result[0]).toMatchObject({
|
|
601
139
|
currentInvoiceId: '001',
|
|
@@ -604,7 +142,7 @@ describe('bookingInvoiceService', function () {
|
|
|
604
142
|
});
|
|
605
143
|
});
|
|
606
144
|
it('should use products from first invoice only', function () {
|
|
607
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
145
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingWithMultipleInvoices, mockIntl);
|
|
608
146
|
expect(result[0].products).toHaveLength(1);
|
|
609
147
|
expect(result[0].products[0]).toMatchObject({
|
|
610
148
|
type: 'ACCOMMODATION',
|
|
@@ -617,7 +155,7 @@ describe('bookingInvoiceService', function () {
|
|
|
617
155
|
});
|
|
618
156
|
});
|
|
619
157
|
it('should preserve all invoice data in the invoices array', function () {
|
|
620
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
158
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingWithMultipleInvoices, mockIntl);
|
|
621
159
|
expect(result).toHaveLength(2);
|
|
622
160
|
expect(bookingWithMultipleInvoices.invoices[1]).toMatchObject({
|
|
623
161
|
currentInvoiceId: '002',
|
|
@@ -627,20 +165,20 @@ describe('bookingInvoiceService', function () {
|
|
|
627
165
|
});
|
|
628
166
|
});
|
|
629
167
|
it('should format company owner name correctly', function () {
|
|
630
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
168
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingData_1.booking1, mockIntl);
|
|
631
169
|
expect(result[0].company.ownerName).toBe('App.admin.bookings.invoice.companyResponsibleName.value: John Doe');
|
|
632
170
|
});
|
|
633
|
-
it('should initialise the products correctly for
|
|
634
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
171
|
+
it('should initialise the products correctly for booking12', function () {
|
|
172
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingData_1.booking2, mockIntl);
|
|
635
173
|
expect(result[0].products).toHaveLength(1);
|
|
636
174
|
});
|
|
637
|
-
it('should initialise correct invoice for
|
|
638
|
-
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(
|
|
175
|
+
it('should initialise correct invoice for booking13', function () {
|
|
176
|
+
var result = (0, bookingInvoiceService_1.initialiseInvoiceData)(companyData_1.company, mockUser, bookingData_1.booking13, mockIntl);
|
|
639
177
|
expect(result).toBeDefined();
|
|
640
178
|
expect(Array.isArray(result)).toBe(true);
|
|
641
|
-
expect(result[0].products).toHaveLength(
|
|
179
|
+
expect(result[0].products).toHaveLength(3);
|
|
642
180
|
var productsServiceItems = result[0].products.filter(function (item) { return item.type === bookingInvoiceService_1.INVOICE_PRODUCT.SERVICE; });
|
|
643
|
-
expect(productsServiceItems).toHaveLength(
|
|
181
|
+
expect(productsServiceItems).toHaveLength(2);
|
|
644
182
|
expect(productsServiceItems).toEqual(expect.arrayContaining([
|
|
645
183
|
expect.objectContaining({
|
|
646
184
|
type: bookingInvoiceService_1.INVOICE_PRODUCT.SERVICE,
|
|
@@ -651,28 +189,22 @@ describe('bookingInvoiceService', function () {
|
|
|
651
189
|
]));
|
|
652
190
|
expect(productsServiceItems).toEqual(expect.arrayContaining([
|
|
653
191
|
expect.objectContaining({
|
|
654
|
-
description: '
|
|
655
|
-
quantity:
|
|
656
|
-
rate:
|
|
192
|
+
description: 'Kurtaxe LS',
|
|
193
|
+
quantity: 16,
|
|
194
|
+
rate: 5,
|
|
657
195
|
tax: 0,
|
|
658
|
-
taxType:
|
|
659
|
-
total:
|
|
660
|
-
|
|
661
|
-
expect.objectContaining({
|
|
662
|
-
description: 'Winter Special',
|
|
663
|
-
quantity: 1,
|
|
664
|
-
rate: 42,
|
|
665
|
-
tax: 8,
|
|
666
|
-
taxType: interfaces_1.SERVICE_TAX_TYPE.SALES_TAX,
|
|
667
|
-
total: 50,
|
|
196
|
+
taxType: 'NO_TAX',
|
|
197
|
+
total: 80,
|
|
198
|
+
type: 'SERVICE',
|
|
668
199
|
}),
|
|
669
200
|
expect.objectContaining({
|
|
670
|
-
description: '
|
|
671
|
-
quantity:
|
|
672
|
-
rate:
|
|
201
|
+
description: 'Roomservice',
|
|
202
|
+
quantity: 16,
|
|
203
|
+
rate: 10,
|
|
673
204
|
tax: 0,
|
|
674
|
-
taxType:
|
|
675
|
-
total:
|
|
205
|
+
taxType: 'NO_TAX',
|
|
206
|
+
total: 160,
|
|
207
|
+
type: 'SERVICE',
|
|
676
208
|
}),
|
|
677
209
|
]));
|
|
678
210
|
});
|