@voyant-travel/finance 0.119.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +192 -0
- package/dist/action-ledger-drift.d.ts +29 -0
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/action-ledger-drift.js +166 -0
- package/dist/booking-tax.d.ts +124 -0
- package/dist/booking-tax.d.ts.map +1 -0
- package/dist/booking-tax.js +264 -0
- package/dist/checkout-routes.d.ts +1154 -0
- package/dist/checkout-routes.d.ts.map +1 -0
- package/dist/checkout-routes.js +116 -0
- package/dist/checkout-service-plan.d.ts +137 -0
- package/dist/checkout-service-plan.d.ts.map +1 -0
- package/dist/checkout-service-plan.js +119 -0
- package/dist/checkout-service.d.ts +9 -0
- package/dist/checkout-service.d.ts.map +1 -0
- package/dist/checkout-service.js +324 -0
- package/dist/checkout-validation.d.ts +1682 -0
- package/dist/checkout-validation.d.ts.map +1 -0
- package/dist/checkout-validation.js +228 -0
- package/dist/document-download.d.ts +3 -0
- package/dist/document-download.d.ts.map +1 -0
- package/dist/document-download.js +1 -0
- package/dist/fx-money.d.ts +17 -0
- package/dist/fx-money.d.ts.map +1 -0
- package/dist/fx-money.js +194 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/invoice-fx.d.ts +134 -0
- package/dist/invoice-fx.d.ts.map +1 -0
- package/dist/invoice-fx.js +240 -0
- package/dist/invoice-number-errors.d.ts +2 -0
- package/dist/invoice-number-errors.d.ts.map +1 -0
- package/dist/invoice-number-errors.js +58 -0
- package/dist/markets-ref.d.ts +149 -0
- package/dist/markets-ref.d.ts.map +1 -0
- package/dist/markets-ref.js +17 -0
- package/dist/payment-link.d.ts +23 -0
- package/dist/payment-link.d.ts.map +1 -0
- package/dist/payment-link.js +30 -0
- package/dist/payment-policy.d.ts +113 -0
- package/dist/payment-policy.d.ts.map +1 -0
- package/dist/payment-policy.js +193 -0
- package/dist/route-runtime.d.ts +22 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/route-runtime.js +18 -0
- package/dist/routes-action-ledger.d.ts +181 -0
- package/dist/routes-action-ledger.d.ts.map +1 -0
- package/dist/routes-action-ledger.js +142 -0
- package/dist/routes-booking-billing.d.ts +852 -0
- package/dist/routes-booking-billing.d.ts.map +1 -0
- package/dist/routes-booking-billing.js +223 -0
- package/dist/routes-booking-create.d.ts +3 -0
- package/dist/routes-booking-create.d.ts.map +1 -0
- package/dist/routes-booking-create.js +194 -0
- package/dist/routes-booking-reads.d.ts +46 -0
- package/dist/routes-booking-reads.d.ts.map +1 -0
- package/dist/routes-booking-reads.js +20 -0
- package/dist/routes-documents.d.ts +195 -0
- package/dist/routes-documents.d.ts.map +1 -0
- package/dist/routes-documents.js +93 -0
- package/dist/routes-invoice-core.d.ts +794 -0
- package/dist/routes-invoice-core.d.ts.map +1 -0
- package/dist/routes-invoice-core.js +238 -0
- package/dist/routes-invoice-documents.d.ts +401 -0
- package/dist/routes-invoice-documents.d.ts.map +1 -0
- package/dist/routes-invoice-documents.js +91 -0
- package/dist/routes-invoice-issue.d.ts +384 -0
- package/dist/routes-invoice-issue.d.ts.map +1 -0
- package/dist/routes-invoice-issue.js +208 -0
- package/dist/routes-payment-processing.d.ts +1193 -0
- package/dist/routes-payment-processing.d.ts.map +1 -0
- package/dist/routes-payment-processing.js +238 -0
- package/dist/routes-payments.d.ts +309 -0
- package/dist/routes-payments.d.ts.map +1 -0
- package/dist/routes-payments.js +94 -0
- package/dist/routes-public.d.ts +1948 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +275 -0
- package/dist/routes-reference-data.d.ts +977 -0
- package/dist/routes-reference-data.d.ts.map +1 -0
- package/dist/routes-reference-data.js +191 -0
- package/dist/routes-reports.d.ts +344 -0
- package/dist/routes-reports.d.ts.map +1 -0
- package/dist/routes-reports.js +93 -0
- package/dist/routes-runtime.d.ts +71 -0
- package/dist/routes-runtime.d.ts.map +1 -0
- package/dist/routes-runtime.js +59 -0
- package/dist/routes-settlement.d.ts +67 -0
- package/dist/routes-settlement.d.ts.map +1 -0
- package/dist/routes-settlement.js +23 -0
- package/dist/routes-shared.d.ts +35 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +10 -0
- package/dist/routes-supplier-invoices.d.ts +778 -0
- package/dist/routes-supplier-invoices.d.ts.map +1 -0
- package/dist/routes-supplier-invoices.js +159 -0
- package/dist/routes-vouchers.d.ts +228 -0
- package/dist/routes-vouchers.d.ts.map +1 -0
- package/dist/routes-vouchers.js +54 -0
- package/dist/routes.d.ts +5577 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +44 -0
- package/dist/schema/booking-billing.d.ts +1006 -0
- package/dist/schema/booking-billing.d.ts.map +1 -0
- package/dist/schema/booking-billing.js +106 -0
- package/dist/schema/enums.d.ts +48 -0
- package/dist/schema/enums.d.ts.map +1 -0
- package/dist/schema/enums.js +237 -0
- package/dist/schema/invoice-documents.d.ts +1245 -0
- package/dist/schema/invoice-documents.d.ts.map +1 -0
- package/dist/schema/invoice-documents.js +140 -0
- package/dist/schema/payment-instruments.d.ts +418 -0
- package/dist/schema/payment-instruments.d.ts.map +1 -0
- package/dist/schema/payment-instruments.js +45 -0
- package/dist/schema/payment-processing.d.ts +563 -0
- package/dist/schema/payment-processing.d.ts.map +1 -0
- package/dist/schema/payment-processing.js +65 -0
- package/dist/schema/payment-sessions.d.ts +728 -0
- package/dist/schema/payment-sessions.d.ts.map +1 -0
- package/dist/schema/payment-sessions.js +79 -0
- package/dist/schema/receivables.d.ts +1474 -0
- package/dist/schema/receivables.d.ts.map +1 -0
- package/dist/schema/receivables.js +179 -0
- package/dist/schema/relations.d.ts +82 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/relations.js +144 -0
- package/dist/schema/supplier-invoices.d.ts +1619 -0
- package/dist/schema/supplier-invoices.d.ts.map +1 -0
- package/dist/schema/supplier-invoices.js +228 -0
- package/dist/schema/tax.d.ts +712 -0
- package/dist/schema/tax.d.ts.map +1 -0
- package/dist/schema/tax.js +98 -0
- package/dist/schema/vouchers.d.ts +444 -0
- package/dist/schema/vouchers.d.ts.map +1 -0
- package/dist/schema/vouchers.js +64 -0
- package/dist/schema.d.ts +12 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +11 -0
- package/dist/service-accountant-shares.d.ts +106 -0
- package/dist/service-accountant-shares.d.ts.map +1 -0
- package/dist/service-accountant-shares.js +331 -0
- package/dist/service-action-ledger-accounting.d.ts +104 -0
- package/dist/service-action-ledger-accounting.d.ts.map +1 -0
- package/dist/service-action-ledger-accounting.js +386 -0
- package/dist/service-action-ledger-booking-payments.d.ts +48 -0
- package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-booking-payments.js +178 -0
- package/dist/service-action-ledger-bookings.d.ts +44 -0
- package/dist/service-action-ledger-bookings.d.ts.map +1 -0
- package/dist/service-action-ledger-bookings.js +81 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-authorizations.js +209 -0
- package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
- package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-sessions.js +294 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts +27 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-invoices.js +111 -0
- package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
- package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-payments.js +97 -0
- package/dist/service-action-ledger.d.ts +7 -0
- package/dist/service-action-ledger.d.ts.map +1 -0
- package/dist/service-action-ledger.js +6 -0
- package/dist/service-aggregates.d.ts +96 -0
- package/dist/service-aggregates.d.ts.map +1 -0
- package/dist/service-aggregates.js +294 -0
- package/dist/service-booking-billing.d.ts +2322 -0
- package/dist/service-booking-billing.d.ts.map +1 -0
- package/dist/service-booking-billing.js +8 -0
- package/dist/service-booking-create.d.ts +410 -0
- package/dist/service-booking-create.d.ts.map +1 -0
- package/dist/service-booking-create.js +1256 -0
- package/dist/service-booking-guarantees.d.ts +725 -0
- package/dist/service-booking-guarantees.d.ts.map +1 -0
- package/dist/service-booking-guarantees.js +153 -0
- package/dist/service-booking-item-billing.d.ts +1062 -0
- package/dist/service-booking-item-billing.d.ts.map +1 -0
- package/dist/service-booking-item-billing.js +77 -0
- package/dist/service-booking-payment-schedules.d.ts +557 -0
- package/dist/service-booking-payment-schedules.d.ts.map +1 -0
- package/dist/service-booking-payment-schedules.js +372 -0
- package/dist/service-bookings-dual-create.d.ts +308 -0
- package/dist/service-bookings-dual-create.d.ts.map +1 -0
- package/dist/service-bookings-dual-create.js +131 -0
- package/dist/service-boundary-sql.d.ts +6 -0
- package/dist/service-boundary-sql.d.ts.map +1 -0
- package/dist/service-boundary-sql.js +15 -0
- package/dist/service-cost-categories.d.ts +26 -0
- package/dist/service-cost-categories.d.ts.map +1 -0
- package/dist/service-cost-categories.js +76 -0
- package/dist/service-documents.d.ts +80 -0
- package/dist/service-documents.d.ts.map +1 -0
- package/dist/service-documents.js +228 -0
- package/dist/service-invoice-artifacts.d.ts +246 -0
- package/dist/service-invoice-artifacts.d.ts.map +1 -0
- package/dist/service-invoice-artifacts.js +277 -0
- package/dist/service-invoice-core.d.ts +405 -0
- package/dist/service-invoice-core.d.ts.map +1 -0
- package/dist/service-invoice-core.js +290 -0
- package/dist/service-invoice-credit-notes.d.ts +973 -0
- package/dist/service-invoice-credit-notes.d.ts.map +1 -0
- package/dist/service-invoice-credit-notes.js +142 -0
- package/dist/service-invoice-from-booking.d.ts +41 -0
- package/dist/service-invoice-from-booking.d.ts.map +1 -0
- package/dist/service-invoice-from-booking.js +267 -0
- package/dist/service-invoice-line-items.d.ts +432 -0
- package/dist/service-invoice-line-items.d.ts.map +1 -0
- package/dist/service-invoice-line-items.js +102 -0
- package/dist/service-invoice-numbering.d.ts +227 -0
- package/dist/service-invoice-numbering.d.ts.map +1 -0
- package/dist/service-invoice-numbering.js +260 -0
- package/dist/service-invoice-payments.d.ts +673 -0
- package/dist/service-invoice-payments.d.ts.map +1 -0
- package/dist/service-invoice-payments.js +398 -0
- package/dist/service-invoices.d.ts +2501 -0
- package/dist/service-invoices.d.ts.map +1 -0
- package/dist/service-invoices.js +12 -0
- package/dist/service-issue.d.ts +207 -0
- package/dist/service-issue.d.ts.map +1 -0
- package/dist/service-issue.js +431 -0
- package/dist/service-payment-authorizations.d.ts +164 -0
- package/dist/service-payment-authorizations.d.ts.map +1 -0
- package/dist/service-payment-authorizations.js +227 -0
- package/dist/service-payment-instruments.d.ts +116 -0
- package/dist/service-payment-instruments.d.ts.map +1 -0
- package/dist/service-payment-instruments.js +99 -0
- package/dist/service-payment-processing.d.ts +676 -0
- package/dist/service-payment-processing.d.ts.map +1 -0
- package/dist/service-payment-processing.js +10 -0
- package/dist/service-payment-session-completion.d.ts +48 -0
- package/dist/service-payment-session-completion.d.ts.map +1 -0
- package/dist/service-payment-session-completion.js +238 -0
- package/dist/service-payment-sessions.d.ts +361 -0
- package/dist/service-payment-sessions.d.ts.map +1 -0
- package/dist/service-payment-sessions.js +280 -0
- package/dist/service-profitability.d.ts +114 -0
- package/dist/service-profitability.d.ts.map +1 -0
- package/dist/service-profitability.js +794 -0
- package/dist/service-public.d.ts +553 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +583 -0
- package/dist/service-reference-data.d.ts +272 -0
- package/dist/service-reference-data.d.ts.map +1 -0
- package/dist/service-reference-data.js +280 -0
- package/dist/service-rendition-wait.d.ts +38 -0
- package/dist/service-rendition-wait.d.ts.map +1 -0
- package/dist/service-rendition-wait.js +67 -0
- package/dist/service-reports.d.ts +37 -0
- package/dist/service-reports.d.ts.map +1 -0
- package/dist/service-reports.js +62 -0
- package/dist/service-settlement.d.ts +46 -0
- package/dist/service-settlement.d.ts.map +1 -0
- package/dist/service-settlement.js +185 -0
- package/dist/service-shared.d.ts +541 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +764 -0
- package/dist/service-supplier-invoices.d.ts +871 -0
- package/dist/service-supplier-invoices.d.ts.map +1 -0
- package/dist/service-supplier-invoices.js +744 -0
- package/dist/service-supplier-payments.d.ts +69 -0
- package/dist/service-supplier-payments.d.ts.map +1 -0
- package/dist/service-supplier-payments.js +136 -0
- package/dist/service-vouchers-migration.d.ts +44 -0
- package/dist/service-vouchers-migration.d.ts.map +1 -0
- package/dist/service-vouchers-migration.js +148 -0
- package/dist/service-vouchers.d.ts +157 -0
- package/dist/service-vouchers.d.ts.map +1 -0
- package/dist/service-vouchers.js +191 -0
- package/dist/service.d.ts +6490 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +29 -0
- package/dist/validation-billing.d.ts +2 -0
- package/dist/validation-billing.d.ts.map +1 -0
- package/dist/validation-billing.js +1 -0
- package/dist/validation-payments.d.ts +2 -0
- package/dist/validation-payments.d.ts.map +1 -0
- package/dist/validation-payments.js +1 -0
- package/dist/validation-public.d.ts +2 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +1 -0
- package/dist/validation-shared.d.ts +2 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +1 -0
- package/dist/validation-vouchers.d.ts +2 -0
- package/dist/validation-vouchers.d.ts.map +1 -0
- package/dist/validation-vouchers.js +1 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receivables.d.ts","sourceRoot":"","sources":["../../src/schema/receivables.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmFpB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAClD,MAAM,MAAM,UAAU,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAIrD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B5B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAClE,MAAM,MAAM,kBAAkB,GAAG,OAAO,gBAAgB,CAAC,YAAY,CAAA;AAIrE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDpB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAClD,MAAM,MAAM,UAAU,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AAIrD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BvB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,WAAW,CAAC,YAAY,CAAA;AACxD,MAAM,MAAM,aAAa,GAAG,OAAO,WAAW,CAAC,YAAY,CAAA;AAI3D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB/B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,OAAO,mBAAmB,CAAC,YAAY,CAAA"}
|
|
@@ -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, () => ({}));
|