@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-reference-data.d.ts","sourceRoot":"","sources":["../src/routes-reference-data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAuB7C,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAuPnC,CAAA"}
@@ -0,0 +1,191 @@
1
+ import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
2
+ import { Hono } from "hono";
3
+ import { financeService } from "./service.js";
4
+ import { insertInvoiceNumberSeriesSchema, insertInvoiceTemplateSchema, insertTaxClassSchema, insertTaxPolicyProfileSchema, insertTaxPolicyRuleSchema, insertTaxRegimeSchema, invoiceNumberSeriesListQuerySchema, invoiceTemplateListQuerySchema, taxClassListQuerySchema, taxPolicyProfileListQuerySchema, taxPolicyRuleListQuerySchema, taxRegimeListQuerySchema, updateInvoiceNumberSeriesSchema, updateInvoiceTemplateSchema, updateTaxClassSchema, updateTaxPolicyProfileSchema, updateTaxPolicyRuleSchema, updateTaxRegimeSchema, } from "./validation.js";
5
+ export const financeReferenceDataRoutes = new Hono()
6
+ // ========================================================================
7
+ // Invoice Number Series
8
+ // ========================================================================
9
+ .get("/invoice-number-series", async (c) => {
10
+ const query = parseQuery(c, invoiceNumberSeriesListQuerySchema);
11
+ return c.json(await financeService.listInvoiceNumberSeries(c.get("db"), query));
12
+ })
13
+ .post("/invoice-number-series", async (c) => {
14
+ const row = await financeService.createInvoiceNumberSeries(c.get("db"), await parseJsonBody(c, insertInvoiceNumberSeriesSchema));
15
+ return c.json({ data: row }, 201);
16
+ })
17
+ .get("/invoice-number-series/:id", async (c) => {
18
+ const row = await financeService.getInvoiceNumberSeriesById(c.get("db"), c.req.param("id"));
19
+ if (!row)
20
+ return c.json({ error: "Invoice number series not found" }, 404);
21
+ return c.json({ data: row });
22
+ })
23
+ .patch("/invoice-number-series/:id", async (c) => {
24
+ const row = await financeService.updateInvoiceNumberSeries(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateInvoiceNumberSeriesSchema));
25
+ if (!row)
26
+ return c.json({ error: "Invoice number series not found" }, 404);
27
+ return c.json({ data: row });
28
+ })
29
+ .delete("/invoice-number-series/:id", async (c) => {
30
+ const row = await financeService.deleteInvoiceNumberSeries(c.get("db"), c.req.param("id"));
31
+ if (!row)
32
+ return c.json({ error: "Invoice number series not found" }, 404);
33
+ return c.json({ success: true });
34
+ })
35
+ .post("/invoice-number-series/:id/allocate", async (c) => {
36
+ const result = await financeService.allocateInvoiceNumber(c.get("db"), c.req.param("id"));
37
+ if (result.status === "not_found") {
38
+ return c.json({ error: "Invoice number series not found" }, 404);
39
+ }
40
+ if (result.status === "inactive") {
41
+ return c.json({ error: "Invoice number series is inactive" }, 409);
42
+ }
43
+ return c.json({
44
+ data: { sequence: result.sequence, formattedNumber: result.formattedNumber },
45
+ });
46
+ })
47
+ // ========================================================================
48
+ // Invoice Templates
49
+ // ========================================================================
50
+ .get("/invoice-templates", async (c) => {
51
+ const query = parseQuery(c, invoiceTemplateListQuerySchema);
52
+ return c.json(await financeService.listInvoiceTemplates(c.get("db"), query));
53
+ })
54
+ .post("/invoice-templates", async (c) => {
55
+ const row = await financeService.createInvoiceTemplate(c.get("db"), await parseJsonBody(c, insertInvoiceTemplateSchema));
56
+ return c.json({ data: row }, 201);
57
+ })
58
+ .get("/invoice-templates/:id", async (c) => {
59
+ const row = await financeService.getInvoiceTemplateById(c.get("db"), c.req.param("id"));
60
+ if (!row)
61
+ return c.json({ error: "Invoice template not found" }, 404);
62
+ return c.json({ data: row });
63
+ })
64
+ .patch("/invoice-templates/:id", async (c) => {
65
+ const row = await financeService.updateInvoiceTemplate(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateInvoiceTemplateSchema));
66
+ if (!row)
67
+ return c.json({ error: "Invoice template not found" }, 404);
68
+ return c.json({ data: row });
69
+ })
70
+ .delete("/invoice-templates/:id", async (c) => {
71
+ const row = await financeService.deleteInvoiceTemplate(c.get("db"), c.req.param("id"));
72
+ if (!row)
73
+ return c.json({ error: "Invoice template not found" }, 404);
74
+ return c.json({ success: true });
75
+ })
76
+ // ========================================================================
77
+ // Tax Regimes
78
+ // ========================================================================
79
+ .get("/tax-regimes", async (c) => {
80
+ const query = parseQuery(c, taxRegimeListQuerySchema);
81
+ return c.json(await financeService.listTaxRegimes(c.get("db"), query));
82
+ })
83
+ .post("/tax-regimes", async (c) => {
84
+ const row = await financeService.createTaxRegime(c.get("db"), await parseJsonBody(c, insertTaxRegimeSchema));
85
+ return c.json({ data: row }, 201);
86
+ })
87
+ .get("/tax-regimes/:id", async (c) => {
88
+ const row = await financeService.getTaxRegimeById(c.get("db"), c.req.param("id"));
89
+ if (!row)
90
+ return c.json({ error: "Tax regime not found" }, 404);
91
+ return c.json({ data: row });
92
+ })
93
+ .patch("/tax-regimes/:id", async (c) => {
94
+ const row = await financeService.updateTaxRegime(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxRegimeSchema));
95
+ if (!row)
96
+ return c.json({ error: "Tax regime not found" }, 404);
97
+ return c.json({ data: row });
98
+ })
99
+ .delete("/tax-regimes/:id", async (c) => {
100
+ const row = await financeService.deleteTaxRegime(c.get("db"), c.req.param("id"));
101
+ if (!row)
102
+ return c.json({ error: "Tax regime not found" }, 404);
103
+ return c.json({ success: true });
104
+ })
105
+ // ========================================================================
106
+ // Tax Classes
107
+ // ========================================================================
108
+ .get("/tax-classes", async (c) => {
109
+ const query = parseQuery(c, taxClassListQuerySchema);
110
+ return c.json(await financeService.listTaxClasses(c.get("db"), query));
111
+ })
112
+ .post("/tax-classes", async (c) => {
113
+ const row = await financeService.createTaxClass(c.get("db"), await parseJsonBody(c, insertTaxClassSchema));
114
+ return c.json({ data: row }, 201);
115
+ })
116
+ .get("/tax-classes/:id", async (c) => {
117
+ const row = await financeService.getTaxClassById(c.get("db"), c.req.param("id"));
118
+ if (!row)
119
+ return c.json({ error: "Tax class not found" }, 404);
120
+ return c.json({ data: row });
121
+ })
122
+ .patch("/tax-classes/:id", async (c) => {
123
+ const row = await financeService.updateTaxClass(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxClassSchema));
124
+ if (!row)
125
+ return c.json({ error: "Tax class not found" }, 404);
126
+ return c.json({ data: row });
127
+ })
128
+ .delete("/tax-classes/:id", async (c) => {
129
+ const row = await financeService.deleteTaxClass(c.get("db"), c.req.param("id"));
130
+ if (!row)
131
+ return c.json({ error: "Tax class not found" }, 404);
132
+ return c.json({ success: true });
133
+ })
134
+ // ========================================================================
135
+ // Tax Policy Profiles
136
+ // ========================================================================
137
+ .get("/tax-policy-profiles", async (c) => {
138
+ const query = parseQuery(c, taxPolicyProfileListQuerySchema);
139
+ return c.json(await financeService.listTaxPolicyProfiles(c.get("db"), query));
140
+ })
141
+ .post("/tax-policy-profiles", async (c) => {
142
+ const row = await financeService.createTaxPolicyProfile(c.get("db"), await parseJsonBody(c, insertTaxPolicyProfileSchema));
143
+ return c.json({ data: row }, 201);
144
+ })
145
+ .get("/tax-policy-profiles/:id", async (c) => {
146
+ const row = await financeService.getTaxPolicyProfileById(c.get("db"), c.req.param("id"));
147
+ if (!row)
148
+ return c.json({ error: "Tax policy profile not found" }, 404);
149
+ return c.json({ data: row });
150
+ })
151
+ .patch("/tax-policy-profiles/:id", async (c) => {
152
+ const row = await financeService.updateTaxPolicyProfile(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxPolicyProfileSchema));
153
+ if (!row)
154
+ return c.json({ error: "Tax policy profile not found" }, 404);
155
+ return c.json({ data: row });
156
+ })
157
+ .delete("/tax-policy-profiles/:id", async (c) => {
158
+ const row = await financeService.deleteTaxPolicyProfile(c.get("db"), c.req.param("id"));
159
+ if (!row)
160
+ return c.json({ error: "Tax policy profile not found" }, 404);
161
+ return c.json({ success: true });
162
+ })
163
+ // ========================================================================
164
+ // Tax Policy Rules
165
+ // ========================================================================
166
+ .get("/tax-policy-rules", async (c) => {
167
+ const query = parseQuery(c, taxPolicyRuleListQuerySchema);
168
+ return c.json(await financeService.listTaxPolicyRules(c.get("db"), query));
169
+ })
170
+ .post("/tax-policy-rules", async (c) => {
171
+ const row = await financeService.createTaxPolicyRule(c.get("db"), await parseJsonBody(c, insertTaxPolicyRuleSchema));
172
+ return c.json({ data: row }, 201);
173
+ })
174
+ .get("/tax-policy-rules/:id", async (c) => {
175
+ const row = await financeService.getTaxPolicyRuleById(c.get("db"), c.req.param("id"));
176
+ if (!row)
177
+ return c.json({ error: "Tax policy rule not found" }, 404);
178
+ return c.json({ data: row });
179
+ })
180
+ .patch("/tax-policy-rules/:id", async (c) => {
181
+ const row = await financeService.updateTaxPolicyRule(c.get("db"), c.req.param("id"), await parseJsonBody(c, updateTaxPolicyRuleSchema));
182
+ if (!row)
183
+ return c.json({ error: "Tax policy rule not found" }, 404);
184
+ return c.json({ data: row });
185
+ })
186
+ .delete("/tax-policy-rules/:id", async (c) => {
187
+ const row = await financeService.deleteTaxPolicyRule(c.get("db"), c.req.param("id"));
188
+ if (!row)
189
+ return c.json({ error: "Tax policy rule not found" }, 404);
190
+ return c.json({ success: true });
191
+ });
@@ -0,0 +1,344 @@
1
+ import type { Env } from "./routes-shared.js";
2
+ export declare const financeReportRoutes: import("hono/hono-base").HonoBase<Env, {
3
+ "/reports/revenue": {
4
+ $get: {
5
+ input: {};
6
+ output: {
7
+ data: {
8
+ month: string;
9
+ totalCents: number;
10
+ count: number;
11
+ }[];
12
+ };
13
+ outputFormat: "json";
14
+ status: import("hono/utils/http-status").ContentfulStatusCode;
15
+ };
16
+ };
17
+ } & {
18
+ "/reports/aging": {
19
+ $get: {
20
+ input: {};
21
+ output: {
22
+ data: {
23
+ bucket: string;
24
+ totalCents: number;
25
+ count: number;
26
+ }[];
27
+ };
28
+ outputFormat: "json";
29
+ status: import("hono/utils/http-status").ContentfulStatusCode;
30
+ };
31
+ };
32
+ } & {
33
+ "/reports/profitability": {
34
+ $get: {
35
+ input: {};
36
+ output: {
37
+ data: {
38
+ bookingId: string;
39
+ bookingNumber: string;
40
+ sellAmountCents: number | null;
41
+ costAmountCents: number | null;
42
+ marginPercent: number | null;
43
+ }[];
44
+ };
45
+ outputFormat: "json";
46
+ status: import("hono/utils/http-status").ContentfulStatusCode;
47
+ };
48
+ };
49
+ } & {
50
+ "/reports/profitability/departures": {
51
+ $get: {
52
+ input: {};
53
+ output: {
54
+ data: {
55
+ rows: {
56
+ departureId: string;
57
+ departureLabel: string | null;
58
+ productId: string | null;
59
+ productName: string | null;
60
+ departureDate: string | null;
61
+ currency: string;
62
+ revenueCents: number;
63
+ actualCostCents: number;
64
+ plannedCostCents: number;
65
+ profitCents: number;
66
+ marginPercent: number | null;
67
+ varianceCents: number;
68
+ }[];
69
+ costByServiceType: {
70
+ serviceType: string;
71
+ currency: string;
72
+ amountCents: number;
73
+ }[];
74
+ unattributed: {
75
+ currency: string;
76
+ amountCents: number;
77
+ }[];
78
+ base?: {
79
+ currency: string;
80
+ rows: {
81
+ departureId: string;
82
+ departureLabel: string | null;
83
+ productId: string | null;
84
+ productName: string | null;
85
+ departureDate: string | null;
86
+ currency: string;
87
+ revenueCents: number;
88
+ actualCostCents: number;
89
+ plannedCostCents: number;
90
+ profitCents: number;
91
+ marginPercent: number | null;
92
+ varianceCents: number;
93
+ }[];
94
+ costByServiceType: {
95
+ serviceType: string;
96
+ currency: string;
97
+ amountCents: number;
98
+ }[];
99
+ unattributedCents: number;
100
+ unconvertibleCurrencies: string[];
101
+ } | undefined;
102
+ };
103
+ };
104
+ outputFormat: "json";
105
+ status: import("hono/utils/http-status").ContentfulStatusCode;
106
+ };
107
+ };
108
+ } & {
109
+ "/reports/profitability/products": {
110
+ $get: {
111
+ input: {};
112
+ output: {
113
+ data: {
114
+ rows: {
115
+ productId: string;
116
+ productName: string | null;
117
+ currency: string;
118
+ departureCount: number;
119
+ revenueCents: number;
120
+ actualCostCents: number;
121
+ plannedCostCents: number;
122
+ profitCents: number;
123
+ marginPercent: number | null;
124
+ varianceCents: number;
125
+ }[];
126
+ costByServiceType: {
127
+ serviceType: string;
128
+ currency: string;
129
+ amountCents: number;
130
+ }[];
131
+ unattributed: {
132
+ currency: string;
133
+ amountCents: number;
134
+ }[];
135
+ base?: {
136
+ currency: string;
137
+ rows: {
138
+ productId: string;
139
+ productName: string | null;
140
+ currency: string;
141
+ departureCount: number;
142
+ revenueCents: number;
143
+ actualCostCents: number;
144
+ plannedCostCents: number;
145
+ profitCents: number;
146
+ marginPercent: number | null;
147
+ varianceCents: number;
148
+ }[];
149
+ costByServiceType: {
150
+ serviceType: string;
151
+ currency: string;
152
+ amountCents: number;
153
+ }[];
154
+ unattributedCents: number;
155
+ unconvertibleCurrencies: string[];
156
+ } | undefined;
157
+ };
158
+ };
159
+ outputFormat: "json";
160
+ status: import("hono/utils/http-status").ContentfulStatusCode;
161
+ };
162
+ };
163
+ } & {
164
+ "/reports/profitability/travelers": {
165
+ $get: {
166
+ input: {};
167
+ output: {
168
+ data: {
169
+ departureId: string;
170
+ currency: string;
171
+ travelerCount: number;
172
+ rows: {
173
+ travelerId: string;
174
+ travelerName: string;
175
+ bookingId: string;
176
+ currency: string;
177
+ revenueCents: number;
178
+ actualCostCents: number;
179
+ plannedCostCents: number;
180
+ profitCents: number;
181
+ marginPercent: number | null;
182
+ varianceCents: number;
183
+ }[];
184
+ };
185
+ };
186
+ outputFormat: "json";
187
+ status: import("hono/utils/http-status").ContentfulStatusCode;
188
+ };
189
+ };
190
+ } & {
191
+ "/reports/profitability/departures/export": {
192
+ $get: {
193
+ input: {};
194
+ output: {};
195
+ outputFormat: string;
196
+ status: import("hono/utils/http-status").StatusCode;
197
+ };
198
+ };
199
+ } & {
200
+ "/reports/profitability/products/export": {
201
+ $get: {
202
+ input: {};
203
+ output: {};
204
+ outputFormat: string;
205
+ status: import("hono/utils/http-status").StatusCode;
206
+ };
207
+ };
208
+ } & {
209
+ "/cost-categories": {
210
+ $get: {
211
+ input: {};
212
+ output: {
213
+ data: {
214
+ id: string;
215
+ name: string;
216
+ sortOrder: number;
217
+ archived: boolean;
218
+ createdAt: string;
219
+ updatedAt: string;
220
+ }[];
221
+ };
222
+ outputFormat: "json";
223
+ status: import("hono/utils/http-status").ContentfulStatusCode;
224
+ };
225
+ };
226
+ } & {
227
+ "/cost-categories": {
228
+ $post: {
229
+ input: {};
230
+ output: {
231
+ data: {
232
+ id: string;
233
+ name: string;
234
+ sortOrder: number;
235
+ archived: boolean;
236
+ createdAt: string;
237
+ updatedAt: string;
238
+ };
239
+ };
240
+ outputFormat: "json";
241
+ status: 201;
242
+ };
243
+ };
244
+ } & {
245
+ "/cost-categories/:id": {
246
+ $patch: {
247
+ input: {
248
+ param: {
249
+ id: string;
250
+ };
251
+ };
252
+ output: {
253
+ error: string;
254
+ };
255
+ outputFormat: "json";
256
+ status: 404;
257
+ } | {
258
+ input: {
259
+ param: {
260
+ id: string;
261
+ };
262
+ };
263
+ output: {
264
+ data: {
265
+ id: string;
266
+ name: string;
267
+ sortOrder: number;
268
+ archived: boolean;
269
+ createdAt: string;
270
+ updatedAt: string;
271
+ };
272
+ };
273
+ outputFormat: "json";
274
+ status: import("hono/utils/http-status").ContentfulStatusCode;
275
+ };
276
+ };
277
+ } & {
278
+ "/accountant-shares": {
279
+ $get: {
280
+ input: {};
281
+ output: {
282
+ data: {
283
+ id: string;
284
+ createdAt: string;
285
+ expiresAt: string;
286
+ lastAccessedAt: string | null;
287
+ accessCount: number;
288
+ from: string | null;
289
+ to: string | null;
290
+ baseCurrency: string | null;
291
+ }[];
292
+ };
293
+ outputFormat: "json";
294
+ status: import("hono/utils/http-status").ContentfulStatusCode;
295
+ };
296
+ };
297
+ } & {
298
+ "/accountant-shares": {
299
+ $post: {
300
+ input: {};
301
+ output: {
302
+ data: {
303
+ from: string | null;
304
+ to: string | null;
305
+ baseCurrency: string | null;
306
+ id: string;
307
+ url: string;
308
+ expiresAt: string | null;
309
+ };
310
+ };
311
+ outputFormat: "json";
312
+ status: 201;
313
+ };
314
+ };
315
+ } & {
316
+ "/accountant-shares/:id/revoke": {
317
+ $post: {
318
+ input: {
319
+ param: {
320
+ id: string;
321
+ };
322
+ };
323
+ output: {
324
+ error: string;
325
+ };
326
+ outputFormat: "json";
327
+ status: 404;
328
+ } | {
329
+ input: {
330
+ param: {
331
+ id: string;
332
+ };
333
+ };
334
+ output: {
335
+ data: {
336
+ id: string;
337
+ };
338
+ };
339
+ outputFormat: "json";
340
+ status: import("hono/utils/http-status").ContentfulStatusCode;
341
+ };
342
+ };
343
+ }, "/", "/accountant-shares/:id/revoke">;
344
+ //# sourceMappingURL=routes-reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-reports.d.ts","sourceRoot":"","sources":["../src/routes-reports.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAmB7C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAkH5B,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { parseJsonBody, parseQuery } from "@voyant-travel/hono";
2
+ import { Hono } from "hono";
3
+ import { csvDownload, getFinanceRouteRuntime } from "./routes-runtime.js";
4
+ import { financeService } from "./service.js";
5
+ import { accountantSharesService } from "./service-accountant-shares.js";
6
+ import { buildDepartureProfitabilityCsv, buildProductProfitabilityCsv, } from "./service-profitability.js";
7
+ import { agingReportQuerySchema, createAccountantShareSchema, departureProfitabilityQuerySchema, insertCostCategorySchema, productProfitabilityQuerySchema, profitabilityQuerySchema, revenueReportQuerySchema, travelerProfitabilityQuerySchema, updateCostCategorySchema, } from "./validation.js";
8
+ export const financeReportRoutes = new Hono()
9
+ // ========================================================================
10
+ // Reports (static paths first)
11
+ // ========================================================================
12
+ // GET /reports/revenue — Revenue by month
13
+ .get("/reports/revenue", async (c) => {
14
+ const query = parseQuery(c, revenueReportQuerySchema);
15
+ return c.json({ data: await financeService.getRevenueReport(c.get("db"), query) });
16
+ })
17
+ // GET /reports/aging — Outstanding invoices by age buckets
18
+ .get("/reports/aging", async (c) => {
19
+ const query = parseQuery(c, agingReportQuerySchema);
20
+ return c.json({ data: await financeService.getAgingReport(c.get("db"), query) });
21
+ })
22
+ // GET /reports/profitability — Per-booking margin summary
23
+ .get("/reports/profitability", async (c) => {
24
+ const query = parseQuery(c, profitabilityQuerySchema);
25
+ return c.json({ data: await financeService.getProfitabilityReport(c.get("db"), query) });
26
+ })
27
+ // GET /reports/profitability/departures — Per-departure P&L (RFC §8)
28
+ .get("/reports/profitability/departures", async (c) => {
29
+ const query = parseQuery(c, departureProfitabilityQuerySchema);
30
+ return c.json({
31
+ data: await financeService.getDepartureProfitability(c.get("db"), query, getFinanceRouteRuntime(c)),
32
+ });
33
+ })
34
+ // GET /reports/profitability/products — Per-product P&L roll-up (RFC §8)
35
+ .get("/reports/profitability/products", async (c) => {
36
+ const query = parseQuery(c, productProfitabilityQuerySchema);
37
+ return c.json({
38
+ data: await financeService.getProductProfitability(c.get("db"), query, getFinanceRouteRuntime(c)),
39
+ });
40
+ })
41
+ // GET /reports/profitability/travelers — Per-traveller P&L for one departure (RFC §6)
42
+ .get("/reports/profitability/travelers", async (c) => {
43
+ const query = parseQuery(c, travelerProfitabilityQuerySchema);
44
+ return c.json({ data: await financeService.getTravelerProfitability(c.get("db"), query) });
45
+ })
46
+ // GET /reports/profitability/departures/export — CSV for accountant sharing
47
+ .get("/reports/profitability/departures/export", async (c) => {
48
+ const query = parseQuery(c, departureProfitabilityQuerySchema);
49
+ const report = await financeService.getDepartureProfitability(c.get("db"), query, getFinanceRouteRuntime(c));
50
+ return csvDownload(buildDepartureProfitabilityCsv(report), "departure-profitability.csv");
51
+ })
52
+ // GET /reports/profitability/products/export — CSV for accountant sharing
53
+ .get("/reports/profitability/products/export", async (c) => {
54
+ const query = parseQuery(c, productProfitabilityQuerySchema);
55
+ const report = await financeService.getProductProfitability(c.get("db"), query, getFinanceRouteRuntime(c));
56
+ return csvDownload(buildProductProfitabilityCsv(report), "product-profitability.csv");
57
+ })
58
+ // ----- Cost categories (operator-configurable cost classification) -----
59
+ .get("/cost-categories", async (c) => {
60
+ const includeArchived = c.req.query("includeArchived") === "true";
61
+ return c.json({
62
+ data: await financeService.costCategories.list(c.get("db"), { includeArchived }),
63
+ });
64
+ })
65
+ .post("/cost-categories", async (c) => {
66
+ const input = await parseJsonBody(c, insertCostCategorySchema);
67
+ return c.json({ data: await financeService.costCategories.create(c.get("db"), input) }, 201);
68
+ })
69
+ .patch("/cost-categories/:id", async (c) => {
70
+ const input = await parseJsonBody(c, updateCostCategorySchema);
71
+ const row = await financeService.costCategories.update(c.get("db"), c.req.param("id"), input);
72
+ if (!row)
73
+ return c.json({ error: "Cost category not found" }, 404);
74
+ return c.json({ data: row });
75
+ })
76
+ // ----- Accountant shares (revocable public finance-portal links, RFC §13.2) -----
77
+ .get("/accountant-shares", async (c) => {
78
+ return c.json({ data: await accountantSharesService.list(c.get("db")) });
79
+ })
80
+ .post("/accountant-shares", async (c) => {
81
+ const input = await parseJsonBody(c, createAccountantShareSchema);
82
+ const share = await accountantSharesService.create(c.get("db"), input, {
83
+ publicBaseUrl: new URL(c.req.url).origin,
84
+ userId: c.get("userId") ?? null,
85
+ });
86
+ return c.json({ data: share }, 201);
87
+ })
88
+ .post("/accountant-shares/:id/revoke", async (c) => {
89
+ const revoked = await accountantSharesService.revoke(c.get("db"), c.req.param("id"), c.get("userId") ?? null);
90
+ if (!revoked)
91
+ return c.json({ error: "Accountant share not found" }, 404);
92
+ return c.json({ data: { id: revoked.id } });
93
+ });