@voyant-travel/finance 0.157.0 → 0.158.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.
@@ -0,0 +1,431 @@
1
+ /** Static payload schemas used by the import-cheap Finance deployment manifest. */
2
+ export const invoiceTypeSchema = { enum: ["invoice", "proforma", "credit_note"] };
3
+ export const invoiceStatusSchema = {
4
+ enum: [
5
+ "draft",
6
+ "pending_external_allocation",
7
+ "issued",
8
+ "partially_paid",
9
+ "paid",
10
+ "overdue",
11
+ "void",
12
+ ],
13
+ };
14
+ export const renditionFormatSchema = { enum: ["html", "pdf", "xml", "json"] };
15
+ export const nullableStringSchema = { type: ["string", "null"] };
16
+ export const invoiceIssuedPayloadSchema = {
17
+ type: "object",
18
+ required: ["invoiceId", "invoiceNumber", "invoiceType", "bookingId", "totalCents", "currency"],
19
+ properties: {
20
+ invoiceId: { type: "string" },
21
+ invoiceNumber: { type: "string" },
22
+ invoiceType: invoiceTypeSchema,
23
+ bookingId: nullableStringSchema,
24
+ totalCents: { type: "integer" },
25
+ currency: { type: "string" },
26
+ baseCurrency: { type: "string" },
27
+ fxRateSetId: { type: "string" },
28
+ fxRate: { type: "number" },
29
+ fxRateSource: { type: "string" },
30
+ fxRateQuotedAt: { type: "string", format: "date-time" },
31
+ fxRateValidUntil: { type: "string", format: "date-time" },
32
+ fxCommissionBps: { type: "integer" },
33
+ effectiveRate: { type: "number" },
34
+ fxCommissionInvoiceMention: { type: "string" },
35
+ convertedFromInvoiceId: nullableStringSchema,
36
+ clientName: { type: "string" },
37
+ clientEmail: nullableStringSchema,
38
+ clientPhone: nullableStringSchema,
39
+ clientAddress: nullableStringSchema,
40
+ clientCity: nullableStringSchema,
41
+ clientCounty: nullableStringSchema,
42
+ clientCountry: nullableStringSchema,
43
+ clientVatCode: nullableStringSchema,
44
+ clientRegCom: nullableStringSchema,
45
+ lineItems: {
46
+ type: "array",
47
+ items: {
48
+ type: "object",
49
+ required: ["description", "quantity", "unitPrice", "currency"],
50
+ properties: {
51
+ description: { type: "string" },
52
+ quantity: { type: "number" },
53
+ unitPrice: { type: "number" },
54
+ currency: { type: "string" },
55
+ bookingPaymentScheduleId: { type: "string" },
56
+ scheduleType: { enum: ["deposit", "installment", "balance", "hold", "other"] },
57
+ schedulePercent: { type: "number" },
58
+ taxPercentage: { type: "number" },
59
+ taxName: nullableStringSchema,
60
+ taxRegimeCode: {
61
+ type: ["string", "null"],
62
+ enum: [
63
+ "standard",
64
+ "reduced",
65
+ "exempt",
66
+ "reverse_charge",
67
+ "margin_scheme_art311",
68
+ "zero_rated",
69
+ "out_of_scope",
70
+ "other",
71
+ null,
72
+ ],
73
+ },
74
+ isService: { type: "boolean" },
75
+ },
76
+ additionalProperties: false,
77
+ },
78
+ },
79
+ bookingNumber: nullableStringSchema,
80
+ issueDate: { type: "string" },
81
+ dueDate: { type: "string" },
82
+ externalAllocationRequired: { type: "boolean" },
83
+ externalProvider: nullableStringSchema,
84
+ externalConfigKey: nullableStringSchema,
85
+ externalSeriesId: nullableStringSchema,
86
+ externalPlaceholderNumber: nullableStringSchema,
87
+ skipExternalSync: { type: "boolean" },
88
+ },
89
+ additionalProperties: false,
90
+ };
91
+ export const invoiceProformaConvertedPayloadSchema = {
92
+ ...invoiceIssuedPayloadSchema,
93
+ required: [...invoiceIssuedPayloadSchema.required, "id", "proformaId", "proformaInvoiceNumber"],
94
+ properties: {
95
+ ...invoiceIssuedPayloadSchema.properties,
96
+ id: { type: "string" },
97
+ proformaId: { type: "string" },
98
+ proformaInvoiceNumber: { type: "string" },
99
+ },
100
+ };
101
+ export const invoiceVoidedPayloadSchema = {
102
+ type: "object",
103
+ required: [
104
+ "invoiceId",
105
+ "invoiceNumber",
106
+ "invoiceType",
107
+ "bookingId",
108
+ "totalCents",
109
+ "currency",
110
+ "reason",
111
+ "voidedAt",
112
+ ],
113
+ properties: {
114
+ invoiceId: { type: "string" },
115
+ invoiceNumber: { type: "string" },
116
+ invoiceType: invoiceTypeSchema,
117
+ bookingId: nullableStringSchema,
118
+ totalCents: { type: "integer" },
119
+ currency: { type: "string" },
120
+ reason: nullableStringSchema,
121
+ voidedAt: { type: "string", format: "date-time" },
122
+ externalProvider: nullableStringSchema,
123
+ externalNumber: nullableStringSchema,
124
+ externalSeriesName: nullableStringSchema,
125
+ },
126
+ additionalProperties: false,
127
+ };
128
+ export const invoiceSettledPayloadSchema = {
129
+ type: "object",
130
+ required: [
131
+ "invoiceId",
132
+ "paymentId",
133
+ "provider",
134
+ "newlyAppliedAmountCents",
135
+ "paidCents",
136
+ "balanceDueCents",
137
+ ],
138
+ properties: {
139
+ invoiceId: { type: "string" },
140
+ paymentId: { type: "string" },
141
+ provider: { type: "string" },
142
+ newlyAppliedAmountCents: { type: "integer" },
143
+ paidCents: { type: "integer" },
144
+ balanceDueCents: { type: "integer" },
145
+ },
146
+ additionalProperties: false,
147
+ };
148
+ export const invoiceRenderedPayloadSchema = {
149
+ type: "object",
150
+ required: [
151
+ "invoiceId",
152
+ "invoiceStatus",
153
+ "invoiceType",
154
+ "renditionId",
155
+ "format",
156
+ "storageKey",
157
+ "contentType",
158
+ "byteSize",
159
+ "contentHash",
160
+ ],
161
+ properties: {
162
+ invoiceId: { type: "string" },
163
+ invoiceStatus: invoiceStatusSchema,
164
+ invoiceType: invoiceTypeSchema,
165
+ renditionId: { type: "string" },
166
+ format: renditionFormatSchema,
167
+ storageKey: nullableStringSchema,
168
+ contentType: { type: "string" },
169
+ byteSize: { type: ["integer", "null"] },
170
+ contentHash: nullableStringSchema,
171
+ },
172
+ additionalProperties: false,
173
+ };
174
+ export const invoiceDocumentGeneratedPayloadSchema = {
175
+ type: "object",
176
+ required: [
177
+ "invoiceId",
178
+ "invoiceStatus",
179
+ "invoiceType",
180
+ "renditionId",
181
+ "format",
182
+ "renderedBodyFormat",
183
+ "regenerated",
184
+ ],
185
+ properties: {
186
+ invoiceId: { type: "string" },
187
+ invoiceStatus: invoiceStatusSchema,
188
+ invoiceType: invoiceTypeSchema,
189
+ renditionId: { type: "string" },
190
+ format: renditionFormatSchema,
191
+ renderedBodyFormat: { enum: ["html", "markdown", "lexical_json"] },
192
+ regenerated: { type: "boolean" },
193
+ },
194
+ additionalProperties: false,
195
+ };
196
+ export const invoicePaymentRecordedPayloadSchema = {
197
+ type: "object",
198
+ required: [
199
+ "invoiceId",
200
+ "invoiceNumber",
201
+ "invoiceType",
202
+ "bookingId",
203
+ "invoiceCurrency",
204
+ "invoiceTotalCents",
205
+ "invoicePaidCents",
206
+ "invoiceBalanceDueCents",
207
+ "paymentId",
208
+ "amountCents",
209
+ "currency",
210
+ "baseCurrency",
211
+ "baseAmountCents",
212
+ "paymentMethod",
213
+ "status",
214
+ "referenceNumber",
215
+ "paymentDate",
216
+ ],
217
+ properties: {
218
+ invoiceId: { type: "string" },
219
+ invoiceNumber: { type: "string" },
220
+ invoiceType: invoiceTypeSchema,
221
+ bookingId: nullableStringSchema,
222
+ invoiceCurrency: { type: "string" },
223
+ invoiceTotalCents: { type: "integer" },
224
+ invoicePaidCents: { type: "integer" },
225
+ invoiceBalanceDueCents: { type: "integer" },
226
+ paymentId: { type: "string" },
227
+ amountCents: { type: "integer" },
228
+ currency: { type: "string" },
229
+ baseCurrency: nullableStringSchema,
230
+ baseAmountCents: { type: ["integer", "null"] },
231
+ paymentMethod: {
232
+ enum: [
233
+ "bank_transfer",
234
+ "credit_card",
235
+ "debit_card",
236
+ "cash",
237
+ "cheque",
238
+ "wallet",
239
+ "direct_bill",
240
+ "travel_credit",
241
+ "other",
242
+ ],
243
+ },
244
+ status: { enum: ["pending", "completed", "failed", "refunded"] },
245
+ referenceNumber: nullableStringSchema,
246
+ paymentDate: { type: "string" },
247
+ },
248
+ additionalProperties: false,
249
+ };
250
+ export const paymentCompletedPayloadSchema = {
251
+ type: "object",
252
+ required: [
253
+ "paymentSessionId",
254
+ "targetType",
255
+ "targetId",
256
+ "bookingId",
257
+ "legacyOrderId",
258
+ "invoiceId",
259
+ "bookingPaymentScheduleId",
260
+ "bookingGuaranteeId",
261
+ "amountCents",
262
+ "currency",
263
+ "provider",
264
+ ],
265
+ properties: {
266
+ paymentSessionId: { type: "string" },
267
+ targetType: {
268
+ enum: [
269
+ "booking",
270
+ "order",
271
+ "invoice",
272
+ "booking_payment_schedule",
273
+ "booking_guarantee",
274
+ "flight_order",
275
+ "other",
276
+ ],
277
+ },
278
+ targetId: nullableStringSchema,
279
+ bookingId: nullableStringSchema,
280
+ legacyOrderId: nullableStringSchema,
281
+ invoiceId: nullableStringSchema,
282
+ bookingPaymentScheduleId: nullableStringSchema,
283
+ bookingGuaranteeId: nullableStringSchema,
284
+ amountCents: { type: "integer" },
285
+ currency: { type: "string" },
286
+ provider: nullableStringSchema,
287
+ },
288
+ additionalProperties: false,
289
+ };
290
+ export const bookingCreatedPayloadSchema = {
291
+ type: "object",
292
+ required: [
293
+ "bookingId",
294
+ "bookingNumber",
295
+ "productId",
296
+ "travelerCount",
297
+ "paymentScheduleCount",
298
+ "travelCreditRedeemedCents",
299
+ "groupId",
300
+ "documentGeneration",
301
+ "createdByUserId",
302
+ "occurredAt",
303
+ ],
304
+ properties: {
305
+ bookingId: { type: "string" },
306
+ bookingNumber: { type: "string" },
307
+ productId: { type: "string" },
308
+ travelerCount: { type: "integer" },
309
+ paymentScheduleCount: { type: "integer" },
310
+ travelCreditRedeemedCents: { type: ["integer", "null"] },
311
+ groupId: nullableStringSchema,
312
+ documentGeneration: {
313
+ type: "object",
314
+ required: ["contractDocument", "invoiceDocument", "invoiceType"],
315
+ properties: {
316
+ contractDocument: { type: "boolean" },
317
+ invoiceDocument: { type: "boolean" },
318
+ invoiceType: { enum: ["invoice", "proforma"] },
319
+ },
320
+ additionalProperties: false,
321
+ },
322
+ createdByUserId: nullableStringSchema,
323
+ occurredAt: { type: "string", format: "date-time" },
324
+ },
325
+ additionalProperties: false,
326
+ };
327
+ export const bookingConfirmedPayloadSchema = {
328
+ type: "object",
329
+ required: ["bookingId", "bookingNumber", "actorId"],
330
+ properties: {
331
+ bookingId: { type: "string" },
332
+ bookingNumber: { type: "string" },
333
+ actorId: nullableStringSchema,
334
+ suppressNotifications: { type: "boolean" },
335
+ },
336
+ additionalProperties: false,
337
+ };
338
+ export const bookingDualCreatedPayloadSchema = {
339
+ type: "object",
340
+ required: [
341
+ "groupId",
342
+ "primaryBookingId",
343
+ "secondaryBookingId",
344
+ "productId",
345
+ "createdByUserId",
346
+ "occurredAt",
347
+ ],
348
+ properties: {
349
+ groupId: { type: "string" },
350
+ primaryBookingId: { type: "string" },
351
+ secondaryBookingId: { type: "string" },
352
+ productId: { type: "string" },
353
+ createdByUserId: nullableStringSchema,
354
+ occurredAt: { type: "string", format: "date-time" },
355
+ },
356
+ additionalProperties: false,
357
+ };
358
+ export const bookingCreateRejectedPayloadSchema = {
359
+ type: "object",
360
+ required: [
361
+ "reason",
362
+ "productId",
363
+ "optionId",
364
+ "slotId",
365
+ "bookingNumber",
366
+ "mismatchCount",
367
+ "mismatches",
368
+ "createdByUserId",
369
+ "occurredAt",
370
+ ],
371
+ properties: {
372
+ reason: { const: "payload_resolver_mismatch" },
373
+ productId: { type: "string" },
374
+ optionId: nullableStringSchema,
375
+ slotId: nullableStringSchema,
376
+ bookingNumber: { type: "string" },
377
+ mismatchCount: { type: "integer" },
378
+ mismatches: {
379
+ type: "array",
380
+ items: {
381
+ type: "object",
382
+ required: ["kind", "optionUnitId", "submittedQuantity", "resolvedQuantity"],
383
+ properties: {
384
+ kind: { enum: ["qty", "missing", "extra"] },
385
+ optionUnitId: { type: "string" },
386
+ submittedQuantity: { type: "number" },
387
+ resolvedQuantity: { type: "number" },
388
+ },
389
+ additionalProperties: false,
390
+ },
391
+ },
392
+ createdByUserId: nullableStringSchema,
393
+ occurredAt: { type: "string", format: "date-time" },
394
+ },
395
+ additionalProperties: false,
396
+ };
397
+ export const bookingContractDocumentRequestedPayloadSchema = {
398
+ type: "object",
399
+ required: ["bookingId", "bookingNumber", "createdByUserId", "occurredAt"],
400
+ properties: {
401
+ bookingId: { type: "string" },
402
+ bookingNumber: { type: "string" },
403
+ createdByUserId: nullableStringSchema,
404
+ occurredAt: { type: "string", format: "date-time" },
405
+ },
406
+ additionalProperties: false,
407
+ };
408
+ export const bookingPaymentSchedulePaidPayloadSchema = {
409
+ type: "object",
410
+ required: [
411
+ "bookingId",
412
+ "bookingPaymentScheduleId",
413
+ "paymentSessionId",
414
+ "paymentId",
415
+ "scheduleType",
416
+ "amountCents",
417
+ "currency",
418
+ "provider",
419
+ ],
420
+ properties: {
421
+ bookingId: { type: "string" },
422
+ bookingPaymentScheduleId: { type: "string" },
423
+ paymentSessionId: { type: "string" },
424
+ paymentId: nullableStringSchema,
425
+ scheduleType: { enum: ["deposit", "installment", "balance", "hold", "other"] },
426
+ amountCents: { type: "integer" },
427
+ currency: { type: "string" },
428
+ provider: nullableStringSchema,
429
+ },
430
+ additionalProperties: false,
431
+ };