Stufe 0: Grundgerüst mit Rechenkern, Datenbank, Oberfläche und Docker-Betrieb
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
149
src/server/tabellen.ts
Normal file
149
src/server/tabellen.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
// Eingabeprüfung für die Tabellen aus Stufe 0. Feldnamen = Spaltennamen.
|
||||
import { z } from "zod";
|
||||
|
||||
const datum = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Datum im Format JJJJ-MM-TT");
|
||||
const cent = z.number().int("Betrag in ganzen Cent");
|
||||
const id = z.uuid();
|
||||
const text = z.string().trim().min(1, "darf nicht leer sein");
|
||||
const optText = z.string().trim().nullable().optional();
|
||||
|
||||
export interface Tabelle {
|
||||
name: string;
|
||||
pfad: string;
|
||||
schema: z.ZodObject;
|
||||
sortierung: string;
|
||||
}
|
||||
|
||||
export const TABELLEN: Tabelle[] = [
|
||||
{
|
||||
name: "kontakt",
|
||||
pfad: "kontakte",
|
||||
sortierung: "name",
|
||||
schema: z.object({
|
||||
name: text,
|
||||
firma: optText,
|
||||
rolle: z.enum(["bauherr", "subunternehmer", "lieferant", "planer", "mitarbeiter", "sonstige"]).optional(),
|
||||
telefon: optText,
|
||||
email: optText,
|
||||
gewerk: optText,
|
||||
notiz: optText,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "projekt",
|
||||
pfad: "projekte",
|
||||
sortierung: "reihenfolge, nummer",
|
||||
schema: z.object({
|
||||
nummer: text,
|
||||
bezeichnung: text,
|
||||
bauherr_id: id.nullable().optional(),
|
||||
status: z.enum(["anfrage", "angebot", "auftrag", "ausfuehrung", "abgerechnet", "gewaehrleistung", "abgeschlossen"]).optional(),
|
||||
umsatz_netto: cent.optional(),
|
||||
material_kosten: cent.optional(),
|
||||
fremd_kosten: cent.optional(),
|
||||
sonstige_kosten: cent.optional(),
|
||||
vertragsart: z.enum(["vob", "bgb"]).nullable().optional(),
|
||||
abnahme_am: datum.nullable().optional(),
|
||||
farbe: optText,
|
||||
nextcloud_link: optText,
|
||||
reihenfolge: z.number().int().optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "abschnitt",
|
||||
pfad: "abschnitte",
|
||||
sortierung: "projekt_id, reihenfolge",
|
||||
schema: z.object({
|
||||
projekt_id: id,
|
||||
name: text,
|
||||
ist_meilenstein: z.boolean().optional(),
|
||||
reihenfolge: z.number().int().optional(),
|
||||
erledigt: z.boolean().optional(),
|
||||
termin: datum.nullable().optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "vorgang",
|
||||
pfad: "vorgaenge",
|
||||
sortierung: "abschnitt_id, reihenfolge, start",
|
||||
schema: z.object({
|
||||
abschnitt_id: id,
|
||||
name: text,
|
||||
start: datum,
|
||||
dauer: z.number().min(0).optional(),
|
||||
stunden: z.number().min(0).nullable().optional(),
|
||||
kontakt_id: id.nullable().optional(),
|
||||
reihenfolge: z.number().int().optional(),
|
||||
fortschritt: z.number().int().min(0).max(100).optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "vorgang_vorgaenger",
|
||||
pfad: "verknuepfungen",
|
||||
sortierung: "vorgang_id",
|
||||
schema: z.object({
|
||||
vorgang_id: id,
|
||||
vorgaenger_id: id,
|
||||
art: z.enum(["EA", "AA", "EE", "AE"]).optional(),
|
||||
verzoegerung: z.number().int().optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "zahlung",
|
||||
pfad: "zahlungen",
|
||||
sortierung: "projekt_id, reihenfolge, termin",
|
||||
schema: z.object({
|
||||
projekt_id: id,
|
||||
vorgang_id: id.nullable().optional(),
|
||||
art: z.enum(["anzahlung", "abschlag", "nachtrag", "schluss", "einbehalt"]).optional(),
|
||||
bezeichnung: text,
|
||||
netto: cent,
|
||||
termin: datum,
|
||||
status: z.enum(["geplant", "gestellt", "bezahlt"]).optional(),
|
||||
rechnungsdatum: datum.nullable().optional(),
|
||||
bezahlt_am: datum.nullable().optional(),
|
||||
reihenfolge: z.number().int().optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "kosten",
|
||||
pfad: "kosten",
|
||||
sortierung: "projekt_id, termin",
|
||||
schema: z.object({
|
||||
projekt_id: id,
|
||||
art: z.enum(["material", "fremd", "sonstiges"]),
|
||||
bezeichnung: text,
|
||||
netto: cent,
|
||||
termin: datum,
|
||||
kontakt_id: id.nullable().optional(),
|
||||
mit_vorsteuer: z.boolean().optional(),
|
||||
status: z.enum(["geplant", "bestellt", "bezahlt"]).optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "laufende_kosten",
|
||||
pfad: "laufende-kosten",
|
||||
sortierung: "kategorie, bezeichnung",
|
||||
schema: z.object({
|
||||
bezeichnung: text,
|
||||
kategorie: text.optional(),
|
||||
betrag: cent,
|
||||
rhythmus: z.enum(["einmalig", "monatlich", "vierteljaehrlich", "jaehrlich"]).optional(),
|
||||
start: datum,
|
||||
ende: datum.nullable().optional(),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "aufgabe",
|
||||
pfad: "aufgaben",
|
||||
sortierung: "erledigt_am nulls first, faellig_am nulls last, angelegt_am",
|
||||
schema: z.object({
|
||||
text: text,
|
||||
faellig_am: datum.nullable().optional(),
|
||||
langfristig: z.boolean().optional(),
|
||||
projekt_id: id.nullable().optional(),
|
||||
kontakt_id: id.nullable().optional(),
|
||||
erledigt_am: z.iso.datetime({ offset: true }).nullable().optional(),
|
||||
}),
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user