Files
FEDEO/backend/db/schema/contracts.ts
florianfederspiel 3f8ce5daf7
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 30s
Build and Push Docker Images / build-frontend (push) Successful in 1m8s
Tasks und Vertragstyp fix #17
2026-02-15 22:02:16 +01:00

82 lines
2.4 KiB
TypeScript

import {
pgTable,
bigint,
text,
timestamp,
boolean,
jsonb,
uuid,
} from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { customers } from "./customers"
import { contacts } from "./contacts"
import { contracttypes } from "./contracttypes"
import { authUsers } from "./auth_users"
export const contracts = pgTable(
"contracts",
{
id: bigint("id", { mode: "number" })
.primaryKey()
.generatedByDefaultAsIdentity(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
tenant: bigint("tenant", { mode: "number" }).notNull(),
name: text("name").notNull(),
customer: bigint("customer", { mode: "number" })
.notNull()
.references(() => customers.id),
notes: text("notes"),
active: boolean("active").notNull().default(true),
recurring: boolean("recurring").notNull().default(false),
rhythm: jsonb("rhythm"),
startDate: timestamp("startDate", { withTimezone: true }),
endDate: timestamp("endDate", { withTimezone: true }),
signDate: timestamp("signDate", { withTimezone: true }),
duration: text("duration"),
contact: bigint("contact", { mode: "number" }).references(
() => contacts.id
),
contracttype: bigint("contracttype", { mode: "number" }).references(
() => contracttypes.id
),
bankingIban: text("bankingIban"),
bankingBIC: text("bankingBIC"),
bankingName: text("bankingName"),
bankingOwner: text("bankingOwner"),
sepaRef: text("sepaRef"),
sepaDate: timestamp("sepaDate", { withTimezone: true }),
paymentType: text("paymentType"),
billingInterval: text("billingInterval"),
invoiceDispatch: text("invoiceDispatch"),
ownFields: jsonb("ownFields").notNull().default({}),
profiles: jsonb("profiles").notNull().default([]),
archived: boolean("archived").notNull().default(false),
contractNumber: text("contractNumber"),
updatedAt: timestamp("updated_at", { withTimezone: true }),
updatedBy: uuid("updated_by").references(() => authUsers.id),
}
)
export type Contract = typeof contracts.$inferSelect
export type NewContract = typeof contracts.$inferInsert