@voyant-travel/finance 0.119.5
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/LICENSE +201 -0
- package/README.md +192 -0
- package/dist/action-ledger-drift.d.ts +29 -0
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/action-ledger-drift.js +166 -0
- package/dist/booking-tax.d.ts +124 -0
- package/dist/booking-tax.d.ts.map +1 -0
- package/dist/booking-tax.js +264 -0
- package/dist/checkout-routes.d.ts +1154 -0
- package/dist/checkout-routes.d.ts.map +1 -0
- package/dist/checkout-routes.js +116 -0
- package/dist/checkout-service-plan.d.ts +137 -0
- package/dist/checkout-service-plan.d.ts.map +1 -0
- package/dist/checkout-service-plan.js +119 -0
- package/dist/checkout-service.d.ts +9 -0
- package/dist/checkout-service.d.ts.map +1 -0
- package/dist/checkout-service.js +324 -0
- package/dist/checkout-validation.d.ts +1682 -0
- package/dist/checkout-validation.d.ts.map +1 -0
- package/dist/checkout-validation.js +228 -0
- package/dist/document-download.d.ts +3 -0
- package/dist/document-download.d.ts.map +1 -0
- package/dist/document-download.js +1 -0
- package/dist/fx-money.d.ts +17 -0
- package/dist/fx-money.d.ts.map +1 -0
- package/dist/fx-money.js +194 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/invoice-fx.d.ts +134 -0
- package/dist/invoice-fx.d.ts.map +1 -0
- package/dist/invoice-fx.js +240 -0
- package/dist/invoice-number-errors.d.ts +2 -0
- package/dist/invoice-number-errors.d.ts.map +1 -0
- package/dist/invoice-number-errors.js +58 -0
- package/dist/markets-ref.d.ts +149 -0
- package/dist/markets-ref.d.ts.map +1 -0
- package/dist/markets-ref.js +17 -0
- package/dist/payment-link.d.ts +23 -0
- package/dist/payment-link.d.ts.map +1 -0
- package/dist/payment-link.js +30 -0
- package/dist/payment-policy.d.ts +113 -0
- package/dist/payment-policy.d.ts.map +1 -0
- package/dist/payment-policy.js +193 -0
- package/dist/route-runtime.d.ts +22 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/route-runtime.js +18 -0
- package/dist/routes-action-ledger.d.ts +181 -0
- package/dist/routes-action-ledger.d.ts.map +1 -0
- package/dist/routes-action-ledger.js +142 -0
- package/dist/routes-booking-billing.d.ts +852 -0
- package/dist/routes-booking-billing.d.ts.map +1 -0
- package/dist/routes-booking-billing.js +223 -0
- package/dist/routes-booking-create.d.ts +3 -0
- package/dist/routes-booking-create.d.ts.map +1 -0
- package/dist/routes-booking-create.js +194 -0
- package/dist/routes-booking-reads.d.ts +46 -0
- package/dist/routes-booking-reads.d.ts.map +1 -0
- package/dist/routes-booking-reads.js +20 -0
- package/dist/routes-documents.d.ts +195 -0
- package/dist/routes-documents.d.ts.map +1 -0
- package/dist/routes-documents.js +93 -0
- package/dist/routes-invoice-core.d.ts +794 -0
- package/dist/routes-invoice-core.d.ts.map +1 -0
- package/dist/routes-invoice-core.js +238 -0
- package/dist/routes-invoice-documents.d.ts +401 -0
- package/dist/routes-invoice-documents.d.ts.map +1 -0
- package/dist/routes-invoice-documents.js +91 -0
- package/dist/routes-invoice-issue.d.ts +384 -0
- package/dist/routes-invoice-issue.d.ts.map +1 -0
- package/dist/routes-invoice-issue.js +208 -0
- package/dist/routes-payment-processing.d.ts +1193 -0
- package/dist/routes-payment-processing.d.ts.map +1 -0
- package/dist/routes-payment-processing.js +238 -0
- package/dist/routes-payments.d.ts +309 -0
- package/dist/routes-payments.d.ts.map +1 -0
- package/dist/routes-payments.js +94 -0
- package/dist/routes-public.d.ts +1948 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +275 -0
- package/dist/routes-reference-data.d.ts +977 -0
- package/dist/routes-reference-data.d.ts.map +1 -0
- package/dist/routes-reference-data.js +191 -0
- package/dist/routes-reports.d.ts +344 -0
- package/dist/routes-reports.d.ts.map +1 -0
- package/dist/routes-reports.js +93 -0
- package/dist/routes-runtime.d.ts +71 -0
- package/dist/routes-runtime.d.ts.map +1 -0
- package/dist/routes-runtime.js +59 -0
- package/dist/routes-settlement.d.ts +67 -0
- package/dist/routes-settlement.d.ts.map +1 -0
- package/dist/routes-settlement.js +23 -0
- package/dist/routes-shared.d.ts +35 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +10 -0
- package/dist/routes-supplier-invoices.d.ts +778 -0
- package/dist/routes-supplier-invoices.d.ts.map +1 -0
- package/dist/routes-supplier-invoices.js +159 -0
- package/dist/routes-vouchers.d.ts +228 -0
- package/dist/routes-vouchers.d.ts.map +1 -0
- package/dist/routes-vouchers.js +54 -0
- package/dist/routes.d.ts +5577 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +44 -0
- package/dist/schema/booking-billing.d.ts +1006 -0
- package/dist/schema/booking-billing.d.ts.map +1 -0
- package/dist/schema/booking-billing.js +106 -0
- package/dist/schema/enums.d.ts +48 -0
- package/dist/schema/enums.d.ts.map +1 -0
- package/dist/schema/enums.js +237 -0
- package/dist/schema/invoice-documents.d.ts +1245 -0
- package/dist/schema/invoice-documents.d.ts.map +1 -0
- package/dist/schema/invoice-documents.js +140 -0
- package/dist/schema/payment-instruments.d.ts +418 -0
- package/dist/schema/payment-instruments.d.ts.map +1 -0
- package/dist/schema/payment-instruments.js +45 -0
- package/dist/schema/payment-processing.d.ts +563 -0
- package/dist/schema/payment-processing.d.ts.map +1 -0
- package/dist/schema/payment-processing.js +65 -0
- package/dist/schema/payment-sessions.d.ts +728 -0
- package/dist/schema/payment-sessions.d.ts.map +1 -0
- package/dist/schema/payment-sessions.js +79 -0
- package/dist/schema/receivables.d.ts +1474 -0
- package/dist/schema/receivables.d.ts.map +1 -0
- package/dist/schema/receivables.js +179 -0
- package/dist/schema/relations.d.ts +82 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/relations.js +144 -0
- package/dist/schema/supplier-invoices.d.ts +1619 -0
- package/dist/schema/supplier-invoices.d.ts.map +1 -0
- package/dist/schema/supplier-invoices.js +228 -0
- package/dist/schema/tax.d.ts +712 -0
- package/dist/schema/tax.d.ts.map +1 -0
- package/dist/schema/tax.js +98 -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 +12 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +11 -0
- package/dist/service-accountant-shares.d.ts +106 -0
- package/dist/service-accountant-shares.d.ts.map +1 -0
- package/dist/service-accountant-shares.js +331 -0
- package/dist/service-action-ledger-accounting.d.ts +104 -0
- package/dist/service-action-ledger-accounting.d.ts.map +1 -0
- package/dist/service-action-ledger-accounting.js +386 -0
- package/dist/service-action-ledger-booking-payments.d.ts +48 -0
- package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-booking-payments.js +178 -0
- package/dist/service-action-ledger-bookings.d.ts +44 -0
- package/dist/service-action-ledger-bookings.d.ts.map +1 -0
- package/dist/service-action-ledger-bookings.js +81 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-authorizations.js +209 -0
- package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
- package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-sessions.js +294 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts +27 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-invoices.js +111 -0
- package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
- package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-payments.js +97 -0
- package/dist/service-action-ledger.d.ts +7 -0
- package/dist/service-action-ledger.d.ts.map +1 -0
- package/dist/service-action-ledger.js +6 -0
- package/dist/service-aggregates.d.ts +96 -0
- package/dist/service-aggregates.d.ts.map +1 -0
- package/dist/service-aggregates.js +294 -0
- package/dist/service-booking-billing.d.ts +2322 -0
- package/dist/service-booking-billing.d.ts.map +1 -0
- package/dist/service-booking-billing.js +8 -0
- package/dist/service-booking-create.d.ts +410 -0
- package/dist/service-booking-create.d.ts.map +1 -0
- package/dist/service-booking-create.js +1256 -0
- package/dist/service-booking-guarantees.d.ts +725 -0
- package/dist/service-booking-guarantees.d.ts.map +1 -0
- package/dist/service-booking-guarantees.js +153 -0
- package/dist/service-booking-item-billing.d.ts +1062 -0
- package/dist/service-booking-item-billing.d.ts.map +1 -0
- package/dist/service-booking-item-billing.js +77 -0
- package/dist/service-booking-payment-schedules.d.ts +557 -0
- package/dist/service-booking-payment-schedules.d.ts.map +1 -0
- package/dist/service-booking-payment-schedules.js +372 -0
- package/dist/service-bookings-dual-create.d.ts +308 -0
- package/dist/service-bookings-dual-create.d.ts.map +1 -0
- package/dist/service-bookings-dual-create.js +131 -0
- package/dist/service-boundary-sql.d.ts +6 -0
- package/dist/service-boundary-sql.d.ts.map +1 -0
- package/dist/service-boundary-sql.js +15 -0
- package/dist/service-cost-categories.d.ts +26 -0
- package/dist/service-cost-categories.d.ts.map +1 -0
- package/dist/service-cost-categories.js +76 -0
- package/dist/service-documents.d.ts +80 -0
- package/dist/service-documents.d.ts.map +1 -0
- package/dist/service-documents.js +228 -0
- package/dist/service-invoice-artifacts.d.ts +246 -0
- package/dist/service-invoice-artifacts.d.ts.map +1 -0
- package/dist/service-invoice-artifacts.js +277 -0
- package/dist/service-invoice-core.d.ts +405 -0
- package/dist/service-invoice-core.d.ts.map +1 -0
- package/dist/service-invoice-core.js +290 -0
- package/dist/service-invoice-credit-notes.d.ts +973 -0
- package/dist/service-invoice-credit-notes.d.ts.map +1 -0
- package/dist/service-invoice-credit-notes.js +142 -0
- package/dist/service-invoice-from-booking.d.ts +41 -0
- package/dist/service-invoice-from-booking.d.ts.map +1 -0
- package/dist/service-invoice-from-booking.js +267 -0
- package/dist/service-invoice-line-items.d.ts +432 -0
- package/dist/service-invoice-line-items.d.ts.map +1 -0
- package/dist/service-invoice-line-items.js +102 -0
- package/dist/service-invoice-numbering.d.ts +227 -0
- package/dist/service-invoice-numbering.d.ts.map +1 -0
- package/dist/service-invoice-numbering.js +260 -0
- package/dist/service-invoice-payments.d.ts +673 -0
- package/dist/service-invoice-payments.d.ts.map +1 -0
- package/dist/service-invoice-payments.js +398 -0
- package/dist/service-invoices.d.ts +2501 -0
- package/dist/service-invoices.d.ts.map +1 -0
- package/dist/service-invoices.js +12 -0
- package/dist/service-issue.d.ts +207 -0
- package/dist/service-issue.d.ts.map +1 -0
- package/dist/service-issue.js +431 -0
- package/dist/service-payment-authorizations.d.ts +164 -0
- package/dist/service-payment-authorizations.d.ts.map +1 -0
- package/dist/service-payment-authorizations.js +227 -0
- package/dist/service-payment-instruments.d.ts +116 -0
- package/dist/service-payment-instruments.d.ts.map +1 -0
- package/dist/service-payment-instruments.js +99 -0
- package/dist/service-payment-processing.d.ts +676 -0
- package/dist/service-payment-processing.d.ts.map +1 -0
- package/dist/service-payment-processing.js +10 -0
- package/dist/service-payment-session-completion.d.ts +48 -0
- package/dist/service-payment-session-completion.d.ts.map +1 -0
- package/dist/service-payment-session-completion.js +238 -0
- package/dist/service-payment-sessions.d.ts +361 -0
- package/dist/service-payment-sessions.d.ts.map +1 -0
- package/dist/service-payment-sessions.js +280 -0
- package/dist/service-profitability.d.ts +114 -0
- package/dist/service-profitability.d.ts.map +1 -0
- package/dist/service-profitability.js +794 -0
- package/dist/service-public.d.ts +553 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +583 -0
- package/dist/service-reference-data.d.ts +272 -0
- package/dist/service-reference-data.d.ts.map +1 -0
- package/dist/service-reference-data.js +280 -0
- package/dist/service-rendition-wait.d.ts +38 -0
- package/dist/service-rendition-wait.d.ts.map +1 -0
- package/dist/service-rendition-wait.js +67 -0
- package/dist/service-reports.d.ts +37 -0
- package/dist/service-reports.d.ts.map +1 -0
- package/dist/service-reports.js +62 -0
- package/dist/service-settlement.d.ts +46 -0
- package/dist/service-settlement.d.ts.map +1 -0
- package/dist/service-settlement.js +185 -0
- package/dist/service-shared.d.ts +541 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +764 -0
- package/dist/service-supplier-invoices.d.ts +871 -0
- package/dist/service-supplier-invoices.d.ts.map +1 -0
- package/dist/service-supplier-invoices.js +744 -0
- package/dist/service-supplier-payments.d.ts +69 -0
- package/dist/service-supplier-payments.d.ts.map +1 -0
- package/dist/service-supplier-payments.js +136 -0
- package/dist/service-vouchers-migration.d.ts +44 -0
- package/dist/service-vouchers-migration.d.ts.map +1 -0
- package/dist/service-vouchers-migration.js +148 -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 +6490 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +29 -0
- package/dist/validation-billing.d.ts +2 -0
- package/dist/validation-billing.d.ts.map +1 -0
- package/dist/validation-billing.js +1 -0
- package/dist/validation-payments.d.ts +2 -0
- package/dist/validation-payments.d.ts.map +1 -0
- package/dist/validation-payments.js +1 -0
- package/dist/validation-public.d.ts +2 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +1 -0
- package/dist/validation-shared.d.ts +2 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +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 +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { EventBus, ModuleContainer } from "@voyant-travel/core";
|
|
2
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
3
|
+
import { financeDocumentsService } from "./service-documents.js";
|
|
4
|
+
type Env = {
|
|
5
|
+
Bindings: Record<string, unknown>;
|
|
6
|
+
Variables: {
|
|
7
|
+
container: ModuleContainer;
|
|
8
|
+
db: PostgresJsDatabase;
|
|
9
|
+
userId?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type InvoiceDocumentGenerator = Parameters<typeof financeDocumentsService.generateInvoiceDocument>[3]["generator"];
|
|
13
|
+
export interface FinanceDocumentRouteOptions {
|
|
14
|
+
invoiceDocumentGenerator?: InvoiceDocumentGenerator;
|
|
15
|
+
resolveInvoiceDocumentGenerator?: (bindings: Record<string, unknown>) => InvoiceDocumentGenerator | undefined;
|
|
16
|
+
resolveDocumentDownloadUrl?: (bindings: unknown, storageKey: string) => Promise<string | null> | string | null;
|
|
17
|
+
eventBus?: EventBus;
|
|
18
|
+
resolveEventBus?: (bindings: Record<string, unknown>) => EventBus | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function createFinanceAdminDocumentRoutes(options?: FinanceDocumentRouteOptions): import("hono/hono-base").HonoBase<Env, {
|
|
21
|
+
"/invoices/:id/generate-document": {
|
|
22
|
+
$post: {
|
|
23
|
+
input: {
|
|
24
|
+
param: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
output: {
|
|
29
|
+
error: string;
|
|
30
|
+
};
|
|
31
|
+
outputFormat: "json";
|
|
32
|
+
status: 501;
|
|
33
|
+
} | {
|
|
34
|
+
input: {
|
|
35
|
+
param: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
output: {
|
|
40
|
+
error: string;
|
|
41
|
+
};
|
|
42
|
+
outputFormat: "json";
|
|
43
|
+
status: 404;
|
|
44
|
+
} | {
|
|
45
|
+
input: {
|
|
46
|
+
param: {
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
output: {
|
|
51
|
+
error: string;
|
|
52
|
+
};
|
|
53
|
+
outputFormat: "json";
|
|
54
|
+
status: 502;
|
|
55
|
+
} | {
|
|
56
|
+
input: {
|
|
57
|
+
param: {
|
|
58
|
+
id: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
output: {
|
|
62
|
+
data: {
|
|
63
|
+
status: "generated";
|
|
64
|
+
invoiceId: string;
|
|
65
|
+
renderedBodyFormat: "html" | "markdown" | "lexical_json";
|
|
66
|
+
renderedBody: string;
|
|
67
|
+
rendition: {
|
|
68
|
+
format: "json" | "html" | "pdf" | "xml";
|
|
69
|
+
id: string;
|
|
70
|
+
createdAt: string;
|
|
71
|
+
updatedAt: string;
|
|
72
|
+
metadata: import("hono/utils/types").JSONValue;
|
|
73
|
+
status: "failed" | "pending" | "ready" | "stale";
|
|
74
|
+
errorMessage: string | null;
|
|
75
|
+
invoiceId: string;
|
|
76
|
+
templateId: string | null;
|
|
77
|
+
language: string | null;
|
|
78
|
+
storageKey: string | null;
|
|
79
|
+
fileSize: number | null;
|
|
80
|
+
checksum: string | null;
|
|
81
|
+
generatedAt: string | null;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
outputFormat: "json";
|
|
86
|
+
status: 201;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
} & {
|
|
90
|
+
"/invoices/:id/regenerate-document": {
|
|
91
|
+
$post: {
|
|
92
|
+
input: {
|
|
93
|
+
param: {
|
|
94
|
+
id: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
output: {
|
|
98
|
+
error: string;
|
|
99
|
+
};
|
|
100
|
+
outputFormat: "json";
|
|
101
|
+
status: 501;
|
|
102
|
+
} | {
|
|
103
|
+
input: {
|
|
104
|
+
param: {
|
|
105
|
+
id: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
output: {
|
|
109
|
+
error: string;
|
|
110
|
+
};
|
|
111
|
+
outputFormat: "json";
|
|
112
|
+
status: 404;
|
|
113
|
+
} | {
|
|
114
|
+
input: {
|
|
115
|
+
param: {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
output: {
|
|
120
|
+
error: string;
|
|
121
|
+
};
|
|
122
|
+
outputFormat: "json";
|
|
123
|
+
status: 502;
|
|
124
|
+
} | {
|
|
125
|
+
input: {
|
|
126
|
+
param: {
|
|
127
|
+
id: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
output: {
|
|
131
|
+
data: {
|
|
132
|
+
status: "generated";
|
|
133
|
+
invoiceId: string;
|
|
134
|
+
renderedBodyFormat: "html" | "markdown" | "lexical_json";
|
|
135
|
+
renderedBody: string;
|
|
136
|
+
rendition: {
|
|
137
|
+
format: "json" | "html" | "pdf" | "xml";
|
|
138
|
+
id: string;
|
|
139
|
+
createdAt: string;
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
metadata: import("hono/utils/types").JSONValue;
|
|
142
|
+
status: "failed" | "pending" | "ready" | "stale";
|
|
143
|
+
errorMessage: string | null;
|
|
144
|
+
invoiceId: string;
|
|
145
|
+
templateId: string | null;
|
|
146
|
+
language: string | null;
|
|
147
|
+
storageKey: string | null;
|
|
148
|
+
fileSize: number | null;
|
|
149
|
+
checksum: string | null;
|
|
150
|
+
generatedAt: string | null;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
outputFormat: "json";
|
|
155
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
} & {
|
|
159
|
+
"/invoice-renditions/:id/download": {
|
|
160
|
+
$get: {
|
|
161
|
+
input: {
|
|
162
|
+
param: {
|
|
163
|
+
id: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
output: undefined;
|
|
167
|
+
outputFormat: "redirect";
|
|
168
|
+
status: 302;
|
|
169
|
+
} | {
|
|
170
|
+
input: {
|
|
171
|
+
param: {
|
|
172
|
+
id: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
output: {
|
|
176
|
+
error: string;
|
|
177
|
+
};
|
|
178
|
+
outputFormat: "json";
|
|
179
|
+
status: 404;
|
|
180
|
+
} | {
|
|
181
|
+
input: {
|
|
182
|
+
param: {
|
|
183
|
+
id: string;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
output: {
|
|
187
|
+
error: string;
|
|
188
|
+
};
|
|
189
|
+
outputFormat: "json";
|
|
190
|
+
status: 501;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}, "/", "/invoice-renditions/:id/download">;
|
|
194
|
+
export {};
|
|
195
|
+
//# sourceMappingURL=routes-documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-documents.d.ts","sourceRoot":"","sources":["../src/routes-documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAMpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAUjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAGhE,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,EAAE;QACT,SAAS,EAAE,eAAe,CAAA;QAC1B,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAC/C,OAAO,uBAAuB,CAAC,uBAAuB,CACvD,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;AAEjB,MAAM,WAAW,2BAA2B;IAC1C,wBAAwB,CAAC,EAAE,wBAAwB,CAAA;IACnD,+BAA+B,CAAC,EAAE,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,wBAAwB,GAAG,SAAS,CAAA;IACzC,0BAA0B,CAAC,EAAE,CAC3B,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3C,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,QAAQ,GAAG,SAAS,CAAA;CAC9E;AAaD,wBAAgB,gCAAgC,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAwEzF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createDrizzlePublicDocumentDeliveryGrantStore, createPublicDocumentDeliveryGrant, parseOptionalJsonBody, } from "@voyant-travel/hono";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { resolveStoredDocumentDownload } from "./document-download.js";
|
|
4
|
+
import { buildFinanceRouteRuntime, FINANCE_ROUTE_RUNTIME_CONTAINER_KEY, } from "./route-runtime.js";
|
|
5
|
+
import { financeService } from "./service.js";
|
|
6
|
+
import { financeDocumentsService } from "./service-documents.js";
|
|
7
|
+
import { generateInvoiceDocumentInputSchema } from "./validation.js";
|
|
8
|
+
function getRuntime(options, bindings, resolveFromContainer) {
|
|
9
|
+
return (resolveFromContainer?.(FINANCE_ROUTE_RUNTIME_CONTAINER_KEY) ??
|
|
10
|
+
buildFinanceRouteRuntime(bindings, options));
|
|
11
|
+
}
|
|
12
|
+
export function createFinanceAdminDocumentRoutes(options = {}) {
|
|
13
|
+
return new Hono()
|
|
14
|
+
.post("/invoices/:id/generate-document", async (c) => {
|
|
15
|
+
const runtime = getRuntime(options, c.env, (key) => c.var.container?.resolve(key));
|
|
16
|
+
const generator = runtime.invoiceDocumentGenerator;
|
|
17
|
+
if (!generator) {
|
|
18
|
+
return c.json({ error: "Invoice document generator is not configured" }, 501);
|
|
19
|
+
}
|
|
20
|
+
const input = await parseOptionalJsonBody(c, generateInvoiceDocumentInputSchema);
|
|
21
|
+
const result = await financeDocumentsService.generateInvoiceDocument(c.get("db"), c.req.param("id"), input, { generator, bindings: c.env, eventBus: runtime.eventBus });
|
|
22
|
+
if (result.status === "not_found")
|
|
23
|
+
return c.json({ error: "Invoice not found" }, 404);
|
|
24
|
+
if (result.status === "generator_failed") {
|
|
25
|
+
return c.json({ error: "Invoice document generation failed" }, 502);
|
|
26
|
+
}
|
|
27
|
+
if (!("rendition" in result)) {
|
|
28
|
+
return c.json({ error: "Invoice document generation failed" }, 502);
|
|
29
|
+
}
|
|
30
|
+
return c.json({ data: await attachDownloadEnvelope(c, runtime, result, input) }, 201);
|
|
31
|
+
})
|
|
32
|
+
.post("/invoices/:id/regenerate-document", async (c) => {
|
|
33
|
+
const runtime = getRuntime(options, c.env, (key) => c.var.container?.resolve(key));
|
|
34
|
+
const generator = runtime.invoiceDocumentGenerator;
|
|
35
|
+
if (!generator) {
|
|
36
|
+
return c.json({ error: "Invoice document generator is not configured" }, 501);
|
|
37
|
+
}
|
|
38
|
+
const input = await parseOptionalJsonBody(c, generateInvoiceDocumentInputSchema);
|
|
39
|
+
const result = await financeDocumentsService.regenerateInvoiceDocument(c.get("db"), c.req.param("id"), input, { generator, bindings: c.env, eventBus: runtime.eventBus });
|
|
40
|
+
if (result.status === "not_found")
|
|
41
|
+
return c.json({ error: "Invoice not found" }, 404);
|
|
42
|
+
if (result.status === "generator_failed") {
|
|
43
|
+
return c.json({ error: "Invoice document generation failed" }, 502);
|
|
44
|
+
}
|
|
45
|
+
if (!("rendition" in result)) {
|
|
46
|
+
return c.json({ error: "Invoice document generation failed" }, 502);
|
|
47
|
+
}
|
|
48
|
+
return c.json({ data: await attachDownloadEnvelope(c, runtime, result, input) });
|
|
49
|
+
})
|
|
50
|
+
.get("/invoice-renditions/:id/download", async (c) => {
|
|
51
|
+
const runtime = getRuntime(options, c.env, (key) => c.var.container?.resolve(key));
|
|
52
|
+
const rendition = await financeService.getInvoiceRenditionById(c.get("db"), c.req.param("id"));
|
|
53
|
+
if (!rendition) {
|
|
54
|
+
return c.json({ error: "Invoice rendition not found" }, 404);
|
|
55
|
+
}
|
|
56
|
+
const download = await resolveStoredDocumentDownload(rendition, {
|
|
57
|
+
bindings: c.env,
|
|
58
|
+
resolveDocumentDownloadUrl: runtime.resolveDocumentDownloadUrl,
|
|
59
|
+
});
|
|
60
|
+
if (download.status === "resolver_not_configured") {
|
|
61
|
+
return c.json({ error: "Document download resolver is not configured" }, 501);
|
|
62
|
+
}
|
|
63
|
+
if (download.status !== "ready") {
|
|
64
|
+
return c.json({ error: "Invoice document is not available" }, 404);
|
|
65
|
+
}
|
|
66
|
+
return c.redirect(download.download.url, 302);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function attachDownloadEnvelope(c, runtime, result, input) {
|
|
70
|
+
const download = await resolveStoredDocumentDownload(result.rendition, {
|
|
71
|
+
bindings: c.env,
|
|
72
|
+
resolveDocumentDownloadUrl: runtime.resolveDocumentDownloadUrl,
|
|
73
|
+
});
|
|
74
|
+
const withAdminDownload = download.status === "ready" ? { ...result, download: download.download } : result;
|
|
75
|
+
if (!input.publicDelivery || !result.rendition.storageKey) {
|
|
76
|
+
return withAdminDownload;
|
|
77
|
+
}
|
|
78
|
+
const publicDownload = await createPublicDocumentDeliveryGrant(createDrizzlePublicDocumentDeliveryGrantStore(c.get("db")), {
|
|
79
|
+
storageKey: result.rendition.storageKey,
|
|
80
|
+
publicBaseUrl: new URL(c.req.url).origin,
|
|
81
|
+
ttlSeconds: input.publicDeliveryTtlSeconds,
|
|
82
|
+
filename: download.status === "ready" ? download.download.filename : null,
|
|
83
|
+
contentType: result.rendition.format === "pdf" ? "application/pdf" : null,
|
|
84
|
+
source: {
|
|
85
|
+
module: "finance",
|
|
86
|
+
entity: "invoice_rendition",
|
|
87
|
+
id: result.rendition.id ?? null,
|
|
88
|
+
},
|
|
89
|
+
createdBy: c.get("userId") ?? null,
|
|
90
|
+
createdByType: c.get("userId") ? "staff" : null,
|
|
91
|
+
});
|
|
92
|
+
return { ...withAdminDownload, publicDownload };
|
|
93
|
+
}
|