You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}
enum Role {
ADMIN
MANAGER
WORKER
}
enum Status {
PENDING
APPROVED
REJECTED
PAID
}
model User {
id String @id @default(cuid())
name String
email String @unique
password String?
role Role @default(WORKER)
department String?
reimbursements Reimbursement[]
overtimes Overtime[]
payslips Payslip[]
logs AuditLog[]
deletedAt DateTime?
}
model Account {
id String @id @default(cuid())
name String
balance Decimal @db.Decimal(20, 2)
type String // "ASSET" or "LIABILITY"
transactions CompanyTransaction[]
deletedAt DateTime?
}
model Category {
id String @id @default(cuid())
name String
parentId String?
parent Category? @relation("CategoryToCategory", fields: [parentId], references: [id])
children Category[] @relation("CategoryToCategory")
transactions CompanyTransaction[]
deletedAt DateTime?
}
model Reimbursement {
id String @id @default(cuid())
amount Decimal @db.Decimal(20, 2)
description String
category String // e.g., "Travel", "Medical"
receiptUrl String? // URL from S3/Uploadthing
status Status @default(PENDING)
userId String
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
deletedAt DateTime?
}
model Overtime {
id String @id @default(cuid())
date DateTime
hours Float
reason String
status Status @default(PENDING)
userId String
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
deletedAt DateTime?
}
model CompanyTransaction {
id String @id @default(cuid())
amount Decimal @db.Decimal(20, 2)
type String // "CREDIT" or "DEBIT"
description String
accountId String
account Account @relation(fields: [accountId], references: [id])
categoryId String?
category Category? @relation(fields: [categoryId], references: [id])
date DateTime @default(now())
deletedAt DateTime?
}
model AuditLog {
id String @id @default(cuid())
action String // e.g., "UPDATE_REIMBURSEMENT"
entityId String?
oldValue String?
newValue String?
userId String
user User @relation(fields: [userId], references: [id])
timestamp DateTime @default(now())
}
model Budget {
id String @id @default(cuid())
department String
amount Decimal @db.Decimal(20, 2)
period String // e.g., "2024-Q1", "2024-01"
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
}
model Payslip {
id String @id @default(cuid())
userId String
user User @relation(fields: [userId], references: [id])
month Int // 1-12
year Int
pdfUrl String
amount Decimal @db.Decimal(20, 2)
createdAt DateTime @default(now())
}