@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 @@
|
|
|
1
|
+
{"version":3,"file":"routes-payment-processing.d.ts","sourceRoot":"","sources":["../src/routes-payment-processing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAsB7C,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgUvC,CAAA"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { getActionLedgerRequestContext, getFinanceRouteRuntime } from "./routes-runtime.js";
|
|
4
|
+
import { financeService, PaymentValidationError } from "./service.js";
|
|
5
|
+
import { cancelPaymentSessionSchema, completePaymentSessionSchema, expirePaymentSessionSchema, failPaymentSessionSchema, insertPaymentAuthorizationSchema, insertPaymentCaptureSchema, insertPaymentInstrumentSchema, insertPaymentSessionSchema, markPaymentSessionRequiresRedirectSchema, paymentAuthorizationListQuerySchema, paymentCaptureListQuerySchema, paymentInstrumentListQuerySchema, paymentSessionListQuerySchema, updatePaymentAuthorizationSchema, updatePaymentCaptureSchema, updatePaymentInstrumentSchema, updatePaymentSessionSchema, } from "./validation.js";
|
|
6
|
+
export const financePaymentProcessingRoutes = new Hono()
|
|
7
|
+
// ========================================================================
|
|
8
|
+
// Payment Sessions
|
|
9
|
+
// ========================================================================
|
|
10
|
+
.get("/payment-sessions", async (c) => {
|
|
11
|
+
const query = parseQuery(c, paymentSessionListQuerySchema);
|
|
12
|
+
return c.json(await financeService.listPaymentSessions(c.get("db"), query));
|
|
13
|
+
})
|
|
14
|
+
.post("/payment-sessions", async (c) => {
|
|
15
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
16
|
+
return c.json({
|
|
17
|
+
data: await financeService.createPaymentSession(c.get("db"), await parseJsonBody(c, insertPaymentSessionSchema), {
|
|
18
|
+
eventBus: runtime?.eventBus,
|
|
19
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
20
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
21
|
+
}),
|
|
22
|
+
}, 201);
|
|
23
|
+
})
|
|
24
|
+
.get("/payment-sessions/:id", async (c) => {
|
|
25
|
+
const row = await financeService.getPaymentSessionById(c.get("db"), c.req.param("id"));
|
|
26
|
+
if (!row)
|
|
27
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
28
|
+
return c.json({ data: row });
|
|
29
|
+
})
|
|
30
|
+
.patch("/payment-sessions/:id", async (c) => {
|
|
31
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
32
|
+
const row = await financeService.updatePaymentSession(c.get("db"), c.req.param("id"), await parseJsonBody(c, updatePaymentSessionSchema), {
|
|
33
|
+
eventBus: runtime?.eventBus,
|
|
34
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
35
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
36
|
+
});
|
|
37
|
+
if (!row)
|
|
38
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
39
|
+
return c.json({ data: row });
|
|
40
|
+
})
|
|
41
|
+
.post("/payment-sessions/:id/requires-redirect", async (c) => {
|
|
42
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
43
|
+
const row = await financeService.markPaymentSessionRequiresRedirect(c.get("db"), c.req.param("id"), await parseJsonBody(c, markPaymentSessionRequiresRedirectSchema), {
|
|
44
|
+
eventBus: runtime?.eventBus,
|
|
45
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
46
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
47
|
+
});
|
|
48
|
+
if (!row)
|
|
49
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
50
|
+
return c.json({ data: row });
|
|
51
|
+
})
|
|
52
|
+
.post("/payment-sessions/:id/complete", async (c) => {
|
|
53
|
+
try {
|
|
54
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
55
|
+
const row = await financeService.completePaymentSession(c.get("db"), c.req.param("id"), await parseJsonBody(c, completePaymentSessionSchema), {
|
|
56
|
+
eventBus: runtime?.eventBus,
|
|
57
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
58
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
59
|
+
});
|
|
60
|
+
if (!row)
|
|
61
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
62
|
+
return c.json({ data: row });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof PaymentValidationError) {
|
|
66
|
+
return c.json({ error: error.message, code: error.code, details: error.details }, error.status);
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
.post("/payment-sessions/:id/fail", async (c) => {
|
|
72
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
73
|
+
const row = await financeService.failPaymentSession(c.get("db"), c.req.param("id"), await parseJsonBody(c, failPaymentSessionSchema), {
|
|
74
|
+
eventBus: runtime?.eventBus,
|
|
75
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
76
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
77
|
+
});
|
|
78
|
+
if (!row)
|
|
79
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
80
|
+
return c.json({ data: row });
|
|
81
|
+
})
|
|
82
|
+
.post("/payment-sessions/:id/cancel", async (c) => {
|
|
83
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
84
|
+
const row = await financeService.cancelPaymentSession(c.get("db"), c.req.param("id"), await parseJsonBody(c, cancelPaymentSessionSchema), {
|
|
85
|
+
eventBus: runtime?.eventBus,
|
|
86
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
87
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
88
|
+
});
|
|
89
|
+
if (!row)
|
|
90
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
91
|
+
return c.json({ data: row });
|
|
92
|
+
})
|
|
93
|
+
.post("/payment-sessions/:id/expire", async (c) => {
|
|
94
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
95
|
+
const row = await financeService.expirePaymentSession(c.get("db"), c.req.param("id"), await parseJsonBody(c, expirePaymentSessionSchema), {
|
|
96
|
+
eventBus: runtime?.eventBus,
|
|
97
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
98
|
+
actionLedgerAuthorizationSource: "finance.payment_session.route",
|
|
99
|
+
});
|
|
100
|
+
if (!row)
|
|
101
|
+
return c.json({ error: "Payment session not found" }, 404);
|
|
102
|
+
return c.json({ data: row });
|
|
103
|
+
})
|
|
104
|
+
// ========================================================================
|
|
105
|
+
// Payment Instruments
|
|
106
|
+
// ========================================================================
|
|
107
|
+
.get("/payment-instruments", async (c) => {
|
|
108
|
+
const query = parseQuery(c, paymentInstrumentListQuerySchema);
|
|
109
|
+
return c.json(await financeService.listPaymentInstruments(c.get("db"), query));
|
|
110
|
+
})
|
|
111
|
+
.post("/payment-instruments", async (c) => {
|
|
112
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
113
|
+
return c.json({
|
|
114
|
+
data: await financeService.createPaymentInstrument(c.get("db"), await parseJsonBody(c, insertPaymentInstrumentSchema), {
|
|
115
|
+
eventBus: runtime?.eventBus,
|
|
116
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
117
|
+
actionLedgerAuthorizationSource: "finance.payment_instrument.route",
|
|
118
|
+
}),
|
|
119
|
+
}, 201);
|
|
120
|
+
})
|
|
121
|
+
.get("/payment-instruments/:id", async (c) => {
|
|
122
|
+
const row = await financeService.getPaymentInstrumentById(c.get("db"), c.req.param("id"));
|
|
123
|
+
if (!row)
|
|
124
|
+
return c.json({ error: "Payment instrument not found" }, 404);
|
|
125
|
+
return c.json({ data: row });
|
|
126
|
+
})
|
|
127
|
+
.patch("/payment-instruments/:id", async (c) => {
|
|
128
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
129
|
+
const row = await financeService.updatePaymentInstrument(c.get("db"), c.req.param("id"), await parseJsonBody(c, updatePaymentInstrumentSchema), {
|
|
130
|
+
eventBus: runtime?.eventBus,
|
|
131
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
132
|
+
actionLedgerAuthorizationSource: "finance.payment_instrument.route",
|
|
133
|
+
});
|
|
134
|
+
if (!row)
|
|
135
|
+
return c.json({ error: "Payment instrument not found" }, 404);
|
|
136
|
+
return c.json({ data: row });
|
|
137
|
+
})
|
|
138
|
+
.delete("/payment-instruments/:id", async (c) => {
|
|
139
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
140
|
+
const row = await financeService.deletePaymentInstrument(c.get("db"), c.req.param("id"), {
|
|
141
|
+
eventBus: runtime?.eventBus,
|
|
142
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
143
|
+
actionLedgerAuthorizationSource: "finance.payment_instrument.route",
|
|
144
|
+
});
|
|
145
|
+
if (!row)
|
|
146
|
+
return c.json({ error: "Payment instrument not found" }, 404);
|
|
147
|
+
return c.json({ success: true });
|
|
148
|
+
})
|
|
149
|
+
// ========================================================================
|
|
150
|
+
// Payment Authorizations
|
|
151
|
+
// ========================================================================
|
|
152
|
+
.get("/payment-authorizations", async (c) => {
|
|
153
|
+
const query = parseQuery(c, paymentAuthorizationListQuerySchema);
|
|
154
|
+
return c.json(await financeService.listPaymentAuthorizations(c.get("db"), query));
|
|
155
|
+
})
|
|
156
|
+
.post("/payment-authorizations", async (c) => {
|
|
157
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
158
|
+
return c.json({
|
|
159
|
+
data: await financeService.createPaymentAuthorization(c.get("db"), await parseJsonBody(c, insertPaymentAuthorizationSchema), {
|
|
160
|
+
eventBus: runtime?.eventBus,
|
|
161
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
162
|
+
actionLedgerAuthorizationSource: "finance.payment_authorization.route",
|
|
163
|
+
}),
|
|
164
|
+
}, 201);
|
|
165
|
+
})
|
|
166
|
+
.get("/payment-authorizations/:id", async (c) => {
|
|
167
|
+
const row = await financeService.getPaymentAuthorizationById(c.get("db"), c.req.param("id"));
|
|
168
|
+
if (!row)
|
|
169
|
+
return c.json({ error: "Payment authorization not found" }, 404);
|
|
170
|
+
return c.json({ data: row });
|
|
171
|
+
})
|
|
172
|
+
.patch("/payment-authorizations/:id", async (c) => {
|
|
173
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
174
|
+
const row = await financeService.updatePaymentAuthorization(c.get("db"), c.req.param("id"), await parseJsonBody(c, updatePaymentAuthorizationSchema), {
|
|
175
|
+
eventBus: runtime?.eventBus,
|
|
176
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
177
|
+
actionLedgerAuthorizationSource: "finance.payment_authorization.route",
|
|
178
|
+
});
|
|
179
|
+
if (!row)
|
|
180
|
+
return c.json({ error: "Payment authorization not found" }, 404);
|
|
181
|
+
return c.json({ data: row });
|
|
182
|
+
})
|
|
183
|
+
.delete("/payment-authorizations/:id", async (c) => {
|
|
184
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
185
|
+
const row = await financeService.deletePaymentAuthorization(c.get("db"), c.req.param("id"), {
|
|
186
|
+
eventBus: runtime?.eventBus,
|
|
187
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
188
|
+
actionLedgerAuthorizationSource: "finance.payment_authorization.route",
|
|
189
|
+
});
|
|
190
|
+
if (!row)
|
|
191
|
+
return c.json({ error: "Payment authorization not found" }, 404);
|
|
192
|
+
return c.json({ success: true });
|
|
193
|
+
})
|
|
194
|
+
// ========================================================================
|
|
195
|
+
// Payment Captures
|
|
196
|
+
// ========================================================================
|
|
197
|
+
.get("/payment-captures", async (c) => {
|
|
198
|
+
const query = parseQuery(c, paymentCaptureListQuerySchema);
|
|
199
|
+
return c.json(await financeService.listPaymentCaptures(c.get("db"), query));
|
|
200
|
+
})
|
|
201
|
+
.post("/payment-captures", async (c) => {
|
|
202
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
203
|
+
return c.json({
|
|
204
|
+
data: await financeService.createPaymentCapture(c.get("db"), await parseJsonBody(c, insertPaymentCaptureSchema), {
|
|
205
|
+
eventBus: runtime?.eventBus,
|
|
206
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
207
|
+
actionLedgerAuthorizationSource: "finance.payment_capture.route",
|
|
208
|
+
}),
|
|
209
|
+
}, 201);
|
|
210
|
+
})
|
|
211
|
+
.get("/payment-captures/:id", async (c) => {
|
|
212
|
+
const row = await financeService.getPaymentCaptureById(c.get("db"), c.req.param("id"));
|
|
213
|
+
if (!row)
|
|
214
|
+
return c.json({ error: "Payment capture not found" }, 404);
|
|
215
|
+
return c.json({ data: row });
|
|
216
|
+
})
|
|
217
|
+
.patch("/payment-captures/:id", async (c) => {
|
|
218
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
219
|
+
const row = await financeService.updatePaymentCapture(c.get("db"), c.req.param("id"), await parseJsonBody(c, updatePaymentCaptureSchema), {
|
|
220
|
+
eventBus: runtime?.eventBus,
|
|
221
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
222
|
+
actionLedgerAuthorizationSource: "finance.payment_capture.route",
|
|
223
|
+
});
|
|
224
|
+
if (!row)
|
|
225
|
+
return c.json({ error: "Payment capture not found" }, 404);
|
|
226
|
+
return c.json({ data: row });
|
|
227
|
+
})
|
|
228
|
+
.delete("/payment-captures/:id", async (c) => {
|
|
229
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
230
|
+
const row = await financeService.deletePaymentCapture(c.get("db"), c.req.param("id"), {
|
|
231
|
+
eventBus: runtime?.eventBus,
|
|
232
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
233
|
+
actionLedgerAuthorizationSource: "finance.payment_capture.route",
|
|
234
|
+
});
|
|
235
|
+
if (!row)
|
|
236
|
+
return c.json({ error: "Payment capture not found" }, 404);
|
|
237
|
+
return c.json({ success: true });
|
|
238
|
+
});
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { Env } from "./routes-shared.js";
|
|
2
|
+
export declare const financePaymentRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
3
|
+
"/payments": {
|
|
4
|
+
$get: {
|
|
5
|
+
input: {};
|
|
6
|
+
output: {
|
|
7
|
+
data: {
|
|
8
|
+
kind: "customer" | "supplier";
|
|
9
|
+
id: string;
|
|
10
|
+
invoiceId: string | null;
|
|
11
|
+
invoiceNumber: string | null;
|
|
12
|
+
bookingId: string | null;
|
|
13
|
+
bookingNumber: string | null;
|
|
14
|
+
supplierId: string | null;
|
|
15
|
+
supplierName: string | null;
|
|
16
|
+
personId: string | null;
|
|
17
|
+
personName: string | null;
|
|
18
|
+
organizationId: string | null;
|
|
19
|
+
organizationName: string | null;
|
|
20
|
+
amountCents: number;
|
|
21
|
+
currency: string;
|
|
22
|
+
baseCurrency: string | null;
|
|
23
|
+
baseAmountCents: number | null;
|
|
24
|
+
paymentMethod: string;
|
|
25
|
+
status: string;
|
|
26
|
+
referenceNumber: string | null;
|
|
27
|
+
paymentDate: string;
|
|
28
|
+
notes: string | null;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}[];
|
|
32
|
+
total: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
offset: number;
|
|
35
|
+
};
|
|
36
|
+
outputFormat: "json";
|
|
37
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
} & {
|
|
41
|
+
"/payments/:id": {
|
|
42
|
+
$get: {
|
|
43
|
+
input: {
|
|
44
|
+
param: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
output: {
|
|
49
|
+
error: string;
|
|
50
|
+
};
|
|
51
|
+
outputFormat: "json";
|
|
52
|
+
status: 404;
|
|
53
|
+
} | {
|
|
54
|
+
input: {
|
|
55
|
+
param: {
|
|
56
|
+
id: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
output: {
|
|
60
|
+
data: {
|
|
61
|
+
kind: "customer" | "supplier";
|
|
62
|
+
id: string;
|
|
63
|
+
invoiceId: string | null;
|
|
64
|
+
invoiceNumber: string | null;
|
|
65
|
+
bookingId: string | null;
|
|
66
|
+
bookingNumber: string | null;
|
|
67
|
+
supplierId: string | null;
|
|
68
|
+
supplierName: string | null;
|
|
69
|
+
personId: string | null;
|
|
70
|
+
personName: string | null;
|
|
71
|
+
organizationId: string | null;
|
|
72
|
+
organizationName: string | null;
|
|
73
|
+
amountCents: number;
|
|
74
|
+
currency: string;
|
|
75
|
+
baseCurrency: string | null;
|
|
76
|
+
baseAmountCents: number | null;
|
|
77
|
+
paymentMethod: string;
|
|
78
|
+
status: string;
|
|
79
|
+
referenceNumber: string | null;
|
|
80
|
+
paymentDate: string;
|
|
81
|
+
notes: string | null;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
updatedAt: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
outputFormat: "json";
|
|
87
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
} & {
|
|
91
|
+
"/payments/:id": {
|
|
92
|
+
$patch: {
|
|
93
|
+
input: {
|
|
94
|
+
param: {
|
|
95
|
+
id: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
output: {
|
|
99
|
+
error: string;
|
|
100
|
+
};
|
|
101
|
+
outputFormat: "json";
|
|
102
|
+
status: 400;
|
|
103
|
+
} | {
|
|
104
|
+
input: {
|
|
105
|
+
param: {
|
|
106
|
+
id: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
output: {
|
|
110
|
+
error: string;
|
|
111
|
+
};
|
|
112
|
+
outputFormat: "json";
|
|
113
|
+
status: 404;
|
|
114
|
+
} | {
|
|
115
|
+
input: {
|
|
116
|
+
param: {
|
|
117
|
+
id: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
output: {
|
|
121
|
+
data: {
|
|
122
|
+
id: string;
|
|
123
|
+
invoiceId: string;
|
|
124
|
+
amountCents: number;
|
|
125
|
+
currency: string;
|
|
126
|
+
baseCurrency: string | null;
|
|
127
|
+
baseAmountCents: number | null;
|
|
128
|
+
fxRateSetId: string | null;
|
|
129
|
+
paymentMethod: "other" | "bank_transfer" | "credit_card" | "voucher" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill";
|
|
130
|
+
paymentInstrumentId: string | null;
|
|
131
|
+
paymentAuthorizationId: string | null;
|
|
132
|
+
paymentCaptureId: string | null;
|
|
133
|
+
status: "failed" | "pending" | "completed" | "refunded";
|
|
134
|
+
referenceNumber: string | null;
|
|
135
|
+
paymentDate: string;
|
|
136
|
+
notes: string | null;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
updatedAt: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
outputFormat: "json";
|
|
142
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
} & {
|
|
146
|
+
"/payments/:id": {
|
|
147
|
+
$delete: {
|
|
148
|
+
input: {
|
|
149
|
+
param: {
|
|
150
|
+
id: string;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
output: {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
156
|
+
outputFormat: "json";
|
|
157
|
+
status: 400;
|
|
158
|
+
} | {
|
|
159
|
+
input: {
|
|
160
|
+
param: {
|
|
161
|
+
id: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
output: {
|
|
165
|
+
error: string;
|
|
166
|
+
};
|
|
167
|
+
outputFormat: "json";
|
|
168
|
+
status: 404;
|
|
169
|
+
} | {
|
|
170
|
+
input: {
|
|
171
|
+
param: {
|
|
172
|
+
id: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
output: {
|
|
176
|
+
data: {
|
|
177
|
+
id: string;
|
|
178
|
+
invoiceId: string;
|
|
179
|
+
amountCents: number;
|
|
180
|
+
currency: string;
|
|
181
|
+
baseCurrency: string | null;
|
|
182
|
+
baseAmountCents: number | null;
|
|
183
|
+
fxRateSetId: string | null;
|
|
184
|
+
paymentMethod: "other" | "bank_transfer" | "credit_card" | "voucher" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill";
|
|
185
|
+
paymentInstrumentId: string | null;
|
|
186
|
+
paymentAuthorizationId: string | null;
|
|
187
|
+
paymentCaptureId: string | null;
|
|
188
|
+
status: "failed" | "pending" | "completed" | "refunded";
|
|
189
|
+
referenceNumber: string | null;
|
|
190
|
+
paymentDate: string;
|
|
191
|
+
notes: string | null;
|
|
192
|
+
createdAt: string;
|
|
193
|
+
updatedAt: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
outputFormat: "json";
|
|
197
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
} & {
|
|
201
|
+
"/supplier-payments": {
|
|
202
|
+
$get: {
|
|
203
|
+
input: {};
|
|
204
|
+
output: {
|
|
205
|
+
data: {
|
|
206
|
+
id: string;
|
|
207
|
+
bookingId: string | null;
|
|
208
|
+
supplierId: string | null;
|
|
209
|
+
bookingSupplierStatusId: string | null;
|
|
210
|
+
supplierInvoiceId: string | null;
|
|
211
|
+
amountCents: number;
|
|
212
|
+
currency: string;
|
|
213
|
+
baseCurrency: string | null;
|
|
214
|
+
baseAmountCents: number | null;
|
|
215
|
+
fxRateSetId: string | null;
|
|
216
|
+
paymentMethod: "other" | "bank_transfer" | "credit_card" | "voucher" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill";
|
|
217
|
+
paymentInstrumentId: string | null;
|
|
218
|
+
status: "failed" | "pending" | "completed" | "refunded";
|
|
219
|
+
referenceNumber: string | null;
|
|
220
|
+
paymentDate: string;
|
|
221
|
+
notes: string | null;
|
|
222
|
+
createdAt: string;
|
|
223
|
+
updatedAt: string;
|
|
224
|
+
}[];
|
|
225
|
+
total: number;
|
|
226
|
+
limit: number;
|
|
227
|
+
offset: number;
|
|
228
|
+
};
|
|
229
|
+
outputFormat: "json";
|
|
230
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
} & {
|
|
234
|
+
"/supplier-payments": {
|
|
235
|
+
$post: {
|
|
236
|
+
input: {};
|
|
237
|
+
output: {
|
|
238
|
+
data: {
|
|
239
|
+
currency: string;
|
|
240
|
+
id: string;
|
|
241
|
+
createdAt: string;
|
|
242
|
+
updatedAt: string;
|
|
243
|
+
status: "failed" | "pending" | "completed" | "refunded";
|
|
244
|
+
bookingId: string | null;
|
|
245
|
+
amountCents: number;
|
|
246
|
+
notes: string | null;
|
|
247
|
+
paymentMethod: "other" | "bank_transfer" | "credit_card" | "voucher" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill";
|
|
248
|
+
baseCurrency: string | null;
|
|
249
|
+
fxRateSetId: string | null;
|
|
250
|
+
supplierId: string | null;
|
|
251
|
+
paymentInstrumentId: string | null;
|
|
252
|
+
referenceNumber: string | null;
|
|
253
|
+
baseAmountCents: number | null;
|
|
254
|
+
paymentDate: string;
|
|
255
|
+
supplierInvoiceId: string | null;
|
|
256
|
+
bookingSupplierStatusId: string | null;
|
|
257
|
+
} | null;
|
|
258
|
+
};
|
|
259
|
+
outputFormat: "json";
|
|
260
|
+
status: 201;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
} & {
|
|
264
|
+
"/supplier-payments/:id": {
|
|
265
|
+
$patch: {
|
|
266
|
+
input: {
|
|
267
|
+
param: {
|
|
268
|
+
id: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
output: {
|
|
272
|
+
error: string;
|
|
273
|
+
};
|
|
274
|
+
outputFormat: "json";
|
|
275
|
+
status: 404;
|
|
276
|
+
} | {
|
|
277
|
+
input: {
|
|
278
|
+
param: {
|
|
279
|
+
id: string;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
output: {
|
|
283
|
+
data: {
|
|
284
|
+
id: string;
|
|
285
|
+
bookingId: string | null;
|
|
286
|
+
supplierId: string | null;
|
|
287
|
+
bookingSupplierStatusId: string | null;
|
|
288
|
+
supplierInvoiceId: string | null;
|
|
289
|
+
amountCents: number;
|
|
290
|
+
currency: string;
|
|
291
|
+
baseCurrency: string | null;
|
|
292
|
+
baseAmountCents: number | null;
|
|
293
|
+
fxRateSetId: string | null;
|
|
294
|
+
paymentMethod: "other" | "bank_transfer" | "credit_card" | "voucher" | "debit_card" | "cash" | "cheque" | "wallet" | "direct_bill";
|
|
295
|
+
paymentInstrumentId: string | null;
|
|
296
|
+
status: "failed" | "pending" | "completed" | "refunded";
|
|
297
|
+
referenceNumber: string | null;
|
|
298
|
+
paymentDate: string;
|
|
299
|
+
notes: string | null;
|
|
300
|
+
createdAt: string;
|
|
301
|
+
updatedAt: string;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
outputFormat: "json";
|
|
305
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
}, "/", "/supplier-payments/:id">;
|
|
309
|
+
//# sourceMappingURL=routes-payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-payments.d.ts","sourceRoot":"","sources":["../src/routes-payments.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAU7C,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAoH7B,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { getActionLedgerRequestContext, getFinanceRouteRuntime } from "./routes-runtime.js";
|
|
4
|
+
import { financeService } from "./service.js";
|
|
5
|
+
import { insertSupplierPaymentSchema, paymentListQuerySchema, supplierPaymentListQuerySchema, updatePaymentSchema, updateSupplierPaymentSchema, } from "./validation.js";
|
|
6
|
+
export const financePaymentRoutes = new Hono()
|
|
7
|
+
// ========================================================================
|
|
8
|
+
// Unified Payments (customer + supplier)
|
|
9
|
+
// ========================================================================
|
|
10
|
+
// GET /payments — List customer + supplier payments
|
|
11
|
+
.get("/payments", async (c) => {
|
|
12
|
+
const query = parseQuery(c, paymentListQuerySchema);
|
|
13
|
+
return c.json(await financeService.listAllPayments(c.get("db"), query));
|
|
14
|
+
})
|
|
15
|
+
// GET /payments/:id — Look up a single payment (customer or supplier)
|
|
16
|
+
// Dispatches by typeid prefix: spay_* → supplier, pay_* → customer.
|
|
17
|
+
.get("/payments/:id", async (c) => {
|
|
18
|
+
const row = await financeService.getPaymentById(c.get("db"), c.req.param("id"));
|
|
19
|
+
if (!row) {
|
|
20
|
+
return c.json({ error: "Payment not found" }, 404);
|
|
21
|
+
}
|
|
22
|
+
return c.json({ data: row });
|
|
23
|
+
})
|
|
24
|
+
// PATCH /payments/:id — Update a customer payment.
|
|
25
|
+
// Recomputes invoice paidCents/balanceDueCents/status from the
|
|
26
|
+
// remaining completed payments after the change.
|
|
27
|
+
.patch("/payments/:id", async (c) => {
|
|
28
|
+
const id = c.req.param("id");
|
|
29
|
+
if (id.startsWith("spay_")) {
|
|
30
|
+
return c.json({ error: "Use /supplier-payments/:id to update supplier payments" }, 400);
|
|
31
|
+
}
|
|
32
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
33
|
+
const row = await financeService.updatePayment(c.get("db"), id, await parseJsonBody(c, updatePaymentSchema), {
|
|
34
|
+
eventBus: runtime?.eventBus,
|
|
35
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
36
|
+
actionLedgerAuthorizationSource: "finance.payment.route",
|
|
37
|
+
});
|
|
38
|
+
if (!row) {
|
|
39
|
+
return c.json({ error: "Payment not found" }, 404);
|
|
40
|
+
}
|
|
41
|
+
return c.json({ data: row });
|
|
42
|
+
})
|
|
43
|
+
// DELETE /payments/:id — Remove a customer payment.
|
|
44
|
+
// Recomputes invoice totals the same way PATCH does, so an
|
|
45
|
+
// accidentally-recorded payment can be reverted without going
|
|
46
|
+
// through a credit note.
|
|
47
|
+
.delete("/payments/:id", async (c) => {
|
|
48
|
+
const id = c.req.param("id");
|
|
49
|
+
if (id.startsWith("spay_")) {
|
|
50
|
+
return c.json({ error: "Use /supplier-payments/:id to delete supplier payments" }, 400);
|
|
51
|
+
}
|
|
52
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
53
|
+
const row = await financeService.deletePayment(c.get("db"), id, {
|
|
54
|
+
eventBus: runtime?.eventBus,
|
|
55
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
56
|
+
actionLedgerAuthorizationSource: "finance.payment.route",
|
|
57
|
+
});
|
|
58
|
+
if (!row) {
|
|
59
|
+
return c.json({ error: "Payment not found" }, 404);
|
|
60
|
+
}
|
|
61
|
+
return c.json({ data: row });
|
|
62
|
+
})
|
|
63
|
+
// ========================================================================
|
|
64
|
+
// Supplier Payments
|
|
65
|
+
// ========================================================================
|
|
66
|
+
// GET /supplier-payments — List supplier payments
|
|
67
|
+
.get("/supplier-payments", async (c) => {
|
|
68
|
+
const query = parseQuery(c, supplierPaymentListQuerySchema);
|
|
69
|
+
return c.json(await financeService.listSupplierPayments(c.get("db"), query));
|
|
70
|
+
})
|
|
71
|
+
// POST /supplier-payments — Record supplier payment
|
|
72
|
+
.post("/supplier-payments", async (c) => {
|
|
73
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
74
|
+
return c.json({
|
|
75
|
+
data: await financeService.createSupplierPayment(c.get("db"), await parseJsonBody(c, insertSupplierPaymentSchema), {
|
|
76
|
+
...(runtime ?? {}),
|
|
77
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
78
|
+
actionLedgerAuthorizationSource: "finance.supplier_payment.route",
|
|
79
|
+
}),
|
|
80
|
+
}, 201);
|
|
81
|
+
})
|
|
82
|
+
// PATCH /supplier-payments/:id — Update supplier payment
|
|
83
|
+
.patch("/supplier-payments/:id", async (c) => {
|
|
84
|
+
const runtime = getFinanceRouteRuntime(c);
|
|
85
|
+
const row = await financeService.updateSupplierPayment(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateSupplierPaymentSchema), {
|
|
86
|
+
...(runtime ?? {}),
|
|
87
|
+
actionLedgerContext: getActionLedgerRequestContext(c),
|
|
88
|
+
actionLedgerAuthorizationSource: "finance.supplier_payment.route",
|
|
89
|
+
});
|
|
90
|
+
if (!row) {
|
|
91
|
+
return c.json({ error: "Supplier payment not found" }, 404);
|
|
92
|
+
}
|
|
93
|
+
return c.json({ data: row });
|
|
94
|
+
});
|