generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model Client { id String @id @default(uuid()) companyId String? // Optional company identifier name String email String @unique address Json logoUrl String? phoneNumber String? vatNumber String? companyNumber String? representative String status CustomerStatus @default(active) invoicesReceived Invoice[] @relation("InvoiceTo") } model Service { id String @id @default(uuid()) name String sprint Float hour Float month Float tenantId String tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade) lineItems LineItem[] } model Invoice { id String @id @default(uuid()) sent Int? // Number of times sent dueDate DateTime status InvoiceStatus currency Currency quantityType QuantityType subTotal Float createDate DateTime month Month discount Float? taxes Float? totalAmount Float invoiceNumber String @unique pdfRef String? invoiceFromId String invoiceFrom Tenant @relation(fields: [invoiceFromId], references: [id], onDelete: Cascade) invoiceToId String invoiceTo Client @relation("InvoiceTo", fields: [invoiceToId], references: [id], onDelete: Cascade) items LineItem[] } model LineItem { id String @id @default(uuid()) title String price Float total Float quantity Int description String? serviceId String service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade) invoiceId String invoice Invoice @relation(fields: [invoiceId], references: [id], onDelete: Cascade) } model Tenant { id String @id @default(cuid()) name String email String @unique address Json // Holds {street: string, city?: string, country: string, state?: string, zip: string} bankAccounts Json? // Holds {eur?: {accountNumber?, bicSwift?, iban?, routingNumber?}, usd?: {...}} logoUrl String? phoneNumber String? vatNumber String? companyNumber String? representative String lastInvoiceNumber String @default("0") createdAt DateTime @default(now()) updatedAt DateTime @updatedAt invoicesSent Invoice[] services Service[] employees Employee[] } model Employee { id String @id @default(uuid()) name String email String @unique status EmployeeStatus @default(active) iban String? cv String? photo String? project String? tenantId String tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade) } // Enums enum CustomerStatus { active banned inactive } enum InvoiceStatus { draft processing pending overdue paid } enum Currency { EUR USD } enum QuantityType { Unit Hour Sprint Month } enum Month { January February March April May June July August September October November December } enum EmployeeStatus { active inactive }