@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.
Files changed (61) hide show
  1. package/dist/client.d.ts +14 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +59 -0
  4. package/dist/hooks/index.d.ts +14 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +13 -0
  7. package/dist/hooks/use-invoice-credit-note-mutation.d.ts +38 -0
  8. package/dist/hooks/use-invoice-credit-note-mutation.d.ts.map +1 -0
  9. package/dist/hooks/use-invoice-credit-note-mutation.js +35 -0
  10. package/dist/hooks/use-invoice-credit-notes.d.ts +17 -0
  11. package/dist/hooks/use-invoice-credit-notes.d.ts.map +1 -0
  12. package/dist/hooks/use-invoice-credit-notes.js +12 -0
  13. package/dist/hooks/use-invoice-line-item-mutation.d.ts +40 -0
  14. package/dist/hooks/use-invoice-line-item-mutation.d.ts.map +1 -0
  15. package/dist/hooks/use-invoice-line-item-mutation.js +42 -0
  16. package/dist/hooks/use-invoice-line-items.d.ts +17 -0
  17. package/dist/hooks/use-invoice-line-items.d.ts.map +1 -0
  18. package/dist/hooks/use-invoice-line-items.js +12 -0
  19. package/dist/hooks/use-invoice-mutation.d.ts +65 -0
  20. package/dist/hooks/use-invoice-mutation.d.ts.map +1 -0
  21. package/dist/hooks/use-invoice-mutation.js +44 -0
  22. package/dist/hooks/use-invoice-note-mutation.d.ts +11 -0
  23. package/dist/hooks/use-invoice-note-mutation.d.ts.map +1 -0
  24. package/dist/hooks/use-invoice-note-mutation.js +23 -0
  25. package/dist/hooks/use-invoice-notes.d.ts +13 -0
  26. package/dist/hooks/use-invoice-notes.d.ts.map +1 -0
  27. package/dist/hooks/use-invoice-notes.js +12 -0
  28. package/dist/hooks/use-invoice-payment-mutation.d.ts +22 -0
  29. package/dist/hooks/use-invoice-payment-mutation.d.ts.map +1 -0
  30. package/dist/hooks/use-invoice-payment-mutation.js +24 -0
  31. package/dist/hooks/use-invoice-payments.d.ts +18 -0
  32. package/dist/hooks/use-invoice-payments.d.ts.map +1 -0
  33. package/dist/hooks/use-invoice-payments.js +12 -0
  34. package/dist/hooks/use-invoice.d.ts +25 -0
  35. package/dist/hooks/use-invoice.d.ts.map +1 -0
  36. package/dist/hooks/use-invoice.js +12 -0
  37. package/dist/hooks/use-invoices.d.ts +29 -0
  38. package/dist/hooks/use-invoices.d.ts.map +1 -0
  39. package/dist/hooks/use-invoices.js +12 -0
  40. package/dist/hooks/use-supplier-payment-mutation.d.ts +44 -0
  41. package/dist/hooks/use-supplier-payment-mutation.d.ts.map +1 -0
  42. package/dist/hooks/use-supplier-payment-mutation.js +33 -0
  43. package/dist/hooks/use-supplier-payments.d.ts +23 -0
  44. package/dist/hooks/use-supplier-payments.d.ts.map +1 -0
  45. package/dist/hooks/use-supplier-payments.js +12 -0
  46. package/dist/index.d.ts +7 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +6 -0
  49. package/dist/provider.d.ts +2 -0
  50. package/dist/provider.d.ts.map +1 -0
  51. package/dist/provider.js +1 -0
  52. package/dist/query-keys.d.ts +22 -0
  53. package/dist/query-keys.d.ts.map +1 -0
  54. package/dist/query-keys.js +12 -0
  55. package/dist/query-options.d.ts +485 -0
  56. package/dist/query-options.d.ts.map +1 -0
  57. package/dist/query-options.js +92 -0
  58. package/dist/schemas.d.ts +276 -0
  59. package/dist/schemas.d.ts.map +1 -0
  60. package/dist/schemas.js +100 -0
  61. package/package.json +79 -0
