Files
RFP_Finanzen/prisma/schema.prisma
Jan 34e5f96db7
Some checks failed
CI / Build (push) Failing after 1m6s
CI / Deploy (push) Has been skipped
Bereits an AG übergeben läuft jetzt so, wie du es beschrieben hast:
Bezahlt setzen zählt in der Budgetanzeige automatisch mit.
Zusätzlich gibt es unter Neue Ausgabe eine eigene Insel für zusätzlich bereits übergebenes Geld, falls das nicht über einzelne Ausgaben läuft.
In den Budgetkarten wird das als gestrichelte Querlinie plus eigenem Chip dargestellt
2026-04-13 21:22:02 +02:00

159 lines
5.3 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
ADMIN
FINANCE
MEMBER
}
enum ApprovalType {
CHAIR_A
CHAIR_B
FINANCE
}
enum ApprovalStatus {
PENDING
APPROVED
}
enum ExpenseRecurrence {
NONE
MONTHLY
}
model User {
id String @id @default(cuid())
name String
username String @unique
email String? @unique
passwordHash String @map("password_hash")
role Role
approvalPreference ApprovalType? @map("approval_preference")
approvalPermissions ApprovalType[] @default([]) @map("approval_permissions")
workingGroupId String? @map("working_group_id")
workingGroup WorkingGroup? @relation(fields: [workingGroupId], references: [id], onDelete: SetNull)
createdExpenses Expense[] @relation("ExpenseCreator")
approvals Approval[]
auditLogs AuditLog[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("users")
}
model AccountingPeriod {
id String @id @default(cuid())
name String @unique
startsAt DateTime @map("starts_at")
endsAt DateTime @map("ends_at")
isCurrent Boolean @default(false) @map("is_current")
budgets Budget[]
expenses Expense[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("accounting_periods")
}
model AppSettings {
id String @id @default("global")
approvalThreshold Decimal @default(50) @db.Decimal(10, 2) @map("approval_threshold")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("app_settings")
}
model WorkingGroup {
id String @id @default(cuid())
name String @unique
members User[]
budgets Budget[]
expenses Expense[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("working_groups")
}
model Budget {
id String @id @default(cuid())
name String
totalBudget Decimal @db.Decimal(10, 2) @map("total_budget")
releasedAmount Decimal @default(0) @db.Decimal(10, 2) @map("released_amount")
colorCode String @map("color_code")
workingGroupId String @map("working_group_id")
periodId String @map("period_id")
workingGroup WorkingGroup @relation(fields: [workingGroupId], references: [id], onDelete: Cascade)
period AccountingPeriod @relation(fields: [periodId], references: [id], onDelete: Restrict)
expenses Expense[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@unique([workingGroupId, periodId, name])
@@map("budgets")
}
model Expense {
id String @id @default(cuid())
title String
description String?
amount Decimal @db.Decimal(10, 2)
creatorId String @map("creator_id")
agId String @map("ag_id")
budgetId String @map("budget_id")
periodId String @map("period_id")
approvalStatus ApprovalStatus @default(PENDING) @map("approval_status")
recurrence ExpenseRecurrence @default(NONE)
recurrenceStartAt DateTime? @map("recurrence_start_at")
paidAt DateTime? @map("paid_at")
documentedAt DateTime? @map("documented_at")
proofUrl String? @map("proof_url")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
creator User @relation("ExpenseCreator", fields: [creatorId], references: [id], onDelete: Restrict)
workingGroup WorkingGroup @relation(fields: [agId], references: [id], onDelete: Cascade)
budget Budget @relation(fields: [budgetId], references: [id], onDelete: Restrict)
period AccountingPeriod @relation(fields: [periodId], references: [id], onDelete: Restrict)
approvals Approval[]
@@map("expenses")
}
model Approval {
id String @id @default(cuid())
expenseId String @map("expense_id")
userId String @map("user_id")
approvalType ApprovalType @map("approval_type")
timestamp DateTime @default(now())
expense Expense @relation(fields: [expenseId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([expenseId, approvalType])
@@map("approvals")
}
model AuditLog {
id String @id @default(cuid())
actorId String? @map("actor_id")
actor User? @relation(fields: [actorId], references: [id], onDelete: SetNull)
action String
entityType String @map("entity_type")
entityId String? @map("entity_id")
entityLabel String? @map("entity_label")
summary String
metadata Json?
createdAt DateTime @default(now()) @map("created_at")
@@index([createdAt])
@@map("audit_logs")
}