@voyantjs/distribution 0.2.0 → 0.3.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-finance.d.ts","sourceRoot":"","sources":["../src/schema-finance.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BjC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BlC,CAAA;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BrC,CAAA;AAED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MAAM,MAAM,yBAAyB,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACtF,MAAM,MAAM,4BAA4B,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACzF,MAAM,MAAM,0BAA0B,GAAG,OAAO,2BAA2B,CAAC,YAAY,CAAA;AACxF,MAAM,MAAM,6BAA6B,GAAG,OAAO,2BAA2B,CAAC,YAAY,CAAA;AAC3F,MAAM,MAAM,yBAAyB,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA;AACtF,MAAM,MAAM,4BAA4B,GAAG,OAAO,0BAA0B,CAAC,YAAY,CAAA"}
@@ -0,0 +1,147 @@
1
+ import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
2
+ import { date, index, integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
3
+ import { channelBookingLinks, channelCommissionRules, channelContracts, channels, } from "./schema-core";
4
+ import { channelReconciliationIssueTypeEnum, channelReconciliationResolutionStatusEnum, channelReconciliationRunStatusEnum, channelReconciliationSeverityEnum, channelRemittanceExceptionStatusEnum, channelSettlementApprovalStatusEnum, channelSettlementItemStatusEnum, channelSettlementRunStatusEnum, } from "./schema-shared";
5
+ export const channelSettlementRuns = pgTable("channel_settlement_runs", {
6
+ id: typeId("channel_settlement_runs"),
7
+ channelId: typeIdRef("channel_id")
8
+ .notNull()
9
+ .references(() => channels.id, { onDelete: "cascade" }),
10
+ contractId: typeIdRef("contract_id").references(() => channelContracts.id, {
11
+ onDelete: "set null",
12
+ }),
13
+ status: channelSettlementRunStatusEnum("status").notNull().default("draft"),
14
+ currencyCode: text("currency_code"),
15
+ periodStart: date("period_start"),
16
+ periodEnd: date("period_end"),
17
+ statementReference: text("statement_reference"),
18
+ generatedAt: timestamp("generated_at", { withTimezone: true }),
19
+ postedAt: timestamp("posted_at", { withTimezone: true }),
20
+ paidAt: timestamp("paid_at", { withTimezone: true }),
21
+ notes: text("notes"),
22
+ metadata: jsonb("metadata").$type(),
23
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
24
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
25
+ }, (table) => [
26
+ index("idx_channel_settlement_runs_channel").on(table.channelId),
27
+ index("idx_channel_settlement_runs_contract").on(table.contractId),
28
+ index("idx_channel_settlement_runs_status").on(table.status),
29
+ index("idx_channel_settlement_runs_period").on(table.periodStart, table.periodEnd),
30
+ ]);
31
+ export const channelSettlementItems = pgTable("channel_settlement_items", {
32
+ id: typeId("channel_settlement_items"),
33
+ settlementRunId: typeIdRef("settlement_run_id")
34
+ .notNull()
35
+ .references(() => channelSettlementRuns.id, { onDelete: "cascade" }),
36
+ bookingLinkId: typeIdRef("booking_link_id").references(() => channelBookingLinks.id, {
37
+ onDelete: "set null",
38
+ }),
39
+ bookingId: text("booking_id"),
40
+ commissionRuleId: typeIdRef("commission_rule_id").references(() => channelCommissionRules.id, {
41
+ onDelete: "set null",
42
+ }),
43
+ status: channelSettlementItemStatusEnum("status").notNull().default("pending"),
44
+ grossAmountCents: integer("gross_amount_cents").notNull().default(0),
45
+ commissionAmountCents: integer("commission_amount_cents").notNull().default(0),
46
+ netRemittanceAmountCents: integer("net_remittance_amount_cents").notNull().default(0),
47
+ currencyCode: text("currency_code"),
48
+ remittanceDueAt: timestamp("remittance_due_at", { withTimezone: true }),
49
+ paidAt: timestamp("paid_at", { withTimezone: true }),
50
+ notes: text("notes"),
51
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
52
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
53
+ }, (table) => [
54
+ index("idx_channel_settlement_items_run").on(table.settlementRunId),
55
+ index("idx_channel_settlement_items_booking_link").on(table.bookingLinkId),
56
+ index("idx_channel_settlement_items_booking").on(table.bookingId),
57
+ index("idx_channel_settlement_items_status").on(table.status),
58
+ ]);
59
+ export const channelReconciliationRuns = pgTable("channel_reconciliation_runs", {
60
+ id: typeId("channel_reconciliation_runs"),
61
+ channelId: typeIdRef("channel_id")
62
+ .notNull()
63
+ .references(() => channels.id, { onDelete: "cascade" }),
64
+ contractId: typeIdRef("contract_id").references(() => channelContracts.id, {
65
+ onDelete: "set null",
66
+ }),
67
+ status: channelReconciliationRunStatusEnum("status").notNull().default("draft"),
68
+ periodStart: date("period_start"),
69
+ periodEnd: date("period_end"),
70
+ externalReportReference: text("external_report_reference"),
71
+ startedAt: timestamp("started_at", { withTimezone: true }),
72
+ completedAt: timestamp("completed_at", { withTimezone: true }),
73
+ notes: text("notes"),
74
+ metadata: jsonb("metadata").$type(),
75
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
76
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
77
+ }, (table) => [
78
+ index("idx_channel_reconciliation_runs_channel").on(table.channelId),
79
+ index("idx_channel_reconciliation_runs_contract").on(table.contractId),
80
+ index("idx_channel_reconciliation_runs_status").on(table.status),
81
+ ]);
82
+ export const channelReconciliationItems = pgTable("channel_reconciliation_items", {
83
+ id: typeId("channel_reconciliation_items"),
84
+ reconciliationRunId: typeIdRef("reconciliation_run_id")
85
+ .notNull()
86
+ .references(() => channelReconciliationRuns.id, { onDelete: "cascade" }),
87
+ bookingLinkId: typeIdRef("booking_link_id").references(() => channelBookingLinks.id, {
88
+ onDelete: "set null",
89
+ }),
90
+ bookingId: text("booking_id"),
91
+ externalBookingId: text("external_booking_id"),
92
+ issueType: channelReconciliationIssueTypeEnum("issue_type").notNull().default("other"),
93
+ severity: channelReconciliationSeverityEnum("severity").notNull().default("warning"),
94
+ resolutionStatus: channelReconciliationResolutionStatusEnum("resolution_status")
95
+ .notNull()
96
+ .default("open"),
97
+ notes: text("notes"),
98
+ resolvedAt: timestamp("resolved_at", { withTimezone: true }),
99
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
100
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
101
+ }, (table) => [
102
+ index("idx_channel_reconciliation_items_run").on(table.reconciliationRunId),
103
+ index("idx_channel_reconciliation_items_booking_link").on(table.bookingLinkId),
104
+ index("idx_channel_reconciliation_items_booking").on(table.bookingId),
105
+ index("idx_channel_reconciliation_items_issue").on(table.issueType),
106
+ index("idx_channel_reconciliation_items_resolution").on(table.resolutionStatus),
107
+ ]);
108
+ export const channelRemittanceExceptions = pgTable("channel_remittance_exceptions", {
109
+ id: typeId("channel_remittance_exceptions"),
110
+ channelId: typeIdRef("channel_id")
111
+ .notNull()
112
+ .references(() => channels.id, { onDelete: "cascade" }),
113
+ settlementItemId: typeIdRef("settlement_item_id").references(() => channelSettlementItems.id, {
114
+ onDelete: "set null",
115
+ }),
116
+ reconciliationItemId: typeIdRef("reconciliation_item_id").references(() => channelReconciliationItems.id, { onDelete: "set null" }),
117
+ exceptionType: text("exception_type").notNull(),
118
+ severity: channelReconciliationSeverityEnum("severity").notNull().default("warning"),
119
+ status: channelRemittanceExceptionStatusEnum("status").notNull().default("open"),
120
+ openedAt: timestamp("opened_at", { withTimezone: true }).notNull().defaultNow(),
121
+ resolvedAt: timestamp("resolved_at", { withTimezone: true }),
122
+ notes: text("notes"),
123
+ metadata: jsonb("metadata").$type(),
124
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
125
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
126
+ }, (table) => [
127
+ index("idx_channel_remittance_exceptions_channel").on(table.channelId),
128
+ index("idx_channel_remittance_exceptions_settlement_item").on(table.settlementItemId),
129
+ index("idx_channel_remittance_exceptions_reconciliation_item").on(table.reconciliationItemId),
130
+ index("idx_channel_remittance_exceptions_status").on(table.status),
131
+ ]);
132
+ export const channelSettlementApprovals = pgTable("channel_settlement_approvals", {
133
+ id: typeId("channel_settlement_approvals"),
134
+ settlementRunId: typeIdRef("settlement_run_id")
135
+ .notNull()
136
+ .references(() => channelSettlementRuns.id, { onDelete: "cascade" }),
137
+ approverUserId: text("approver_user_id"),
138
+ status: channelSettlementApprovalStatusEnum("status").notNull().default("pending"),
139
+ decidedAt: timestamp("decided_at", { withTimezone: true }),
140
+ notes: text("notes"),
141
+ metadata: jsonb("metadata").$type(),
142
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
143
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
144
+ }, (table) => [
145
+ index("idx_channel_settlement_approvals_run").on(table.settlementRunId),
146
+ index("idx_channel_settlement_approvals_status").on(table.status),
147
+ ]);