@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-invoice-core.d.ts","sourceRoot":"","sources":["../src/routes-invoice-core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAe7C,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA+UjC,CAAA"}
@@ -0,0 +1,238 @@
1
+ import { parseJsonBody, parseOptionalJsonBody, requireUserId } 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 { createPaymentSessionFromInvoiceSchema, insertCreditNoteLineItemSchema, insertCreditNoteSchema, insertFinanceNoteSchema, insertInvoiceLineItemSchema, insertPaymentSchema, updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceSchema, voidInvoiceSchema, } from "./validation.js";
6
+ export const financeInvoiceCoreRoutes = new Hono()
7
+ // GET /invoices/:id — Get single invoice // GET /invoices/:id — Get single invoice
8
+ .get("/invoices/:id", async (c) => {
9
+ const row = await financeService.getInvoiceById(c.get("db"), c.req.param("id"));
10
+ if (!row) {
11
+ return c.json({ error: "Invoice not found" }, 404);
12
+ }
13
+ return c.json({ data: row });
14
+ })
15
+ // PATCH /invoices/:id — Update invoice
16
+ .patch("/invoices/:id", async (c) => {
17
+ const runtime = getFinanceRouteRuntime(c);
18
+ const row = await financeService.updateInvoice(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateInvoiceSchema), {
19
+ eventBus: runtime?.eventBus,
20
+ actionLedgerContext: getActionLedgerRequestContext(c),
21
+ actionLedgerAuthorizationSource: "finance.invoice.route",
22
+ });
23
+ if (!row) {
24
+ return c.json({ error: "Invoice not found" }, 404);
25
+ }
26
+ return c.json({ data: row });
27
+ })
28
+ // DELETE /invoices/:id — Delete invoice (draft only)
29
+ .delete("/invoices/:id", async (c) => {
30
+ const runtime = getFinanceRouteRuntime(c);
31
+ const result = await financeService.deleteInvoice(c.get("db"), c.req.param("id"), {
32
+ eventBus: runtime?.eventBus,
33
+ actionLedgerContext: getActionLedgerRequestContext(c),
34
+ actionLedgerAuthorizationSource: "finance.invoice.route",
35
+ });
36
+ if (result.status === "not_found") {
37
+ return c.json({ error: "Invoice not found" }, 404);
38
+ }
39
+ if (result.status === "not_draft") {
40
+ return c.json({ error: "Only draft invoices can be deleted" }, 400);
41
+ }
42
+ return c.json({ success: true }, 200);
43
+ })
44
+ // POST /invoices/:id/void — Void an issued invoice without deleting audit history.
45
+ .post("/invoices/:id/void", async (c) => {
46
+ const runtime = getFinanceRouteRuntime(c);
47
+ const result = await financeService.voidInvoice(c.get("db"), c.req.param("id"), await parseOptionalJsonBody(c, voidInvoiceSchema), {
48
+ eventBus: runtime?.eventBus,
49
+ actionLedgerContext: getActionLedgerRequestContext(c),
50
+ actionLedgerAuthorizationSource: "finance.invoice.route",
51
+ });
52
+ if (result.status === "not_found") {
53
+ return c.json({ error: "Invoice not found" }, 404);
54
+ }
55
+ if (result.status === "already_void") {
56
+ return c.json({ error: "Invoice is already void" }, 409);
57
+ }
58
+ if (result.status === "draft") {
59
+ return c.json({ error: "Draft invoices can be deleted instead" }, 400);
60
+ }
61
+ if (result.status === "invalid_status") {
62
+ return c.json({ error: "Invoice cannot be voided from its current status" }, 409);
63
+ }
64
+ if (result.status === "has_payments") {
65
+ return c.json({ error: "Invoices with payments cannot be voided" }, 409);
66
+ }
67
+ if (result.status === "has_credit_notes") {
68
+ return c.json({ error: "Invoices with credit notes cannot be voided" }, 409);
69
+ }
70
+ return c.json({ data: result.invoice }, 200);
71
+ })
72
+ .post("/invoices/:id/payment-session", async (c) => {
73
+ try {
74
+ const runtime = getFinanceRouteRuntime(c);
75
+ const row = await financeService.createPaymentSessionFromInvoice(c.get("db"), c.req.param("id"), await parseJsonBody(c, createPaymentSessionFromInvoiceSchema), {
76
+ eventBus: runtime?.eventBus,
77
+ actionLedgerContext: getActionLedgerRequestContext(c),
78
+ actionLedgerAuthorizationSource: "finance.payment_session.route",
79
+ });
80
+ if (!row) {
81
+ return c.json({ error: "Invoice not found" }, 404);
82
+ }
83
+ return c.json({ data: row }, 201);
84
+ }
85
+ catch (error) {
86
+ const message = error instanceof Error ? error.message : "Unable to create payment session";
87
+ return c.json({ error: message }, 409);
88
+ }
89
+ })
90
+ // ========================================================================
91
+ // Invoice Line Items
92
+ // ========================================================================
93
+ // GET /invoices/:id/line-items — List line items
94
+ .get("/invoices/:id/line-items", async (c) => {
95
+ return c.json({
96
+ data: await financeService.listInvoiceLineItems(c.get("db"), c.req.param("id")),
97
+ });
98
+ })
99
+ // POST /invoices/:id/line-items — Add line item
100
+ .post("/invoices/:id/line-items", async (c) => {
101
+ const runtime = getFinanceRouteRuntime(c);
102
+ const row = await financeService.createInvoiceLineItem(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertInvoiceLineItemSchema), {
103
+ eventBus: runtime?.eventBus,
104
+ actionLedgerContext: getActionLedgerRequestContext(c),
105
+ actionLedgerAuthorizationSource: "finance.invoice_line_item.route",
106
+ });
107
+ if (!row) {
108
+ return c.json({ error: "Invoice not found" }, 404);
109
+ }
110
+ return c.json({ data: row }, 201);
111
+ })
112
+ // PATCH /invoices/:id/line-items/:lineId — Update line item
113
+ .patch("/invoices/:id/line-items/:lineId", async (c) => {
114
+ const runtime = getFinanceRouteRuntime(c);
115
+ const row = await financeService.updateInvoiceLineItem(c.get("db"), c.req.param("lineId"), await parseJsonBody(c, updateInvoiceLineItemSchema), {
116
+ eventBus: runtime?.eventBus,
117
+ actionLedgerContext: getActionLedgerRequestContext(c),
118
+ actionLedgerAuthorizationSource: "finance.invoice_line_item.route",
119
+ });
120
+ if (!row) {
121
+ return c.json({ error: "Line item not found" }, 404);
122
+ }
123
+ return c.json({ data: row });
124
+ })
125
+ // DELETE /invoices/:id/line-items/:lineId — Delete line item
126
+ .delete("/invoices/:id/line-items/:lineId", async (c) => {
127
+ const runtime = getFinanceRouteRuntime(c);
128
+ const row = await financeService.deleteInvoiceLineItem(c.get("db"), c.req.param("lineId"), {
129
+ eventBus: runtime?.eventBus,
130
+ actionLedgerContext: getActionLedgerRequestContext(c),
131
+ actionLedgerAuthorizationSource: "finance.invoice_line_item.route",
132
+ });
133
+ if (!row) {
134
+ return c.json({ error: "Line item not found" }, 404);
135
+ }
136
+ return c.json({ success: true }, 200);
137
+ })
138
+ // ========================================================================
139
+ // Payments
140
+ // ========================================================================
141
+ // GET /invoices/:id/payments — List payments
142
+ .get("/invoices/:id/payments", async (c) => {
143
+ return c.json({ data: await financeService.listPayments(c.get("db"), c.req.param("id")) });
144
+ })
145
+ // POST /invoices/:id/payments — Record payment (transaction)
146
+ .post("/invoices/:id/payments", async (c) => {
147
+ try {
148
+ const runtime = getFinanceRouteRuntime(c);
149
+ const row = await financeService.createPayment(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertPaymentSchema), {
150
+ ...(runtime ?? {}),
151
+ actionLedgerContext: getActionLedgerRequestContext(c),
152
+ actionLedgerAuthorizationSource: "finance.payment.route",
153
+ });
154
+ if (!row) {
155
+ return c.json({ error: "Invoice not found" }, 404);
156
+ }
157
+ return c.json({ data: row }, 201);
158
+ }
159
+ catch (error) {
160
+ if (error instanceof PaymentValidationError) {
161
+ return c.json({ error: error.message, code: error.code, details: error.details }, error.status);
162
+ }
163
+ throw error;
164
+ }
165
+ })
166
+ // ========================================================================
167
+ // Credit Notes
168
+ // ========================================================================
169
+ // GET /invoices/:id/credit-notes — List credit notes
170
+ .get("/invoices/:id/credit-notes", async (c) => {
171
+ return c.json({
172
+ data: await financeService.listCreditNotes(c.get("db"), c.req.param("id")),
173
+ });
174
+ })
175
+ // POST /invoices/:id/credit-notes — Create credit note
176
+ .post("/invoices/:id/credit-notes", async (c) => {
177
+ const runtime = getFinanceRouteRuntime(c);
178
+ const row = await financeService.createCreditNote(c.get("db"), c.req.param("id"), await parseJsonBody(c, insertCreditNoteSchema), {
179
+ ...(runtime ?? {}),
180
+ actionLedgerContext: getActionLedgerRequestContext(c),
181
+ actionLedgerAuthorizationSource: "finance.credit_note.route",
182
+ });
183
+ if (!row) {
184
+ return c.json({ error: "Invoice not found" }, 404);
185
+ }
186
+ return c.json({ data: row }, 201);
187
+ })
188
+ // PATCH /invoices/:id/credit-notes/:creditNoteId — Update credit note
189
+ .patch("/invoices/:id/credit-notes/:creditNoteId", async (c) => {
190
+ const runtime = getFinanceRouteRuntime(c);
191
+ const row = await financeService.updateCreditNote(c.get("db"), c.req.param("creditNoteId"), await parseJsonBody(c, updateCreditNoteSchema), {
192
+ ...(runtime ?? {}),
193
+ actionLedgerContext: getActionLedgerRequestContext(c),
194
+ actionLedgerAuthorizationSource: "finance.credit_note.route",
195
+ });
196
+ if (!row) {
197
+ return c.json({ error: "Credit note not found" }, 404);
198
+ }
199
+ return c.json({ data: row });
200
+ })
201
+ // ========================================================================
202
+ // Credit Note Line Items
203
+ // ========================================================================
204
+ // GET /invoices/:id/credit-notes/:creditNoteId/line-items — List credit note line items
205
+ .get("/invoices/:id/credit-notes/:creditNoteId/line-items", async (c) => {
206
+ return c.json({
207
+ data: await financeService.listCreditNoteLineItems(c.get("db"), c.req.param("creditNoteId")),
208
+ });
209
+ })
210
+ // POST /invoices/:id/credit-notes/:creditNoteId/line-items — Add credit note line item
211
+ .post("/invoices/:id/credit-notes/:creditNoteId/line-items", async (c) => {
212
+ const runtime = getFinanceRouteRuntime(c);
213
+ const row = await financeService.createCreditNoteLineItem(c.get("db"), c.req.param("creditNoteId"), await parseJsonBody(c, insertCreditNoteLineItemSchema), {
214
+ eventBus: runtime?.eventBus,
215
+ actionLedgerContext: getActionLedgerRequestContext(c),
216
+ actionLedgerAuthorizationSource: "finance.credit_note_line_item.route",
217
+ });
218
+ if (!row) {
219
+ return c.json({ error: "Credit note not found" }, 404);
220
+ }
221
+ return c.json({ data: row }, 201);
222
+ })
223
+ // ========================================================================
224
+ // Finance Notes
225
+ // ========================================================================
226
+ // GET /invoices/:id/notes — List notes
227
+ .get("/invoices/:id/notes", async (c) => {
228
+ return c.json({ data: await financeService.listNotes(c.get("db"), c.req.param("id")) });
229
+ })
230
+ // POST /invoices/:id/notes — Add note
231
+ .post("/invoices/:id/notes", async (c) => {
232
+ const userId = requireUserId(c);
233
+ const row = await financeService.createNote(c.get("db"), c.req.param("id"), userId, await parseJsonBody(c, insertFinanceNoteSchema));
234
+ if (!row) {
235
+ return c.json({ error: "Invoice not found" }, 404);
236
+ }
237
+ return c.json({ data: row }, 201);
238
+ });
@@ -0,0 +1,401 @@
1
+ import type { Env } from "./routes-shared.js";
2
+ export declare const financeInvoiceDocumentRoutes: import("hono/hono-base").HonoBase<Env, {
3
+ "/invoices/:id/renditions": {
4
+ $get: {
5
+ input: {
6
+ param: {
7
+ id: string;
8
+ };
9
+ };
10
+ output: {
11
+ data: {
12
+ id: string;
13
+ invoiceId: string;
14
+ templateId: string | null;
15
+ format: "json" | "html" | "pdf" | "xml";
16
+ status: "failed" | "pending" | "ready" | "stale";
17
+ storageKey: string | null;
18
+ fileSize: number | null;
19
+ checksum: string | null;
20
+ language: string | null;
21
+ errorMessage: string | null;
22
+ generatedAt: string | null;
23
+ metadata: import("hono/utils/types").JSONValue;
24
+ createdAt: string;
25
+ updatedAt: string;
26
+ }[];
27
+ };
28
+ outputFormat: "json";
29
+ status: import("hono/utils/http-status").ContentfulStatusCode;
30
+ };
31
+ };
32
+ } & {
33
+ "/invoices/:id/attachments": {
34
+ $get: {
35
+ input: {
36
+ param: {
37
+ id: string;
38
+ };
39
+ };
40
+ output: {
41
+ data: {
42
+ id: string;
43
+ invoiceId: string;
44
+ kind: string;
45
+ name: string;
46
+ mimeType: string | null;
47
+ fileSize: number | null;
48
+ storageKey: string | null;
49
+ checksum: string | null;
50
+ metadata: import("hono/utils/types").JSONValue;
51
+ createdAt: string;
52
+ }[];
53
+ };
54
+ outputFormat: "json";
55
+ status: import("hono/utils/http-status").ContentfulStatusCode;
56
+ };
57
+ };
58
+ } & {
59
+ "/invoices/:id/attachments": {
60
+ $post: {
61
+ input: {
62
+ param: {
63
+ id: string;
64
+ };
65
+ };
66
+ output: {
67
+ error: string;
68
+ };
69
+ outputFormat: "json";
70
+ status: 404;
71
+ } | {
72
+ input: {
73
+ param: {
74
+ id: string;
75
+ };
76
+ };
77
+ output: {
78
+ data: {
79
+ id: string;
80
+ name: string;
81
+ createdAt: string;
82
+ metadata: import("hono/utils/types").JSONValue;
83
+ invoiceId: string;
84
+ kind: string;
85
+ storageKey: string | null;
86
+ fileSize: number | null;
87
+ checksum: string | null;
88
+ mimeType: string | null;
89
+ };
90
+ };
91
+ outputFormat: "json";
92
+ status: 201;
93
+ };
94
+ };
95
+ } & {
96
+ "/invoices/:id/attachments/:attachmentId": {
97
+ $patch: {
98
+ input: {
99
+ param: {
100
+ id: string;
101
+ } & {
102
+ attachmentId: string;
103
+ };
104
+ };
105
+ output: {
106
+ error: string;
107
+ };
108
+ outputFormat: "json";
109
+ status: 404;
110
+ } | {
111
+ input: {
112
+ param: {
113
+ id: string;
114
+ } & {
115
+ attachmentId: string;
116
+ };
117
+ };
118
+ output: {
119
+ data: {
120
+ id: string;
121
+ invoiceId: string;
122
+ kind: string;
123
+ name: string;
124
+ mimeType: string | null;
125
+ fileSize: number | null;
126
+ storageKey: string | null;
127
+ checksum: string | null;
128
+ metadata: import("hono/utils/types").JSONValue;
129
+ createdAt: string;
130
+ };
131
+ };
132
+ outputFormat: "json";
133
+ status: import("hono/utils/http-status").ContentfulStatusCode;
134
+ };
135
+ };
136
+ } & {
137
+ "/invoice-attachments/:id/download": {
138
+ $get: {
139
+ input: {
140
+ param: {
141
+ id: string;
142
+ };
143
+ };
144
+ output: {
145
+ error: string;
146
+ };
147
+ outputFormat: "json";
148
+ status: 404;
149
+ } | {
150
+ input: {
151
+ param: {
152
+ id: string;
153
+ };
154
+ };
155
+ output: {
156
+ error: string;
157
+ };
158
+ outputFormat: "json";
159
+ status: 501;
160
+ } | {
161
+ input: {
162
+ param: {
163
+ id: string;
164
+ };
165
+ };
166
+ output: undefined;
167
+ outputFormat: "redirect";
168
+ status: 302;
169
+ };
170
+ };
171
+ } & {
172
+ "/invoices/:id/attachments/:attachmentId": {
173
+ $delete: {
174
+ input: {
175
+ param: {
176
+ id: string;
177
+ } & {
178
+ attachmentId: string;
179
+ };
180
+ };
181
+ output: {
182
+ error: string;
183
+ };
184
+ outputFormat: "json";
185
+ status: 404;
186
+ } | {
187
+ input: {
188
+ param: {
189
+ id: string;
190
+ } & {
191
+ attachmentId: string;
192
+ };
193
+ };
194
+ output: {
195
+ success: true;
196
+ };
197
+ outputFormat: "json";
198
+ status: import("hono/utils/http-status").ContentfulStatusCode;
199
+ };
200
+ };
201
+ } & {
202
+ "/invoices/:id/render": {
203
+ $post: {
204
+ input: {
205
+ param: {
206
+ id: string;
207
+ };
208
+ };
209
+ output: {
210
+ error: string;
211
+ };
212
+ outputFormat: "json";
213
+ status: 404;
214
+ } | {
215
+ input: {
216
+ param: {
217
+ id: string;
218
+ };
219
+ };
220
+ output: {
221
+ data: {
222
+ rendition: {
223
+ format: "json" | "html" | "pdf" | "xml";
224
+ id: string;
225
+ createdAt: string;
226
+ updatedAt: string;
227
+ metadata: import("hono/utils/types").JSONValue;
228
+ status: "failed" | "pending" | "ready" | "stale";
229
+ errorMessage: string | null;
230
+ invoiceId: string;
231
+ templateId: string | null;
232
+ language: string | null;
233
+ storageKey: string | null;
234
+ fileSize: number | null;
235
+ checksum: string | null;
236
+ generatedAt: string | null;
237
+ };
238
+ };
239
+ };
240
+ outputFormat: "json";
241
+ status: 202;
242
+ } | {
243
+ input: {
244
+ param: {
245
+ id: string;
246
+ };
247
+ };
248
+ output: {
249
+ data: {
250
+ download: {
251
+ url: string;
252
+ expiresAt: string | null;
253
+ filename: string | null;
254
+ };
255
+ rendition: {
256
+ format: "json" | "html" | "pdf" | "xml";
257
+ id: string;
258
+ createdAt: string;
259
+ updatedAt: string;
260
+ metadata: import("hono/utils/types").JSONValue;
261
+ status: "failed" | "pending" | "ready" | "stale";
262
+ errorMessage: string | null;
263
+ invoiceId: string;
264
+ templateId: string | null;
265
+ language: string | null;
266
+ storageKey: string | null;
267
+ fileSize: number | null;
268
+ checksum: string | null;
269
+ generatedAt: string | null;
270
+ };
271
+ };
272
+ };
273
+ outputFormat: "json";
274
+ status: 201;
275
+ } | {
276
+ input: {
277
+ param: {
278
+ id: string;
279
+ };
280
+ };
281
+ output: {
282
+ data: {
283
+ format: "json" | "html" | "pdf" | "xml";
284
+ id: string;
285
+ createdAt: string;
286
+ updatedAt: string;
287
+ metadata: import("hono/utils/types").JSONValue;
288
+ status: "failed" | "pending" | "ready" | "stale";
289
+ errorMessage: string | null;
290
+ invoiceId: string;
291
+ templateId: string | null;
292
+ language: string | null;
293
+ storageKey: string | null;
294
+ fileSize: number | null;
295
+ checksum: string | null;
296
+ generatedAt: string | null;
297
+ } | null;
298
+ };
299
+ outputFormat: "json";
300
+ status: 201;
301
+ };
302
+ };
303
+ } & {
304
+ "/invoices/:id/external-refs": {
305
+ $get: {
306
+ input: {
307
+ param: {
308
+ id: string;
309
+ };
310
+ };
311
+ output: {
312
+ data: {
313
+ id: string;
314
+ invoiceId: string;
315
+ provider: string;
316
+ externalId: string | null;
317
+ externalNumber: string | null;
318
+ externalUrl: string | null;
319
+ status: string | null;
320
+ metadata: import("hono/utils/types").JSONValue;
321
+ syncedAt: string | null;
322
+ syncError: string | null;
323
+ createdAt: string;
324
+ updatedAt: string;
325
+ }[];
326
+ };
327
+ outputFormat: "json";
328
+ status: import("hono/utils/http-status").ContentfulStatusCode;
329
+ };
330
+ };
331
+ } & {
332
+ "/invoices/:id/external-refs": {
333
+ $post: {
334
+ input: {
335
+ param: {
336
+ id: string;
337
+ };
338
+ };
339
+ output: {
340
+ error: string;
341
+ };
342
+ outputFormat: "json";
343
+ status: 404;
344
+ } | {
345
+ input: {
346
+ param: {
347
+ id: string;
348
+ };
349
+ };
350
+ output: {
351
+ data: {
352
+ id: string;
353
+ createdAt: string;
354
+ updatedAt: string;
355
+ metadata: import("hono/utils/types").JSONValue;
356
+ status: string | null;
357
+ provider: string;
358
+ invoiceId: string;
359
+ externalId: string | null;
360
+ externalNumber: string | null;
361
+ externalUrl: string | null;
362
+ syncedAt: string | null;
363
+ syncError: string | null;
364
+ };
365
+ };
366
+ outputFormat: "json";
367
+ status: 201;
368
+ };
369
+ };
370
+ } & {
371
+ "/invoices/:id/external-refs/:refId": {
372
+ $delete: {
373
+ input: {
374
+ param: {
375
+ id: string;
376
+ } & {
377
+ refId: string;
378
+ };
379
+ };
380
+ output: {
381
+ error: string;
382
+ };
383
+ outputFormat: "json";
384
+ status: 404;
385
+ } | {
386
+ input: {
387
+ param: {
388
+ id: string;
389
+ } & {
390
+ refId: string;
391
+ };
392
+ };
393
+ output: {
394
+ success: true;
395
+ };
396
+ outputFormat: "json";
397
+ status: import("hono/utils/http-status").ContentfulStatusCode;
398
+ };
399
+ };
400
+ }, "/", "/invoices/:id/external-refs/:refId">;
401
+ //# sourceMappingURL=routes-invoice-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-invoice-documents.d.ts","sourceRoot":"","sources":["../src/routes-invoice-documents.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAW7C,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CA6GrC,CAAA"}