aves-sdk 1.5.1 → 1.7.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aves-sdk",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "description": "TypeScript SDK for AVES XML REST",
5
5
  "homepage": "https://github.com/simoneguglielmi/aves-sdk#readme",
6
6
  "repository": [
@@ -38,7 +38,8 @@
38
38
  "sideEffects": false,
39
39
  "files": [
40
40
  "dist",
41
- "README.md"
41
+ "README.md",
42
+ "CHANGELOG.md"
42
43
  ],
43
44
  "publishConfig": {
44
45
  "access": "public"
@@ -1,551 +0,0 @@
1
- # Guida implementazione — Booking ops AVES SDK 1.5.0
2
-
3
- Guida pratica per le operazioni di booking (aves-sdk@1.5.0), derivate dallo spike API AVES XML 1.8.0.
4
-
5
- **Escluso:** creazione/ricerca del Programma come entità master (gap Datagest — non coperto dai PDF).
6
- **Incluso:** uso del Programma su pratica, update/delete costi, riassegnazione package, annullamento pratica.
7
-
8
- ---
9
-
10
- ## Setup client
11
-
12
- ```ts
13
- import { AvesClient } from "aves-sdk";
14
-
15
- const client = new AvesClient({
16
- baseURL: "https://<aves-host>",
17
- hostID: "000000", // 6 digit
18
- xtoken: "TOKEN000000",
19
- languageCode: "01", // opzionale
20
- timeoutMs: 30_000,
21
- });
22
- ```
23
-
24
- Tutti i metodi restituiscono `Result<T, AvesError>`:
25
-
26
- ```ts
27
- const result = await client.modBookingServices(/* ... */);
28
- if (!result.success) {
29
- console.error(result.error.kind, result.error.message, result.error.code);
30
- return;
31
- }
32
- const data = result.data; // tipizzato
33
- ```
34
-
35
- ---
36
-
37
- ## Mappa task → metodo SDK
38
-
39
- | Task spike | Metodo | Endpoint |
40
- |---|---|---|
41
- | Update voci di costo | `modBookingServices` | `/interop/booking/v2/rest/ModBookingFileServices` |
42
- | Delete voci / overwrite | `modBookingServices` (+ opz. `setBookingServiceStatus`) | stesso / `SetBookingFileServiceStatus` |
43
- | Assegna / riassegna Programma | `modBookingServices` (`selectedPackageDetail`) | stesso |
44
- | Annulla pratica (soft) | `setBookingStatus` | `/interop/booking/v2/rest/SetBookingFileStatus` |
45
- | Annulla pratica (delete) | `cancelBooking` | `/interop/booking/v2/rest/CancelBookingFile` |
46
- | Nullify singola riga | `setBookingServiceStatus` | `/interop/booking/v2/rest/SetBookingFileServiceStatus` |
47
- | Incassi sul booking | `insertFilePaymentList` | `/interop/booking/v2/rest/InsertFilePaymentList` |
48
- | Header (pax/note/billing) | `modBookingHeader` | `/interop/booking/v2/rest/ModBookingFileHeader` |
49
-
50
- > **Programma** = Package AVES (`pCode` / `PackageCode`). Non esiste API SDK per create/search package.
51
-
52
- ---
53
-
54
- ## 1. Aggiornamento voci di costo
55
-
56
- Aggiorna una riga già presente: passa `bookedServiceRef` (RPH) e incrementa `avesSession`. Imposta costi/prezzi con `serviceFare`.
57
-
58
- ```ts
59
- const result = await client.modBookingServices({
60
- customerRecordCode: "138311",
61
- bookingFileCode: "14/036654",
62
- selectedServiceList: {
63
- selectedServiceDetail: [
64
- {
65
- sCode: "HT00110840",
66
- ssCode: "DL",
67
- avesServiceType: "TOP",
68
- toServiceType: "RESIDENCE",
69
- subServiceDesc: "DOPPIA DE LUXE",
70
- startDate: "2015-01-22T00:00:00",
71
- endDate: "2015-01-25T00:00:00",
72
- qty: "1",
73
- pax: "2",
74
- paxAssociated: [{ pax: "001" }, { pax: "002" }],
75
- avesSession: "2", // incrementare ad ogni modifica della stessa riga
76
- bookedServiceRef: "001", // RPH servizio già in pratica
77
- serviceFare: {
78
- currencyCode: "EUR",
79
- cost: "180.00",
80
- costTax: "0.00",
81
- costType: "FORFAIT",
82
- price: "220.00",
83
- priceTax: "0.00",
84
- priceType: "FORFAIT",
85
- },
86
- avesServiceInfo: {
87
- packageCode: "2014MDE0000010",
88
- packageReference: "05",
89
- priceListCode: "G",
90
- costListCode: "G",
91
- },
92
- },
93
- ],
94
- },
95
- });
96
-
97
- if (result.success) {
98
- console.log(result.data.bookingFileDetail?.bookingFileCode);
99
- console.log(result.data.bookingFileDetail?.totalAmountDetail);
100
- }
101
- ```
102
-
103
- ### Note
104
-
105
- - `selectedServiceList.selectedServiceDetail` è un **array** (shape Mod ≠ Create).
106
- - `ModBookingFileHeader` **non** aggiorna costi.
107
-
108
- ---
109
-
110
- ## 2. Cancellazione voci + overwrite integrale
111
-
112
- Pattern: `DELETE`/`NULLIFY` delle righe esistenti → re-insert del nuovo set nello stesso (o successivo) `modBookingServices`.
113
-
114
- ```ts
115
- const result = await client.modBookingServices({
116
- customerRecordCode: "138311",
117
- bookingFileCode: "14/036654",
118
- cancellableBookedServiceList: {
119
- cancellableBookedServiceDetail: [
120
- {
121
- cancelOperationType: "DELETE", // o "NULLIFY"
122
- serviceRefType: "RPH",
123
- serviceRefValue: "001",
124
- },
125
- {
126
- cancelOperationType: "DELETE",
127
- serviceRefType: "RPH",
128
- serviceRefValue: "002",
129
- },
130
- ],
131
- },
132
- // nuovo set (obbligatorio: almeno 1 servizio nello schema SDK)
133
- selectedServiceList: {
134
- selectedServiceDetail: [
135
- {
136
- sCode: "VLGENFLEX",
137
- avesServiceType: "OTHER",
138
- toServiceType: "OTHER",
139
- startDate: "2015-01-22T00:00:00",
140
- endDate: "2015-01-25T00:00:00",
141
- qty: "2",
142
- pax: "2",
143
- paxAssociated: [],
144
- avesSession: "1",
145
- serviceFare: {
146
- currencyCode: "EUR",
147
- cost: "50.00",
148
- price: "80.00",
149
- },
150
- },
151
- {
152
- sCode: "HT00110840",
153
- ssCode: "DIN",
154
- avesServiceType: "TOP",
155
- toServiceType: "RESIDENCE",
156
- subServiceDesc: "CENA ADULTO",
157
- startDate: "2015-01-22T00:00:00",
158
- endDate: "2015-01-25T00:00:00",
159
- qty: "2",
160
- pax: "2",
161
- paxAssociated: [{ pax: "001" }, { pax: "002" }],
162
- avesSession: "1",
163
- serviceFare: {
164
- currencyCode: "EUR",
165
- cost: "40.00",
166
- price: "60.00",
167
- },
168
- },
169
- ],
170
- },
171
- });
172
- ```
173
-
174
- ### Alternativa: nullify di una sola riga
175
-
176
- ```ts
177
- const result = await client.setBookingServiceStatus({
178
- customerRecordCode: "000001",
179
- bookingFileCode: "18/000252",
180
- bookingServiceRef: "002",
181
- bookingFileServiceStatus: "NULLIFIED",
182
- bookingFileServiceStatusDate: "2018-11-29T12:50:00+01:00",
183
- });
184
- ```
185
-
186
- | `cancelOperationType` | Uso tipico |
187
- |---|---|
188
- | `DELETE` | rimozione (wipe + re-insert) |
189
- | `NULLIFY` | annullamento contabile/operativo della riga |
190
-
191
- ---
192
-
193
- ## 3. Assegnazione / riassegnazione Programma
194
-
195
- Su pratica già esistente: `selectedPackageDetail` in `modBookingServices`.
196
- Collegare i servizi al package con `avesServiceInfo.packageCode` + `packageReference`.
197
-
198
- ```ts
199
- const result = await client.modBookingServices({
200
- customerRecordCode: "138311",
201
- bookingFileCode: "14/036654",
202
- selectedPackageDetail: {
203
- pCode: "2014MDE0000010",
204
- startDate: "2015-01-22T00:00:00",
205
- endDate: "2015-01-25T00:00:00",
206
- getServicesFromPackage: false, // true = auto-carica solo ADV/GRP
207
- },
208
- selectedServiceList: {
209
- selectedServiceDetail: [
210
- {
211
- sCode: "HT00110840",
212
- ssCode: "DL",
213
- avesServiceType: "TOP",
214
- toServiceType: "RESIDENCE",
215
- startDate: "2015-01-22T00:00:00",
216
- endDate: "2015-01-25T00:00:00",
217
- qty: "1",
218
- pax: "2",
219
- paxAssociated: [{ pax: "001" }, { pax: "002" }],
220
- avesSession: "1",
221
- bookedServiceRef: "001", // se aggiorni riga esistente
222
- avesServiceInfo: {
223
- packageCode: "2014MDE0000010",
224
- packageReference: "01",
225
- },
226
- serviceFare: {
227
- currencyCode: "EUR",
228
- cost: "100.00",
229
- price: "120.00",
230
- },
231
- },
232
- ],
233
- },
234
- });
235
-
236
- if (result.success) {
237
- // PackageCode sulla pratica (se AVES lo aggiorna)
238
- console.log(result.data.bookingFileDetail?.packageCode);
239
- }
240
- ```
241
-
242
- ### In creazione pratica (riferimento)
243
-
244
- ```ts
245
- await client.createBooking({
246
- customerDetail: { recordCode: "138311" },
247
- bookingFileStatus: { value: "QUOTATION" },
248
- startDate: "2015-01-22T00:00:00",
249
- endDate: "2015-01-25T00:00:00",
250
- selectedPackageList: {
251
- selectedPackageDetail: [
252
- {
253
- pCode: "2014MDE0000010",
254
- startDate: "2015-01-22T00:00:00",
255
- endDate: "2015-01-25T00:00:00",
256
- },
257
- ],
258
- },
259
- selectedServiceList: [
260
- {
261
- selectedServiceDetail: {
262
- sCode: "HT00110840",
263
- ssCode: "DL",
264
- avesServiceType: "TOP",
265
- toServiceType: "RESIDENCE",
266
- startDate: "2015-01-22T00:00:00",
267
- endDate: "2015-01-25T00:00:00",
268
- qty: "1",
269
- pax: "2",
270
- paxAssociated: [],
271
- avesSession: "1",
272
- avesServiceInfo: {
273
- packageCode: "2014MDE0000010",
274
- packageReference: "01",
275
- },
276
- },
277
- },
278
- ],
279
- passengerList: [
280
- {
281
- passengerDetail: {
282
- rph: "001",
283
- roomRph: "001",
284
- name: "ADULTI 001",
285
- categoryCode: "AD", // obbligatorio in create
286
- sex: "M",
287
- },
288
- },
289
- ],
290
- });
291
- ```
292
-
293
- > Shape lista servizi: **Create** = array di wrapper `{ selectedServiceDetail: one }`; **Mod** = `{ selectedServiceDetail: one[] }`.
294
-
295
- ---
296
-
297
- ## 4. Annullabilità pratica
298
-
299
- ### Soft — cambio stato
300
-
301
- ```ts
302
- // CANCELED
303
- const canceled = await client.setBookingStatus({
304
- customerRecordCode: "000170",
305
- bookingFileCode: "14/000081",
306
- fileStatus: { value: "CANCELED" },
307
- backOfficeRequest: true,
308
- bookingFileDocument: {
309
- printDoc: false,
310
- sendDocViaEmail: false,
311
- },
312
- });
313
-
314
- // NULLIFIED con penali
315
- const nullified = await client.setBookingStatus({
316
- customerRecordCode: "000170",
317
- bookingFileCode: "14/000081",
318
- fileStatus: { value: "NULLIFIED" },
319
- backOfficeRequest: true,
320
- penalty: {
321
- apply: true, // false = penali automatiche di sistema
322
- specificCode: "ZPENAL", // Top service code penali (se apply=true)
323
- },
324
- simulateCancelAndGetPenaltyAmount: false,
325
- });
326
-
327
- // Solo simulazione penali
328
- const simulation = await client.setBookingStatus({
329
- customerRecordCode: "000170",
330
- bookingFileCode: "14/000081",
331
- fileStatus: { value: "NULLIFIED" },
332
- simulateCancelAndGetPenaltyAmount: true,
333
- });
334
- if (simulation.success) {
335
- console.log(simulation.data.totalAmountDetailAfterCancellation);
336
- }
337
- ```
338
-
339
- Stati `fileStatus.value` ammessi:
340
- `QUOTATION` | `WORK_IN_PROGRESS` | `CONFIRMED` | `OPTIONED` | `NULLIFIED` | `CANCELED`
341
-
342
- ### Hard — delete pratica
343
-
344
- ```ts
345
- const result = await client.cancelBooking({
346
- bookingFileCode: "14/000081",
347
- customerRecordCode: "000170",
348
- });
349
-
350
- if (result.success) {
351
- console.log(result.data.rsStatus.status); // "OK"
352
- }
353
- ```
354
-
355
- | Metodo | Effetto |
356
- |---|---|
357
- | `setBookingStatus` → `CANCELED` / `NULLIFIED` | pratica resta, cambia stato |
358
- | `cancelBooking` | delete della pratica in AVES |
359
-
360
- ---
361
-
362
- ## 5. Modifica header (senza costi)
363
-
364
- ```ts
365
- const result = await client.modBookingHeader({
366
- bookingFileCode: "14/000043",
367
- bookingFileStartDate: "2014-04-28",
368
- customerRecordCode: "103737",
369
- bookingNote: "Nota libera max 999 caratteri",
370
- passengerList: {
371
- passengerDetail: [
372
- {
373
- rph: "001",
374
- name: "ADULTI 001",
375
- sex: "M",
376
- birthDate: "1964-09-26T00:00:00",
377
- // categoryCode opzionale in Mod
378
- },
379
- {
380
- rph: "002",
381
- name: "ADULTI 002",
382
- sex: "F",
383
- birthDate: "1964-09-26T00:00:00",
384
- },
385
- ],
386
- },
387
- bookingFinancialInfo: {
388
- customer_PaymentType: "BANK",
389
- },
390
- });
391
- ```
392
-
393
- ---
394
-
395
- ## Payload combinato tipico (Lead retroattivo + overwrite)
396
-
397
- Flusso consigliato dopo lo spike:
398
-
399
- 1. Opzionale: `DELETE` voci obsolete
400
- 2. `selectedPackageDetail` con il Programma Lead
401
- 3. Nuovo `selectedServiceList` con costi e `packageCode` sui servizi
402
-
403
- ```ts
404
- const result = await client.modBookingServices({
405
- customerRecordCode: "138311",
406
- bookingFileCode: "14/036654",
407
- selectedPackageDetail: {
408
- pCode: "2014MDE0000010",
409
- startDate: "2015-01-22T00:00:00",
410
- endDate: "2015-01-25T00:00:00",
411
- },
412
- cancellableBookedServiceList: {
413
- cancellableBookedServiceDetail: [
414
- {
415
- cancelOperationType: "DELETE",
416
- serviceRefType: "RPH",
417
- serviceRefValue: "001",
418
- },
419
- {
420
- cancelOperationType: "DELETE",
421
- serviceRefType: "RPH",
422
- serviceRefValue: "002",
423
- },
424
- ],
425
- },
426
- selectedServiceList: {
427
- selectedServiceDetail: [
428
- {
429
- sCode: "HT00110840",
430
- ssCode: "DL",
431
- avesServiceType: "TOP",
432
- toServiceType: "RESIDENCE",
433
- startDate: "2015-01-22T00:00:00",
434
- endDate: "2015-01-25T00:00:00",
435
- qty: "1",
436
- pax: "2",
437
- paxAssociated: [{ pax: "001" }, { pax: "002" }],
438
- avesSession: "1",
439
- avesServiceInfo: {
440
- packageCode: "2014MDE0000010",
441
- packageReference: "01",
442
- costListCode: "G",
443
- priceListCode: "G",
444
- },
445
- serviceFare: {
446
- currencyCode: "EUR",
447
- cost: "180.00",
448
- price: "220.00",
449
- costType: "FORFAIT",
450
- priceType: "FORFAIT",
451
- },
452
- },
453
- ],
454
- },
455
- });
456
- ```
457
-
458
- ---
459
-
460
- ## 6. InsertFilePaymentList — incassi sul booking
461
-
462
- Registra uno o più pagamenti sul booking file appena creato (flusso Lead confermato).
463
-
464
- ```ts
465
- const payments = await client.insertFilePaymentList({
466
- bookingFileCode: "18/000172", // da createBooking → bookingFileDetail.bookingFileCode
467
- paymentUser: "MLDN",
468
- enableMultiplePayments: true,
469
- operationType: "AbsoluteAmountsInsertion",
470
- filePaymentList: {
471
- filePaymentDetail: [
472
- {
473
- paymentDate: "2018-09-08",
474
- paymentNote: "INCASSO LEAD",
475
- amount: "100.00",
476
- paymentType: "B", // C cash | B bank | R credit card | …
477
- },
478
- {
479
- paymentDate: "2018-10-08",
480
- paymentNote: "INCASSO LEAD",
481
- amount: "800.25",
482
- paymentType: "C",
483
- },
484
- ],
485
- },
486
- });
487
- ```
488
-
489
- `operationType`:
490
- - `AbsoluteAmountsInsertion` — inserisce gli importi da incassare (anche multipli)
491
- - `FinalAmountToAchieve` / `FinalAmountToAchieveWithoutControls` — totale già incassato; AVES calcola la differenza
492
-
493
- Obbligatorio: `bookingFileCode` **oppure** `bookingFileRefCode`.
494
-
495
- ### Flusso atomico applicativo (Lead → AVES)
496
-
497
- ```ts
498
- const created = await client.createBooking(/* ... */);
499
- if (!created.success) throw created.error;
500
-
501
- const bookingFileCode = created.data.bookingFileDetail?.bookingFileCode;
502
- // 1) salva subito bookingFileCode sul Lead (#76002)
503
- await saveAvesCodeOnLead(leadId, bookingFileCode);
504
-
505
- const paid = await client.insertFilePaymentList({
506
- bookingFileCode,
507
- enableMultiplePayments: true,
508
- operationType: "AbsoluteAmountsInsertion",
509
- filePaymentList: {
510
- filePaymentDetail: leadPayments.map((p) => ({
511
- paymentDate: p.date,
512
- paymentNote: p.note,
513
- amount: p.amount,
514
- paymentType: p.type,
515
- })),
516
- },
517
- });
518
-
519
- if (!paid.success) {
520
- // 2) errore parziale (#76003): pratica AVES già creata, payment fallito
521
- await markPartialSyncError(leadId, paid.error);
522
- }
523
- ```
524
-
525
- ---
526
-
527
- ## Tipi esportati (1.5.0)
528
-
529
- ```ts
530
- import type {
531
- ModFileServicesRQ,
532
- ModFileHeaderRQ,
533
- CancelFileRQ,
534
- SetFileStatusRQ,
535
- SetFileServiceStatusRQ,
536
- FilePaymentListRQ,
537
- BookingFileDetailRS, // alias di BookingFileRS
538
- BookingStatusOnlyRS,
539
- BookingFileRQ,
540
- BookingFileRS,
541
- } from "aves-sdk";
542
- ```
543
-
544
- ---
545
-
546
- ## Caveat operativi (da verificare live)
547
-
548
- 1. `DELETE` vs `NULLIFY` — vincoli di stato pratica / documenti / pagamenti.
549
- 2. `selectedPackageDetail` su pratica già con package — replace vs add.
550
- 3. Differenza operativa `cancelBooking` vs status `CANCELED`/`NULLIFIED`.
551
- 4. Create/search Programma — **non disponibile** in questo SDK; serve doc Catalog/Package Datagest.