Mehrere Stichtage pro Zeitraum verwalten
All checks were successful
CI / Build and Deploy (push) Successful in 2m43s

This commit is contained in:
jan
2026-05-12 01:37:28 +02:00
parent 08df13c044
commit 5591d10d96
11 changed files with 790 additions and 88 deletions

View File

@@ -0,0 +1,37 @@
CREATE TABLE "period_cutoffs" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"date" TIMESTAMP(3),
"period_id" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "period_cutoffs_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "period_cutoffs_period_id_idx" ON "period_cutoffs"("period_id");
ALTER TABLE "period_cutoffs"
ADD CONSTRAINT "period_cutoffs_period_id_fkey"
FOREIGN KEY ("period_id") REFERENCES "accounting_periods"("id")
ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "expenses" ADD COLUMN "cutoff_id" TEXT;
INSERT INTO "period_cutoffs" ("id", "name", "date", "period_id", "created_at", "updated_at")
SELECT
'cutoff_' || md5("id"),
COALESCE(NULLIF("cutoff_name", ''), 'Open Air'),
"cutoff_date",
"id",
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP
FROM "accounting_periods";
UPDATE "expenses"
SET "cutoff_id" = 'cutoff_' || md5("period_id");
ALTER TABLE "expenses"
ADD CONSTRAINT "expenses_cutoff_id_fkey"
FOREIGN KEY ("cutoff_id") REFERENCES "period_cutoffs"("id")
ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -86,6 +86,7 @@ model AccountingPeriod {
isCurrent Boolean @default(false) @map("is_current")
cutoffName String @default("Open Air") @map("cutoff_name")
cutoffDate DateTime? @map("cutoff_date")
cutoffs PeriodCutoff[]
budgets Budget[]
expenses Expense[]
donations Donation[]
@@ -95,6 +96,20 @@ model AccountingPeriod {
@@map("accounting_periods")
}
model PeriodCutoff {
id String @id @default(cuid())
name String
date DateTime? @map("date")
periodId String @map("period_id")
period AccountingPeriod @relation(fields: [periodId], references: [id], onDelete: Cascade)
expenses Expense[]
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@index([periodId])
@@map("period_cutoffs")
}
model AppSettings {
id String @id @default("global")
approvalThreshold Decimal @default(50) @db.Decimal(10, 2) @map("approval_threshold")
@@ -148,6 +163,7 @@ model Expense {
approvalStatus ApprovalStatus @default(PENDING) @map("approval_status")
recurrence ExpenseRecurrence @default(NONE)
recurrenceStartAt DateTime? @map("recurrence_start_at")
cutoffId String? @map("cutoff_id")
cutoffPhase CutoffPhase @default(PRE) @map("cutoff_phase")
paidAt DateTime? @map("paid_at")
documentedAt DateTime? @map("documented_at")
@@ -157,6 +173,7 @@ model Expense {
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)
cutoff PeriodCutoff? @relation(fields: [cutoffId], references: [id], onDelete: SetNull)
approvals Approval[]
documents ExpenseDocument[]
donations Donation[]