@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.
Files changed (294) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +192 -0
  3. package/dist/action-ledger-drift.d.ts +29 -0
  4. package/dist/action-ledger-drift.d.ts.map +1 -0
  5. package/dist/action-ledger-drift.js +166 -0
  6. package/dist/booking-tax.d.ts +124 -0
  7. package/dist/booking-tax.d.ts.map +1 -0
  8. package/dist/booking-tax.js +264 -0
  9. package/dist/checkout-routes.d.ts +1154 -0
  10. package/dist/checkout-routes.d.ts.map +1 -0
  11. package/dist/checkout-routes.js +116 -0
  12. package/dist/checkout-service-plan.d.ts +137 -0
  13. package/dist/checkout-service-plan.d.ts.map +1 -0
  14. package/dist/checkout-service-plan.js +119 -0
  15. package/dist/checkout-service.d.ts +9 -0
  16. package/dist/checkout-service.d.ts.map +1 -0
  17. package/dist/checkout-service.js +324 -0
  18. package/dist/checkout-validation.d.ts +1682 -0
  19. package/dist/checkout-validation.d.ts.map +1 -0
  20. package/dist/checkout-validation.js +228 -0
  21. package/dist/document-download.d.ts +3 -0
  22. package/dist/document-download.d.ts.map +1 -0
  23. package/dist/document-download.js +1 -0
  24. package/dist/fx-money.d.ts +17 -0
  25. package/dist/fx-money.d.ts.map +1 -0
  26. package/dist/fx-money.js +194 -0
  27. package/dist/index.d.ts +65 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +108 -0
  30. package/dist/invoice-fx.d.ts +134 -0
  31. package/dist/invoice-fx.d.ts.map +1 -0
  32. package/dist/invoice-fx.js +240 -0
  33. package/dist/invoice-number-errors.d.ts +2 -0
  34. package/dist/invoice-number-errors.d.ts.map +1 -0
  35. package/dist/invoice-number-errors.js +58 -0
  36. package/dist/markets-ref.d.ts +149 -0
  37. package/dist/markets-ref.d.ts.map +1 -0
  38. package/dist/markets-ref.js +17 -0
  39. package/dist/payment-link.d.ts +23 -0
  40. package/dist/payment-link.d.ts.map +1 -0
  41. package/dist/payment-link.js +30 -0
  42. package/dist/payment-policy.d.ts +113 -0
  43. package/dist/payment-policy.d.ts.map +1 -0
  44. package/dist/payment-policy.js +193 -0
  45. package/dist/route-runtime.d.ts +22 -0
  46. package/dist/route-runtime.d.ts.map +1 -0
  47. package/dist/route-runtime.js +18 -0
  48. package/dist/routes-action-ledger.d.ts +181 -0
  49. package/dist/routes-action-ledger.d.ts.map +1 -0
  50. package/dist/routes-action-ledger.js +142 -0
  51. package/dist/routes-booking-billing.d.ts +852 -0
  52. package/dist/routes-booking-billing.d.ts.map +1 -0
  53. package/dist/routes-booking-billing.js +223 -0
  54. package/dist/routes-booking-create.d.ts +3 -0
  55. package/dist/routes-booking-create.d.ts.map +1 -0
  56. package/dist/routes-booking-create.js +194 -0
  57. package/dist/routes-booking-reads.d.ts +46 -0
  58. package/dist/routes-booking-reads.d.ts.map +1 -0
  59. package/dist/routes-booking-reads.js +20 -0
  60. package/dist/routes-documents.d.ts +195 -0
  61. package/dist/routes-documents.d.ts.map +1 -0
  62. package/dist/routes-documents.js +93 -0
  63. package/dist/routes-invoice-core.d.ts +794 -0
  64. package/dist/routes-invoice-core.d.ts.map +1 -0
  65. package/dist/routes-invoice-core.js +238 -0
  66. package/dist/routes-invoice-documents.d.ts +401 -0
  67. package/dist/routes-invoice-documents.d.ts.map +1 -0
  68. package/dist/routes-invoice-documents.js +91 -0
  69. package/dist/routes-invoice-issue.d.ts +384 -0
  70. package/dist/routes-invoice-issue.d.ts.map +1 -0
  71. package/dist/routes-invoice-issue.js +208 -0
  72. package/dist/routes-payment-processing.d.ts +1193 -0
  73. package/dist/routes-payment-processing.d.ts.map +1 -0
  74. package/dist/routes-payment-processing.js +238 -0
  75. package/dist/routes-payments.d.ts +309 -0
  76. package/dist/routes-payments.d.ts.map +1 -0
  77. package/dist/routes-payments.js +94 -0
  78. package/dist/routes-public.d.ts +1948 -0
  79. package/dist/routes-public.d.ts.map +1 -0
  80. package/dist/routes-public.js +275 -0
  81. package/dist/routes-reference-data.d.ts +977 -0
  82. package/dist/routes-reference-data.d.ts.map +1 -0
  83. package/dist/routes-reference-data.js +191 -0
  84. package/dist/routes-reports.d.ts +344 -0
  85. package/dist/routes-reports.d.ts.map +1 -0
  86. package/dist/routes-reports.js +93 -0
  87. package/dist/routes-runtime.d.ts +71 -0
  88. package/dist/routes-runtime.d.ts.map +1 -0
  89. package/dist/routes-runtime.js +59 -0
  90. package/dist/routes-settlement.d.ts +67 -0
  91. package/dist/routes-settlement.d.ts.map +1 -0
  92. package/dist/routes-settlement.js +23 -0
  93. package/dist/routes-shared.d.ts +35 -0
  94. package/dist/routes-shared.d.ts.map +1 -0
  95. package/dist/routes-shared.js +10 -0
  96. package/dist/routes-supplier-invoices.d.ts +778 -0
  97. package/dist/routes-supplier-invoices.d.ts.map +1 -0
  98. package/dist/routes-supplier-invoices.js +159 -0
  99. package/dist/routes-vouchers.d.ts +228 -0
  100. package/dist/routes-vouchers.d.ts.map +1 -0
  101. package/dist/routes-vouchers.js +54 -0
  102. package/dist/routes.d.ts +5577 -0
  103. package/dist/routes.d.ts.map +1 -0
  104. package/dist/routes.js +44 -0
  105. package/dist/schema/booking-billing.d.ts +1006 -0
  106. package/dist/schema/booking-billing.d.ts.map +1 -0
  107. package/dist/schema/booking-billing.js +106 -0
  108. package/dist/schema/enums.d.ts +48 -0
  109. package/dist/schema/enums.d.ts.map +1 -0
  110. package/dist/schema/enums.js +237 -0
  111. package/dist/schema/invoice-documents.d.ts +1245 -0
  112. package/dist/schema/invoice-documents.d.ts.map +1 -0
  113. package/dist/schema/invoice-documents.js +140 -0
  114. package/dist/schema/payment-instruments.d.ts +418 -0
  115. package/dist/schema/payment-instruments.d.ts.map +1 -0
  116. package/dist/schema/payment-instruments.js +45 -0
  117. package/dist/schema/payment-processing.d.ts +563 -0
  118. package/dist/schema/payment-processing.d.ts.map +1 -0
  119. package/dist/schema/payment-processing.js +65 -0
  120. package/dist/schema/payment-sessions.d.ts +728 -0
  121. package/dist/schema/payment-sessions.d.ts.map +1 -0
  122. package/dist/schema/payment-sessions.js +79 -0
  123. package/dist/schema/receivables.d.ts +1474 -0
  124. package/dist/schema/receivables.d.ts.map +1 -0
  125. package/dist/schema/receivables.js +179 -0
  126. package/dist/schema/relations.d.ts +82 -0
  127. package/dist/schema/relations.d.ts.map +1 -0
  128. package/dist/schema/relations.js +144 -0
  129. package/dist/schema/supplier-invoices.d.ts +1619 -0
  130. package/dist/schema/supplier-invoices.d.ts.map +1 -0
  131. package/dist/schema/supplier-invoices.js +228 -0
  132. package/dist/schema/tax.d.ts +712 -0
  133. package/dist/schema/tax.d.ts.map +1 -0
  134. package/dist/schema/tax.js +98 -0
  135. package/dist/schema/vouchers.d.ts +444 -0
  136. package/dist/schema/vouchers.d.ts.map +1 -0
  137. package/dist/schema/vouchers.js +64 -0
  138. package/dist/schema.d.ts +12 -0
  139. package/dist/schema.d.ts.map +1 -0
  140. package/dist/schema.js +11 -0
  141. package/dist/service-accountant-shares.d.ts +106 -0
  142. package/dist/service-accountant-shares.d.ts.map +1 -0
  143. package/dist/service-accountant-shares.js +331 -0
  144. package/dist/service-action-ledger-accounting.d.ts +104 -0
  145. package/dist/service-action-ledger-accounting.d.ts.map +1 -0
  146. package/dist/service-action-ledger-accounting.js +386 -0
  147. package/dist/service-action-ledger-booking-payments.d.ts +48 -0
  148. package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
  149. package/dist/service-action-ledger-booking-payments.js +178 -0
  150. package/dist/service-action-ledger-bookings.d.ts +44 -0
  151. package/dist/service-action-ledger-bookings.d.ts.map +1 -0
  152. package/dist/service-action-ledger-bookings.js +81 -0
  153. package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
  154. package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
  155. package/dist/service-action-ledger-payment-authorizations.js +209 -0
  156. package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
  157. package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
  158. package/dist/service-action-ledger-payment-sessions.js +294 -0
  159. package/dist/service-action-ledger-supplier-invoices.d.ts +27 -0
  160. package/dist/service-action-ledger-supplier-invoices.d.ts.map +1 -0
  161. package/dist/service-action-ledger-supplier-invoices.js +111 -0
  162. package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
  163. package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
  164. package/dist/service-action-ledger-supplier-payments.js +97 -0
  165. package/dist/service-action-ledger.d.ts +7 -0
  166. package/dist/service-action-ledger.d.ts.map +1 -0
  167. package/dist/service-action-ledger.js +6 -0
  168. package/dist/service-aggregates.d.ts +96 -0
  169. package/dist/service-aggregates.d.ts.map +1 -0
  170. package/dist/service-aggregates.js +294 -0
  171. package/dist/service-booking-billing.d.ts +2322 -0
  172. package/dist/service-booking-billing.d.ts.map +1 -0
  173. package/dist/service-booking-billing.js +8 -0
  174. package/dist/service-booking-create.d.ts +410 -0
  175. package/dist/service-booking-create.d.ts.map +1 -0
  176. package/dist/service-booking-create.js +1256 -0
  177. package/dist/service-booking-guarantees.d.ts +725 -0
  178. package/dist/service-booking-guarantees.d.ts.map +1 -0
  179. package/dist/service-booking-guarantees.js +153 -0
  180. package/dist/service-booking-item-billing.d.ts +1062 -0
  181. package/dist/service-booking-item-billing.d.ts.map +1 -0
  182. package/dist/service-booking-item-billing.js +77 -0
  183. package/dist/service-booking-payment-schedules.d.ts +557 -0
  184. package/dist/service-booking-payment-schedules.d.ts.map +1 -0
  185. package/dist/service-booking-payment-schedules.js +372 -0
  186. package/dist/service-bookings-dual-create.d.ts +308 -0
  187. package/dist/service-bookings-dual-create.d.ts.map +1 -0
  188. package/dist/service-bookings-dual-create.js +131 -0
  189. package/dist/service-boundary-sql.d.ts +6 -0
  190. package/dist/service-boundary-sql.d.ts.map +1 -0
  191. package/dist/service-boundary-sql.js +15 -0
  192. package/dist/service-cost-categories.d.ts +26 -0
  193. package/dist/service-cost-categories.d.ts.map +1 -0
  194. package/dist/service-cost-categories.js +76 -0
  195. package/dist/service-documents.d.ts +80 -0
  196. package/dist/service-documents.d.ts.map +1 -0
  197. package/dist/service-documents.js +228 -0
  198. package/dist/service-invoice-artifacts.d.ts +246 -0
  199. package/dist/service-invoice-artifacts.d.ts.map +1 -0
  200. package/dist/service-invoice-artifacts.js +277 -0
  201. package/dist/service-invoice-core.d.ts +405 -0
  202. package/dist/service-invoice-core.d.ts.map +1 -0
  203. package/dist/service-invoice-core.js +290 -0
  204. package/dist/service-invoice-credit-notes.d.ts +973 -0
  205. package/dist/service-invoice-credit-notes.d.ts.map +1 -0
  206. package/dist/service-invoice-credit-notes.js +142 -0
  207. package/dist/service-invoice-from-booking.d.ts +41 -0
  208. package/dist/service-invoice-from-booking.d.ts.map +1 -0
  209. package/dist/service-invoice-from-booking.js +267 -0
  210. package/dist/service-invoice-line-items.d.ts +432 -0
  211. package/dist/service-invoice-line-items.d.ts.map +1 -0
  212. package/dist/service-invoice-line-items.js +102 -0
  213. package/dist/service-invoice-numbering.d.ts +227 -0
  214. package/dist/service-invoice-numbering.d.ts.map +1 -0
  215. package/dist/service-invoice-numbering.js +260 -0
  216. package/dist/service-invoice-payments.d.ts +673 -0
  217. package/dist/service-invoice-payments.d.ts.map +1 -0
  218. package/dist/service-invoice-payments.js +398 -0
  219. package/dist/service-invoices.d.ts +2501 -0
  220. package/dist/service-invoices.d.ts.map +1 -0
  221. package/dist/service-invoices.js +12 -0
  222. package/dist/service-issue.d.ts +207 -0
  223. package/dist/service-issue.d.ts.map +1 -0
  224. package/dist/service-issue.js +431 -0
  225. package/dist/service-payment-authorizations.d.ts +164 -0
  226. package/dist/service-payment-authorizations.d.ts.map +1 -0
  227. package/dist/service-payment-authorizations.js +227 -0
  228. package/dist/service-payment-instruments.d.ts +116 -0
  229. package/dist/service-payment-instruments.d.ts.map +1 -0
  230. package/dist/service-payment-instruments.js +99 -0
  231. package/dist/service-payment-processing.d.ts +676 -0
  232. package/dist/service-payment-processing.d.ts.map +1 -0
  233. package/dist/service-payment-processing.js +10 -0
  234. package/dist/service-payment-session-completion.d.ts +48 -0
  235. package/dist/service-payment-session-completion.d.ts.map +1 -0
  236. package/dist/service-payment-session-completion.js +238 -0
  237. package/dist/service-payment-sessions.d.ts +361 -0
  238. package/dist/service-payment-sessions.d.ts.map +1 -0
  239. package/dist/service-payment-sessions.js +280 -0
  240. package/dist/service-profitability.d.ts +114 -0
  241. package/dist/service-profitability.d.ts.map +1 -0
  242. package/dist/service-profitability.js +794 -0
  243. package/dist/service-public.d.ts +553 -0
  244. package/dist/service-public.d.ts.map +1 -0
  245. package/dist/service-public.js +583 -0
  246. package/dist/service-reference-data.d.ts +272 -0
  247. package/dist/service-reference-data.d.ts.map +1 -0
  248. package/dist/service-reference-data.js +280 -0
  249. package/dist/service-rendition-wait.d.ts +38 -0
  250. package/dist/service-rendition-wait.d.ts.map +1 -0
  251. package/dist/service-rendition-wait.js +67 -0
  252. package/dist/service-reports.d.ts +37 -0
  253. package/dist/service-reports.d.ts.map +1 -0
  254. package/dist/service-reports.js +62 -0
  255. package/dist/service-settlement.d.ts +46 -0
  256. package/dist/service-settlement.d.ts.map +1 -0
  257. package/dist/service-settlement.js +185 -0
  258. package/dist/service-shared.d.ts +541 -0
  259. package/dist/service-shared.d.ts.map +1 -0
  260. package/dist/service-shared.js +764 -0
  261. package/dist/service-supplier-invoices.d.ts +871 -0
  262. package/dist/service-supplier-invoices.d.ts.map +1 -0
  263. package/dist/service-supplier-invoices.js +744 -0
  264. package/dist/service-supplier-payments.d.ts +69 -0
  265. package/dist/service-supplier-payments.d.ts.map +1 -0
  266. package/dist/service-supplier-payments.js +136 -0
  267. package/dist/service-vouchers-migration.d.ts +44 -0
  268. package/dist/service-vouchers-migration.d.ts.map +1 -0
  269. package/dist/service-vouchers-migration.js +148 -0
  270. package/dist/service-vouchers.d.ts +157 -0
  271. package/dist/service-vouchers.d.ts.map +1 -0
  272. package/dist/service-vouchers.js +191 -0
  273. package/dist/service.d.ts +6490 -0
  274. package/dist/service.d.ts.map +1 -0
  275. package/dist/service.js +29 -0
  276. package/dist/validation-billing.d.ts +2 -0
  277. package/dist/validation-billing.d.ts.map +1 -0
  278. package/dist/validation-billing.js +1 -0
  279. package/dist/validation-payments.d.ts +2 -0
  280. package/dist/validation-payments.d.ts.map +1 -0
  281. package/dist/validation-payments.js +1 -0
  282. package/dist/validation-public.d.ts +2 -0
  283. package/dist/validation-public.d.ts.map +1 -0
  284. package/dist/validation-public.js +1 -0
  285. package/dist/validation-shared.d.ts +2 -0
  286. package/dist/validation-shared.d.ts.map +1 -0
  287. package/dist/validation-shared.js +1 -0
  288. package/dist/validation-vouchers.d.ts +2 -0
  289. package/dist/validation-vouchers.d.ts.map +1 -0
  290. package/dist/validation-vouchers.js +1 -0
  291. package/dist/validation.d.ts +2 -0
  292. package/dist/validation.d.ts.map +1 -0
  293. package/dist/validation.js +1 -0
  294. 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
+ });