@voyantjs/finance 0.3.0 → 0.4.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/dist/index.d.ts +18 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -5
- package/dist/routes-documents.d.ts +159 -0
- package/dist/routes-documents.d.ts.map +1 -0
- package/dist/routes-documents.js +35 -0
- package/dist/routes-public.d.ts +517 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +60 -0
- package/dist/routes-settlement.d.ts +63 -0
- package/dist/routes-settlement.d.ts.map +1 -0
- package/dist/routes-settlement.js +18 -0
- package/dist/routes-shared.d.ts +12 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +3 -0
- package/dist/routes.d.ts +207 -161
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +40 -1
- package/dist/schema.d.ts +17 -17
- package/dist/service-documents.d.ts +67 -0
- package/dist/service-documents.d.ts.map +1 -0
- package/dist/service-documents.js +226 -0
- package/dist/service-public.d.ts +251 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +418 -0
- package/dist/service-settlement.d.ts +36 -0
- package/dist/service-settlement.d.ts.map +1 -0
- package/dist/service-settlement.js +172 -0
- package/dist/service.d.ts +175 -181
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +54 -67
- package/dist/validation-billing.d.ts +119 -9
- package/dist/validation-billing.d.ts.map +1 -1
- package/dist/validation-billing.js +54 -1
- package/dist/validation-payments.d.ts +83 -83
- package/dist/validation-public.d.ts +443 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +183 -0
- package/dist/validation-shared.d.ts +24 -24
- package/dist/validation.d.ts +1 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +1 -0
- package/package.json +15 -5
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { type Env } from "./routes-shared.js";
|
|
2
|
+
export declare const publicFinanceRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
3
|
+
"/vouchers/validate": {
|
|
4
|
+
$post: {
|
|
5
|
+
input: {};
|
|
6
|
+
output: {
|
|
7
|
+
data: {
|
|
8
|
+
valid: false;
|
|
9
|
+
reason: "not_found";
|
|
10
|
+
voucher: null;
|
|
11
|
+
} | {
|
|
12
|
+
valid: false;
|
|
13
|
+
reason: "inactive";
|
|
14
|
+
voucher: {
|
|
15
|
+
id: string;
|
|
16
|
+
code: string;
|
|
17
|
+
label: string;
|
|
18
|
+
provider: string | null;
|
|
19
|
+
currency: string | null;
|
|
20
|
+
amountCents: number | null;
|
|
21
|
+
remainingAmountCents: number | null;
|
|
22
|
+
expiresAt: string | null;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
valid: false;
|
|
26
|
+
reason: "not_started";
|
|
27
|
+
voucher: {
|
|
28
|
+
id: string;
|
|
29
|
+
code: string;
|
|
30
|
+
label: string;
|
|
31
|
+
provider: string | null;
|
|
32
|
+
currency: string | null;
|
|
33
|
+
amountCents: number | null;
|
|
34
|
+
remainingAmountCents: number | null;
|
|
35
|
+
expiresAt: string | null;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
valid: false;
|
|
39
|
+
reason: "expired";
|
|
40
|
+
voucher: {
|
|
41
|
+
id: string;
|
|
42
|
+
code: string;
|
|
43
|
+
label: string;
|
|
44
|
+
provider: string | null;
|
|
45
|
+
currency: string | null;
|
|
46
|
+
amountCents: number | null;
|
|
47
|
+
remainingAmountCents: number | null;
|
|
48
|
+
expiresAt: string | null;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
valid: false;
|
|
52
|
+
reason: "booking_mismatch";
|
|
53
|
+
voucher: {
|
|
54
|
+
id: string;
|
|
55
|
+
code: string;
|
|
56
|
+
label: string;
|
|
57
|
+
provider: string | null;
|
|
58
|
+
currency: string | null;
|
|
59
|
+
amountCents: number | null;
|
|
60
|
+
remainingAmountCents: number | null;
|
|
61
|
+
expiresAt: string | null;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
valid: false;
|
|
65
|
+
reason: "currency_mismatch";
|
|
66
|
+
voucher: {
|
|
67
|
+
id: string;
|
|
68
|
+
code: string;
|
|
69
|
+
label: string;
|
|
70
|
+
provider: string | null;
|
|
71
|
+
currency: string | null;
|
|
72
|
+
amountCents: number | null;
|
|
73
|
+
remainingAmountCents: number | null;
|
|
74
|
+
expiresAt: string | null;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
valid: false;
|
|
78
|
+
reason: "insufficient_balance";
|
|
79
|
+
voucher: {
|
|
80
|
+
id: string;
|
|
81
|
+
code: string;
|
|
82
|
+
label: string;
|
|
83
|
+
provider: string | null;
|
|
84
|
+
currency: string | null;
|
|
85
|
+
amountCents: number | null;
|
|
86
|
+
remainingAmountCents: number | null;
|
|
87
|
+
expiresAt: string | null;
|
|
88
|
+
};
|
|
89
|
+
} | {
|
|
90
|
+
valid: true;
|
|
91
|
+
reason: null;
|
|
92
|
+
voucher: {
|
|
93
|
+
id: string;
|
|
94
|
+
code: string;
|
|
95
|
+
label: string;
|
|
96
|
+
provider: string | null;
|
|
97
|
+
currency: string | null;
|
|
98
|
+
amountCents: number | null;
|
|
99
|
+
remainingAmountCents: number | null;
|
|
100
|
+
expiresAt: string | null;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
outputFormat: "json";
|
|
105
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
} & {
|
|
109
|
+
"/bookings/:bookingId/documents": {
|
|
110
|
+
$get: {
|
|
111
|
+
input: {
|
|
112
|
+
param: {
|
|
113
|
+
bookingId: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
output: {
|
|
117
|
+
data: {
|
|
118
|
+
bookingId: string;
|
|
119
|
+
documents: {
|
|
120
|
+
invoiceId: string;
|
|
121
|
+
invoiceNumber: string;
|
|
122
|
+
invoiceType: "invoice" | "proforma" | "credit_note";
|
|
123
|
+
invoiceStatus: "draft" | "sent" | "partially_paid" | "paid" | "overdue" | "void";
|
|
124
|
+
currency: string;
|
|
125
|
+
totalCents: number;
|
|
126
|
+
paidCents: number;
|
|
127
|
+
balanceDueCents: number;
|
|
128
|
+
issueDate: string;
|
|
129
|
+
dueDate: string;
|
|
130
|
+
renditionId: string | null;
|
|
131
|
+
documentStatus: "pending" | "failed" | "ready" | "stale" | "missing";
|
|
132
|
+
format: "json" | "pdf" | "html" | "xml" | null;
|
|
133
|
+
language: string | null;
|
|
134
|
+
generatedAt: string | null;
|
|
135
|
+
fileSize: number | null;
|
|
136
|
+
checksum: string | null;
|
|
137
|
+
downloadUrl: string | null;
|
|
138
|
+
}[];
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
outputFormat: "json";
|
|
142
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
143
|
+
} | {
|
|
144
|
+
input: {
|
|
145
|
+
param: {
|
|
146
|
+
bookingId: string;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
output: {
|
|
150
|
+
error: string;
|
|
151
|
+
};
|
|
152
|
+
outputFormat: "json";
|
|
153
|
+
status: 404;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
} & {
|
|
157
|
+
"/bookings/:bookingId/payments": {
|
|
158
|
+
$get: {
|
|
159
|
+
input: {
|
|
160
|
+
param: {
|
|
161
|
+
bookingId: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
output: {
|
|
165
|
+
error: string;
|
|
166
|
+
};
|
|
167
|
+
outputFormat: "json";
|
|
168
|
+
status: 404;
|
|
169
|
+
} | {
|
|
170
|
+
input: {
|
|
171
|
+
param: {
|
|
172
|
+
bookingId: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
output: {
|
|
176
|
+
data: {
|
|
177
|
+
bookingId: string;
|
|
178
|
+
payments: {
|
|
179
|
+
id: string;
|
|
180
|
+
invoiceId: string;
|
|
181
|
+
invoiceNumber: string;
|
|
182
|
+
invoiceType: "invoice" | "proforma" | "credit_note";
|
|
183
|
+
status: "completed" | "pending" | "failed" | "refunded";
|
|
184
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill";
|
|
185
|
+
amountCents: number;
|
|
186
|
+
currency: string;
|
|
187
|
+
paymentDate: string;
|
|
188
|
+
referenceNumber: string | null;
|
|
189
|
+
notes: string | null;
|
|
190
|
+
}[];
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
outputFormat: "json";
|
|
194
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
} & {
|
|
198
|
+
"/bookings/:bookingId/payment-options": {
|
|
199
|
+
$get: {
|
|
200
|
+
input: {
|
|
201
|
+
param: {
|
|
202
|
+
bookingId: string;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
output: {
|
|
206
|
+
error: string;
|
|
207
|
+
};
|
|
208
|
+
outputFormat: "json";
|
|
209
|
+
status: 404;
|
|
210
|
+
} | {
|
|
211
|
+
input: {
|
|
212
|
+
param: {
|
|
213
|
+
bookingId: string;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
output: {
|
|
217
|
+
data: {
|
|
218
|
+
bookingId: string;
|
|
219
|
+
accounts: {
|
|
220
|
+
id: string;
|
|
221
|
+
label: string;
|
|
222
|
+
provider: string | null;
|
|
223
|
+
instrumentType: "other" | "voucher" | "wallet" | "credit_card" | "debit_card" | "cash" | "direct_bill" | "bank_account";
|
|
224
|
+
status: "expired" | "revoked" | "active" | "inactive" | "failed_verification";
|
|
225
|
+
brand: string | null;
|
|
226
|
+
last4: string | null;
|
|
227
|
+
expiryMonth: number | null;
|
|
228
|
+
expiryYear: number | null;
|
|
229
|
+
isDefault: boolean;
|
|
230
|
+
}[];
|
|
231
|
+
schedules: {
|
|
232
|
+
id: string;
|
|
233
|
+
scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
|
|
234
|
+
status: "expired" | "cancelled" | "pending" | "paid" | "due" | "waived";
|
|
235
|
+
dueDate: string;
|
|
236
|
+
currency: string;
|
|
237
|
+
amountCents: number;
|
|
238
|
+
notes: string | null;
|
|
239
|
+
}[];
|
|
240
|
+
guarantees: {
|
|
241
|
+
id: string;
|
|
242
|
+
bookingPaymentScheduleId: string | null;
|
|
243
|
+
guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
|
|
244
|
+
status: "expired" | "cancelled" | "pending" | "released" | "failed" | "active";
|
|
245
|
+
currency: string | null;
|
|
246
|
+
amountCents: number | null;
|
|
247
|
+
provider: string | null;
|
|
248
|
+
referenceNumber: string | null;
|
|
249
|
+
expiresAt: string | null;
|
|
250
|
+
notes: string | null;
|
|
251
|
+
}[];
|
|
252
|
+
recommendedTarget: {
|
|
253
|
+
targetType: "booking_payment_schedule" | "booking_guarantee";
|
|
254
|
+
targetId: string | null;
|
|
255
|
+
} | null;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
outputFormat: "json";
|
|
259
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
} & {
|
|
263
|
+
"/payment-sessions/:sessionId": {
|
|
264
|
+
$get: {
|
|
265
|
+
input: {
|
|
266
|
+
param: {
|
|
267
|
+
sessionId: string;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
output: {
|
|
271
|
+
error: string;
|
|
272
|
+
};
|
|
273
|
+
outputFormat: "json";
|
|
274
|
+
status: 404;
|
|
275
|
+
} | {
|
|
276
|
+
input: {
|
|
277
|
+
param: {
|
|
278
|
+
sessionId: string;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
output: {
|
|
282
|
+
data: {
|
|
283
|
+
id: string;
|
|
284
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
285
|
+
targetId: string | null;
|
|
286
|
+
bookingId: string | null;
|
|
287
|
+
invoiceId: string | null;
|
|
288
|
+
bookingPaymentScheduleId: string | null;
|
|
289
|
+
bookingGuaranteeId: string | null;
|
|
290
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
291
|
+
provider: string | null;
|
|
292
|
+
providerSessionId: string | null;
|
|
293
|
+
providerPaymentId: string | null;
|
|
294
|
+
externalReference: string | null;
|
|
295
|
+
clientReference: string | null;
|
|
296
|
+
currency: string;
|
|
297
|
+
amountCents: number;
|
|
298
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
299
|
+
payerEmail: string | null;
|
|
300
|
+
payerName: string | null;
|
|
301
|
+
redirectUrl: string | null;
|
|
302
|
+
returnUrl: string | null;
|
|
303
|
+
cancelUrl: string | null;
|
|
304
|
+
expiresAt: string | null;
|
|
305
|
+
completedAt: string | null;
|
|
306
|
+
failureCode: string | null;
|
|
307
|
+
failureMessage: string | null;
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
outputFormat: "json";
|
|
311
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
} & {
|
|
315
|
+
"/bookings/:bookingId/payment-schedules/:scheduleId/payment-session": {
|
|
316
|
+
$post: {
|
|
317
|
+
input: {
|
|
318
|
+
param: {
|
|
319
|
+
bookingId: string;
|
|
320
|
+
} & {
|
|
321
|
+
scheduleId: string;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
output: {
|
|
325
|
+
error: string;
|
|
326
|
+
};
|
|
327
|
+
outputFormat: "json";
|
|
328
|
+
status: 404;
|
|
329
|
+
} | {
|
|
330
|
+
input: {
|
|
331
|
+
param: {
|
|
332
|
+
bookingId: string;
|
|
333
|
+
} & {
|
|
334
|
+
scheduleId: string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
output: {
|
|
338
|
+
data: {
|
|
339
|
+
id: string;
|
|
340
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
341
|
+
targetId: string | null;
|
|
342
|
+
bookingId: string | null;
|
|
343
|
+
invoiceId: string | null;
|
|
344
|
+
bookingPaymentScheduleId: string | null;
|
|
345
|
+
bookingGuaranteeId: string | null;
|
|
346
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
347
|
+
provider: string | null;
|
|
348
|
+
providerSessionId: string | null;
|
|
349
|
+
providerPaymentId: string | null;
|
|
350
|
+
externalReference: string | null;
|
|
351
|
+
clientReference: string | null;
|
|
352
|
+
currency: string;
|
|
353
|
+
amountCents: number;
|
|
354
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
355
|
+
payerEmail: string | null;
|
|
356
|
+
payerName: string | null;
|
|
357
|
+
redirectUrl: string | null;
|
|
358
|
+
returnUrl: string | null;
|
|
359
|
+
cancelUrl: string | null;
|
|
360
|
+
expiresAt: string | null;
|
|
361
|
+
completedAt: string | null;
|
|
362
|
+
failureCode: string | null;
|
|
363
|
+
failureMessage: string | null;
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
outputFormat: "json";
|
|
367
|
+
status: 201;
|
|
368
|
+
} | {
|
|
369
|
+
input: {
|
|
370
|
+
param: {
|
|
371
|
+
bookingId: string;
|
|
372
|
+
} & {
|
|
373
|
+
scheduleId: string;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
output: {
|
|
377
|
+
error: string;
|
|
378
|
+
};
|
|
379
|
+
outputFormat: "json";
|
|
380
|
+
status: 409;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
} & {
|
|
384
|
+
"/bookings/:bookingId/guarantees/:guaranteeId/payment-session": {
|
|
385
|
+
$post: {
|
|
386
|
+
input: {
|
|
387
|
+
param: {
|
|
388
|
+
bookingId: string;
|
|
389
|
+
} & {
|
|
390
|
+
guaranteeId: string;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
output: {
|
|
394
|
+
error: string;
|
|
395
|
+
};
|
|
396
|
+
outputFormat: "json";
|
|
397
|
+
status: 404;
|
|
398
|
+
} | {
|
|
399
|
+
input: {
|
|
400
|
+
param: {
|
|
401
|
+
bookingId: string;
|
|
402
|
+
} & {
|
|
403
|
+
guaranteeId: string;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
output: {
|
|
407
|
+
data: {
|
|
408
|
+
id: string;
|
|
409
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
410
|
+
targetId: string | null;
|
|
411
|
+
bookingId: string | null;
|
|
412
|
+
invoiceId: string | null;
|
|
413
|
+
bookingPaymentScheduleId: string | null;
|
|
414
|
+
bookingGuaranteeId: string | null;
|
|
415
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
416
|
+
provider: string | null;
|
|
417
|
+
providerSessionId: string | null;
|
|
418
|
+
providerPaymentId: string | null;
|
|
419
|
+
externalReference: string | null;
|
|
420
|
+
clientReference: string | null;
|
|
421
|
+
currency: string;
|
|
422
|
+
amountCents: number;
|
|
423
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
424
|
+
payerEmail: string | null;
|
|
425
|
+
payerName: string | null;
|
|
426
|
+
redirectUrl: string | null;
|
|
427
|
+
returnUrl: string | null;
|
|
428
|
+
cancelUrl: string | null;
|
|
429
|
+
expiresAt: string | null;
|
|
430
|
+
completedAt: string | null;
|
|
431
|
+
failureCode: string | null;
|
|
432
|
+
failureMessage: string | null;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
outputFormat: "json";
|
|
436
|
+
status: 201;
|
|
437
|
+
} | {
|
|
438
|
+
input: {
|
|
439
|
+
param: {
|
|
440
|
+
bookingId: string;
|
|
441
|
+
} & {
|
|
442
|
+
guaranteeId: string;
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
output: {
|
|
446
|
+
error: string;
|
|
447
|
+
};
|
|
448
|
+
outputFormat: "json";
|
|
449
|
+
status: 409;
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
} & {
|
|
453
|
+
"/invoices/:invoiceId/payment-session": {
|
|
454
|
+
$post: {
|
|
455
|
+
input: {
|
|
456
|
+
param: {
|
|
457
|
+
invoiceId: string;
|
|
458
|
+
};
|
|
459
|
+
};
|
|
460
|
+
output: {
|
|
461
|
+
error: string;
|
|
462
|
+
};
|
|
463
|
+
outputFormat: "json";
|
|
464
|
+
status: 404;
|
|
465
|
+
} | {
|
|
466
|
+
input: {
|
|
467
|
+
param: {
|
|
468
|
+
invoiceId: string;
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
output: {
|
|
472
|
+
data: {
|
|
473
|
+
id: string;
|
|
474
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
475
|
+
targetId: string | null;
|
|
476
|
+
bookingId: string | null;
|
|
477
|
+
invoiceId: string | null;
|
|
478
|
+
bookingPaymentScheduleId: string | null;
|
|
479
|
+
bookingGuaranteeId: string | null;
|
|
480
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
481
|
+
provider: string | null;
|
|
482
|
+
providerSessionId: string | null;
|
|
483
|
+
providerPaymentId: string | null;
|
|
484
|
+
externalReference: string | null;
|
|
485
|
+
clientReference: string | null;
|
|
486
|
+
currency: string;
|
|
487
|
+
amountCents: number;
|
|
488
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
489
|
+
payerEmail: string | null;
|
|
490
|
+
payerName: string | null;
|
|
491
|
+
redirectUrl: string | null;
|
|
492
|
+
returnUrl: string | null;
|
|
493
|
+
cancelUrl: string | null;
|
|
494
|
+
expiresAt: string | null;
|
|
495
|
+
completedAt: string | null;
|
|
496
|
+
failureCode: string | null;
|
|
497
|
+
failureMessage: string | null;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
outputFormat: "json";
|
|
501
|
+
status: 201;
|
|
502
|
+
} | {
|
|
503
|
+
input: {
|
|
504
|
+
param: {
|
|
505
|
+
invoiceId: string;
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
output: {
|
|
509
|
+
error: string;
|
|
510
|
+
};
|
|
511
|
+
outputFormat: "json";
|
|
512
|
+
status: 409;
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
}, "/", "/invoices/:invoiceId/payment-session">;
|
|
516
|
+
export type PublicFinanceRoutes = typeof publicFinanceRoutes;
|
|
517
|
+
//# sourceMappingURL=routes-public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-public.d.ts","sourceRoot":"","sources":["../src/routes-public.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,oBAAoB,CAAA;AAgBvD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAoF5B,CAAA;AAEJ,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { notFound } from "./routes-shared.js";
|
|
3
|
+
import { publicFinanceService } from "./service-public.js";
|
|
4
|
+
import { publicPaymentOptionsQuerySchema, publicStartPaymentSessionSchema, publicValidateVoucherSchema, } from "./validation-public.js";
|
|
5
|
+
function paymentConflictError(error) {
|
|
6
|
+
if (error instanceof Error) {
|
|
7
|
+
return error.message;
|
|
8
|
+
}
|
|
9
|
+
return "Unable to start payment session";
|
|
10
|
+
}
|
|
11
|
+
export const publicFinanceRoutes = new Hono()
|
|
12
|
+
.post("/vouchers/validate", async (c) => {
|
|
13
|
+
const result = await publicFinanceService.validateVoucher(c.get("db"), publicValidateVoucherSchema.parse(await c.req.json()));
|
|
14
|
+
return c.json({ data: result });
|
|
15
|
+
})
|
|
16
|
+
.get("/bookings/:bookingId/documents", async (c) => {
|
|
17
|
+
const documents = await publicFinanceService.getBookingDocuments(c.get("db"), c.req.param("bookingId"));
|
|
18
|
+
return documents ? c.json({ data: documents }) : notFound(c, "Booking documents not found");
|
|
19
|
+
})
|
|
20
|
+
.get("/bookings/:bookingId/payments", async (c) => {
|
|
21
|
+
const payments = await publicFinanceService.getBookingPayments(c.get("db"), c.req.param("bookingId"));
|
|
22
|
+
return payments ? c.json({ data: payments }) : notFound(c, "Booking payments not found");
|
|
23
|
+
})
|
|
24
|
+
.get("/bookings/:bookingId/payment-options", async (c) => {
|
|
25
|
+
const options = await publicFinanceService.getBookingPaymentOptions(c.get("db"), c.req.param("bookingId"), publicPaymentOptionsQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)));
|
|
26
|
+
return options ? c.json({ data: options }) : notFound(c, "Booking payment options not found");
|
|
27
|
+
})
|
|
28
|
+
.get("/payment-sessions/:sessionId", async (c) => {
|
|
29
|
+
const session = await publicFinanceService.getPaymentSession(c.get("db"), c.req.param("sessionId"));
|
|
30
|
+
return session ? c.json({ data: session }) : notFound(c, "Payment session not found");
|
|
31
|
+
})
|
|
32
|
+
.post("/bookings/:bookingId/payment-schedules/:scheduleId/payment-session", async (c) => {
|
|
33
|
+
try {
|
|
34
|
+
const session = await publicFinanceService.startBookingSchedulePaymentSession(c.get("db"), c.req.param("bookingId"), c.req.param("scheduleId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
35
|
+
return session
|
|
36
|
+
? c.json({ data: session }, 201)
|
|
37
|
+
: notFound(c, "Booking payment schedule not found");
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.post("/bookings/:bookingId/guarantees/:guaranteeId/payment-session", async (c) => {
|
|
44
|
+
try {
|
|
45
|
+
const session = await publicFinanceService.startBookingGuaranteePaymentSession(c.get("db"), c.req.param("bookingId"), c.req.param("guaranteeId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
46
|
+
return session ? c.json({ data: session }, 201) : notFound(c, "Booking guarantee not found");
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.post("/invoices/:invoiceId/payment-session", async (c) => {
|
|
53
|
+
try {
|
|
54
|
+
const session = await publicFinanceService.startInvoicePaymentSession(c.get("db"), c.req.param("invoiceId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
55
|
+
return session ? c.json({ data: session }, 201) : notFound(c, "Invoice not found");
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type InvoiceSettlementPoller } from "./service-settlement.js";
|
|
2
|
+
type Env = {
|
|
3
|
+
Bindings: Record<string, unknown>;
|
|
4
|
+
Variables: {
|
|
5
|
+
db: import("drizzle-orm/postgres-js").PostgresJsDatabase;
|
|
6
|
+
userId?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export interface FinanceSettlementRouteOptions {
|
|
10
|
+
invoiceSettlementPollers?: Record<string, InvoiceSettlementPoller>;
|
|
11
|
+
resolveInvoiceSettlementPollers?: (bindings: Record<string, unknown>) => Record<string, InvoiceSettlementPoller> | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function createFinanceAdminSettlementRoutes(options?: FinanceSettlementRouteOptions): import("hono/hono-base").HonoBase<Env, {
|
|
14
|
+
"/invoices/:id/poll-settlement": {
|
|
15
|
+
$post: {
|
|
16
|
+
input: {
|
|
17
|
+
param: {
|
|
18
|
+
id: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
output: {
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
24
|
+
outputFormat: "json";
|
|
25
|
+
status: 404;
|
|
26
|
+
} | {
|
|
27
|
+
input: {
|
|
28
|
+
param: {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
output: {
|
|
33
|
+
data: {
|
|
34
|
+
invoiceId: string;
|
|
35
|
+
invoiceStatus: "draft" | "sent" | "partially_paid" | "paid" | "overdue" | "void";
|
|
36
|
+
paidCents: number;
|
|
37
|
+
balanceDueCents: number;
|
|
38
|
+
results: {
|
|
39
|
+
provider: string;
|
|
40
|
+
externalRefId: string;
|
|
41
|
+
externalId: string | null;
|
|
42
|
+
externalNumber: string | null;
|
|
43
|
+
externalUrl: string | null;
|
|
44
|
+
status: string | null;
|
|
45
|
+
paidAmountCents: number | null;
|
|
46
|
+
unpaidAmountCents: number | null;
|
|
47
|
+
syncedAt: string | null;
|
|
48
|
+
settledAt: string | null;
|
|
49
|
+
createdPaymentId: string | null;
|
|
50
|
+
newlyAppliedAmountCents: number;
|
|
51
|
+
syncError: string | null;
|
|
52
|
+
}[];
|
|
53
|
+
} | {
|
|
54
|
+
status: "not_found";
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
outputFormat: "json";
|
|
58
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}, "/", "/invoices/:id/poll-settlement">;
|
|
62
|
+
export type { InvoiceSettlementPoller } from "./service-settlement.js";
|
|
63
|
+
//# sourceMappingURL=routes-settlement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-settlement.d.ts","sourceRoot":"","sources":["../src/routes-settlement.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGhG,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,EAAE,EAAE,OAAO,yBAAyB,EAAE,kBAAkB,CAAA;QACxD,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,MAAM,WAAW,6BAA6B;IAC5C,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;IAClE,+BAA+B,CAAC,EAAE,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAAG,SAAS,CAAA;CACzD;AAWD,wBAAgB,kCAAkC,CAAC,OAAO,GAAE,6BAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAkB7F;AAED,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { financeSettlementService } from "./service-settlement.js";
|
|
3
|
+
import { pollInvoiceSettlementInputSchema } from "./validation.js";
|
|
4
|
+
function resolveInvoiceSettlementPollers(options, bindings) {
|
|
5
|
+
return (options?.resolveInvoiceSettlementPollers?.(bindings) ?? options?.invoiceSettlementPollers ?? {});
|
|
6
|
+
}
|
|
7
|
+
export function createFinanceAdminSettlementRoutes(options = {}) {
|
|
8
|
+
return new Hono().post("/invoices/:id/poll-settlement", async (c) => {
|
|
9
|
+
const result = await financeSettlementService.pollInvoiceSettlement(c.get("db"), c.req.param("id"), pollInvoiceSettlementInputSchema.parse(await c.req.json().catch(() => ({}))), {
|
|
10
|
+
bindings: c.env,
|
|
11
|
+
invoiceSettlementPollers: resolveInvoiceSettlementPollers(options, c.env),
|
|
12
|
+
});
|
|
13
|
+
if ("status" in result && result.status === "not_found") {
|
|
14
|
+
return c.json({ error: "Invoice not found" }, 404);
|
|
15
|
+
}
|
|
16
|
+
return c.json({ data: result });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { Context } from "hono";
|
|
3
|
+
export type Env = {
|
|
4
|
+
Variables: {
|
|
5
|
+
db: PostgresJsDatabase;
|
|
6
|
+
userId?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare function notFound<T extends Env>(c: Context<T>, error: string): Response & import("hono").TypedResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}, 404, "json">;
|
|
12
|
+
//# sourceMappingURL=routes-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-shared.d.ts","sourceRoot":"","sources":["../src/routes-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,MAAM,MAAM,GAAG,GAAG;IAChB,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM;;gBAEnE"}
|