import { pgTable, bigint, timestamp, text, doublePrecision, boolean, uuid, } from "drizzle-orm/pg-core" import { bankaccounts } from "./bankaccounts" import { createddocuments } from "./createddocuments" import { tenants } from "./tenants" import { incominginvoices } from "./incominginvoices" import { contracts } from "./contracts" import { authUsers } from "./auth_users" export const bankstatements = pgTable("bankstatements", { id: bigint("id", { mode: "number" }) .primaryKey() .generatedByDefaultAsIdentity(), createdAt: timestamp("created_at", { withTimezone: true }) .notNull() .defaultNow(), account: bigint("account", { mode: "number" }) .notNull() .references(() => bankaccounts.id), date: text("date").notNull(), credIban: text("credIban"), credName: text("credName"), text: text("text"), amount: doublePrecision("amount").notNull(), tenant: bigint("tenant", { mode: "number" }) .notNull() .references(() => tenants.id), debIban: text("debIban"), debName: text("debName"), gocardlessId: text("gocardlessId"), currency: text("currency"), valueDate: text("valueDate"), mandateId: text("mandateId"), contract: bigint("contract", { mode: "number" }).references( () => contracts.id ), archived: boolean("archived").notNull().default(false), updatedAt: timestamp("updated_at", { withTimezone: true }), updatedBy: uuid("updated_by").references(() => authUsers.id), }) export type BankStatement = typeof bankstatements.$inferSelect export type NewBankStatement = typeof bankstatements.$inferInsert