@@ -0,0 +1,25 @@
1
+ export interface UseInvoiceOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useInvoice(id: string | null | undefined, options?: UseInvoiceOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ invoiceNumber: string;
8
+ bookingId: string;
9
+ personId: string | null;
10
+ organizationId: string | null;
11
+ status: "draft" | "void" | "sent" | "partially_paid" | "paid" | "overdue";
12
+ currency: string;
13
+ subtotalCents: number;
14
+ taxCents: number;
15
+ totalCents: number;
16
+ paidCents: number;
17
+ balanceDueCents: number;
18
+ issueDate: string;
19
+ dueDate: string;
20
+ notes: string | null;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ };
24
+ }, Error>;
25
+ //# sourceMappingURL=use-invoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-invoice.d.ts","sourceRoot":"","sources":["../../src/hooks/use-invoice.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;;;UAQxF"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFinanceContext } from "../provider.js";
4
+ import { getInvoiceQueryOptions } from "../query-options.js";
5
+ export function useInvoice(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getInvoiceQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,29 @@
1
+ import type { FinanceInvoiceListFilters } from "../query-keys.js";
2
+ export interface UseInvoicesOptions extends FinanceInvoiceListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useInvoices(options?: UseInvoicesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ invoiceNumber: string;
9
+ bookingId: string;
10
+ personId: string | null;
11
+ organizationId: string | null;
12
+ status: "draft" | "void" | "sent" | "partially_paid" | "paid" | "overdue";
13
+ currency: string;
14
+ subtotalCents: number;
15
+ taxCents: number;
16
+ totalCents: number;
17
+ paidCents: number;
18
+ balanceDueCents: number;
19
+ issueDate: string;
20
+ dueDate: string;
21
+ notes: string | null;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }[];
25
+ total: number;
26
+ limit: number;
27
+ offset: number;
28
+ }, Error>;
29
+ //# sourceMappingURL=use-invoices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-invoices.d.ts","sourceRoot":"","sources":["../../src/hooks/use-invoices.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAGjE,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;;;;;;UAQ3D"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFinanceContext } from "../provider.js";
4
+ import { getInvoicesQueryOptions } from "../query-options.js";
5
+ export function useInvoices(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getInvoicesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,44 @@
1
+ export interface CreateSupplierPaymentInput {
2
+ bookingId: string;
3
+ supplierId?: string | null;
4
+ amountCents: number;
5
+ currency: string;
6
+ paymentMethod: "bank_transfer" | "credit_card" | "cash" | "cheque" | "other";
7
+ status: "pending" | "completed" | "failed" | "refunded";
8
+ referenceNumber?: string | null;
9
+ paymentDate: string;
10
+ notes?: string | null;
11
+ }
12
+ export type UpdateSupplierPaymentInput = Partial<CreateSupplierPaymentInput>;
13
+ export declare function useSupplierPaymentMutation(): {
14
+ create: import("@tanstack/react-query").UseMutationResult<{
15
+ id: string;
16
+ bookingId: string;
17
+ supplierId: string | null;
18
+ amountCents: number;
19
+ currency: string;
20
+ paymentMethod: string;
21
+ status: "pending" | "completed" | "failed" | "refunded";
22
+ referenceNumber: string | null;
23
+ paymentDate: string;
24
+ createdAt: string;
25
+ notes?: string | null | undefined;
26
+ }, Error, CreateSupplierPaymentInput, unknown>;
27
+ update: import("@tanstack/react-query").UseMutationResult<{
28
+ id: string;
29
+ bookingId: string;
30
+ supplierId: string | null;
31
+ amountCents: number;
32
+ currency: string;
33
+ paymentMethod: string;
34
+ status: "pending" | "completed" | "failed" | "refunded";
35
+ referenceNumber: string | null;
36
+ paymentDate: string;
37
+ createdAt: string;
38
+ notes?: string | null | undefined;
39
+ }, Error, {
40
+ id: string;
41
+ input: UpdateSupplierPaymentInput;
42
+ }, unknown>;
43
+ };
44
+ //# sourceMappingURL=use-supplier-payment-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-supplier-payment-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-supplier-payment-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,eAAe,GAAG,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IAC5E,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAA;IACvD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;AAM5E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoBE,MAAM;eAAS,0BAA0B;;EAepF"}
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantFinanceContext } from "../provider.js";
6
+ import { financeQueryKeys } from "../query-keys.js";
7
+ import { supplierPaymentRecordSchema } from "../schemas.js";
8
+ const supplierPaymentSingleResponse = z.object({
9
+ data: supplierPaymentRecordSchema,
10
+ });
11
+ export function useSupplierPaymentMutation() {
12
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
13
+ const queryClient = useQueryClient();
14
+ const create = useMutation({
15
+ mutationFn: async (input) => {
16
+ const { data } = await fetchWithValidation("/v1/finance/supplier-payments", supplierPaymentSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
17
+ return data;
18
+ },
19
+ onSuccess: () => {
20
+ void queryClient.invalidateQueries({ queryKey: financeQueryKeys.supplierPayments() });
21
+ },
22
+ });
23
+ const update = useMutation({
24
+ mutationFn: async ({ id, input }) => {
25
+ const { data } = await fetchWithValidation(`/v1/finance/supplier-payments/${id}`, supplierPaymentSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
26
+ return data;
27
+ },
28
+ onSuccess: () => {
29
+ void queryClient.invalidateQueries({ queryKey: financeQueryKeys.supplierPayments() });
30
+ },
31
+ });
32
+ return { create, update };
33
+ }
@@ -0,0 +1,23 @@
1
+ import type { FinanceSupplierPaymentListFilters } from "../query-keys.js";
2
+ export interface UseSupplierPaymentsOptions extends FinanceSupplierPaymentListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useSupplierPayments(options?: UseSupplierPaymentsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ bookingId: string;
9
+ supplierId: string | null;
10
+ amountCents: number;
11
+ currency: string;
12
+ paymentMethod: string;
13
+ status: "pending" | "completed" | "failed" | "refunded";
14
+ referenceNumber: string | null;
15
+ paymentDate: string;
16
+ createdAt: string;
17
+ notes?: string | null | undefined;
18
+ }[];
19
+ total: number;
20
+ limit: number;
21
+ offset: number;
22
+ }, Error>;
23
+ //# sourceMappingURL=use-supplier-payments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-supplier-payments.d.ts","sourceRoot":"","sources":["../../src/hooks/use-supplier-payments.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAA;AAGzE,MAAM,WAAW,0BAA2B,SAAQ,iCAAiC;IACnF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;;;;;UAQ3E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFinanceContext } from "../provider.js";
4
+ import { getSupplierPaymentsQueryOptions } from "../query-options.js";
5
+ export function useSupplierPayments(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFinanceContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getSupplierPaymentsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,7 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantFinanceContext, type VoyantFinanceContextValue, VoyantFinanceProvider, type VoyantFinanceProviderProps, } from "./provider.js";
4
+ export { financeQueryKeys } from "./query-keys.js";
5
+ export { getInvoiceCreditNotesQueryOptions, getInvoiceLineItemsQueryOptions, getInvoiceNotesQueryOptions, getInvoicePaymentsQueryOptions, getInvoiceQueryOptions, getInvoicesQueryOptions, getSupplierPaymentsQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EACL,iCAAiC,EACjC,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,GAChC,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantFinanceContext, VoyantFinanceProvider, } from "./provider.js";
4
+ export { financeQueryKeys } from "./query-keys.js";
5
+ export { getInvoiceCreditNotesQueryOptions, getInvoiceLineItemsQueryOptions, getInvoiceNotesQueryOptions, getInvoicePaymentsQueryOptions, getInvoiceQueryOptions, getInvoicesQueryOptions, getSupplierPaymentsQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
@@ -0,0 +1,2 @@
1
+ export { useVoyantReactContext as useVoyantFinanceContext, type VoyantReactContextValue as VoyantFinanceContextValue, VoyantReactProvider as VoyantFinanceProvider, type VoyantReactProviderProps as VoyantFinanceProviderProps, } from "@voyantjs/react";
2
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,uBAAuB,EAChD,KAAK,uBAAuB,IAAI,yBAAyB,EACzD,mBAAmB,IAAI,qBAAqB,EAC5C,KAAK,wBAAwB,IAAI,0BAA0B,GAC5D,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export { useVoyantReactContext as useVoyantFinanceContext, VoyantReactProvider as VoyantFinanceProvider, } from "@voyantjs/react";
@@ -0,0 +1,22 @@
1
+ export interface FinanceInvoiceListFilters {
2
+ search?: string | undefined;
3
+ limit?: number | undefined;
4
+ offset?: number | undefined;
5
+ }
6
+ export interface FinanceSupplierPaymentListFilters {
7
+ limit?: number | undefined;
8
+ offset?: number | undefined;
9
+ }
10
+ export declare const financeQueryKeys: {
11
+ readonly all: readonly ["voyant", "finance"];
12
+ readonly invoices: () => readonly ["voyant", "finance", "invoices"];
13
+ readonly invoicesList: (filters: FinanceInvoiceListFilters) => readonly ["voyant", "finance", "invoices", "list", FinanceInvoiceListFilters];
14
+ readonly invoice: (id: string) => readonly ["voyant", "finance", "invoices", "detail", string];
15
+ readonly lineItems: (invoiceId: string) => readonly ["voyant", "finance", "invoices", "detail", string, "line-items"];
16
+ readonly payments: (invoiceId: string) => readonly ["voyant", "finance", "invoices", "detail", string, "payments"];
17
+ readonly creditNotes: (invoiceId: string) => readonly ["voyant", "finance", "invoices", "detail", string, "credit-notes"];
18
+ readonly notes: (invoiceId: string) => readonly ["voyant", "finance", "invoices", "detail", string, "notes"];
19
+ readonly supplierPayments: () => readonly ["voyant", "finance", "supplier-payments"];
20
+ readonly supplierPaymentsList: (filters: FinanceSupplierPaymentListFilters) => readonly ["voyant", "finance", "supplier-payments", "list", FinanceSupplierPaymentListFilters];
21
+ };
22
+ //# sourceMappingURL=query-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,iCAAiC;IAChD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB;;;qCAIH,yBAAyB;2BAEnC,MAAM;oCACG,MAAM;mCACP,MAAM;sCACH,MAAM;gCAEZ,MAAM;;6CAGO,iCAAiC;CAEzD,CAAA"}
@@ -0,0 +1,12 @@
1
+ export const financeQueryKeys = {
2
+ all: ["voyant", "finance"],
3
+ invoices: () => [...financeQueryKeys.all, "invoices"],
4
+ invoicesList: (filters) => [...financeQueryKeys.invoices(), "list", filters],
5
+ invoice: (id) => [...financeQueryKeys.invoices(), "detail", id],
6
+ lineItems: (invoiceId) => [...financeQueryKeys.invoice(invoiceId), "line-items"],
7
+ payments: (invoiceId) => [...financeQueryKeys.invoice(invoiceId), "payments"],
8
+ creditNotes: (invoiceId) => [...financeQueryKeys.invoice(invoiceId), "credit-notes"],
9
+ notes: (invoiceId) => [...financeQueryKeys.invoice(invoiceId), "notes"],
10
+ supplierPayments: () => [...financeQueryKeys.all, "supplier-payments"],
11
+ supplierPaymentsList: (filters) => [...financeQueryKeys.supplierPayments(), "list", filters],
12
+ };