70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import {
|
|
pgTable,
|
|
uuid,
|
|
bigint,
|
|
integer,
|
|
text,
|
|
timestamp,
|
|
boolean,
|
|
doublePrecision,
|
|
} from "drizzle-orm/pg-core"
|
|
|
|
import { tenants } from "./tenants"
|
|
import { authUsers } from "./auth_users"
|
|
import { customers } from "./customers"
|
|
import { vendors } from "./vendors"
|
|
import { ownaccounts } from "./ownaccounts"
|
|
import { incominginvoices } from "./incominginvoices"
|
|
import { createddocuments } from "./createddocuments"
|
|
import { bankstatements } from "./bankstatements"
|
|
import { accounts } from "./accounts" // Falls noch nicht erstellt → bitte melden!
|
|
|
|
export const statementallocations = pgTable("statementallocations", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
|
|
// foreign keys
|
|
bankstatement: integer("bs_id")
|
|
.notNull()
|
|
.references(() => bankstatements.id),
|
|
|
|
createddocument: integer("cd_id").references(() => createddocuments.id),
|
|
|
|
amount: doublePrecision("amount").notNull().default(0),
|
|
|
|
incominginvoice: bigint("ii_id", { mode: "number" }).references(
|
|
() => incominginvoices.id
|
|
),
|
|
|
|
tenant: bigint("tenant", { mode: "number" })
|
|
.notNull()
|
|
.references(() => tenants.id),
|
|
|
|
account: bigint("account", { mode: "number" }).references(
|
|
() => accounts.id
|
|
),
|
|
|
|
created_at: timestamp("created_at", {
|
|
withTimezone: false,
|
|
}).defaultNow(),
|
|
|
|
ownaccount: uuid("ownaccount").references(() => ownaccounts.id),
|
|
|
|
description: text("description"),
|
|
|
|
customer: bigint("customer", { mode: "number" }).references(
|
|
() => customers.id
|
|
),
|
|
|
|
vendor: bigint("vendor", { mode: "number" }).references(() => vendors.id),
|
|
|
|
updated_at: timestamp("updated_at", { withTimezone: true }),
|
|
|
|
updated_by: uuid("updated_by").references(() => authUsers.id),
|
|
|
|
archived: boolean("archived").notNull().default(false),
|
|
})
|
|
|
|
export type StatementAllocation = typeof statementallocations.$inferSelect
|
|
export type NewStatementAllocation =
|
|
typeof statementallocations.$inferInsert
|