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

View File

@@ -6,6 +6,7 @@ import { existsSync } from "node:fs";
import { z, ZodError } from "zod";
import { type Client, type Pool, transaktion } from "./db.js";
import { mitNeuplanung, pruefeVerknuepfung, terminplan } from "./terminplan.js";
import { uebersicht } from "./uebersicht.js";
import { TABELLEN } from "./tabellen.js";
import { EinstellungenSchema, type Einstellungen } from "./einstellungen.js";
import { liquiditaet } from "../domain/liquiditaet.js";
@@ -135,8 +136,7 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
anzahl: z.coerce.number().int().min(1).max(104).default(12),
});
app.get("/api/liquiditaet", async (req) => {
const q = LiquiAnfrage.parse(req.query);
async function berechneLiquiditaet(q: z.infer<typeof LiquiAnfrage>) {
const e = await ladeEinstellungen();
const [projekte, vorgaenge, zahlungen, kosten, laufend] = await Promise.all([
pool.query("select * from projekt"),
@@ -159,6 +159,23 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
);
const start = q.start ?? new Date().toISOString().slice(0, 10);
return liquiditaet(daten, { ansicht: q.ansicht, start, anzahl: q.anzahl, startsaldo: e.startsaldo, ziele: e.zahlungsziele, ust: e.ust });
}
app.get("/api/liquiditaet", async (req) => berechneLiquiditaet(LiquiAnfrage.parse(req.query)));
// Startseite: Aufgaben, Warnungen, wer macht was in den nächsten zwei Wochen, Liquidität 4 Wochen
app.get("/api/uebersicht", async (req) => {
const heute = z.object({ heute: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional() }).parse(req.query).heute ?? new Date().toISOString().slice(0, 10);
const e = await ladeEinstellungen();
const woche = { tage: e.arbeitstage };
const [tp, aufgaben, liqui] = await Promise.all([
terminplan(pool, woche),
pool.query(`select a.*, p.nummer as projekt_nummer from aufgabe a left join projekt p on p.id = a.projekt_id
where a.erledigt_am is null order by a.faellig_am nulls last, a.angelegt_am`),
berechneLiquiditaet({ ansicht: "woche", start: heute, anzahl: 4 }),
]);
return uebersicht({ heute, woche, tp, aufgaben: aufgaben.rows, liqui, mindestreserve: e.mindestreserve,
kontostandErfasst: e.startsaldo !== 0 || e.startsaldoDatum !== null });
});
app.get("/api/terminplan", async () => {