@voyantjs/finance-react 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/use-invoice-credit-note-mutation.d.ts +38 -0
- package/dist/hooks/use-invoice-credit-note-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-credit-note-mutation.js +35 -0
- package/dist/hooks/use-invoice-credit-notes.d.ts +17 -0
- package/dist/hooks/use-invoice-credit-notes.d.ts.map +1 -0
- package/dist/hooks/use-invoice-credit-notes.js +12 -0
- package/dist/hooks/use-invoice-line-item-mutation.d.ts +40 -0
- package/dist/hooks/use-invoice-line-item-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-line-item-mutation.js +42 -0
- package/dist/hooks/use-invoice-line-items.d.ts +17 -0
- package/dist/hooks/use-invoice-line-items.d.ts.map +1 -0
- package/dist/hooks/use-invoice-line-items.js +12 -0
- package/dist/hooks/use-invoice-mutation.d.ts +65 -0
- package/dist/hooks/use-invoice-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-mutation.js +44 -0
- package/dist/hooks/use-invoice-note-mutation.d.ts +11 -0
- package/dist/hooks/use-invoice-note-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-note-mutation.js +23 -0
- package/dist/hooks/use-invoice-notes.d.ts +13 -0
- package/dist/hooks/use-invoice-notes.d.ts.map +1 -0
- package/dist/hooks/use-invoice-notes.js +12 -0
- package/dist/hooks/use-invoice-payment-mutation.d.ts +22 -0
- package/dist/hooks/use-invoice-payment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-invoice-payment-mutation.js +24 -0
- package/dist/hooks/use-invoice-payments.d.ts +18 -0
- package/dist/hooks/use-invoice-payments.d.ts.map +1 -0
- package/dist/hooks/use-invoice-payments.js +12 -0
- package/dist/hooks/use-invoice.d.ts +25 -0
- package/dist/hooks/use-invoice.d.ts.map +1 -0
- package/dist/hooks/use-invoice.js +12 -0
- package/dist/hooks/use-invoices.d.ts +29 -0
- package/dist/hooks/use-invoices.d.ts.map +1 -0
- package/dist/hooks/use-invoices.js +12 -0
- package/dist/hooks/use-supplier-payment-mutation.d.ts +44 -0
- package/dist/hooks/use-supplier-payment-mutation.d.ts.map +1 -0
- package/dist/hooks/use-supplier-payment-mutation.js +33 -0
- package/dist/hooks/use-supplier-payments.d.ts +23 -0
- package/dist/hooks/use-supplier-payments.d.ts.map +1 -0
- package/dist/hooks/use-supplier-payments.js +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +22 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +12 -0
- package/dist/query-options.d.ts +485 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +92 -0
- package/dist/schemas.d.ts +276 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +100 -0
- package/package.json +79 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const paginatedEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
|
|
3
|
+
data: z.ZodArray<T>;
|
|
4
|
+
total: z.ZodNumber;
|
|
5
|
+
limit: z.ZodNumber;
|
|
6
|
+
offset: z.ZodNumber;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const singleEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
|
|
9
|
+
data: T;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const arrayEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
|
|
12
|
+
data: z.ZodArray<T>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const successEnvelope: z.ZodObject<{
|
|
15
|
+
success: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const invoiceStatusSchema: z.ZodEnum<{
|
|
18
|
+
draft: "draft";
|
|
19
|
+
void: "void";
|
|
20
|
+
sent: "sent";
|
|
21
|
+
partially_paid: "partially_paid";
|
|
22
|
+
paid: "paid";
|
|
23
|
+
overdue: "overdue";
|
|
24
|
+
}>;
|
|
25
|
+
export declare const paymentStatusSchema: z.ZodEnum<{
|
|
26
|
+
pending: "pending";
|
|
27
|
+
completed: "completed";
|
|
28
|
+
failed: "failed";
|
|
29
|
+
refunded: "refunded";
|
|
30
|
+
}>;
|
|
31
|
+
export declare const creditNoteStatusSchema: z.ZodEnum<{
|
|
32
|
+
draft: "draft";
|
|
33
|
+
issued: "issued";
|
|
34
|
+
applied: "applied";
|
|
35
|
+
}>;
|
|
36
|
+
export declare const invoiceRecordSchema: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
invoiceNumber: z.ZodString;
|
|
39
|
+
bookingId: z.ZodString;
|
|
40
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
41
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
42
|
+
status: z.ZodEnum<{
|
|
43
|
+
draft: "draft";
|
|
44
|
+
void: "void";
|
|
45
|
+
sent: "sent";
|
|
46
|
+
partially_paid: "partially_paid";
|
|
47
|
+
paid: "paid";
|
|
48
|
+
overdue: "overdue";
|
|
49
|
+
}>;
|
|
50
|
+
currency: z.ZodString;
|
|
51
|
+
subtotalCents: z.ZodNumber;
|
|
52
|
+
taxCents: z.ZodNumber;
|
|
53
|
+
totalCents: z.ZodNumber;
|
|
54
|
+
paidCents: z.ZodNumber;
|
|
55
|
+
balanceDueCents: z.ZodNumber;
|
|
56
|
+
issueDate: z.ZodString;
|
|
57
|
+
dueDate: z.ZodString;
|
|
58
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
59
|
+
createdAt: z.ZodString;
|
|
60
|
+
updatedAt: z.ZodString;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type InvoiceRecord = z.infer<typeof invoiceRecordSchema>;
|
|
63
|
+
export declare const lineItemRecordSchema: z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
invoiceId: z.ZodString;
|
|
66
|
+
description: z.ZodString;
|
|
67
|
+
quantity: z.ZodNumber;
|
|
68
|
+
unitPriceCents: z.ZodNumber;
|
|
69
|
+
totalCents: z.ZodNumber;
|
|
70
|
+
taxRate: z.ZodNullable<z.ZodNumber>;
|
|
71
|
+
sortOrder: z.ZodNumber;
|
|
72
|
+
createdAt: z.ZodString;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type LineItemRecord = z.infer<typeof lineItemRecordSchema>;
|
|
75
|
+
export declare const paymentRecordSchema: z.ZodObject<{
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
invoiceId: z.ZodString;
|
|
78
|
+
amountCents: z.ZodNumber;
|
|
79
|
+
currency: z.ZodString;
|
|
80
|
+
paymentMethod: z.ZodString;
|
|
81
|
+
status: z.ZodEnum<{
|
|
82
|
+
pending: "pending";
|
|
83
|
+
completed: "completed";
|
|
84
|
+
failed: "failed";
|
|
85
|
+
refunded: "refunded";
|
|
86
|
+
}>;
|
|
87
|
+
referenceNumber: z.ZodNullable<z.ZodString>;
|
|
88
|
+
paymentDate: z.ZodString;
|
|
89
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
90
|
+
createdAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export type PaymentRecord = z.infer<typeof paymentRecordSchema>;
|
|
93
|
+
export declare const creditNoteRecordSchema: z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
creditNoteNumber: z.ZodString;
|
|
96
|
+
invoiceId: z.ZodString;
|
|
97
|
+
status: z.ZodEnum<{
|
|
98
|
+
draft: "draft";
|
|
99
|
+
issued: "issued";
|
|
100
|
+
applied: "applied";
|
|
101
|
+
}>;
|
|
102
|
+
amountCents: z.ZodNumber;
|
|
103
|
+
currency: z.ZodString;
|
|
104
|
+
reason: z.ZodString;
|
|
105
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
106
|
+
createdAt: z.ZodString;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export type CreditNoteRecord = z.infer<typeof creditNoteRecordSchema>;
|
|
109
|
+
export declare const financeNoteRecordSchema: z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
invoiceId: z.ZodString;
|
|
112
|
+
authorId: z.ZodString;
|
|
113
|
+
content: z.ZodString;
|
|
114
|
+
createdAt: z.ZodString;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
export type FinanceNoteRecord = z.infer<typeof financeNoteRecordSchema>;
|
|
117
|
+
export declare const supplierPaymentRecordSchema: z.ZodObject<{
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
bookingId: z.ZodString;
|
|
120
|
+
supplierId: z.ZodNullable<z.ZodString>;
|
|
121
|
+
amountCents: z.ZodNumber;
|
|
122
|
+
currency: z.ZodString;
|
|
123
|
+
paymentMethod: z.ZodString;
|
|
124
|
+
status: z.ZodEnum<{
|
|
125
|
+
pending: "pending";
|
|
126
|
+
completed: "completed";
|
|
127
|
+
failed: "failed";
|
|
128
|
+
refunded: "refunded";
|
|
129
|
+
}>;
|
|
130
|
+
referenceNumber: z.ZodNullable<z.ZodString>;
|
|
131
|
+
paymentDate: z.ZodString;
|
|
132
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
createdAt: z.ZodString;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type SupplierPaymentRecord = z.infer<typeof supplierPaymentRecordSchema>;
|
|
136
|
+
export declare const invoiceListResponse: z.ZodObject<{
|
|
137
|
+
data: z.ZodArray<z.ZodObject<{
|
|
138
|
+
id: z.ZodString;
|
|
139
|
+
invoiceNumber: z.ZodString;
|
|
140
|
+
bookingId: z.ZodString;
|
|
141
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
142
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
143
|
+
status: z.ZodEnum<{
|
|
144
|
+
draft: "draft";
|
|
145
|
+
void: "void";
|
|
146
|
+
sent: "sent";
|
|
147
|
+
partially_paid: "partially_paid";
|
|
148
|
+
paid: "paid";
|
|
149
|
+
overdue: "overdue";
|
|
150
|
+
}>;
|
|
151
|
+
currency: z.ZodString;
|
|
152
|
+
subtotalCents: z.ZodNumber;
|
|
153
|
+
taxCents: z.ZodNumber;
|
|
154
|
+
totalCents: z.ZodNumber;
|
|
155
|
+
paidCents: z.ZodNumber;
|
|
156
|
+
balanceDueCents: z.ZodNumber;
|
|
157
|
+
issueDate: z.ZodString;
|
|
158
|
+
dueDate: z.ZodString;
|
|
159
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
160
|
+
createdAt: z.ZodString;
|
|
161
|
+
updatedAt: z.ZodString;
|
|
162
|
+
}, z.core.$strip>>;
|
|
163
|
+
total: z.ZodNumber;
|
|
164
|
+
limit: z.ZodNumber;
|
|
165
|
+
offset: z.ZodNumber;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export declare const supplierPaymentListResponse: z.ZodObject<{
|
|
168
|
+
data: z.ZodArray<z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
bookingId: z.ZodString;
|
|
171
|
+
supplierId: z.ZodNullable<z.ZodString>;
|
|
172
|
+
amountCents: z.ZodNumber;
|
|
173
|
+
currency: z.ZodString;
|
|
174
|
+
paymentMethod: z.ZodString;
|
|
175
|
+
status: z.ZodEnum<{
|
|
176
|
+
pending: "pending";
|
|
177
|
+
completed: "completed";
|
|
178
|
+
failed: "failed";
|
|
179
|
+
refunded: "refunded";
|
|
180
|
+
}>;
|
|
181
|
+
referenceNumber: z.ZodNullable<z.ZodString>;
|
|
182
|
+
paymentDate: z.ZodString;
|
|
183
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
184
|
+
createdAt: z.ZodString;
|
|
185
|
+
}, z.core.$strip>>;
|
|
186
|
+
total: z.ZodNumber;
|
|
187
|
+
limit: z.ZodNumber;
|
|
188
|
+
offset: z.ZodNumber;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
export declare const invoiceSingleResponse: z.ZodObject<{
|
|
191
|
+
data: z.ZodObject<{
|
|
192
|
+
id: z.ZodString;
|
|
193
|
+
invoiceNumber: z.ZodString;
|
|
194
|
+
bookingId: z.ZodString;
|
|
195
|
+
personId: z.ZodNullable<z.ZodString>;
|
|
196
|
+
organizationId: z.ZodNullable<z.ZodString>;
|
|
197
|
+
status: z.ZodEnum<{
|
|
198
|
+
draft: "draft";
|
|
199
|
+
void: "void";
|
|
200
|
+
sent: "sent";
|
|
201
|
+
partially_paid: "partially_paid";
|
|
202
|
+
paid: "paid";
|
|
203
|
+
overdue: "overdue";
|
|
204
|
+
}>;
|
|
205
|
+
currency: z.ZodString;
|
|
206
|
+
subtotalCents: z.ZodNumber;
|
|
207
|
+
taxCents: z.ZodNumber;
|
|
208
|
+
totalCents: z.ZodNumber;
|
|
209
|
+
paidCents: z.ZodNumber;
|
|
210
|
+
balanceDueCents: z.ZodNumber;
|
|
211
|
+
issueDate: z.ZodString;
|
|
212
|
+
dueDate: z.ZodString;
|
|
213
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
214
|
+
createdAt: z.ZodString;
|
|
215
|
+
updatedAt: z.ZodString;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export declare const invoiceLineItemsResponse: z.ZodObject<{
|
|
219
|
+
data: z.ZodArray<z.ZodObject<{
|
|
220
|
+
id: z.ZodString;
|
|
221
|
+
invoiceId: z.ZodString;
|
|
222
|
+
description: z.ZodString;
|
|
223
|
+
quantity: z.ZodNumber;
|
|
224
|
+
unitPriceCents: z.ZodNumber;
|
|
225
|
+
totalCents: z.ZodNumber;
|
|
226
|
+
taxRate: z.ZodNullable<z.ZodNumber>;
|
|
227
|
+
sortOrder: z.ZodNumber;
|
|
228
|
+
createdAt: z.ZodString;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
}, z.core.$strip>;
|
|
231
|
+
export declare const invoicePaymentsResponse: z.ZodObject<{
|
|
232
|
+
data: z.ZodArray<z.ZodObject<{
|
|
233
|
+
id: z.ZodString;
|
|
234
|
+
invoiceId: z.ZodString;
|
|
235
|
+
amountCents: z.ZodNumber;
|
|
236
|
+
currency: z.ZodString;
|
|
237
|
+
paymentMethod: z.ZodString;
|
|
238
|
+
status: z.ZodEnum<{
|
|
239
|
+
pending: "pending";
|
|
240
|
+
completed: "completed";
|
|
241
|
+
failed: "failed";
|
|
242
|
+
refunded: "refunded";
|
|
243
|
+
}>;
|
|
244
|
+
referenceNumber: z.ZodNullable<z.ZodString>;
|
|
245
|
+
paymentDate: z.ZodString;
|
|
246
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
247
|
+
createdAt: z.ZodString;
|
|
248
|
+
}, z.core.$strip>>;
|
|
249
|
+
}, z.core.$strip>;
|
|
250
|
+
export declare const invoiceCreditNotesResponse: z.ZodObject<{
|
|
251
|
+
data: z.ZodArray<z.ZodObject<{
|
|
252
|
+
id: z.ZodString;
|
|
253
|
+
creditNoteNumber: z.ZodString;
|
|
254
|
+
invoiceId: z.ZodString;
|
|
255
|
+
status: z.ZodEnum<{
|
|
256
|
+
draft: "draft";
|
|
257
|
+
issued: "issued";
|
|
258
|
+
applied: "applied";
|
|
259
|
+
}>;
|
|
260
|
+
amountCents: z.ZodNumber;
|
|
261
|
+
currency: z.ZodString;
|
|
262
|
+
reason: z.ZodString;
|
|
263
|
+
notes: z.ZodNullable<z.ZodString>;
|
|
264
|
+
createdAt: z.ZodString;
|
|
265
|
+
}, z.core.$strip>>;
|
|
266
|
+
}, z.core.$strip>;
|
|
267
|
+
export declare const invoiceNotesResponse: z.ZodObject<{
|
|
268
|
+
data: z.ZodArray<z.ZodObject<{
|
|
269
|
+
id: z.ZodString;
|
|
270
|
+
invoiceId: z.ZodString;
|
|
271
|
+
authorId: z.ZodString;
|
|
272
|
+
content: z.ZodString;
|
|
273
|
+
createdAt: z.ZodString;
|
|
274
|
+
}, z.core.$strip>>;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;;;;iBAM7D,CAAA;AAEJ,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAA6B,CAAA;AAC3F,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAAsC,CAAA;AACnG,eAAO,MAAM,eAAe;;iBAAqC,CAAA;AAEjE,eAAO,MAAM,mBAAmB;;;;;;;EAO9B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;EAAyD,CAAA;AACzF,eAAO,MAAM,sBAAsB;;;;EAAyC,CAAA;AAE5E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;iBAkB9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,oBAAoB;;;;;;;;;;iBAU/B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;iBAW9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;iBAUjC,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAErE,eAAO,MAAM,uBAAuB;;;;;;iBAMlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBAYtC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAyC,CAAA;AACzE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAA;AACzF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsC,CAAA;AACxE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;iBAAsC,CAAA;AAC3E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;iBAAqC,CAAA;AACzE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAAwC,CAAA;AAC/E,eAAO,MAAM,oBAAoB;;;;;;;;iBAAyC,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const paginatedEnvelope = (item) => z.object({
|
|
3
|
+
data: z.array(item),
|
|
4
|
+
total: z.number().int(),
|
|
5
|
+
limit: z.number().int(),
|
|
6
|
+
offset: z.number().int(),
|
|
7
|
+
});
|
|
8
|
+
export const singleEnvelope = (item) => z.object({ data: item });
|
|
9
|
+
export const arrayEnvelope = (item) => z.object({ data: z.array(item) });
|
|
10
|
+
export const successEnvelope = z.object({ success: z.boolean() });
|
|
11
|
+
export const invoiceStatusSchema = z.enum([
|
|
12
|
+
"draft",
|
|
13
|
+
"sent",
|
|
14
|
+
"partially_paid",
|
|
15
|
+
"paid",
|
|
16
|
+
"overdue",
|
|
17
|
+
"void",
|
|
18
|
+
]);
|
|
19
|
+
export const paymentStatusSchema = z.enum(["pending", "completed", "failed", "refunded"]);
|
|
20
|
+
export const creditNoteStatusSchema = z.enum(["draft", "issued", "applied"]);
|
|
21
|
+
export const invoiceRecordSchema = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
invoiceNumber: z.string(),
|
|
24
|
+
bookingId: z.string(),
|
|
25
|
+
personId: z.string().nullable(),
|
|
26
|
+
organizationId: z.string().nullable(),
|
|
27
|
+
status: invoiceStatusSchema,
|
|
28
|
+
currency: z.string(),
|
|
29
|
+
subtotalCents: z.number().int(),
|
|
30
|
+
taxCents: z.number().int(),
|
|
31
|
+
totalCents: z.number().int(),
|
|
32
|
+
paidCents: z.number().int(),
|
|
33
|
+
balanceDueCents: z.number().int(),
|
|
34
|
+
issueDate: z.string(),
|
|
35
|
+
dueDate: z.string(),
|
|
36
|
+
notes: z.string().nullable(),
|
|
37
|
+
createdAt: z.string(),
|
|
38
|
+
updatedAt: z.string(),
|
|
39
|
+
});
|
|
40
|
+
export const lineItemRecordSchema = z.object({
|
|
41
|
+
id: z.string(),
|
|
42
|
+
invoiceId: z.string(),
|
|
43
|
+
description: z.string(),
|
|
44
|
+
quantity: z.number().int(),
|
|
45
|
+
unitPriceCents: z.number().int(),
|
|
46
|
+
totalCents: z.number().int(),
|
|
47
|
+
taxRate: z.number().int().nullable(),
|
|
48
|
+
sortOrder: z.number().int(),
|
|
49
|
+
createdAt: z.string(),
|
|
50
|
+
});
|
|
51
|
+
export const paymentRecordSchema = z.object({
|
|
52
|
+
id: z.string(),
|
|
53
|
+
invoiceId: z.string(),
|
|
54
|
+
amountCents: z.number().int(),
|
|
55
|
+
currency: z.string(),
|
|
56
|
+
paymentMethod: z.string(),
|
|
57
|
+
status: paymentStatusSchema,
|
|
58
|
+
referenceNumber: z.string().nullable(),
|
|
59
|
+
paymentDate: z.string(),
|
|
60
|
+
notes: z.string().nullable(),
|
|
61
|
+
createdAt: z.string(),
|
|
62
|
+
});
|
|
63
|
+
export const creditNoteRecordSchema = z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
creditNoteNumber: z.string(),
|
|
66
|
+
invoiceId: z.string(),
|
|
67
|
+
status: creditNoteStatusSchema,
|
|
68
|
+
amountCents: z.number().int(),
|
|
69
|
+
currency: z.string(),
|
|
70
|
+
reason: z.string(),
|
|
71
|
+
notes: z.string().nullable(),
|
|
72
|
+
createdAt: z.string(),
|
|
73
|
+
});
|
|
74
|
+
export const financeNoteRecordSchema = z.object({
|
|
75
|
+
id: z.string(),
|
|
76
|
+
invoiceId: z.string(),
|
|
77
|
+
authorId: z.string(),
|
|
78
|
+
content: z.string(),
|
|
79
|
+
createdAt: z.string(),
|
|
80
|
+
});
|
|
81
|
+
export const supplierPaymentRecordSchema = z.object({
|
|
82
|
+
id: z.string(),
|
|
83
|
+
bookingId: z.string(),
|
|
84
|
+
supplierId: z.string().nullable(),
|
|
85
|
+
amountCents: z.number().int(),
|
|
86
|
+
currency: z.string(),
|
|
87
|
+
paymentMethod: z.string(),
|
|
88
|
+
status: paymentStatusSchema,
|
|
89
|
+
referenceNumber: z.string().nullable(),
|
|
90
|
+
paymentDate: z.string(),
|
|
91
|
+
notes: z.string().nullable().optional(),
|
|
92
|
+
createdAt: z.string(),
|
|
93
|
+
});
|
|
94
|
+
export const invoiceListResponse = paginatedEnvelope(invoiceRecordSchema);
|
|
95
|
+
export const supplierPaymentListResponse = paginatedEnvelope(supplierPaymentRecordSchema);
|
|
96
|
+
export const invoiceSingleResponse = singleEnvelope(invoiceRecordSchema);
|
|
97
|
+
export const invoiceLineItemsResponse = arrayEnvelope(lineItemRecordSchema);
|
|
98
|
+
export const invoicePaymentsResponse = arrayEnvelope(paymentRecordSchema);
|
|
99
|
+
export const invoiceCreditNotesResponse = arrayEnvelope(creditNoteRecordSchema);
|
|
100
|
+
export const invoiceNotesResponse = arrayEnvelope(financeNoteRecordSchema);
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/finance-react",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
8
|
+
"directory": "packages/finance-react"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.ts",
|
|
13
|
+
"./provider": "./src/provider.tsx",
|
|
14
|
+
"./hooks": "./src/hooks/index.ts",
|
|
15
|
+
"./client": "./src/client.ts",
|
|
16
|
+
"./query-keys": "./src/query-keys.ts"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"prepack": "pnpm run build",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "biome check src/",
|
|
24
|
+
"test": "vitest run --passWithNoTests"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@voyantjs/finance": "workspace:*",
|
|
28
|
+
"@tanstack/react-query": "^5.0.0",
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0",
|
|
31
|
+
"zod": "^4.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tanstack/react-query": "^5.96.2",
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@voyantjs/finance": "workspace:*",
|
|
38
|
+
"@voyantjs/react": "workspace:*",
|
|
39
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
40
|
+
"react": "^19.2.4",
|
|
41
|
+
"react-dom": "^19.2.4",
|
|
42
|
+
"typescript": "^6.0.2",
|
|
43
|
+
"vitest": "^4.1.2",
|
|
44
|
+
"zod": "^4.3.6"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@voyantjs/react": "workspace:*"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"import": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./provider": {
|
|
60
|
+
"types": "./dist/provider.d.ts",
|
|
61
|
+
"import": "./dist/provider.js"
|
|
62
|
+
},
|
|
63
|
+
"./hooks": {
|
|
64
|
+
"types": "./dist/hooks/index.d.ts",
|
|
65
|
+
"import": "./dist/hooks/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./client": {
|
|
68
|
+
"types": "./dist/client.d.ts",
|
|
69
|
+
"import": "./dist/client.js"
|
|
70
|
+
},
|
|
71
|
+
"./query-keys": {
|
|
72
|
+
"types": "./dist/query-keys.d.ts",
|
|
73
|
+
"import": "./dist/query-keys.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"main": "./dist/index.js",
|
|
77
|
+
"types": "./dist/index.d.ts"
|
|
78
|
+
}
|
|
79
|
+
}
|