Refactor financial transaction handling: Consolidate Einnahmen and Ausgaben into Buchung model, update routes and UI components, and add new migration scripts for database schema changes.

This commit is contained in:
hwinkel
2026-03-24 21:06:07 +01:00
parent d582c748a2
commit 1ec15600b5
18 changed files with 928 additions and 358 deletions
+11 -9
View File
@@ -52,12 +52,14 @@ export async function loader({ request, params }: { request: Request; params: {
if (!company) throw new Response("Not Found", { status: 404 });
const year = new Date().getFullYear();
const einnahmen = await prisma.betriebseinnahme.findMany({
const einnahmen = await prisma.buchung.findMany({
where: {
companyId: params.id,
datum: { gte: new Date(`${year}-01-01`), lt: new Date(`${year + 1}-01-01`) },
type: "EINLAGE",
isBusinessRecord: true,
date: { gte: new Date(`${year}-01-01`), lt: new Date(`${year + 1}-01-01`) },
},
orderBy: { datum: "desc" },
orderBy: { date: "desc" },
});
return {
@@ -66,12 +68,12 @@ export async function loader({ request, params }: { request: Request; params: {
initialYear: year,
einnahmen: einnahmen.map((e) => ({
id: e.id,
kategorie: e.kategorie as EinnahmeKategorieKey,
betrag: Number(e.betrag),
steuersatz: Number(e.steuersatz),
zahlungsart: e.zahlungsart as "KASSE" | "BANK",
datum: e.datum.toISOString(),
beschreibung: e.beschreibung,
kategorie: (e.kategorie || "SONSTIGE_EINNAHMEN") as EinnahmeKategorieKey,
betrag: Number(e.amount),
steuersatz: e.steuersatz || 0,
zahlungsart: (e.zahlungsart as "KASSE" | "BANK") || "BANK",
datum: e.date.toISOString(),
beschreibung: e.description,
})),
};
}