feat: add financial transactions management for companies

- Implemented a new route for managing financial transactions (money) for companies, including creating, editing, and deleting transactions.
- Added a new model `Buchung` to represent transactions with fields for date, account type, transaction type, amount, and description.
- Updated the `companies` model to include a relation to the new `Buchung` model.
- Enhanced the company overview page to link to the new financial transactions page.
- Added migration scripts to create the necessary database tables and fields for the new functionality.
- Created utility scripts for resetting the admin password and setting up the initial admin user.
This commit is contained in:
hwinkel
2026-03-24 19:25:48 +01:00
parent 6d8c4b615f
commit d582c748a2
29 changed files with 2464 additions and 815 deletions
@@ -0,0 +1,7 @@
-- AlterTable
ALTER TABLE `betriebsausgaben` ADD COLUMN `steuersatz` DECIMAL(5, 2) NOT NULL DEFAULT 0,
ADD COLUMN `zahlungsart` ENUM('KASSE', 'BANK') NOT NULL DEFAULT 'BANK';
-- AlterTable
ALTER TABLE `betriebseinnahmen` ADD COLUMN `steuersatz` DECIMAL(5, 2) NOT NULL DEFAULT 0,
ADD COLUMN `zahlungsart` ENUM('KASSE', 'BANK') NOT NULL DEFAULT 'BANK';
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE `companies` ADD COLUMN `money` JSON NULL;
@@ -0,0 +1,28 @@
/*
Warnings:
- You are about to drop the column `money` on the `companies` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE `companies` DROP COLUMN `money`;
-- CreateTable
CREATE TABLE `buchungen` (
`id` VARCHAR(191) NOT NULL,
`companyId` VARCHAR(191) NOT NULL,
`date` DATETIME(3) NOT NULL,
`account` ENUM('KASSE', 'BANK') NOT NULL,
`type` ENUM('EINLAGE', 'ENTNAHME') NOT NULL,
`amount` DECIMAL(10, 2) NOT NULL,
`description` TEXT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,
INDEX `buchungen_companyId_idx`(`companyId`),
INDEX `buchungen_date_idx`(`date`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `buchungen` ADD CONSTRAINT `buchungen_companyId_fkey` FOREIGN KEY (`companyId`) REFERENCES `companies`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+37
View File
@@ -73,12 +73,40 @@ model Company {
betriebsausgaben Betriebsausgabe[]
betriebseinnahmen Betriebseinnahme[]
anlagegueter Anlagegut[]
buchungen Buchung[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("companies")
}
enum TransactionAccount {
KASSE
BANK
}
enum TransactionType {
EINLAGE
ENTNAHME
}
model Buchung {
id String @id @default(cuid())
companyId String
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
date DateTime
account TransactionAccount
type TransactionType
amount Decimal @db.Decimal(10, 2)
description String? @db.Text
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([companyId])
@@index([date])
@@map("buchungen")
}
model Service {
id String @id @default(cuid())
companyId String
@@ -146,6 +174,11 @@ enum InvoiceStatus {
DELETED
}
enum Zahlungsart {
KASSE
BANK
}
enum EinnahmeKategorie {
FUSSPFLEGE
PRIVATEINLAGEN
@@ -165,6 +198,8 @@ model Betriebseinnahme {
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
kategorie EinnahmeKategorie
betrag Decimal @db.Decimal(10, 2)
steuersatz Decimal @db.Decimal(5, 2) @default(0)
zahlungsart Zahlungsart @default(BANK)
datum DateTime
beschreibung String? @db.Text
createdAt DateTime @default(now())
@@ -219,6 +254,8 @@ model Betriebsausgabe {
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
kategorie AusgabeKategorie
betrag Decimal @db.Decimal(10, 2)
steuersatz Decimal @db.Decimal(5, 2) @default(0)
zahlungsart Zahlungsart @default(BANK)
datum DateTime
beschreibung String? @db.Text
createdAt DateTime @default(now())