@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":"receivables.d.ts","sourceRoot":"","sources":["../../src/schema/receivables.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,179 @@
1
+ import { typeId, typeIdRef } from "@voyant-travel/db/lib/typeid-column";
2
+ import { sql } from "drizzle-orm";
3
+ import { check, date, index, integer, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
4
+ import { bookingPaymentSchedules } from "./booking-billing.js";
5
+ import { creditNoteStatusEnum, invoiceStatusEnum, invoiceTypeEnum, paymentMethodEnum, paymentStatusEnum, } from "./enums.js";
6
+ import { paymentInstruments } from "./payment-instruments.js";
7
+ import { paymentAuthorizations, paymentCaptures } from "./payment-processing.js";
8
+ // ---------- invoices ----------
9
+ export const invoices = pgTable("invoices", {
10
+ id: typeId("invoices"),
11
+ invoiceNumber: text("invoice_number").notNull(),
12
+ invoiceType: invoiceTypeEnum("invoice_type").notNull().default("invoice"),
13
+ /**
14
+ * Source proforma when this row is the final invoice that
15
+ * superseded one. Lets the bank-transfer flow link the proforma
16
+ * issued at checkout to the invoice issued after payment lands —
17
+ * SmartBill's "convert proforma" call returns the same number
18
+ * series, but the local rows stay distinct so the audit trail
19
+ * shows both documents.
20
+ */
21
+ convertedFromInvoiceId: text("converted_from_invoice_id"),
22
+ seriesId: typeIdRef("series_id"),
23
+ sequence: integer("sequence"),
24
+ templateId: typeIdRef("template_id"),
25
+ taxRegimeId: typeIdRef("tax_regime_id"),
26
+ language: text("language"),
27
+ bookingId: text("booking_id").notNull(),
28
+ personId: text("person_id"),
29
+ organizationId: text("organization_id"),
30
+ status: invoiceStatusEnum("status").notNull().default("draft"),
31
+ currency: text("currency").notNull(),
32
+ baseCurrency: text("base_currency"),
33
+ fxRateSetId: text("fx_rate_set_id"),
34
+ subtotalCents: integer("subtotal_cents").notNull().default(0),
35
+ baseSubtotalCents: integer("base_subtotal_cents"),
36
+ taxCents: integer("tax_cents").notNull().default(0),
37
+ baseTaxCents: integer("base_tax_cents"),
38
+ totalCents: integer("total_cents").notNull().default(0),
39
+ baseTotalCents: integer("base_total_cents"),
40
+ paidCents: integer("paid_cents").notNull().default(0),
41
+ basePaidCents: integer("base_paid_cents"),
42
+ balanceDueCents: integer("balance_due_cents").notNull().default(0),
43
+ baseBalanceDueCents: integer("base_balance_due_cents"),
44
+ commissionPercent: integer("commission_percent"),
45
+ commissionAmountCents: integer("commission_amount_cents"),
46
+ issueDate: date("issue_date").notNull(),
47
+ dueDate: date("due_date").notNull(),
48
+ notes: text("notes"),
49
+ voidedAt: timestamp("voided_at", { withTimezone: true }),
50
+ voidReason: text("void_reason"),
51
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
52
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
53
+ }, (table) => [
54
+ index("idx_invoices_booking").on(table.bookingId),
55
+ index("idx_invoices_booking_created").on(table.bookingId, table.createdAt),
56
+ index("idx_invoices_person").on(table.personId),
57
+ index("idx_invoices_organization").on(table.organizationId),
58
+ index("idx_invoices_status").on(table.status),
59
+ index("idx_invoices_status_created").on(table.status, table.createdAt),
60
+ index("idx_invoices_outstanding_due").on(table.status, table.balanceDueCents, table.dueDate),
61
+ // Bare created_at index for the dashboard's monthly rollups, which
62
+ // filter a created_at range without a leading status column.
63
+ index("idx_invoices_created").on(table.createdAt),
64
+ index("idx_invoices_fx_rate_set").on(table.fxRateSetId),
65
+ index("idx_invoices_number").on(table.invoiceNumber),
66
+ uniqueIndex("invoices_invoice_number_type_active_idx")
67
+ .on(table.invoiceNumber, table.invoiceType)
68
+ // agent-quality: raw-sql reviewed -- owner: finance; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
69
+ .where(sql `${table.status} <> 'void'`),
70
+ index("idx_invoices_due_date").on(table.dueDate),
71
+ index("idx_invoices_converted_from").on(table.convertedFromInvoiceId),
72
+ // base_currency covers every base_*_cents column. If any base amount is
73
+ // present, base_currency must be set so reporting can interpret it.
74
+ check("ck_invoices_base_currency_amounts", sql `(
75
+ ${table.baseSubtotalCents} IS NULL
76
+ AND ${table.baseTaxCents} IS NULL
77
+ AND ${table.baseTotalCents} IS NULL
78
+ AND ${table.basePaidCents} IS NULL
79
+ AND ${table.baseBalanceDueCents} IS NULL
80
+ ) OR ${table.baseCurrency} IS NOT NULL`),
81
+ ]);
82
+ // ---------- invoice_line_items ----------
83
+ export const invoiceLineItems = pgTable("invoice_line_items", {
84
+ id: typeId("invoice_line_items"),
85
+ invoiceId: typeIdRef("invoice_id")
86
+ .notNull()
87
+ .references(() => invoices.id, { onDelete: "cascade" }),
88
+ bookingItemId: text("booking_item_id"),
89
+ bookingPaymentScheduleId: text("booking_payment_schedule_id").references(() => bookingPaymentSchedules.id, { onDelete: "set null" }),
90
+ description: text("description").notNull(),
91
+ quantity: integer("quantity").notNull().default(1),
92
+ unitPriceCents: integer("unit_price_cents").notNull(),
93
+ totalCents: integer("total_cents").notNull(),
94
+ taxRate: integer("tax_rate"),
95
+ sortOrder: integer("sort_order").notNull().default(0),
96
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
97
+ }, (table) => [
98
+ index("idx_invoice_line_items_invoice").on(table.invoiceId),
99
+ index("idx_invoice_line_items_invoice_sort").on(table.invoiceId, table.sortOrder),
100
+ index("idx_invoice_line_items_booking_item").on(table.bookingItemId),
101
+ index("idx_invoice_line_items_payment_schedule").on(table.bookingPaymentScheduleId),
102
+ ]);
103
+ // ---------- payments ----------
104
+ export const payments = pgTable("payments", {
105
+ id: typeId("payments"),
106
+ invoiceId: typeIdRef("invoice_id")
107
+ .notNull()
108
+ .references(() => invoices.id, { onDelete: "restrict" }),
109
+ amountCents: integer("amount_cents").notNull(),
110
+ currency: text("currency").notNull(),
111
+ baseCurrency: text("base_currency"),
112
+ baseAmountCents: integer("base_amount_cents"),
113
+ fxRateSetId: text("fx_rate_set_id"),
114
+ paymentMethod: paymentMethodEnum("payment_method").notNull(),
115
+ paymentInstrumentId: typeIdRef("payment_instrument_id").references(() => paymentInstruments.id, {
116
+ onDelete: "set null",
117
+ }),
118
+ paymentAuthorizationId: typeIdRef("payment_authorization_id").references(() => paymentAuthorizations.id, { onDelete: "set null" }),
119
+ paymentCaptureId: typeIdRef("payment_capture_id").references(() => paymentCaptures.id, {
120
+ onDelete: "set null",
121
+ }),
122
+ status: paymentStatusEnum("status").notNull().default("pending"),
123
+ referenceNumber: text("reference_number"),
124
+ paymentDate: date("payment_date").notNull(),
125
+ notes: text("notes"),
126
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
127
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
128
+ }, (table) => [
129
+ index("idx_payments_invoice").on(table.invoiceId),
130
+ index("idx_payments_invoice_date").on(table.invoiceId, table.paymentDate),
131
+ index("idx_payments_fx_rate_set").on(table.fxRateSetId),
132
+ index("idx_payments_instrument").on(table.paymentInstrumentId),
133
+ index("idx_payments_authorization").on(table.paymentAuthorizationId),
134
+ index("idx_payments_capture").on(table.paymentCaptureId),
135
+ index("idx_payments_status").on(table.status),
136
+ index("idx_payments_date").on(table.paymentDate),
137
+ check("ck_payments_base_currency_amount",
138
+ // agent-quality: raw-sql reviewed -- owner: finance; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
139
+ sql `(${table.baseCurrency} IS NULL) = (${table.baseAmountCents} IS NULL)`),
140
+ ]);
141
+ // ---------- credit_notes ----------
142
+ export const creditNotes = pgTable("credit_notes", {
143
+ id: typeId("credit_notes"),
144
+ creditNoteNumber: text("credit_note_number").notNull().unique(),
145
+ invoiceId: typeIdRef("invoice_id")
146
+ .notNull()
147
+ .references(() => invoices.id, { onDelete: "restrict" }),
148
+ status: creditNoteStatusEnum("status").notNull().default("draft"),
149
+ amountCents: integer("amount_cents").notNull(),
150
+ currency: text("currency").notNull(),
151
+ baseCurrency: text("base_currency"),
152
+ baseAmountCents: integer("base_amount_cents"),
153
+ fxRateSetId: text("fx_rate_set_id"),
154
+ reason: text("reason").notNull(),
155
+ notes: text("notes"),
156
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
157
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
158
+ }, (table) => [
159
+ index("idx_credit_notes_invoice").on(table.invoiceId),
160
+ index("idx_credit_notes_invoice_created").on(table.invoiceId, table.createdAt),
161
+ index("idx_credit_notes_fx_rate_set").on(table.fxRateSetId),
162
+ index("idx_credit_notes_number").on(table.creditNoteNumber),
163
+ ]);
164
+ // ---------- credit_note_line_items ----------
165
+ export const creditNoteLineItems = pgTable("credit_note_line_items", {
166
+ id: typeId("credit_note_line_items"),
167
+ creditNoteId: typeIdRef("credit_note_id")
168
+ .notNull()
169
+ .references(() => creditNotes.id, { onDelete: "cascade" }),
170
+ description: text("description").notNull(),
171
+ quantity: integer("quantity").notNull().default(1),
172
+ unitPriceCents: integer("unit_price_cents").notNull(),
173
+ totalCents: integer("total_cents").notNull(),
174
+ sortOrder: integer("sort_order").notNull().default(0),
175
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
176
+ }, (table) => [
177
+ index("idx_credit_note_line_items_credit_note").on(table.creditNoteId),
178
+ index("idx_credit_note_line_items_credit_note_sort").on(table.creditNoteId, table.sortOrder),
179
+ ]);
@@ -0,0 +1,82 @@
1
+ export declare const invoicesRelations: import("drizzle-orm").Relations<"invoices", {
2
+ lineItems: import("drizzle-orm").Many<"invoice_line_items">;
3
+ payments: import("drizzle-orm").Many<"payments">;
4
+ creditNotes: import("drizzle-orm").Many<"credit_notes">;
5
+ notes: import("drizzle-orm").Many<"finance_notes">;
6
+ authorizations: import("drizzle-orm").Many<"payment_authorizations">;
7
+ captures: import("drizzle-orm").Many<"payment_captures">;
8
+ renditions: import("drizzle-orm").Many<"invoice_renditions">;
9
+ attachments: import("drizzle-orm").Many<"invoice_attachments">;
10
+ }>;
11
+ export declare const paymentInstrumentsRelations: import("drizzle-orm").Relations<"payment_instruments", {
12
+ guarantees: import("drizzle-orm").Many<"booking_guarantees">;
13
+ payments: import("drizzle-orm").Many<"payments">;
14
+ supplierPayments: import("drizzle-orm").Many<"supplier_payments">;
15
+ authorizations: import("drizzle-orm").Many<"payment_authorizations">;
16
+ }>;
17
+ export declare const paymentAuthorizationsRelations: import("drizzle-orm").Relations<"payment_authorizations", {
18
+ invoice: import("drizzle-orm").One<"invoices", false>;
19
+ paymentInstrument: import("drizzle-orm").One<"payment_instruments", false>;
20
+ bookingGuarantee: import("drizzle-orm").One<"booking_guarantees", false>;
21
+ captures: import("drizzle-orm").Many<"payment_captures">;
22
+ payments: import("drizzle-orm").Many<"payments">;
23
+ }>;
24
+ export declare const paymentCapturesRelations: import("drizzle-orm").Relations<"payment_captures", {
25
+ paymentAuthorization: import("drizzle-orm").One<"payment_authorizations", false>;
26
+ invoice: import("drizzle-orm").One<"invoices", false>;
27
+ payments: import("drizzle-orm").Many<"payments">;
28
+ }>;
29
+ export declare const bookingPaymentSchedulesRelations: import("drizzle-orm").Relations<"booking_payment_schedules", {
30
+ guarantees: import("drizzle-orm").Many<"booking_guarantees">;
31
+ }>;
32
+ export declare const bookingGuaranteesRelations: import("drizzle-orm").Relations<"booking_guarantees", {
33
+ bookingPaymentSchedule: import("drizzle-orm").One<"booking_payment_schedules", false>;
34
+ paymentInstrument: import("drizzle-orm").One<"payment_instruments", false>;
35
+ paymentAuthorization: import("drizzle-orm").One<"payment_authorizations", false>;
36
+ }>;
37
+ export declare const bookingItemTaxLinesRelations: import("drizzle-orm").Relations<"booking_item_tax_lines", {}>;
38
+ export declare const bookingItemCommissionsRelations: import("drizzle-orm").Relations<"booking_item_commissions", {}>;
39
+ export declare const invoiceLineItemsRelations: import("drizzle-orm").Relations<"invoice_line_items", {
40
+ invoice: import("drizzle-orm").One<"invoices", true>;
41
+ }>;
42
+ export declare const paymentsRelations: import("drizzle-orm").Relations<"payments", {
43
+ invoice: import("drizzle-orm").One<"invoices", true>;
44
+ paymentInstrument: import("drizzle-orm").One<"payment_instruments", false>;
45
+ paymentAuthorization: import("drizzle-orm").One<"payment_authorizations", false>;
46
+ paymentCapture: import("drizzle-orm").One<"payment_captures", false>;
47
+ }>;
48
+ export declare const creditNotesRelations: import("drizzle-orm").Relations<"credit_notes", {
49
+ invoice: import("drizzle-orm").One<"invoices", true>;
50
+ lineItems: import("drizzle-orm").Many<"credit_note_line_items">;
51
+ }>;
52
+ export declare const creditNoteLineItemsRelations: import("drizzle-orm").Relations<"credit_note_line_items", {
53
+ creditNote: import("drizzle-orm").One<"credit_notes", true>;
54
+ }>;
55
+ export declare const supplierPaymentsRelations: import("drizzle-orm").Relations<"supplier_payments", {
56
+ paymentInstrument: import("drizzle-orm").One<"payment_instruments", false>;
57
+ }>;
58
+ export declare const financeNotesRelations: import("drizzle-orm").Relations<"finance_notes", {
59
+ invoice: import("drizzle-orm").One<"invoices", true>;
60
+ }>;
61
+ export declare const invoiceRenditionsRelations: import("drizzle-orm").Relations<"invoice_renditions", {
62
+ invoice: import("drizzle-orm").One<"invoices", true>;
63
+ template: import("drizzle-orm").One<"invoice_templates", false>;
64
+ }>;
65
+ export declare const invoiceAttachmentsRelations: import("drizzle-orm").Relations<"invoice_attachments", {
66
+ invoice: import("drizzle-orm").One<"invoices", true>;
67
+ }>;
68
+ export declare const invoiceExternalRefsRelations: import("drizzle-orm").Relations<"invoice_external_refs", {
69
+ invoice: import("drizzle-orm").One<"invoices", true>;
70
+ }>;
71
+ export declare const vouchersRelations: import("drizzle-orm").Relations<"vouchers", {
72
+ redemptions: import("drizzle-orm").Many<"voucher_redemptions">;
73
+ }>;
74
+ export declare const voucherRedemptionsRelations: import("drizzle-orm").Relations<"voucher_redemptions", {
75
+ voucher: import("drizzle-orm").One<"vouchers", true>;
76
+ }>;
77
+ export declare const invoiceNumberSeriesRelations: import("drizzle-orm").Relations<"invoice_number_series", {}>;
78
+ export declare const invoiceTemplatesRelations: import("drizzle-orm").Relations<"invoice_templates", {
79
+ renditions: import("drizzle-orm").Many<"invoice_renditions">;
80
+ }>;
81
+ export declare const taxRegimesRelations: import("drizzle-orm").Relations<"tax_regimes", {}>;
82
+ //# sourceMappingURL=relations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/schema/relations.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,iBAAiB;;;;;;;;;EAS3B,CAAA;AAEH,eAAO,MAAM,2BAA2B;;;;;EAKrC,CAAA;AAEH,eAAO,MAAM,8BAA8B;;;;;;EAgBxC,CAAA;AAEH,eAAO,MAAM,wBAAwB;;;;EAUlC,CAAA;AAEH,eAAO,MAAM,gCAAgC;;EAE1C,CAAA;AAEH,eAAO,MAAM,0BAA0B;;;;EAcpC,CAAA;AAEH,eAAO,MAAM,4BAA4B,+DAA6C,CAAA;AAEtF,eAAO,MAAM,+BAA+B,iEAAgD,CAAA;AAE5F,eAAO,MAAM,yBAAyB;;EAEnC,CAAA;AAEH,eAAO,MAAM,iBAAiB;;;;;EAc3B,CAAA;AAEH,eAAO,MAAM,oBAAoB;;;EAG9B,CAAA;AAEH,eAAO,MAAM,4BAA4B;;EAKtC,CAAA;AAEH,eAAO,MAAM,yBAAyB;;EAKnC,CAAA;AAEH,eAAO,MAAM,qBAAqB;;EAE/B,CAAA;AAEH,eAAO,MAAM,0BAA0B;;;EAMpC,CAAA;AAEH,eAAO,MAAM,2BAA2B;;EAKrC,CAAA;AAEH,eAAO,MAAM,4BAA4B;;EAKtC,CAAA;AAEH,eAAO,MAAM,iBAAiB;;EAE3B,CAAA;AAEH,eAAO,MAAM,2BAA2B;;EAKrC,CAAA;AAEH,eAAO,MAAM,4BAA4B,8DAA6C,CAAA;AACtF,eAAO,MAAM,yBAAyB;;EAEnC,CAAA;AACH,eAAO,MAAM,mBAAmB,oDAAoC,CAAA"}
@@ -0,0 +1,144 @@
1
+ import { relations } from "drizzle-orm";
2
+ import { bookingGuarantees, bookingItemCommissions, bookingItemTaxLines, bookingPaymentSchedules, } from "./booking-billing.js";
3
+ import { financeNotes, invoiceAttachments, invoiceExternalRefs, invoiceNumberSeries, invoiceRenditions, invoiceTemplates, } from "./invoice-documents.js";
4
+ import { paymentInstruments } from "./payment-instruments.js";
5
+ import { paymentAuthorizations, paymentCaptures } from "./payment-processing.js";
6
+ import { creditNoteLineItems, creditNotes, invoiceLineItems, invoices, payments, } from "./receivables.js";
7
+ import { supplierPayments } from "./supplier-invoices.js";
8
+ import { taxRegimes } from "./tax.js";
9
+ import { voucherRedemptions, vouchers } from "./vouchers.js";
10
+ // ---------- relations ----------
11
+ export const invoicesRelations = relations(invoices, ({ many }) => ({
12
+ lineItems: many(invoiceLineItems),
13
+ payments: many(payments),
14
+ creditNotes: many(creditNotes),
15
+ notes: many(financeNotes),
16
+ authorizations: many(paymentAuthorizations),
17
+ captures: many(paymentCaptures),
18
+ renditions: many(invoiceRenditions),
19
+ attachments: many(invoiceAttachments),
20
+ }));
21
+ export const paymentInstrumentsRelations = relations(paymentInstruments, ({ many }) => ({
22
+ guarantees: many(bookingGuarantees),
23
+ payments: many(payments),
24
+ supplierPayments: many(supplierPayments),
25
+ authorizations: many(paymentAuthorizations),
26
+ }));
27
+ export const paymentAuthorizationsRelations = relations(paymentAuthorizations, ({ one, many }) => ({
28
+ invoice: one(invoices, {
29
+ fields: [paymentAuthorizations.invoiceId],
30
+ references: [invoices.id],
31
+ }),
32
+ paymentInstrument: one(paymentInstruments, {
33
+ fields: [paymentAuthorizations.paymentInstrumentId],
34
+ references: [paymentInstruments.id],
35
+ }),
36
+ bookingGuarantee: one(bookingGuarantees, {
37
+ fields: [paymentAuthorizations.bookingGuaranteeId],
38
+ references: [bookingGuarantees.id],
39
+ relationName: "guarantee_authorization",
40
+ }),
41
+ captures: many(paymentCaptures),
42
+ payments: many(payments),
43
+ }));
44
+ export const paymentCapturesRelations = relations(paymentCaptures, ({ one, many }) => ({
45
+ paymentAuthorization: one(paymentAuthorizations, {
46
+ fields: [paymentCaptures.paymentAuthorizationId],
47
+ references: [paymentAuthorizations.id],
48
+ }),
49
+ invoice: one(invoices, {
50
+ fields: [paymentCaptures.invoiceId],
51
+ references: [invoices.id],
52
+ }),
53
+ payments: many(payments),
54
+ }));
55
+ export const bookingPaymentSchedulesRelations = relations(bookingPaymentSchedules, ({ many }) => ({
56
+ guarantees: many(bookingGuarantees),
57
+ }));
58
+ export const bookingGuaranteesRelations = relations(bookingGuarantees, ({ one }) => ({
59
+ bookingPaymentSchedule: one(bookingPaymentSchedules, {
60
+ fields: [bookingGuarantees.bookingPaymentScheduleId],
61
+ references: [bookingPaymentSchedules.id],
62
+ }),
63
+ paymentInstrument: one(paymentInstruments, {
64
+ fields: [bookingGuarantees.paymentInstrumentId],
65
+ references: [paymentInstruments.id],
66
+ }),
67
+ paymentAuthorization: one(paymentAuthorizations, {
68
+ fields: [bookingGuarantees.paymentAuthorizationId],
69
+ references: [paymentAuthorizations.id],
70
+ relationName: "guarantee_authorization",
71
+ }),
72
+ }));
73
+ export const bookingItemTaxLinesRelations = relations(bookingItemTaxLines, () => ({}));
74
+ export const bookingItemCommissionsRelations = relations(bookingItemCommissions, () => ({}));
75
+ export const invoiceLineItemsRelations = relations(invoiceLineItems, ({ one }) => ({
76
+ invoice: one(invoices, { fields: [invoiceLineItems.invoiceId], references: [invoices.id] }),
77
+ }));
78
+ export const paymentsRelations = relations(payments, ({ one }) => ({
79
+ invoice: one(invoices, { fields: [payments.invoiceId], references: [invoices.id] }),
80
+ paymentInstrument: one(paymentInstruments, {
81
+ fields: [payments.paymentInstrumentId],
82
+ references: [paymentInstruments.id],
83
+ }),
84
+ paymentAuthorization: one(paymentAuthorizations, {
85
+ fields: [payments.paymentAuthorizationId],
86
+ references: [paymentAuthorizations.id],
87
+ }),
88
+ paymentCapture: one(paymentCaptures, {
89
+ fields: [payments.paymentCaptureId],
90
+ references: [paymentCaptures.id],
91
+ }),
92
+ }));
93
+ export const creditNotesRelations = relations(creditNotes, ({ one, many }) => ({
94
+ invoice: one(invoices, { fields: [creditNotes.invoiceId], references: [invoices.id] }),
95
+ lineItems: many(creditNoteLineItems),
96
+ }));
97
+ export const creditNoteLineItemsRelations = relations(creditNoteLineItems, ({ one }) => ({
98
+ creditNote: one(creditNotes, {
99
+ fields: [creditNoteLineItems.creditNoteId],
100
+ references: [creditNotes.id],
101
+ }),
102
+ }));
103
+ export const supplierPaymentsRelations = relations(supplierPayments, ({ one }) => ({
104
+ paymentInstrument: one(paymentInstruments, {
105
+ fields: [supplierPayments.paymentInstrumentId],
106
+ references: [paymentInstruments.id],
107
+ }),
108
+ }));
109
+ export const financeNotesRelations = relations(financeNotes, ({ one }) => ({
110
+ invoice: one(invoices, { fields: [financeNotes.invoiceId], references: [invoices.id] }),
111
+ }));
112
+ export const invoiceRenditionsRelations = relations(invoiceRenditions, ({ one }) => ({
113
+ invoice: one(invoices, { fields: [invoiceRenditions.invoiceId], references: [invoices.id] }),
114
+ template: one(invoiceTemplates, {
115
+ fields: [invoiceRenditions.templateId],
116
+ references: [invoiceTemplates.id],
117
+ }),
118
+ }));
119
+ export const invoiceAttachmentsRelations = relations(invoiceAttachments, ({ one }) => ({
120
+ invoice: one(invoices, {
121
+ fields: [invoiceAttachments.invoiceId],
122
+ references: [invoices.id],
123
+ }),
124
+ }));
125
+ export const invoiceExternalRefsRelations = relations(invoiceExternalRefs, ({ one }) => ({
126
+ invoice: one(invoices, {
127
+ fields: [invoiceExternalRefs.invoiceId],
128
+ references: [invoices.id],
129
+ }),
130
+ }));
131
+ export const vouchersRelations = relations(vouchers, ({ many }) => ({
132
+ redemptions: many(voucherRedemptions),
133
+ }));
134
+ export const voucherRedemptionsRelations = relations(voucherRedemptions, ({ one }) => ({
135
+ voucher: one(vouchers, {
136
+ fields: [voucherRedemptions.voucherId],
137
+ references: [vouchers.id],
138
+ }),
139
+ }));
140
+ export const invoiceNumberSeriesRelations = relations(invoiceNumberSeries, () => ({}));
141
+ export const invoiceTemplatesRelations = relations(invoiceTemplates, ({ many }) => ({
142
+ renditions: many(invoiceRenditions),
143
+ }));
144
+ export const taxRegimesRelations = relations(taxRegimes, () => ({}));