Startseite mit Aufgaben, Warnungen und wer macht was; Aufgaben aus V70 übernehmen

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:
Claude
2026-10-19 19:01:50 +00:00
parent aedd86a29b
commit 8a4fbafa65
10 changed files with 363 additions and 17 deletions

85
src/domain/uebersicht.ts Normal file
View File

@@ -0,0 +1,85 @@
// Startseite (Ü3, Ü7, Ü8): Aufgaben wie in V70 gruppiert, Warnungen und wer was wann wo macht.
import { type Datum, plusTage, wochentag } from "./datum.js";
import { type Arbeitswoche, istArbeitstag } from "./kalender.js";
import { type Besetzung, wer } from "./einsatz.js";
export interface Aufgabe {
id: string;
text: string;
faellig_am?: Datum | null;
langfristig?: boolean;
erledigt_am?: string | null;
}
/** V70: „Diese Woche“ (fällig bis Sonntag), „Noch nicht abgearbeitet“ (überfällig), „Langfristig“ (später oder ohne Datum). */
export function aufgabenGruppen<T extends Aufgabe>(aufgaben: T[], heute: Datum) {
const sonntag = plusTage(heute, (7 - wochentag(heute)) % 7);
const g = { dieseWoche: [] as T[], ueberfaellig: [] as T[], langfristig: [] as T[] };
for (const a of aufgaben) {
if (a.erledigt_am) continue;
const d = a.faellig_am;
if (d && d < heute) g.ueberfaellig.push(a);
else if (d && d <= sonntag && !a.langfristig) g.dieseWoche.push(a);
else g.langfristig.push(a);
}
const nachDatum = (a: T, b: T) => (a.faellig_am ?? "9999") < (b.faellig_am ?? "9999") ? -1 : (a.faellig_am ?? "9999") > (b.faellig_am ?? "9999") ? 1 : a.text.localeCompare(b.text, "de");
g.dieseWoche.sort(nachDatum);
g.ueberfaellig.sort(nachDatum);
g.langfristig.sort(nachDatum);
return g;
}
export interface UeVorgang {
id: string;
name: string;
anfang: Datum;
ende: Datum;
projekt: string;
}
export interface UeBesetzung extends Besetzung {
anzeige: string;
kurz: string;
}
/** Arbeitstage ab heute, so viele wie gewünscht (Freitag ist Reserve und fehlt deshalb). */
export function naechsteArbeitstage(heute: Datum, anzahl: number, woche: Arbeitswoche): Datum[] {
const aus: Datum[] = [];
for (let d = heute; aus.length < anzahl; d = plusTage(d, 1)) if (istArbeitstag(d, woche)) aus.push(d);
return aus;
}
export interface Einsatzzeile {
wer: string;
anzeige: string;
/** je Tag die Vorgänge dieser Person */
tage: { vorgang: string; name: string; projekt: string; vorgemerkt: boolean }[][];
}
/** Ü8: je Person (und Platzhalter) die Vorgänge an den nächsten Arbeitstagen; dazu Vorgänge ohne Besetzung. */
export function einsatzMatrix(vorgaenge: UeVorgang[], besetzungen: UeBesetzung[], tage: Datum[]): { zeilen: Einsatzzeile[]; ohne: Einsatzzeile } {
const zeilen = new Map<string, Einsatzzeile>();
const ohne: Einsatzzeile = { wer: "", anzeige: "Noch nicht besetzt", tage: tage.map(() => []) };
for (const v of vorgaenge) {
const idx = tage.map((d, i) => (d >= v.anfang && d <= v.ende ? i : -1)).filter((i) => i >= 0);
if (!idx.length) continue;
const bs = besetzungen.filter((b) => b.vorgang_id === v.id);
const eintrag = (vorgemerkt: boolean) => ({ vorgang: v.id, name: v.name, projekt: v.projekt, vorgemerkt });
if (!bs.length) idx.forEach((i) => ohne.tage[i]!.push(eintrag(false)));
for (const b of bs) {
const w = wer(b) ?? `nn:${b.anzeige}`;
const z = zeilen.get(w) ?? { wer: w, anzeige: b.anzeige, tage: tage.map(() => []) };
idx.forEach((i) => z.tage[i]!.push(eintrag(!b.freigegeben)));
zeilen.set(w, z);
}
}
return { zeilen: [...zeilen.values()].sort((a, b) => a.anzeige.localeCompare(b.anzeige, "de")), ohne };
}
export interface Warnung {
art: "ueberschneidung" | "unbesetzt" | "freigabe" | "aufgabe" | "kontostand";
text: string;
/** Sprungziel in der App, z. B. "terminplan" */
ziel: string;
}

View File

@@ -76,7 +76,12 @@ export interface V70Sicherung {
firmenkosten_monatlich: V70Firmenkosten[];
firmenkosten_einmalig: V70Firmenkosten[];
arbeitszeit?: { h?: number; eff?: number; rund?: string };
aufgaben?: unknown[];
aufgaben?: V70Aufgabe[];
}
/** Aufgabe im Aufgabenblock: t Text, d fällig, k Kontakt (freier Text), p Projekt als Listenposition */
export interface V70Aufgabe {
id?: string; t?: string; d?: string; k?: string; p?: number | string | null; done?: boolean; doneAt?: number;
}
// --- Ergebnis ---
@@ -108,6 +113,7 @@ export interface Uebernahme {
}[];
kosten: { projekt: string; art: Kostenart; bezeichnung: string; netto: Cent; termin: Datum; mit_vorsteuer: boolean; zahlungsziel_tage: number }[];
laufend: { bezeichnung: string; gruppe?: string; kategorie: string; betrag: Cent; rhythmus: Rhythmus; start: Datum }[];
aufgaben: { text: string; faellig_am?: Datum; projekt?: string; erledigt_am?: string }[];
hinweise: string[];
}
@@ -199,7 +205,7 @@ export function uebernimmV70(roh: unknown, woche: Arbeitswoche = MO_BIS_DO): Ueb
rundung,
zahlungsziele: { kundenTage: zz, materialTage: mz, fremdTage: mz, sonstigeTage: mz },
},
kontakte: [], projekte: [], abschnitte: [], vorgaenge: [], verknuepfungen: [], zahlungen: [], kosten: [], laufend: [],
kontakte: [], projekte: [], abschnitte: [], vorgaenge: [], verknuepfungen: [], zahlungen: [], kosten: [], laufend: [], aufgaben: [],
hinweise,
};
@@ -376,7 +382,17 @@ export function uebernimmV70(roh: unknown, woche: Arbeitswoche = MO_BIS_DO): Ueb
}
u.laufend.push({ bezeichnung: f.t.trim(), gruppe: f.g?.trim() || undefined, kategorie: f.c?.trim() || "Sonstiges", betrag: euroZuCent(f.b), rhythmus: "einmalig", start: f.d });
}
if (s.aufgaben?.length) hinweise.push(`${s.aufgaben.length} Aufgaben aus V70 werden mit Stufe 1 übernommen.`);
for (const a of s.aufgaben ?? []) {
const text = [a.t?.trim(), a.k?.trim() ? `(${a.k.trim()})` : ""].filter(Boolean).join(" ");
if (!text) continue;
const pi = a.p === "" || a.p === null || a.p === undefined ? -1 : Number(a.p);
u.aufgaben.push({
text,
faellig_am: a.d && DATUM.test(a.d) ? a.d : undefined,
projekt: pi >= 0 && pi < s.projekte.length ? `p${pi}` : undefined,
erledigt_am: a.done ? new Date(a.doneAt || Date.now()).toISOString() : undefined,
});
}
return u;
}