@voyant-travel/finance 0.167.0 → 0.168.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/README.md +23 -9
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/booking-lifecycle.d.ts.map +1 -0
- package/dist/booking-schedule/subscriber-runtime.d.ts.map +1 -0
- package/dist/booking-tax.d.ts +31 -19
- package/dist/booking-tax.d.ts.map +1 -0
- package/dist/booking-tax.js +48 -15
- package/dist/card-payment.d.ts.map +1 -0
- package/dist/checkout-routes.d.ts +294 -294
- package/dist/checkout-routes.d.ts.map +1 -0
- package/dist/checkout-service-plan.d.ts +2 -2
- package/dist/checkout-service-plan.d.ts.map +1 -0
- package/dist/checkout-service.d.ts.map +1 -0
- package/dist/checkout-validation.d.ts.map +1 -0
- package/dist/document-download.d.ts.map +1 -0
- package/dist/fx-money.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/invoice-fx.d.ts.map +1 -0
- package/dist/invoice-number-errors.d.ts.map +1 -0
- package/dist/linkables.d.ts.map +1 -0
- package/dist/markets-ref.d.ts.map +1 -0
- package/dist/mcp-runtime.d.ts.map +1 -0
- package/dist/order-payment-sessions.d.ts.map +1 -0
- package/dist/payment-adapter-events.d.ts +3 -3
- package/dist/payment-link.d.ts.map +1 -0
- package/dist/payment-policy-cascade.d.ts.map +1 -0
- package/dist/payment-policy.d.ts.map +1 -0
- package/dist/payment-schedule/routes.d.ts +2 -2
- package/dist/payment-schedule/routes.d.ts.map +1 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/routes-action-ledger.d.ts +25 -25
- package/dist/routes-action-ledger.d.ts.map +1 -0
- package/dist/routes-booking-billing.d.ts +95 -95
- package/dist/routes-booking-billing.d.ts.map +1 -0
- package/dist/routes-booking-create.d.ts.map +1 -0
- package/dist/routes-booking-reads.d.ts +13 -13
- package/dist/routes-booking-reads.d.ts.map +1 -0
- package/dist/routes-documents.d.ts +11 -11
- package/dist/routes-documents.d.ts.map +1 -0
- package/dist/routes-invoice-core.d.ts +87 -87
- package/dist/routes-invoice-core.d.ts.map +1 -0
- package/dist/routes-invoice-documents.d.ts +16 -16
- package/dist/routes-invoice-documents.d.ts.map +1 -0
- package/dist/routes-invoice-issue.d.ts.map +1 -0
- package/dist/routes-invoice-schemas.d.ts +20 -20
- package/dist/routes-invoice-schemas.d.ts.map +1 -0
- package/dist/routes-payment-processing.d.ts +152 -152
- package/dist/routes-payment-processing.d.ts.map +1 -0
- package/dist/routes-payment-schemas.d.ts +17 -17
- package/dist/routes-payment-schemas.d.ts.map +1 -0
- package/dist/routes-payments.d.ts +64 -64
- package/dist/routes-payments.d.ts.map +1 -0
- package/dist/routes-public-accountant.d.ts +19 -19
- package/dist/routes-public.d.ts +102 -102
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-reference-data.d.ts +33 -33
- package/dist/routes-reference-data.d.ts.map +1 -0
- package/dist/routes-reports.d.ts +11 -11
- package/dist/routes-reports.d.ts.map +1 -0
- package/dist/routes-runtime.d.ts +1 -1
- package/dist/routes-runtime.d.ts.map +1 -0
- package/dist/routes-settlement.d.ts +12 -12
- package/dist/routes-settlement.d.ts.map +1 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-supplier-invoices.d.ts +75 -75
- package/dist/routes-supplier-invoices.d.ts.map +1 -0
- package/dist/routes-travel-credits.d.ts +4 -4
- package/dist/routes-vouchers.d.ts +401 -0
- package/dist/routes-vouchers.d.ts.map +1 -0
- package/dist/routes-vouchers.js +176 -0
- package/dist/routes.d.ts +477 -477
- package/dist/routes.d.ts.map +1 -0
- package/dist/runtime-contributor.d.ts.map +1 -0
- package/dist/runtime-port.d.ts +20 -24
- package/dist/runtime-port.d.ts.map +1 -0
- package/dist/runtime-port.js +10 -11
- package/dist/runtime.d.ts.map +1 -0
- package/dist/schema/booking-billing.d.ts +5 -5
- package/dist/schema/booking-billing.d.ts.map +1 -0
- package/dist/schema/enums.d.ts.map +1 -0
- package/dist/schema/invoice-documents.d.ts +1 -1
- package/dist/schema/invoice-documents.d.ts.map +1 -0
- package/dist/schema/payment-instruments.d.ts +1 -1
- package/dist/schema/payment-instruments.d.ts.map +1 -0
- package/dist/schema/payment-processing.d.ts +3 -3
- package/dist/schema/payment-processing.d.ts.map +1 -0
- package/dist/schema/payment-sessions.d.ts +3 -3
- package/dist/schema/payment-sessions.d.ts.map +1 -0
- package/dist/schema/receivables.d.ts +3 -3
- package/dist/schema/receivables.d.ts.map +1 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/supplier-invoices.d.ts +5 -5
- package/dist/schema/supplier-invoices.d.ts.map +1 -0
- package/dist/schema/tax.d.ts +1 -1
- package/dist/schema/tax.d.ts.map +1 -0
- package/dist/schema/vouchers.d.ts +444 -0
- package/dist/schema/vouchers.d.ts.map +1 -0
- package/dist/schema/vouchers.js +64 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/service-accountant-shares.d.ts.map +1 -0
- package/dist/service-action-ledger-accounting.d.ts.map +1 -0
- package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-bookings.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
- package/dist/service-action-ledger.d.ts.map +1 -0
- package/dist/service-aggregates.d.ts.map +1 -0
- package/dist/service-booking-billing.d.ts +111 -111
- package/dist/service-booking-billing.d.ts.map +1 -0
- package/dist/service-booking-create.d.ts +11 -11
- package/dist/service-booking-create.d.ts.map +1 -0
- package/dist/service-booking-guarantees.d.ts +34 -34
- package/dist/service-booking-guarantees.d.ts.map +1 -0
- package/dist/service-booking-item-billing.d.ts +21 -21
- package/dist/service-booking-item-billing.d.ts.map +1 -0
- package/dist/service-booking-payment-schedules.d.ts +56 -56
- package/dist/service-booking-payment-schedules.d.ts.map +1 -0
- package/dist/service-bookings-dual-create.d.ts +22 -22
- package/dist/service-bookings-dual-create.d.ts.map +1 -0
- package/dist/service-boundary-sql.d.ts.map +1 -0
- package/dist/service-cost-categories.d.ts.map +1 -0
- package/dist/service-documents.d.ts.map +1 -0
- package/dist/service-invoice-artifacts.d.ts +24 -24
- package/dist/service-invoice-artifacts.d.ts.map +1 -0
- package/dist/service-invoice-core.d.ts +28 -28
- package/dist/service-invoice-core.d.ts.map +1 -0
- package/dist/service-invoice-credit-notes.d.ts +10 -10
- package/dist/service-invoice-credit-notes.d.ts.map +1 -0
- package/dist/service-invoice-from-booking.d.ts +19 -19
- package/dist/service-invoice-from-booking.d.ts.map +1 -0
- package/dist/service-invoice-line-items.d.ts +10 -10
- package/dist/service-invoice-line-items.d.ts.map +1 -0
- package/dist/service-invoice-numbering.d.ts +28 -28
- package/dist/service-invoice-numbering.d.ts.map +1 -0
- package/dist/service-invoice-payments.d.ts +20 -20
- package/dist/service-invoice-payments.d.ts.map +1 -0
- package/dist/service-invoices.d.ts +87 -87
- package/dist/service-invoices.d.ts.map +1 -0
- package/dist/service-issue.d.ts +38 -38
- package/dist/service-issue.d.ts.map +1 -0
- package/dist/service-payment-authorizations.d.ts +26 -26
- package/dist/service-payment-authorizations.d.ts.map +1 -0
- package/dist/service-payment-instruments.d.ts +10 -10
- package/dist/service-payment-instruments.d.ts.map +1 -0
- package/dist/service-payment-processing.d.ts +77 -77
- package/dist/service-payment-processing.d.ts.map +1 -0
- package/dist/service-payment-session-completion.d.ts +3 -3
- package/dist/service-payment-session-completion.d.ts.map +1 -0
- package/dist/service-payment-sessions.d.ts +38 -38
- package/dist/service-payment-sessions.d.ts.map +1 -0
- package/dist/service-profitability.d.ts.map +1 -0
- package/dist/service-public.d.ts +16 -16
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-reference-data.d.ts +23 -23
- package/dist/service-reference-data.d.ts.map +1 -0
- package/dist/service-rendition-wait.d.ts +1 -1
- package/dist/service-rendition-wait.d.ts.map +1 -0
- package/dist/service-reports.d.ts.map +1 -0
- package/dist/service-settlement.d.ts.map +1 -0
- package/dist/service-shared.d.ts +4 -4
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-supplier-invoices.d.ts +20 -20
- package/dist/service-supplier-invoices.d.ts.map +1 -0
- package/dist/service-supplier-payments.d.ts +16 -16
- package/dist/service-supplier-payments.d.ts.map +1 -0
- package/dist/service-travel-credits.d.ts +10 -10
- package/dist/service-vouchers-migration.d.ts +51 -0
- package/dist/service-vouchers-migration.d.ts.map +1 -0
- package/dist/service-vouchers-migration.js +154 -0
- package/dist/service-vouchers.d.ts +157 -0
- package/dist/service-vouchers.d.ts.map +1 -0
- package/dist/service-vouchers.js +191 -0
- package/dist/service.d.ts +376 -376
- package/dist/service.d.ts.map +1 -0
- package/dist/stale-booking-holds-runtime.d.ts.map +1 -0
- package/dist/tools.d.ts +21 -21
- package/dist/tools.d.ts.map +1 -0
- package/dist/validation-billing.d.ts.map +1 -0
- package/dist/validation-payments.d.ts.map +1 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-vouchers.d.ts +2 -0
- package/dist/validation-vouchers.d.ts.map +1 -0
- package/dist/validation-vouchers.js +1 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/voyant.d.ts +2 -1
- package/dist/voyant.d.ts.map +1 -0
- package/dist/voyant.js +43 -7
- package/openapi/admin/booking-tax-preview.json +33 -0
- package/openapi/admin/{booking-tax.json → booking-tax-settings.json} +7 -32
- package/package.json +205 -170
- package/LICENSE +0 -201
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin voucher routes — mounted by the operator starter under
|
|
3
|
+
* `/v1/admin/finance/...`. Covers voucher issuance, lookup, update, and
|
|
4
|
+
* redemption.
|
|
5
|
+
*
|
|
6
|
+
* Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 /
|
|
7
|
+
* voyant#2208 — finance sub-batch 9C). Request schemas reuse the existing
|
|
8
|
+
* `@voyant-travel/finance-contracts` schemas the handlers already parse;
|
|
9
|
+
* response schemas come from the shared `routes-payment-schemas.ts` row shapes
|
|
10
|
+
* (authored from the Drizzle `$inferSelect` shapes; §17 dates → strings). The
|
|
11
|
+
* single voucher resource is its own `OpenAPIHono` sub-chain composed onto
|
|
12
|
+
* `financeVoucherRoutes` via `.route("/")` so the `.openapi()` operations
|
|
13
|
+
* propagate up through the parent `financeRoutes` registry.
|
|
14
|
+
*/
|
|
15
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
16
|
+
import type { Env } from "./routes-shared.js";
|
|
17
|
+
export declare const financeVoucherRoutes: OpenAPIHono<Env, import("hono/types").MergeSchemaPath<{
|
|
18
|
+
"/vouchers": {
|
|
19
|
+
$get: {
|
|
20
|
+
input: {
|
|
21
|
+
query: {
|
|
22
|
+
status?: "void" | "expired" | "active" | "redeemed" | undefined;
|
|
23
|
+
seriesCode?: string | undefined;
|
|
24
|
+
issuedToPersonId?: string | undefined;
|
|
25
|
+
issuedToOrganizationId?: string | undefined;
|
|
26
|
+
search?: string | undefined;
|
|
27
|
+
hasBalance?: unknown;
|
|
28
|
+
limit?: unknown;
|
|
29
|
+
offset?: unknown;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
output: {
|
|
33
|
+
data: {
|
|
34
|
+
id: string;
|
|
35
|
+
code: string;
|
|
36
|
+
seriesCode: string | null;
|
|
37
|
+
status: "void" | "expired" | "active" | "redeemed";
|
|
38
|
+
currency: string;
|
|
39
|
+
initialAmountCents: number;
|
|
40
|
+
remainingAmountCents: number;
|
|
41
|
+
issuedToPersonId: string | null;
|
|
42
|
+
issuedToOrganizationId: string | null;
|
|
43
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
44
|
+
sourceBookingId: string | null;
|
|
45
|
+
sourcePaymentId: string | null;
|
|
46
|
+
validFrom: string | null;
|
|
47
|
+
expiresAt: string | null;
|
|
48
|
+
notes: string | null;
|
|
49
|
+
issuedByUserId: string | null;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
}[];
|
|
53
|
+
total: number;
|
|
54
|
+
limit: number;
|
|
55
|
+
offset: number;
|
|
56
|
+
};
|
|
57
|
+
outputFormat: "json";
|
|
58
|
+
status: 200;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
} & {
|
|
62
|
+
"/vouchers": {
|
|
63
|
+
$post: {
|
|
64
|
+
input: {
|
|
65
|
+
json: {
|
|
66
|
+
currency: string;
|
|
67
|
+
amountCents: number;
|
|
68
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
69
|
+
code?: string | null | undefined;
|
|
70
|
+
seriesCode?: string | null | undefined;
|
|
71
|
+
issuedToPersonId?: string | null | undefined;
|
|
72
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
73
|
+
sourceBookingId?: string | null | undefined;
|
|
74
|
+
sourcePaymentId?: string | null | undefined;
|
|
75
|
+
validFrom?: string | null | undefined;
|
|
76
|
+
expiresAt?: string | null | undefined;
|
|
77
|
+
notes?: string | null | undefined;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
output: {
|
|
81
|
+
error: string;
|
|
82
|
+
};
|
|
83
|
+
outputFormat: "json";
|
|
84
|
+
status: 400;
|
|
85
|
+
} | {
|
|
86
|
+
input: {
|
|
87
|
+
json: {
|
|
88
|
+
currency: string;
|
|
89
|
+
amountCents: number;
|
|
90
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
91
|
+
code?: string | null | undefined;
|
|
92
|
+
seriesCode?: string | null | undefined;
|
|
93
|
+
issuedToPersonId?: string | null | undefined;
|
|
94
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
95
|
+
sourceBookingId?: string | null | undefined;
|
|
96
|
+
sourcePaymentId?: string | null | undefined;
|
|
97
|
+
validFrom?: string | null | undefined;
|
|
98
|
+
expiresAt?: string | null | undefined;
|
|
99
|
+
notes?: string | null | undefined;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
output: {
|
|
103
|
+
error: string;
|
|
104
|
+
};
|
|
105
|
+
outputFormat: "json";
|
|
106
|
+
status: 409;
|
|
107
|
+
} | {
|
|
108
|
+
input: {
|
|
109
|
+
json: {
|
|
110
|
+
currency: string;
|
|
111
|
+
amountCents: number;
|
|
112
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
113
|
+
code?: string | null | undefined;
|
|
114
|
+
seriesCode?: string | null | undefined;
|
|
115
|
+
issuedToPersonId?: string | null | undefined;
|
|
116
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
117
|
+
sourceBookingId?: string | null | undefined;
|
|
118
|
+
sourcePaymentId?: string | null | undefined;
|
|
119
|
+
validFrom?: string | null | undefined;
|
|
120
|
+
expiresAt?: string | null | undefined;
|
|
121
|
+
notes?: string | null | undefined;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
output: {
|
|
125
|
+
data: {
|
|
126
|
+
id: string;
|
|
127
|
+
code: string;
|
|
128
|
+
seriesCode: string | null;
|
|
129
|
+
status: "void" | "expired" | "active" | "redeemed";
|
|
130
|
+
currency: string;
|
|
131
|
+
initialAmountCents: number;
|
|
132
|
+
remainingAmountCents: number;
|
|
133
|
+
issuedToPersonId: string | null;
|
|
134
|
+
issuedToOrganizationId: string | null;
|
|
135
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
136
|
+
sourceBookingId: string | null;
|
|
137
|
+
sourcePaymentId: string | null;
|
|
138
|
+
validFrom: string | null;
|
|
139
|
+
expiresAt: string | null;
|
|
140
|
+
notes: string | null;
|
|
141
|
+
issuedByUserId: string | null;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
updatedAt: string;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
outputFormat: "json";
|
|
147
|
+
status: 201;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
} & {
|
|
151
|
+
"/vouchers/:id": {
|
|
152
|
+
$get: {
|
|
153
|
+
input: {
|
|
154
|
+
param: {
|
|
155
|
+
id: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
output: {
|
|
159
|
+
error: string;
|
|
160
|
+
};
|
|
161
|
+
outputFormat: "json";
|
|
162
|
+
status: 404;
|
|
163
|
+
} | {
|
|
164
|
+
input: {
|
|
165
|
+
param: {
|
|
166
|
+
id: string;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
output: {
|
|
170
|
+
data: {
|
|
171
|
+
id: string;
|
|
172
|
+
code: string;
|
|
173
|
+
seriesCode: string | null;
|
|
174
|
+
status: "void" | "expired" | "active" | "redeemed";
|
|
175
|
+
currency: string;
|
|
176
|
+
initialAmountCents: number;
|
|
177
|
+
remainingAmountCents: number;
|
|
178
|
+
issuedToPersonId: string | null;
|
|
179
|
+
issuedToOrganizationId: string | null;
|
|
180
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
181
|
+
sourceBookingId: string | null;
|
|
182
|
+
sourcePaymentId: string | null;
|
|
183
|
+
validFrom: string | null;
|
|
184
|
+
expiresAt: string | null;
|
|
185
|
+
notes: string | null;
|
|
186
|
+
issuedByUserId: string | null;
|
|
187
|
+
createdAt: string;
|
|
188
|
+
updatedAt: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
outputFormat: "json";
|
|
192
|
+
status: 200;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
} & {
|
|
196
|
+
"/vouchers/:id": {
|
|
197
|
+
$patch: {
|
|
198
|
+
input: {
|
|
199
|
+
param: {
|
|
200
|
+
id: string;
|
|
201
|
+
};
|
|
202
|
+
} & {
|
|
203
|
+
json: {
|
|
204
|
+
status?: "void" | "expired" | "active" | "redeemed" | undefined;
|
|
205
|
+
seriesCode?: string | null | undefined;
|
|
206
|
+
validFrom?: string | null | undefined;
|
|
207
|
+
expiresAt?: string | null | undefined;
|
|
208
|
+
notes?: string | null | undefined;
|
|
209
|
+
issuedToPersonId?: string | null | undefined;
|
|
210
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
output: {
|
|
214
|
+
error: string;
|
|
215
|
+
};
|
|
216
|
+
outputFormat: "json";
|
|
217
|
+
status: 404;
|
|
218
|
+
} | {
|
|
219
|
+
input: {
|
|
220
|
+
param: {
|
|
221
|
+
id: string;
|
|
222
|
+
};
|
|
223
|
+
} & {
|
|
224
|
+
json: {
|
|
225
|
+
status?: "void" | "expired" | "active" | "redeemed" | undefined;
|
|
226
|
+
seriesCode?: string | null | undefined;
|
|
227
|
+
validFrom?: string | null | undefined;
|
|
228
|
+
expiresAt?: string | null | undefined;
|
|
229
|
+
notes?: string | null | undefined;
|
|
230
|
+
issuedToPersonId?: string | null | undefined;
|
|
231
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
output: {
|
|
235
|
+
error: string;
|
|
236
|
+
};
|
|
237
|
+
outputFormat: "json";
|
|
238
|
+
status: 400;
|
|
239
|
+
} | {
|
|
240
|
+
input: {
|
|
241
|
+
param: {
|
|
242
|
+
id: string;
|
|
243
|
+
};
|
|
244
|
+
} & {
|
|
245
|
+
json: {
|
|
246
|
+
status?: "void" | "expired" | "active" | "redeemed" | undefined;
|
|
247
|
+
seriesCode?: string | null | undefined;
|
|
248
|
+
validFrom?: string | null | undefined;
|
|
249
|
+
expiresAt?: string | null | undefined;
|
|
250
|
+
notes?: string | null | undefined;
|
|
251
|
+
issuedToPersonId?: string | null | undefined;
|
|
252
|
+
issuedToOrganizationId?: string | null | undefined;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
output: {
|
|
256
|
+
data: {
|
|
257
|
+
id: string;
|
|
258
|
+
code: string;
|
|
259
|
+
seriesCode: string | null;
|
|
260
|
+
status: "void" | "expired" | "active" | "redeemed";
|
|
261
|
+
currency: string;
|
|
262
|
+
initialAmountCents: number;
|
|
263
|
+
remainingAmountCents: number;
|
|
264
|
+
issuedToPersonId: string | null;
|
|
265
|
+
issuedToOrganizationId: string | null;
|
|
266
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
267
|
+
sourceBookingId: string | null;
|
|
268
|
+
sourcePaymentId: string | null;
|
|
269
|
+
validFrom: string | null;
|
|
270
|
+
expiresAt: string | null;
|
|
271
|
+
notes: string | null;
|
|
272
|
+
issuedByUserId: string | null;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
updatedAt: string;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
outputFormat: "json";
|
|
278
|
+
status: 200;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
} & {
|
|
282
|
+
"/vouchers/:id/redeem": {
|
|
283
|
+
$post: {
|
|
284
|
+
input: {
|
|
285
|
+
param: {
|
|
286
|
+
id: string;
|
|
287
|
+
};
|
|
288
|
+
} & {
|
|
289
|
+
json: {
|
|
290
|
+
bookingId: string;
|
|
291
|
+
amountCents: number;
|
|
292
|
+
paymentId?: string | null | undefined;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
output: {
|
|
296
|
+
error: string;
|
|
297
|
+
};
|
|
298
|
+
outputFormat: "json";
|
|
299
|
+
status: 404;
|
|
300
|
+
} | {
|
|
301
|
+
input: {
|
|
302
|
+
param: {
|
|
303
|
+
id: string;
|
|
304
|
+
};
|
|
305
|
+
} & {
|
|
306
|
+
json: {
|
|
307
|
+
bookingId: string;
|
|
308
|
+
amountCents: number;
|
|
309
|
+
paymentId?: string | null | undefined;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
output: {
|
|
313
|
+
error: string;
|
|
314
|
+
};
|
|
315
|
+
outputFormat: "json";
|
|
316
|
+
status: 400;
|
|
317
|
+
} | {
|
|
318
|
+
input: {
|
|
319
|
+
param: {
|
|
320
|
+
id: string;
|
|
321
|
+
};
|
|
322
|
+
} & {
|
|
323
|
+
json: {
|
|
324
|
+
bookingId: string;
|
|
325
|
+
amountCents: number;
|
|
326
|
+
paymentId?: string | null | undefined;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
output: {
|
|
330
|
+
error: string;
|
|
331
|
+
};
|
|
332
|
+
outputFormat: "json";
|
|
333
|
+
status: 409;
|
|
334
|
+
} | {
|
|
335
|
+
input: {
|
|
336
|
+
param: {
|
|
337
|
+
id: string;
|
|
338
|
+
};
|
|
339
|
+
} & {
|
|
340
|
+
json: {
|
|
341
|
+
bookingId: string;
|
|
342
|
+
amountCents: number;
|
|
343
|
+
paymentId?: string | null | undefined;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
output: {
|
|
347
|
+
data: {
|
|
348
|
+
voucher: {
|
|
349
|
+
id: string;
|
|
350
|
+
code: string;
|
|
351
|
+
seriesCode: string | null;
|
|
352
|
+
status: "void" | "expired" | "active" | "redeemed";
|
|
353
|
+
currency: string;
|
|
354
|
+
initialAmountCents: number;
|
|
355
|
+
remainingAmountCents: number;
|
|
356
|
+
issuedToPersonId: string | null;
|
|
357
|
+
issuedToOrganizationId: string | null;
|
|
358
|
+
sourceType: "manual" | "refund" | "cancellation_credit" | "gift" | "promo";
|
|
359
|
+
sourceBookingId: string | null;
|
|
360
|
+
sourcePaymentId: string | null;
|
|
361
|
+
validFrom: string | null;
|
|
362
|
+
expiresAt: string | null;
|
|
363
|
+
notes: string | null;
|
|
364
|
+
issuedByUserId: string | null;
|
|
365
|
+
createdAt: string;
|
|
366
|
+
updatedAt: string;
|
|
367
|
+
};
|
|
368
|
+
redemption: {
|
|
369
|
+
id: string;
|
|
370
|
+
voucherId: string;
|
|
371
|
+
bookingId: string;
|
|
372
|
+
paymentId: string | null;
|
|
373
|
+
amountCents: number;
|
|
374
|
+
createdAt: string;
|
|
375
|
+
createdByUserId: string | null;
|
|
376
|
+
} | null;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
outputFormat: "json";
|
|
380
|
+
status: 201;
|
|
381
|
+
} | {
|
|
382
|
+
input: {
|
|
383
|
+
param: {
|
|
384
|
+
id: string;
|
|
385
|
+
};
|
|
386
|
+
} & {
|
|
387
|
+
json: {
|
|
388
|
+
bookingId: string;
|
|
389
|
+
amountCents: number;
|
|
390
|
+
paymentId?: string | null | undefined;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
output: {
|
|
394
|
+
error: string;
|
|
395
|
+
};
|
|
396
|
+
outputFormat: "json";
|
|
397
|
+
status: 422;
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
}, "/">, "/">;
|
|
401
|
+
//# sourceMappingURL=routes-vouchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-vouchers.d.ts","sourceRoot":"","sources":["../src/routes-vouchers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAK/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAsL7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAEL,CAAA"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin voucher routes — mounted by the operator starter under
|
|
3
|
+
* `/v1/admin/finance/...`. Covers voucher issuance, lookup, update, and
|
|
4
|
+
* redemption.
|
|
5
|
+
*
|
|
6
|
+
* Migrated to `@hono/zod-openapi` for the OpenAPI admin backfill (voyant#2114 /
|
|
7
|
+
* voyant#2208 — finance sub-batch 9C). Request schemas reuse the existing
|
|
8
|
+
* `@voyant-travel/finance-contracts` schemas the handlers already parse;
|
|
9
|
+
* response schemas come from the shared `routes-payment-schemas.ts` row shapes
|
|
10
|
+
* (authored from the Drizzle `$inferSelect` shapes; §17 dates → strings). The
|
|
11
|
+
* single voucher resource is its own `OpenAPIHono` sub-chain composed onto
|
|
12
|
+
* `financeVoucherRoutes` via `.route("/")` so the `.openapi()` operations
|
|
13
|
+
* propagate up through the parent `financeRoutes` registry.
|
|
14
|
+
*/
|
|
15
|
+
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
16
|
+
import { openApiValidationHook } from "@voyant-travel/hono";
|
|
17
|
+
import { listResponseSchema } from "@voyant-travel/types";
|
|
18
|
+
import { errorResponseSchema } from "./routes-invoice-schemas.js";
|
|
19
|
+
import { voucherRedeemResultSchema, voucherSchema } from "./routes-payment-schemas.js";
|
|
20
|
+
import { financeService } from "./service.js";
|
|
21
|
+
import { VoucherServiceError } from "./service-vouchers.js";
|
|
22
|
+
import { insertVoucherSchema, redeemVoucherSchema, updateVoucherSchema, voucherListQuerySchema, } from "./validation.js";
|
|
23
|
+
const idParamSchema = z.object({ id: z.string() });
|
|
24
|
+
const listVouchersRoute = createRoute({
|
|
25
|
+
method: "get",
|
|
26
|
+
path: "/vouchers",
|
|
27
|
+
request: { query: voucherListQuerySchema },
|
|
28
|
+
responses: {
|
|
29
|
+
200: {
|
|
30
|
+
description: "List of vouchers",
|
|
31
|
+
content: { "application/json": { schema: listResponseSchema(voucherSchema) } },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const createVoucherRoute = createRoute({
|
|
36
|
+
method: "post",
|
|
37
|
+
path: "/vouchers",
|
|
38
|
+
request: {
|
|
39
|
+
body: {
|
|
40
|
+
required: true,
|
|
41
|
+
content: { "application/json": { schema: insertVoucherSchema } },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
responses: {
|
|
45
|
+
201: {
|
|
46
|
+
description: "The issued voucher",
|
|
47
|
+
content: { "application/json": { schema: z.object({ data: voucherSchema }) } },
|
|
48
|
+
},
|
|
49
|
+
400: {
|
|
50
|
+
description: "invalid_request: request body failed validation",
|
|
51
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
52
|
+
},
|
|
53
|
+
409: {
|
|
54
|
+
description: "The voucher code is already in use",
|
|
55
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const getVoucherRoute = createRoute({
|
|
60
|
+
method: "get",
|
|
61
|
+
path: "/vouchers/{id}",
|
|
62
|
+
request: { params: idParamSchema },
|
|
63
|
+
responses: {
|
|
64
|
+
200: {
|
|
65
|
+
description: "The voucher",
|
|
66
|
+
content: { "application/json": { schema: z.object({ data: voucherSchema }) } },
|
|
67
|
+
},
|
|
68
|
+
404: {
|
|
69
|
+
description: "Voucher not found",
|
|
70
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const updateVoucherRoute = createRoute({
|
|
75
|
+
method: "patch",
|
|
76
|
+
path: "/vouchers/{id}",
|
|
77
|
+
request: {
|
|
78
|
+
params: idParamSchema,
|
|
79
|
+
body: {
|
|
80
|
+
required: true,
|
|
81
|
+
content: { "application/json": { schema: updateVoucherSchema } },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
responses: {
|
|
85
|
+
200: {
|
|
86
|
+
description: "The updated voucher",
|
|
87
|
+
content: { "application/json": { schema: z.object({ data: voucherSchema }) } },
|
|
88
|
+
},
|
|
89
|
+
400: {
|
|
90
|
+
description: "invalid_request: request body failed validation",
|
|
91
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
92
|
+
},
|
|
93
|
+
404: {
|
|
94
|
+
description: "Voucher not found",
|
|
95
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const redeemVoucherRoute = createRoute({
|
|
100
|
+
method: "post",
|
|
101
|
+
path: "/vouchers/{id}/redeem",
|
|
102
|
+
request: {
|
|
103
|
+
params: idParamSchema,
|
|
104
|
+
body: {
|
|
105
|
+
required: true,
|
|
106
|
+
content: { "application/json": { schema: redeemVoucherSchema } },
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
responses: {
|
|
110
|
+
201: {
|
|
111
|
+
description: "The redemption (updated voucher + the recorded redemption row)",
|
|
112
|
+
content: { "application/json": { schema: z.object({ data: voucherRedeemResultSchema }) } },
|
|
113
|
+
},
|
|
114
|
+
400: {
|
|
115
|
+
description: "invalid_request: request body failed validation",
|
|
116
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
117
|
+
},
|
|
118
|
+
404: {
|
|
119
|
+
description: "Voucher not found",
|
|
120
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
121
|
+
},
|
|
122
|
+
409: {
|
|
123
|
+
description: "The voucher has insufficient remaining balance",
|
|
124
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
125
|
+
},
|
|
126
|
+
422: {
|
|
127
|
+
description: "The voucher is inactive, not yet started, or expired",
|
|
128
|
+
content: { "application/json": { schema: errorResponseSchema } },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
const voucherRoutes = new OpenAPIHono({ defaultHook: openApiValidationHook })
|
|
133
|
+
.openapi(listVouchersRoute, async (c) => c.json(await financeService.vouchers.list(c.get("db"), c.req.valid("query")), 200))
|
|
134
|
+
.openapi(createVoucherRoute, async (c) => {
|
|
135
|
+
try {
|
|
136
|
+
const row = await financeService.vouchers.create(c.get("db"), c.req.valid("json"), c.get("userId"));
|
|
137
|
+
if (!row) {
|
|
138
|
+
throw new Error("Failed to create voucher");
|
|
139
|
+
}
|
|
140
|
+
return c.json({ data: row }, 201);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error instanceof VoucherServiceError && error.code === "code_in_use") {
|
|
144
|
+
return c.json({ error: "Voucher code already in use" }, 409);
|
|
145
|
+
}
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
.openapi(getVoucherRoute, async (c) => {
|
|
150
|
+
const row = await financeService.vouchers.getById(c.get("db"), c.req.valid("param").id);
|
|
151
|
+
return row ? c.json({ data: row }, 200) : c.json({ error: "Voucher not found" }, 404);
|
|
152
|
+
})
|
|
153
|
+
.openapi(updateVoucherRoute, async (c) => {
|
|
154
|
+
const row = await financeService.vouchers.update(c.get("db"), c.req.valid("param").id, c.req.valid("json"));
|
|
155
|
+
return row ? c.json({ data: row }, 200) : c.json({ error: "Voucher not found" }, 404);
|
|
156
|
+
})
|
|
157
|
+
.openapi(redeemVoucherRoute, async (c) => {
|
|
158
|
+
try {
|
|
159
|
+
const result = await financeService.vouchers.redeem(c.get("db"), c.req.valid("param").id, c.req.valid("json"), c.get("userId"));
|
|
160
|
+
return c.json({ data: result }, 201);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error instanceof VoucherServiceError) {
|
|
164
|
+
const status = error.code === "voucher_not_found"
|
|
165
|
+
? 404
|
|
166
|
+
: error.code === "insufficient_balance"
|
|
167
|
+
? 409
|
|
168
|
+
: 422;
|
|
169
|
+
return c.json({ error: error.code }, status);
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
export const financeVoucherRoutes = new OpenAPIHono({
|
|
175
|
+
defaultHook: openApiValidationHook,
|
|
176
|
+
}).route("/", voucherRoutes);
|