@voyantjs/finance-contracts 0.95.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 +25 -0
- package/dist/contracts.test.d.ts +2 -0
- package/dist/contracts.test.d.ts.map +1 -0
- package/dist/contracts.test.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/validation-billing.d.ts +827 -0
- package/dist/validation-billing.d.ts.map +1 -0
- package/dist/validation-billing.js +436 -0
- package/dist/validation-payments.d.ts +933 -0
- package/dist/validation-payments.d.ts.map +1 -0
- package/dist/validation-payments.js +339 -0
- package/dist/validation-public.d.ts +505 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +216 -0
- package/dist/validation-shared.d.ts +200 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +179 -0
- package/dist/validation-vouchers.d.ts +62 -0
- package/dist/validation-vouchers.d.ts.map +1 -0
- package/dist/validation-vouchers.js +46 -0
- package/dist/validation.d.ts +6 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +5 -0
- package/package.json +52 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { paymentInstrumentStatusSchema, paymentInstrumentTypeSchema, paymentMethodSchema, paymentScheduleStatusSchema, paymentScheduleTypeSchema, paymentSessionStatusSchema, paymentSessionTargetTypeSchema, } from "./validation-shared.js";
|
|
3
|
+
export const publicFinanceInvoiceTypeSchema = z.enum(["invoice", "proforma", "credit_note"]);
|
|
4
|
+
export const publicFinanceDocumentAvailabilitySchema = z.enum([
|
|
5
|
+
"missing",
|
|
6
|
+
"pending",
|
|
7
|
+
"ready",
|
|
8
|
+
"failed",
|
|
9
|
+
"stale",
|
|
10
|
+
]);
|
|
11
|
+
export const publicFinanceDocumentFormatSchema = z.enum(["html", "pdf", "xml", "json"]);
|
|
12
|
+
export const publicPaymentOptionsQuerySchema = z.object({
|
|
13
|
+
personId: z.string().optional(),
|
|
14
|
+
organizationId: z.string().optional(),
|
|
15
|
+
provider: z.string().optional(),
|
|
16
|
+
instrumentType: paymentInstrumentTypeSchema.optional(),
|
|
17
|
+
includeInactive: z.coerce.boolean().default(false),
|
|
18
|
+
});
|
|
19
|
+
export const publicStartPaymentSessionSchema = z.object({
|
|
20
|
+
provider: z.string().max(255).optional().nullable(),
|
|
21
|
+
paymentMethod: paymentMethodSchema.optional().nullable(),
|
|
22
|
+
paymentInstrumentId: z.string().optional().nullable(),
|
|
23
|
+
payerPersonId: z.string().optional().nullable(),
|
|
24
|
+
payerOrganizationId: z.string().optional().nullable(),
|
|
25
|
+
payerEmail: z.string().email().optional().nullable(),
|
|
26
|
+
payerName: z.string().max(255).optional().nullable(),
|
|
27
|
+
externalReference: z.string().max(255).optional().nullable(),
|
|
28
|
+
idempotencyKey: z.string().max(255).optional().nullable(),
|
|
29
|
+
clientReference: z.string().max(255).optional().nullable(),
|
|
30
|
+
returnUrl: z.string().url().optional().nullable(),
|
|
31
|
+
cancelUrl: z.string().url().optional().nullable(),
|
|
32
|
+
callbackUrl: z.string().url().optional().nullable(),
|
|
33
|
+
expiresAt: z.string().optional().nullable(),
|
|
34
|
+
notes: z.string().optional().nullable(),
|
|
35
|
+
providerPayload: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
36
|
+
metadata: z.record(z.string(), z.unknown()).optional().nullable(),
|
|
37
|
+
});
|
|
38
|
+
export const publicValidateVoucherSchema = z.object({
|
|
39
|
+
code: z.string().min(1).max(255),
|
|
40
|
+
provider: z.string().max(255).optional().nullable(),
|
|
41
|
+
bookingId: z.string().optional().nullable(),
|
|
42
|
+
currency: z.string().min(3).max(3).optional().nullable(),
|
|
43
|
+
amountCents: z.number().int().min(1).optional().nullable(),
|
|
44
|
+
});
|
|
45
|
+
export const publicFinanceDocumentLookupQuerySchema = z.object({
|
|
46
|
+
reference: z.string().min(1).max(255),
|
|
47
|
+
invoiceType: publicFinanceInvoiceTypeSchema.optional(),
|
|
48
|
+
});
|
|
49
|
+
export const publicPaymentAccountSchema = z.object({
|
|
50
|
+
id: z.string(),
|
|
51
|
+
label: z.string(),
|
|
52
|
+
provider: z.string().nullable(),
|
|
53
|
+
instrumentType: paymentInstrumentTypeSchema,
|
|
54
|
+
status: paymentInstrumentStatusSchema,
|
|
55
|
+
brand: z.string().nullable(),
|
|
56
|
+
last4: z.string().nullable(),
|
|
57
|
+
expiryMonth: z.number().int().nullable(),
|
|
58
|
+
expiryYear: z.number().int().nullable(),
|
|
59
|
+
isDefault: z.boolean(),
|
|
60
|
+
});
|
|
61
|
+
export const publicBookingPaymentScheduleSchema = z.object({
|
|
62
|
+
id: z.string(),
|
|
63
|
+
scheduleType: paymentScheduleTypeSchema,
|
|
64
|
+
status: paymentScheduleStatusSchema,
|
|
65
|
+
dueDate: z.string(),
|
|
66
|
+
currency: z.string(),
|
|
67
|
+
amountCents: z.number().int(),
|
|
68
|
+
notes: z.string().nullable(),
|
|
69
|
+
});
|
|
70
|
+
export const publicBookingGuaranteeSchema = z.object({
|
|
71
|
+
id: z.string(),
|
|
72
|
+
bookingPaymentScheduleId: z.string().nullable(),
|
|
73
|
+
guaranteeType: z.string(),
|
|
74
|
+
status: z.string(),
|
|
75
|
+
currency: z.string().nullable(),
|
|
76
|
+
amountCents: z.number().int().nullable(),
|
|
77
|
+
provider: z.string().nullable(),
|
|
78
|
+
referenceNumber: z.string().nullable(),
|
|
79
|
+
expiresAt: z.string().nullable(),
|
|
80
|
+
notes: z.string().nullable(),
|
|
81
|
+
});
|
|
82
|
+
export const publicBookingPaymentOptionsSchema = z.object({
|
|
83
|
+
bookingId: z.string(),
|
|
84
|
+
accounts: z.array(publicPaymentAccountSchema),
|
|
85
|
+
schedules: z.array(publicBookingPaymentScheduleSchema),
|
|
86
|
+
guarantees: z.array(publicBookingGuaranteeSchema),
|
|
87
|
+
recommendedTarget: z
|
|
88
|
+
.object({
|
|
89
|
+
targetType: z.enum(["booking_payment_schedule", "booking_guarantee"]).nullable(),
|
|
90
|
+
targetId: z.string().nullable(),
|
|
91
|
+
})
|
|
92
|
+
.nullable(),
|
|
93
|
+
});
|
|
94
|
+
export const publicPaymentSessionSchema = z.object({
|
|
95
|
+
id: z.string(),
|
|
96
|
+
targetType: paymentSessionTargetTypeSchema,
|
|
97
|
+
targetId: z.string().nullable(),
|
|
98
|
+
bookingId: z.string().nullable(),
|
|
99
|
+
invoiceId: z.string().nullable(),
|
|
100
|
+
bookingPaymentScheduleId: z.string().nullable(),
|
|
101
|
+
bookingGuaranteeId: z.string().nullable(),
|
|
102
|
+
status: paymentSessionStatusSchema,
|
|
103
|
+
provider: z.string().nullable(),
|
|
104
|
+
providerSessionId: z.string().nullable(),
|
|
105
|
+
providerPaymentId: z.string().nullable(),
|
|
106
|
+
externalReference: z.string().nullable(),
|
|
107
|
+
clientReference: z.string().nullable(),
|
|
108
|
+
currency: z.string(),
|
|
109
|
+
amountCents: z.number().int(),
|
|
110
|
+
paymentMethod: paymentMethodSchema.nullable(),
|
|
111
|
+
payerEmail: z.string().nullable(),
|
|
112
|
+
payerName: z.string().nullable(),
|
|
113
|
+
redirectUrl: z.string().nullable(),
|
|
114
|
+
returnUrl: z.string().nullable(),
|
|
115
|
+
cancelUrl: z.string().nullable(),
|
|
116
|
+
expiresAt: z.string().nullable(),
|
|
117
|
+
completedAt: z.string().nullable(),
|
|
118
|
+
failureCode: z.string().nullable(),
|
|
119
|
+
failureMessage: z.string().nullable(),
|
|
120
|
+
/**
|
|
121
|
+
* Operator-supplied human-readable context (e.g. "London → New York,
|
|
122
|
+
* Sat 16 May · Diego Müller"). Surfaced on the public landing page so
|
|
123
|
+
* the customer can see what they're paying for. Server-controlled — only
|
|
124
|
+
* populated when the session is created with `notes`.
|
|
125
|
+
*/
|
|
126
|
+
notes: z.string().nullable(),
|
|
127
|
+
});
|
|
128
|
+
export const publicFinanceBookingDocumentSchema = z.object({
|
|
129
|
+
invoiceId: z.string(),
|
|
130
|
+
invoiceNumber: z.string(),
|
|
131
|
+
invoiceType: publicFinanceInvoiceTypeSchema,
|
|
132
|
+
invoiceStatus: z.enum([
|
|
133
|
+
"draft",
|
|
134
|
+
"pending_external_allocation",
|
|
135
|
+
"issued",
|
|
136
|
+
"partially_paid",
|
|
137
|
+
"paid",
|
|
138
|
+
"overdue",
|
|
139
|
+
"void",
|
|
140
|
+
]),
|
|
141
|
+
currency: z.string(),
|
|
142
|
+
totalCents: z.number().int(),
|
|
143
|
+
paidCents: z.number().int(),
|
|
144
|
+
balanceDueCents: z.number().int(),
|
|
145
|
+
issueDate: z.string(),
|
|
146
|
+
dueDate: z.string(),
|
|
147
|
+
renditionId: z.string().nullable(),
|
|
148
|
+
documentStatus: publicFinanceDocumentAvailabilitySchema,
|
|
149
|
+
format: publicFinanceDocumentFormatSchema.nullable(),
|
|
150
|
+
language: z.string().nullable(),
|
|
151
|
+
generatedAt: z.string().nullable(),
|
|
152
|
+
fileSize: z.number().int().nullable(),
|
|
153
|
+
checksum: z.string().nullable(),
|
|
154
|
+
downloadUrl: z.string().nullable(),
|
|
155
|
+
});
|
|
156
|
+
export const publicBookingFinanceDocumentsSchema = z.object({
|
|
157
|
+
bookingId: z.string(),
|
|
158
|
+
documents: z.array(publicFinanceBookingDocumentSchema),
|
|
159
|
+
});
|
|
160
|
+
export const publicFinanceDocumentLookupSchema = publicFinanceBookingDocumentSchema.extend({
|
|
161
|
+
bookingId: z.string(),
|
|
162
|
+
});
|
|
163
|
+
export const publicFinanceBookingPaymentSchema = z.object({
|
|
164
|
+
id: z.string(),
|
|
165
|
+
invoiceId: z.string(),
|
|
166
|
+
invoiceNumber: z.string(),
|
|
167
|
+
invoiceType: publicFinanceInvoiceTypeSchema,
|
|
168
|
+
status: z.enum(["pending", "completed", "failed", "refunded"]),
|
|
169
|
+
paymentMethod: paymentMethodSchema,
|
|
170
|
+
amountCents: z.number().int(),
|
|
171
|
+
currency: z.string(),
|
|
172
|
+
/**
|
|
173
|
+
* When the customer paid in a currency different from the invoice
|
|
174
|
+
* (`currency`), `baseCurrency` is the invoice's currency and
|
|
175
|
+
* `baseAmountCents` is the converted amount at the payment date.
|
|
176
|
+
* Both are null for same-currency payments.
|
|
177
|
+
*/
|
|
178
|
+
baseCurrency: z.string().nullable(),
|
|
179
|
+
baseAmountCents: z.number().int().nullable(),
|
|
180
|
+
paymentDate: z.string(),
|
|
181
|
+
referenceNumber: z.string().nullable(),
|
|
182
|
+
notes: z.string().nullable(),
|
|
183
|
+
});
|
|
184
|
+
export const publicBookingFinancePaymentsSchema = z.object({
|
|
185
|
+
bookingId: z.string(),
|
|
186
|
+
payments: z.array(publicFinanceBookingPaymentSchema),
|
|
187
|
+
});
|
|
188
|
+
export const publicVoucherValidationSchema = z.object({
|
|
189
|
+
valid: z.boolean(),
|
|
190
|
+
reason: z
|
|
191
|
+
.enum([
|
|
192
|
+
"not_found",
|
|
193
|
+
"inactive",
|
|
194
|
+
"not_started",
|
|
195
|
+
"expired",
|
|
196
|
+
"booking_mismatch",
|
|
197
|
+
"currency_mismatch",
|
|
198
|
+
"insufficient_balance",
|
|
199
|
+
])
|
|
200
|
+
.nullable(),
|
|
201
|
+
voucher: z
|
|
202
|
+
.object({
|
|
203
|
+
id: z.string(),
|
|
204
|
+
code: z.string(),
|
|
205
|
+
// Nullable: the new vouchers table (#239) doesn't carry a separate
|
|
206
|
+
// label column — display falls back to `code`. Legacy
|
|
207
|
+
// payment_instruments rows still populate this.
|
|
208
|
+
label: z.string().nullable(),
|
|
209
|
+
provider: z.string().nullable(),
|
|
210
|
+
currency: z.string().nullable(),
|
|
211
|
+
amountCents: z.number().int().nullable(),
|
|
212
|
+
remainingAmountCents: z.number().int().nullable(),
|
|
213
|
+
expiresAt: z.string().nullable(),
|
|
214
|
+
})
|
|
215
|
+
.nullable(),
|
|
216
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const invoiceStatusSchema: z.ZodEnum<{
|
|
3
|
+
draft: "draft";
|
|
4
|
+
pending_external_allocation: "pending_external_allocation";
|
|
5
|
+
issued: "issued";
|
|
6
|
+
partially_paid: "partially_paid";
|
|
7
|
+
paid: "paid";
|
|
8
|
+
overdue: "overdue";
|
|
9
|
+
void: "void";
|
|
10
|
+
}>;
|
|
11
|
+
export declare const paymentMethodSchema: z.ZodEnum<{
|
|
12
|
+
bank_transfer: "bank_transfer";
|
|
13
|
+
credit_card: "credit_card";
|
|
14
|
+
debit_card: "debit_card";
|
|
15
|
+
cash: "cash";
|
|
16
|
+
cheque: "cheque";
|
|
17
|
+
wallet: "wallet";
|
|
18
|
+
direct_bill: "direct_bill";
|
|
19
|
+
voucher: "voucher";
|
|
20
|
+
other: "other";
|
|
21
|
+
}>;
|
|
22
|
+
export declare const paymentStatusSchema: z.ZodEnum<{
|
|
23
|
+
pending: "pending";
|
|
24
|
+
failed: "failed";
|
|
25
|
+
completed: "completed";
|
|
26
|
+
refunded: "refunded";
|
|
27
|
+
}>;
|
|
28
|
+
export declare const paymentSessionStatusSchema: z.ZodEnum<{
|
|
29
|
+
paid: "paid";
|
|
30
|
+
pending: "pending";
|
|
31
|
+
failed: "failed";
|
|
32
|
+
expired: "expired";
|
|
33
|
+
requires_redirect: "requires_redirect";
|
|
34
|
+
processing: "processing";
|
|
35
|
+
authorized: "authorized";
|
|
36
|
+
cancelled: "cancelled";
|
|
37
|
+
}>;
|
|
38
|
+
export declare const paymentSessionTargetTypeSchema: z.ZodEnum<{
|
|
39
|
+
other: "other";
|
|
40
|
+
invoice: "invoice";
|
|
41
|
+
booking: "booking";
|
|
42
|
+
order: "order";
|
|
43
|
+
booking_payment_schedule: "booking_payment_schedule";
|
|
44
|
+
booking_guarantee: "booking_guarantee";
|
|
45
|
+
flight_order: "flight_order";
|
|
46
|
+
}>;
|
|
47
|
+
export declare const paymentInstrumentTypeSchema: z.ZodEnum<{
|
|
48
|
+
credit_card: "credit_card";
|
|
49
|
+
debit_card: "debit_card";
|
|
50
|
+
cash: "cash";
|
|
51
|
+
wallet: "wallet";
|
|
52
|
+
direct_bill: "direct_bill";
|
|
53
|
+
voucher: "voucher";
|
|
54
|
+
other: "other";
|
|
55
|
+
bank_account: "bank_account";
|
|
56
|
+
}>;
|
|
57
|
+
export declare const paymentInstrumentOwnerTypeSchema: z.ZodEnum<{
|
|
58
|
+
other: "other";
|
|
59
|
+
channel: "channel";
|
|
60
|
+
agency: "agency";
|
|
61
|
+
internal: "internal";
|
|
62
|
+
supplier: "supplier";
|
|
63
|
+
client: "client";
|
|
64
|
+
}>;
|
|
65
|
+
export declare const paymentInstrumentStatusSchema: z.ZodEnum<{
|
|
66
|
+
active: "active";
|
|
67
|
+
inactive: "inactive";
|
|
68
|
+
expired: "expired";
|
|
69
|
+
revoked: "revoked";
|
|
70
|
+
failed_verification: "failed_verification";
|
|
71
|
+
}>;
|
|
72
|
+
export declare const paymentAuthorizationStatusSchema: z.ZodEnum<{
|
|
73
|
+
pending: "pending";
|
|
74
|
+
failed: "failed";
|
|
75
|
+
expired: "expired";
|
|
76
|
+
authorized: "authorized";
|
|
77
|
+
partially_captured: "partially_captured";
|
|
78
|
+
captured: "captured";
|
|
79
|
+
voided: "voided";
|
|
80
|
+
}>;
|
|
81
|
+
export declare const paymentCaptureStatusSchema: z.ZodEnum<{
|
|
82
|
+
pending: "pending";
|
|
83
|
+
failed: "failed";
|
|
84
|
+
voided: "voided";
|
|
85
|
+
completed: "completed";
|
|
86
|
+
refunded: "refunded";
|
|
87
|
+
}>;
|
|
88
|
+
export declare const captureModeSchema: z.ZodEnum<{
|
|
89
|
+
automatic: "automatic";
|
|
90
|
+
manual: "manual";
|
|
91
|
+
}>;
|
|
92
|
+
export declare const creditNoteStatusSchema: z.ZodEnum<{
|
|
93
|
+
draft: "draft";
|
|
94
|
+
issued: "issued";
|
|
95
|
+
applied: "applied";
|
|
96
|
+
}>;
|
|
97
|
+
export declare const paymentScheduleTypeSchema: z.ZodEnum<{
|
|
98
|
+
other: "other";
|
|
99
|
+
deposit: "deposit";
|
|
100
|
+
installment: "installment";
|
|
101
|
+
balance: "balance";
|
|
102
|
+
hold: "hold";
|
|
103
|
+
}>;
|
|
104
|
+
export declare const paymentScheduleStatusSchema: z.ZodEnum<{
|
|
105
|
+
paid: "paid";
|
|
106
|
+
pending: "pending";
|
|
107
|
+
expired: "expired";
|
|
108
|
+
cancelled: "cancelled";
|
|
109
|
+
due: "due";
|
|
110
|
+
waived: "waived";
|
|
111
|
+
}>;
|
|
112
|
+
export declare const guaranteeTypeSchema: z.ZodEnum<{
|
|
113
|
+
bank_transfer: "bank_transfer";
|
|
114
|
+
credit_card: "credit_card";
|
|
115
|
+
voucher: "voucher";
|
|
116
|
+
other: "other";
|
|
117
|
+
deposit: "deposit";
|
|
118
|
+
preauth: "preauth";
|
|
119
|
+
card_on_file: "card_on_file";
|
|
120
|
+
agency_letter: "agency_letter";
|
|
121
|
+
}>;
|
|
122
|
+
export declare const guaranteeStatusSchema: z.ZodEnum<{
|
|
123
|
+
pending: "pending";
|
|
124
|
+
active: "active";
|
|
125
|
+
failed: "failed";
|
|
126
|
+
expired: "expired";
|
|
127
|
+
cancelled: "cancelled";
|
|
128
|
+
released: "released";
|
|
129
|
+
}>;
|
|
130
|
+
export declare const taxScopeSchema: z.ZodEnum<{
|
|
131
|
+
included: "included";
|
|
132
|
+
excluded: "excluded";
|
|
133
|
+
withheld: "withheld";
|
|
134
|
+
}>;
|
|
135
|
+
export declare const commissionRecipientTypeSchema: z.ZodEnum<{
|
|
136
|
+
other: "other";
|
|
137
|
+
channel: "channel";
|
|
138
|
+
affiliate: "affiliate";
|
|
139
|
+
agency: "agency";
|
|
140
|
+
agent: "agent";
|
|
141
|
+
internal: "internal";
|
|
142
|
+
supplier: "supplier";
|
|
143
|
+
}>;
|
|
144
|
+
export declare const commissionModelSchema: z.ZodEnum<{
|
|
145
|
+
percentage: "percentage";
|
|
146
|
+
fixed: "fixed";
|
|
147
|
+
markup: "markup";
|
|
148
|
+
net: "net";
|
|
149
|
+
}>;
|
|
150
|
+
export declare const commissionStatusSchema: z.ZodEnum<{
|
|
151
|
+
paid: "paid";
|
|
152
|
+
void: "void";
|
|
153
|
+
pending: "pending";
|
|
154
|
+
accrued: "accrued";
|
|
155
|
+
payable: "payable";
|
|
156
|
+
}>;
|
|
157
|
+
export declare const paginationSchema: z.ZodObject<{
|
|
158
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
159
|
+
offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
export declare const voucherStatusSchema: z.ZodEnum<{
|
|
162
|
+
void: "void";
|
|
163
|
+
active: "active";
|
|
164
|
+
expired: "expired";
|
|
165
|
+
redeemed: "redeemed";
|
|
166
|
+
}>;
|
|
167
|
+
export declare const voucherSourceTypeSchema: z.ZodEnum<{
|
|
168
|
+
manual: "manual";
|
|
169
|
+
refund: "refund";
|
|
170
|
+
cancellation_credit: "cancellation_credit";
|
|
171
|
+
gift: "gift";
|
|
172
|
+
promo: "promo";
|
|
173
|
+
}>;
|
|
174
|
+
export declare const financeAggregatesQuerySchema: z.ZodObject<{
|
|
175
|
+
range: z.ZodDefault<z.ZodEnum<{
|
|
176
|
+
custom: "custom";
|
|
177
|
+
this_month: "this_month";
|
|
178
|
+
last_month: "last_month";
|
|
179
|
+
year_to_date: "year_to_date";
|
|
180
|
+
all_time: "all_time";
|
|
181
|
+
}>>;
|
|
182
|
+
from: z.ZodOptional<z.ZodString>;
|
|
183
|
+
to: z.ZodOptional<z.ZodString>;
|
|
184
|
+
currency: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodString>>>>;
|
|
185
|
+
invoiceType: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
186
|
+
invoice: "invoice";
|
|
187
|
+
proforma: "proforma";
|
|
188
|
+
}>>>>>;
|
|
189
|
+
status: z.ZodOptional<z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
190
|
+
draft: "draft";
|
|
191
|
+
pending_external_allocation: "pending_external_allocation";
|
|
192
|
+
issued: "issued";
|
|
193
|
+
partially_paid: "partially_paid";
|
|
194
|
+
paid: "paid";
|
|
195
|
+
overdue: "overdue";
|
|
196
|
+
void: "void";
|
|
197
|
+
}>>>>>;
|
|
198
|
+
outstandingTopLimit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
//# sourceMappingURL=validation-shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-shared.d.ts","sourceRoot":"","sources":["../src/validation-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,mBAAmB;;;;;;;;EAQ9B,CAAA;AACF,eAAO,MAAM,mBAAmB;;;;;;;;;;EAU9B,CAAA;AACF,eAAO,MAAM,mBAAmB;;;;;EAAyD,CAAA;AACzF,eAAO,MAAM,0BAA0B;;;;;;;;;EASrC,CAAA;AACF,eAAO,MAAM,8BAA8B;;;;;;;;EAQzC,CAAA;AACF,eAAO,MAAM,2BAA2B;;;;;;;;;EAStC,CAAA;AACF,eAAO,MAAM,gCAAgC;;;;;;;EAO3C,CAAA;AACF,eAAO,MAAM,6BAA6B;;;;;;EAMxC,CAAA;AACF,eAAO,MAAM,gCAAgC;;;;;;;;EAQ3C,CAAA;AACF,eAAO,MAAM,0BAA0B;;;;;;EAMrC,CAAA;AACF,eAAO,MAAM,iBAAiB;;;EAAkC,CAAA;AAChE,eAAO,MAAM,sBAAsB;;;;EAAyC,CAAA;AAC5E,eAAO,MAAM,yBAAyB;;;;;;EAMpC,CAAA;AACF,eAAO,MAAM,2BAA2B;;;;;;;EAOtC,CAAA;AACF,eAAO,MAAM,mBAAmB;;;;;;;;;EAS9B,CAAA;AACF,eAAO,MAAM,qBAAqB;;;;;;;EAOhC,CAAA;AACF,eAAO,MAAM,cAAc;;;;EAA+C,CAAA;AAC1E,eAAO,MAAM,6BAA6B;;;;;;;;EAQxC,CAAA;AACF,eAAO,MAAM,qBAAqB;;;;;EAAmD,CAAA;AACrF,eAAO,MAAM,sBAAsB;;;;;;EAA4D,CAAA;AAE/F,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;EAAoD,CAAA;AACpF,eAAO,MAAM,uBAAuB;;;;;;EAMlC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;iBAiDvC,CAAA"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const invoiceStatusSchema = z.enum([
|
|
3
|
+
"draft",
|
|
4
|
+
"pending_external_allocation",
|
|
5
|
+
"issued",
|
|
6
|
+
"partially_paid",
|
|
7
|
+
"paid",
|
|
8
|
+
"overdue",
|
|
9
|
+
"void",
|
|
10
|
+
]);
|
|
11
|
+
export const paymentMethodSchema = z.enum([
|
|
12
|
+
"bank_transfer",
|
|
13
|
+
"credit_card",
|
|
14
|
+
"debit_card",
|
|
15
|
+
"cash",
|
|
16
|
+
"cheque",
|
|
17
|
+
"wallet",
|
|
18
|
+
"direct_bill",
|
|
19
|
+
"voucher",
|
|
20
|
+
"other",
|
|
21
|
+
]);
|
|
22
|
+
export const paymentStatusSchema = z.enum(["pending", "completed", "failed", "refunded"]);
|
|
23
|
+
export const paymentSessionStatusSchema = z.enum([
|
|
24
|
+
"pending",
|
|
25
|
+
"requires_redirect",
|
|
26
|
+
"processing",
|
|
27
|
+
"authorized",
|
|
28
|
+
"paid",
|
|
29
|
+
"failed",
|
|
30
|
+
"cancelled",
|
|
31
|
+
"expired",
|
|
32
|
+
]);
|
|
33
|
+
export const paymentSessionTargetTypeSchema = z.enum([
|
|
34
|
+
"booking",
|
|
35
|
+
"order",
|
|
36
|
+
"invoice",
|
|
37
|
+
"booking_payment_schedule",
|
|
38
|
+
"booking_guarantee",
|
|
39
|
+
"flight_order",
|
|
40
|
+
"other",
|
|
41
|
+
]);
|
|
42
|
+
export const paymentInstrumentTypeSchema = z.enum([
|
|
43
|
+
"credit_card",
|
|
44
|
+
"debit_card",
|
|
45
|
+
"bank_account",
|
|
46
|
+
"wallet",
|
|
47
|
+
"voucher",
|
|
48
|
+
"direct_bill",
|
|
49
|
+
"cash",
|
|
50
|
+
"other",
|
|
51
|
+
]);
|
|
52
|
+
export const paymentInstrumentOwnerTypeSchema = z.enum([
|
|
53
|
+
"client",
|
|
54
|
+
"supplier",
|
|
55
|
+
"channel",
|
|
56
|
+
"agency",
|
|
57
|
+
"internal",
|
|
58
|
+
"other",
|
|
59
|
+
]);
|
|
60
|
+
export const paymentInstrumentStatusSchema = z.enum([
|
|
61
|
+
"active",
|
|
62
|
+
"inactive",
|
|
63
|
+
"expired",
|
|
64
|
+
"revoked",
|
|
65
|
+
"failed_verification",
|
|
66
|
+
]);
|
|
67
|
+
export const paymentAuthorizationStatusSchema = z.enum([
|
|
68
|
+
"pending",
|
|
69
|
+
"authorized",
|
|
70
|
+
"partially_captured",
|
|
71
|
+
"captured",
|
|
72
|
+
"voided",
|
|
73
|
+
"failed",
|
|
74
|
+
"expired",
|
|
75
|
+
]);
|
|
76
|
+
export const paymentCaptureStatusSchema = z.enum([
|
|
77
|
+
"pending",
|
|
78
|
+
"completed",
|
|
79
|
+
"failed",
|
|
80
|
+
"refunded",
|
|
81
|
+
"voided",
|
|
82
|
+
]);
|
|
83
|
+
export const captureModeSchema = z.enum(["automatic", "manual"]);
|
|
84
|
+
export const creditNoteStatusSchema = z.enum(["draft", "issued", "applied"]);
|
|
85
|
+
export const paymentScheduleTypeSchema = z.enum([
|
|
86
|
+
"deposit",
|
|
87
|
+
"installment",
|
|
88
|
+
"balance",
|
|
89
|
+
"hold",
|
|
90
|
+
"other",
|
|
91
|
+
]);
|
|
92
|
+
export const paymentScheduleStatusSchema = z.enum([
|
|
93
|
+
"pending",
|
|
94
|
+
"due",
|
|
95
|
+
"paid",
|
|
96
|
+
"waived",
|
|
97
|
+
"cancelled",
|
|
98
|
+
"expired",
|
|
99
|
+
]);
|
|
100
|
+
export const guaranteeTypeSchema = z.enum([
|
|
101
|
+
"deposit",
|
|
102
|
+
"credit_card",
|
|
103
|
+
"preauth",
|
|
104
|
+
"card_on_file",
|
|
105
|
+
"bank_transfer",
|
|
106
|
+
"voucher",
|
|
107
|
+
"agency_letter",
|
|
108
|
+
"other",
|
|
109
|
+
]);
|
|
110
|
+
export const guaranteeStatusSchema = z.enum([
|
|
111
|
+
"pending",
|
|
112
|
+
"active",
|
|
113
|
+
"released",
|
|
114
|
+
"failed",
|
|
115
|
+
"cancelled",
|
|
116
|
+
"expired",
|
|
117
|
+
]);
|
|
118
|
+
export const taxScopeSchema = z.enum(["included", "excluded", "withheld"]);
|
|
119
|
+
export const commissionRecipientTypeSchema = z.enum([
|
|
120
|
+
"channel",
|
|
121
|
+
"affiliate",
|
|
122
|
+
"agency",
|
|
123
|
+
"agent",
|
|
124
|
+
"internal",
|
|
125
|
+
"supplier",
|
|
126
|
+
"other",
|
|
127
|
+
]);
|
|
128
|
+
export const commissionModelSchema = z.enum(["percentage", "fixed", "markup", "net"]);
|
|
129
|
+
export const commissionStatusSchema = z.enum(["pending", "accrued", "payable", "paid", "void"]);
|
|
130
|
+
export const paginationSchema = z.object({
|
|
131
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
132
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
133
|
+
});
|
|
134
|
+
export const voucherStatusSchema = z.enum(["active", "redeemed", "expired", "void"]);
|
|
135
|
+
export const voucherSourceTypeSchema = z.enum([
|
|
136
|
+
"refund",
|
|
137
|
+
"cancellation_credit",
|
|
138
|
+
"gift",
|
|
139
|
+
"manual",
|
|
140
|
+
"promo",
|
|
141
|
+
]);
|
|
142
|
+
export const financeAggregatesQuerySchema = z.object({
|
|
143
|
+
range: z
|
|
144
|
+
.enum(["this_month", "last_month", "year_to_date", "all_time", "custom"])
|
|
145
|
+
.default("all_time"),
|
|
146
|
+
from: z.string().datetime().optional(),
|
|
147
|
+
to: z.string().datetime().optional(),
|
|
148
|
+
currency: z
|
|
149
|
+
.preprocess((value) => typeof value === "string"
|
|
150
|
+
? value
|
|
151
|
+
.split(",")
|
|
152
|
+
.map((item) => item.trim())
|
|
153
|
+
.filter(Boolean)
|
|
154
|
+
: value, z.array(z.string().trim().min(1)).optional())
|
|
155
|
+
.optional(),
|
|
156
|
+
invoiceType: z
|
|
157
|
+
.preprocess((value) => typeof value === "string"
|
|
158
|
+
? value
|
|
159
|
+
.split(",")
|
|
160
|
+
.map((item) => item.trim())
|
|
161
|
+
.filter(Boolean)
|
|
162
|
+
: value, z.array(z.enum(["invoice", "proforma"])).optional())
|
|
163
|
+
.optional(),
|
|
164
|
+
status: z
|
|
165
|
+
.preprocess((value) => typeof value === "string"
|
|
166
|
+
? value
|
|
167
|
+
.split(",")
|
|
168
|
+
.map((item) => item.trim())
|
|
169
|
+
.filter(Boolean)
|
|
170
|
+
: value, z.array(invoiceStatusSchema).optional())
|
|
171
|
+
.optional(),
|
|
172
|
+
/**
|
|
173
|
+
* Cap on the top-N outstanding-invoice rows returned alongside the
|
|
174
|
+
* outstanding-by-currency aggregate. The dashboard surfaces 5 rows
|
|
175
|
+
* in its "needs collection" panel; allow up to 20 so adjacent
|
|
176
|
+
* digests can reuse the endpoint.
|
|
177
|
+
*/
|
|
178
|
+
outstandingTopLimit: z.coerce.number().int().min(0).max(20).default(5),
|
|
179
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Issue a new voucher. Code is generated server-side when not supplied. */
|
|
3
|
+
export declare const insertVoucherSchema: z.ZodObject<{
|
|
4
|
+
code: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
5
|
+
seriesCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
currency: z.ZodString;
|
|
7
|
+
amountCents: z.ZodNumber;
|
|
8
|
+
issuedToPersonId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
issuedToOrganizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
sourceType: z.ZodEnum<{
|
|
11
|
+
manual: "manual";
|
|
12
|
+
refund: "refund";
|
|
13
|
+
cancellation_credit: "cancellation_credit";
|
|
14
|
+
gift: "gift";
|
|
15
|
+
promo: "promo";
|
|
16
|
+
}>;
|
|
17
|
+
sourceBookingId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
18
|
+
sourcePaymentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
expiresAt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/**
|
|
24
|
+
* Update metadata. Balance (remainingAmountCents) is not in here on purpose —
|
|
25
|
+
* it's only mutated via `redeem`, transactionally, with a redemption row.
|
|
26
|
+
*/
|
|
27
|
+
export declare const updateVoucherSchema: z.ZodObject<{
|
|
28
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
void: "void";
|
|
30
|
+
active: "active";
|
|
31
|
+
expired: "expired";
|
|
32
|
+
redeemed: "redeemed";
|
|
33
|
+
}>>;
|
|
34
|
+
seriesCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
35
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
36
|
+
expiresAt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
37
|
+
notes: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
38
|
+
issuedToPersonId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
39
|
+
issuedToOrganizationId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
/** Apply a voucher against a booking. */
|
|
42
|
+
export declare const redeemVoucherSchema: z.ZodObject<{
|
|
43
|
+
bookingId: z.ZodString;
|
|
44
|
+
amountCents: z.ZodNumber;
|
|
45
|
+
paymentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export declare const voucherListQuerySchema: z.ZodObject<{
|
|
48
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
void: "void";
|
|
50
|
+
active: "active";
|
|
51
|
+
expired: "expired";
|
|
52
|
+
redeemed: "redeemed";
|
|
53
|
+
}>>;
|
|
54
|
+
seriesCode: z.ZodOptional<z.ZodString>;
|
|
55
|
+
issuedToPersonId: z.ZodOptional<z.ZodString>;
|
|
56
|
+
issuedToOrganizationId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
search: z.ZodOptional<z.ZodString>;
|
|
58
|
+
hasBalance: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
59
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
60
|
+
offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
//# sourceMappingURL=validation-vouchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-vouchers.d.ts","sourceRoot":"","sources":["../src/validation-vouchers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;iBAa9B,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;iBAQ9B,CAAA;AAEF,yCAAyC;AACzC,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAA;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;iBASjC,CAAA"}
|