@voyantjs/finance 0.3.0 → 0.3.1
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 +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/routes-public.d.ts +476 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +56 -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-public.d.ts +250 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +366 -0
- package/dist/service.d.ts +175 -181
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +52 -10
- package/dist/validation-billing.d.ts +10 -10
- package/dist/validation-payments.d.ts +83 -83
- package/dist/validation-public.d.ts +374 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +166 -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 +13 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { LinkableDefinition, Module } from "@voyantjs/core";
|
|
2
2
|
import type { HonoModule } from "@voyantjs/hono/module";
|
|
3
3
|
export type { FinanceRoutes } from "./routes.js";
|
|
4
|
+
export type { PublicFinanceRoutes } from "./routes-public.js";
|
|
5
|
+
export { publicFinanceRoutes } from "./routes-public.js";
|
|
6
|
+
export { publicFinanceService } from "./service-public.js";
|
|
4
7
|
export declare const invoiceLinkable: LinkableDefinition;
|
|
5
8
|
export declare const invoiceTemplateLinkable: LinkableDefinition;
|
|
6
9
|
export declare const creditNoteLinkable: LinkableDefinition;
|
|
@@ -16,4 +19,6 @@ export { bookingGuarantees, bookingItemCommissions, bookingItemTaxLines, booking
|
|
|
16
19
|
export type { InvoiceFromBookingData } from "./service.js";
|
|
17
20
|
export { financeService, renderInvoiceBody } from "./service.js";
|
|
18
21
|
export { agingReportQuerySchema, allocateInvoiceNumberInputSchema, applyDefaultBookingPaymentPlanSchema, cancelPaymentSessionSchema, completePaymentSessionSchema, createPaymentSessionFromGuaranteeSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, expirePaymentSessionSchema, failPaymentSessionSchema, insertBookingGuaranteeSchema, insertBookingItemCommissionSchema, insertBookingItemTaxLineSchema, insertBookingPaymentScheduleSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceExternalRefSchema, insertInvoiceLineItemSchema, insertInvoiceNumberSeriesSchema, insertInvoiceRenditionSchema, insertInvoiceSchema, insertInvoiceTemplateSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSchema, insertPaymentSessionSchema, insertSupplierPaymentSchema, insertTaxRegimeSchema, invoiceFromBookingSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteLineItemSchema, updateCreditNoteSchema, updateInvoiceExternalRefSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceRenditionSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxRegimeSchema, } from "./validation.js";
|
|
22
|
+
export type { PublicBookingFinanceDocuments, PublicBookingPaymentOptions, PublicFinanceBookingDocument, PublicPaymentOptionsQuery, PublicPaymentSession, PublicStartPaymentSessionInput, PublicValidateVoucherInput, PublicVoucherValidationResult, } from "./validation-public.js";
|
|
23
|
+
export { publicBookingFinanceDocumentsSchema, publicBookingPaymentOptionsSchema, publicFinanceBookingDocumentSchema, publicFinanceDocumentAvailabilitySchema, publicFinanceDocumentFormatSchema, publicFinanceInvoiceTypeSchema, publicPaymentOptionsQuerySchema, publicPaymentSessionSchema, publicStartPaymentSessionSchema, publicValidateVoucherSchema, publicVoucherValidationSchema, } from "./validation-public.js";
|
|
19
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAKvD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,eAAO,MAAM,eAAe,EAAE,kBAK7B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,kBAKrC,CAAA;AAED,eAAO,M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AAM,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { financeRoutes } from "./routes.js";
|
|
2
|
+
import { publicFinanceRoutes } from "./routes-public.js";
|
|
3
|
+
export { publicFinanceRoutes } from "./routes-public.js";
|
|
4
|
+
export { publicFinanceService } from "./service-public.js";
|
|
2
5
|
export const invoiceLinkable = {
|
|
3
6
|
module: "finance",
|
|
4
7
|
entity: "invoice",
|
|
@@ -28,8 +31,11 @@ export const financeModule = {
|
|
|
28
31
|
};
|
|
29
32
|
export const financeHonoModule = {
|
|
30
33
|
module: financeModule,
|
|
34
|
+
adminRoutes: financeRoutes,
|
|
35
|
+
publicRoutes: publicFinanceRoutes,
|
|
31
36
|
routes: financeRoutes,
|
|
32
37
|
};
|
|
33
38
|
export { bookingGuarantees, bookingItemCommissions, bookingItemTaxLines, bookingPaymentSchedules, creditNoteLineItems, creditNotes, financeNotes, invoiceExternalRefs, invoiceLineItems, invoiceNumberSeries, invoiceRenditions, invoices, invoiceTemplates, paymentAuthorizations, paymentCaptures, paymentInstruments, paymentSessions, payments, supplierPayments, taxRegimes, } from "./schema.js";
|
|
34
39
|
export { financeService, renderInvoiceBody } from "./service.js";
|
|
35
40
|
export { agingReportQuerySchema, allocateInvoiceNumberInputSchema, applyDefaultBookingPaymentPlanSchema, cancelPaymentSessionSchema, completePaymentSessionSchema, createPaymentSessionFromGuaranteeSchema, createPaymentSessionFromInvoiceSchema, createPaymentSessionFromScheduleSchema, expirePaymentSessionSchema, failPaymentSessionSchema, insertBookingGuaranteeSchema, insertBookingItemCommissionSchema, insertBookingItemTaxLineSchema, insertBookingPaymentScheduleSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceExternalRefSchema, insertInvoiceLineItemSchema, insertInvoiceNumberSeriesSchema, insertInvoiceRenditionSchema, insertInvoiceSchema, insertInvoiceTemplateSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSchema, insertPaymentSessionSchema, insertSupplierPaymentSchema, insertTaxRegimeSchema, invoiceFromBookingSchema, invoiceListQuerySchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, profitabilityQuerySchema, renderInvoiceInputSchema, revenueReportQuerySchema, supplierPaymentListQuerySchema, taxRegimeListQuerySchema, updateBookingGuaranteeSchema, updateBookingItemCommissionSchema, updateBookingItemTaxLineSchema, updateBookingPaymentScheduleSchema, updateCreditNoteLineItemSchema, updateCreditNoteSchema, updateInvoiceExternalRefSchema, updateInvoiceLineItemSchema, updateInvoiceNumberSeriesSchema, updateInvoiceRenditionSchema, updateInvoiceSchema, updateInvoiceTemplateSchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSchema, updatePaymentSessionSchema, updateSupplierPaymentSchema, updateTaxRegimeSchema, } from "./validation.js";
|
|
41
|
+
export { publicBookingFinanceDocumentsSchema, publicBookingPaymentOptionsSchema, publicFinanceBookingDocumentSchema, publicFinanceDocumentAvailabilitySchema, publicFinanceDocumentFormatSchema, publicFinanceInvoiceTypeSchema, publicPaymentOptionsQuerySchema, publicPaymentSessionSchema, publicStartPaymentSessionSchema, publicValidateVoucherSchema, publicVoucherValidationSchema, } from "./validation-public.js";
|
|
@@ -0,0 +1,476 @@
|
|
|
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/payment-options": {
|
|
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
|
+
accounts: {
|
|
179
|
+
id: string;
|
|
180
|
+
label: string;
|
|
181
|
+
provider: string | null;
|
|
182
|
+
instrumentType: "other" | "voucher" | "wallet" | "credit_card" | "debit_card" | "cash" | "direct_bill" | "bank_account";
|
|
183
|
+
status: "expired" | "revoked" | "active" | "inactive" | "failed_verification";
|
|
184
|
+
brand: string | null;
|
|
185
|
+
last4: string | null;
|
|
186
|
+
expiryMonth: number | null;
|
|
187
|
+
expiryYear: number | null;
|
|
188
|
+
isDefault: boolean;
|
|
189
|
+
}[];
|
|
190
|
+
schedules: {
|
|
191
|
+
id: string;
|
|
192
|
+
scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
|
|
193
|
+
status: "expired" | "cancelled" | "pending" | "paid" | "due" | "waived";
|
|
194
|
+
dueDate: string;
|
|
195
|
+
currency: string;
|
|
196
|
+
amountCents: number;
|
|
197
|
+
notes: string | null;
|
|
198
|
+
}[];
|
|
199
|
+
guarantees: {
|
|
200
|
+
id: string;
|
|
201
|
+
bookingPaymentScheduleId: string | null;
|
|
202
|
+
guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
|
|
203
|
+
status: "expired" | "cancelled" | "pending" | "released" | "failed" | "active";
|
|
204
|
+
currency: string | null;
|
|
205
|
+
amountCents: number | null;
|
|
206
|
+
provider: string | null;
|
|
207
|
+
referenceNumber: string | null;
|
|
208
|
+
expiresAt: string | null;
|
|
209
|
+
notes: string | null;
|
|
210
|
+
}[];
|
|
211
|
+
recommendedTarget: {
|
|
212
|
+
targetType: "booking_payment_schedule" | "booking_guarantee";
|
|
213
|
+
targetId: string | null;
|
|
214
|
+
} | null;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
outputFormat: "json";
|
|
218
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
} & {
|
|
222
|
+
"/payment-sessions/:sessionId": {
|
|
223
|
+
$get: {
|
|
224
|
+
input: {
|
|
225
|
+
param: {
|
|
226
|
+
sessionId: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
output: {
|
|
230
|
+
error: string;
|
|
231
|
+
};
|
|
232
|
+
outputFormat: "json";
|
|
233
|
+
status: 404;
|
|
234
|
+
} | {
|
|
235
|
+
input: {
|
|
236
|
+
param: {
|
|
237
|
+
sessionId: string;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
output: {
|
|
241
|
+
data: {
|
|
242
|
+
id: string;
|
|
243
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
244
|
+
targetId: string | null;
|
|
245
|
+
bookingId: string | null;
|
|
246
|
+
invoiceId: string | null;
|
|
247
|
+
bookingPaymentScheduleId: string | null;
|
|
248
|
+
bookingGuaranteeId: string | null;
|
|
249
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
250
|
+
provider: string | null;
|
|
251
|
+
providerSessionId: string | null;
|
|
252
|
+
providerPaymentId: string | null;
|
|
253
|
+
externalReference: string | null;
|
|
254
|
+
clientReference: string | null;
|
|
255
|
+
currency: string;
|
|
256
|
+
amountCents: number;
|
|
257
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
258
|
+
payerEmail: string | null;
|
|
259
|
+
payerName: string | null;
|
|
260
|
+
redirectUrl: string | null;
|
|
261
|
+
returnUrl: string | null;
|
|
262
|
+
cancelUrl: string | null;
|
|
263
|
+
expiresAt: string | null;
|
|
264
|
+
completedAt: string | null;
|
|
265
|
+
failureCode: string | null;
|
|
266
|
+
failureMessage: string | null;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
outputFormat: "json";
|
|
270
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
} & {
|
|
274
|
+
"/bookings/:bookingId/payment-schedules/:scheduleId/payment-session": {
|
|
275
|
+
$post: {
|
|
276
|
+
input: {
|
|
277
|
+
param: {
|
|
278
|
+
bookingId: string;
|
|
279
|
+
} & {
|
|
280
|
+
scheduleId: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
output: {
|
|
284
|
+
error: string;
|
|
285
|
+
};
|
|
286
|
+
outputFormat: "json";
|
|
287
|
+
status: 404;
|
|
288
|
+
} | {
|
|
289
|
+
input: {
|
|
290
|
+
param: {
|
|
291
|
+
bookingId: string;
|
|
292
|
+
} & {
|
|
293
|
+
scheduleId: string;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
output: {
|
|
297
|
+
data: {
|
|
298
|
+
id: string;
|
|
299
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
300
|
+
targetId: string | null;
|
|
301
|
+
bookingId: string | null;
|
|
302
|
+
invoiceId: string | null;
|
|
303
|
+
bookingPaymentScheduleId: string | null;
|
|
304
|
+
bookingGuaranteeId: string | null;
|
|
305
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
306
|
+
provider: string | null;
|
|
307
|
+
providerSessionId: string | null;
|
|
308
|
+
providerPaymentId: string | null;
|
|
309
|
+
externalReference: string | null;
|
|
310
|
+
clientReference: string | null;
|
|
311
|
+
currency: string;
|
|
312
|
+
amountCents: number;
|
|
313
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
314
|
+
payerEmail: string | null;
|
|
315
|
+
payerName: string | null;
|
|
316
|
+
redirectUrl: string | null;
|
|
317
|
+
returnUrl: string | null;
|
|
318
|
+
cancelUrl: string | null;
|
|
319
|
+
expiresAt: string | null;
|
|
320
|
+
completedAt: string | null;
|
|
321
|
+
failureCode: string | null;
|
|
322
|
+
failureMessage: string | null;
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
outputFormat: "json";
|
|
326
|
+
status: 201;
|
|
327
|
+
} | {
|
|
328
|
+
input: {
|
|
329
|
+
param: {
|
|
330
|
+
bookingId: string;
|
|
331
|
+
} & {
|
|
332
|
+
scheduleId: string;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
output: {
|
|
336
|
+
error: string;
|
|
337
|
+
};
|
|
338
|
+
outputFormat: "json";
|
|
339
|
+
status: 409;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
} & {
|
|
343
|
+
"/bookings/:bookingId/guarantees/:guaranteeId/payment-session": {
|
|
344
|
+
$post: {
|
|
345
|
+
input: {
|
|
346
|
+
param: {
|
|
347
|
+
bookingId: string;
|
|
348
|
+
} & {
|
|
349
|
+
guaranteeId: string;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
output: {
|
|
353
|
+
error: string;
|
|
354
|
+
};
|
|
355
|
+
outputFormat: "json";
|
|
356
|
+
status: 404;
|
|
357
|
+
} | {
|
|
358
|
+
input: {
|
|
359
|
+
param: {
|
|
360
|
+
bookingId: string;
|
|
361
|
+
} & {
|
|
362
|
+
guaranteeId: string;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
output: {
|
|
366
|
+
data: {
|
|
367
|
+
id: string;
|
|
368
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
369
|
+
targetId: string | null;
|
|
370
|
+
bookingId: string | null;
|
|
371
|
+
invoiceId: string | null;
|
|
372
|
+
bookingPaymentScheduleId: string | null;
|
|
373
|
+
bookingGuaranteeId: string | null;
|
|
374
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
375
|
+
provider: string | null;
|
|
376
|
+
providerSessionId: string | null;
|
|
377
|
+
providerPaymentId: string | null;
|
|
378
|
+
externalReference: string | null;
|
|
379
|
+
clientReference: string | null;
|
|
380
|
+
currency: string;
|
|
381
|
+
amountCents: number;
|
|
382
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
383
|
+
payerEmail: string | null;
|
|
384
|
+
payerName: string | null;
|
|
385
|
+
redirectUrl: string | null;
|
|
386
|
+
returnUrl: string | null;
|
|
387
|
+
cancelUrl: string | null;
|
|
388
|
+
expiresAt: string | null;
|
|
389
|
+
completedAt: string | null;
|
|
390
|
+
failureCode: string | null;
|
|
391
|
+
failureMessage: string | null;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
outputFormat: "json";
|
|
395
|
+
status: 201;
|
|
396
|
+
} | {
|
|
397
|
+
input: {
|
|
398
|
+
param: {
|
|
399
|
+
bookingId: string;
|
|
400
|
+
} & {
|
|
401
|
+
guaranteeId: string;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
output: {
|
|
405
|
+
error: string;
|
|
406
|
+
};
|
|
407
|
+
outputFormat: "json";
|
|
408
|
+
status: 409;
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
} & {
|
|
412
|
+
"/invoices/:invoiceId/payment-session": {
|
|
413
|
+
$post: {
|
|
414
|
+
input: {
|
|
415
|
+
param: {
|
|
416
|
+
invoiceId: string;
|
|
417
|
+
};
|
|
418
|
+
};
|
|
419
|
+
output: {
|
|
420
|
+
error: string;
|
|
421
|
+
};
|
|
422
|
+
outputFormat: "json";
|
|
423
|
+
status: 404;
|
|
424
|
+
} | {
|
|
425
|
+
input: {
|
|
426
|
+
param: {
|
|
427
|
+
invoiceId: string;
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
output: {
|
|
431
|
+
data: {
|
|
432
|
+
id: string;
|
|
433
|
+
targetType: "other" | "booking" | "order" | "invoice" | "booking_payment_schedule" | "booking_guarantee";
|
|
434
|
+
targetId: string | null;
|
|
435
|
+
bookingId: string | null;
|
|
436
|
+
invoiceId: string | null;
|
|
437
|
+
bookingPaymentScheduleId: string | null;
|
|
438
|
+
bookingGuaranteeId: string | null;
|
|
439
|
+
status: "expired" | "cancelled" | "pending" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
440
|
+
provider: string | null;
|
|
441
|
+
providerSessionId: string | null;
|
|
442
|
+
providerPaymentId: string | null;
|
|
443
|
+
externalReference: string | null;
|
|
444
|
+
clientReference: string | null;
|
|
445
|
+
currency: string;
|
|
446
|
+
amountCents: number;
|
|
447
|
+
paymentMethod: "other" | "voucher" | "wallet" | "bank_transfer" | "credit_card" | "debit_card" | "cash" | "cheque" | "direct_bill" | null;
|
|
448
|
+
payerEmail: string | null;
|
|
449
|
+
payerName: string | null;
|
|
450
|
+
redirectUrl: string | null;
|
|
451
|
+
returnUrl: string | null;
|
|
452
|
+
cancelUrl: string | null;
|
|
453
|
+
expiresAt: string | null;
|
|
454
|
+
completedAt: string | null;
|
|
455
|
+
failureCode: string | null;
|
|
456
|
+
failureMessage: string | null;
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
outputFormat: "json";
|
|
460
|
+
status: 201;
|
|
461
|
+
} | {
|
|
462
|
+
input: {
|
|
463
|
+
param: {
|
|
464
|
+
invoiceId: string;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
output: {
|
|
468
|
+
error: string;
|
|
469
|
+
};
|
|
470
|
+
outputFormat: "json";
|
|
471
|
+
status: 409;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
}, "/", "/invoices/:invoiceId/payment-session">;
|
|
475
|
+
export type PublicFinanceRoutes = typeof publicFinanceRoutes;
|
|
476
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CA4E5B,CAAA;AAEJ,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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/payment-options", async (c) => {
|
|
21
|
+
const options = await publicFinanceService.getBookingPaymentOptions(c.get("db"), c.req.param("bookingId"), publicPaymentOptionsQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)));
|
|
22
|
+
return options ? c.json({ data: options }) : notFound(c, "Booking payment options not found");
|
|
23
|
+
})
|
|
24
|
+
.get("/payment-sessions/:sessionId", async (c) => {
|
|
25
|
+
const session = await publicFinanceService.getPaymentSession(c.get("db"), c.req.param("sessionId"));
|
|
26
|
+
return session ? c.json({ data: session }) : notFound(c, "Payment session not found");
|
|
27
|
+
})
|
|
28
|
+
.post("/bookings/:bookingId/payment-schedules/:scheduleId/payment-session", async (c) => {
|
|
29
|
+
try {
|
|
30
|
+
const session = await publicFinanceService.startBookingSchedulePaymentSession(c.get("db"), c.req.param("bookingId"), c.req.param("scheduleId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
31
|
+
return session
|
|
32
|
+
? c.json({ data: session }, 201)
|
|
33
|
+
: notFound(c, "Booking payment schedule not found");
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
.post("/bookings/:bookingId/guarantees/:guaranteeId/payment-session", async (c) => {
|
|
40
|
+
try {
|
|
41
|
+
const session = await publicFinanceService.startBookingGuaranteePaymentSession(c.get("db"), c.req.param("bookingId"), c.req.param("guaranteeId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
42
|
+
return session ? c.json({ data: session }, 201) : notFound(c, "Booking guarantee not found");
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
.post("/invoices/:invoiceId/payment-session", async (c) => {
|
|
49
|
+
try {
|
|
50
|
+
const session = await publicFinanceService.startInvoicePaymentSession(c.get("db"), c.req.param("invoiceId"), publicStartPaymentSessionSchema.parse(await c.req.json()));
|
|
51
|
+
return session ? c.json({ data: session }, 201) : notFound(c, "Invoice not found");
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return c.json({ error: paymentConflictError(error) }, 409);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -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"}
|