Terminplan: Dauer aus Stunden und Besetzung, Auslastung je Woche (0.12.0)
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:
@@ -148,7 +148,8 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
|
||||
});
|
||||
|
||||
// Änderungen an Vorgängen und Verknüpfungen planen die Nachfolger in derselben Transaktion neu
|
||||
const PLAN = new Set(["vorgang", "vorgang_vorgaenger", "zahlung"]);
|
||||
// T15: auch Besetzung, Abwesenheiten und Arbeitszeitmodelle ändern die Dauer berechneter Vorgänge
|
||||
const PLAN = new Set(["vorgang", "vorgang_vorgaenger", "zahlung", "besetzung", "abwesenheit", "arbeitszeitmodell"]);
|
||||
// P12: Projektänderungen legen den Zahlungsplan an oder führen ihn nach; eine Rate von Hand ändern stellt ihn fest
|
||||
async function geplant<T>(c: Client, tabelle: string, fn: () => Promise<T>, bewegt: string[] = [], zahlungVon?: string): Promise<T> {
|
||||
const e = await ladeEinstellungen();
|
||||
@@ -159,7 +160,7 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
|
||||
}
|
||||
if (!PLAN.has(tabelle)) return fn();
|
||||
const aenderung = zahlungVon ? async () => { const r = await fn(); await zahlungsplanFest(c, zahlungVon); return r; } : fn;
|
||||
return (await mitNeuplanung(c, { tage: e.arbeitstage }, aenderung, bewegt)).ergebnis;
|
||||
return (await mitNeuplanung(c, { tage: e.arbeitstage }, aenderung, bewegt, e.stundenProTag)).ergebnis;
|
||||
}
|
||||
const projektDerZahlung = async (c: Client, tabelle: string, id: string) =>
|
||||
tabelle === "zahlung" ? (await c.query("select projekt_id from zahlung where id = $1", [id])).rows[0]?.projekt_id as string | undefined : undefined;
|
||||
@@ -209,6 +210,8 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
|
||||
const { id } = IdParam.parse(req.params);
|
||||
const daten = teil.parse(req.body) as Record<string, unknown>;
|
||||
if (verboten(req, t, daten)) return reply.status(403).send({ fehler: "Dafür fehlt dir die Berechtigung." });
|
||||
// T15: wer die Dauer von Hand ändert, legt sie fest (wie beim Zahlungsplan)
|
||||
if (t.name === "vorgang" && daten.dauer !== undefined && daten.dauer_fest === undefined) daten.dauer_fest = true;
|
||||
const spalten = felder.filter((f) => daten[f] !== undefined);
|
||||
if (spalten.length === 0) return reply.status(400).send({ fehler: "Keine Änderung angegeben" });
|
||||
const row = await transaktion(pool, benutzer(req), async (c) => {
|
||||
@@ -287,7 +290,7 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
|
||||
const e = await ladeEinstellungen();
|
||||
const woche = { tage: e.arbeitstage };
|
||||
const [tp, aufgaben, liqui] = await Promise.all([
|
||||
terminplan(pool, woche),
|
||||
terminplan(pool, woche, e.stundenProTag),
|
||||
pool.query(`select a.*, p.nummer as projekt_nummer, p.bezeichnung as projekt_name, k.name as kontakt_name, g.name as kategorie
|
||||
from aufgabe a left join projekt p on p.id = a.projekt_id left join kontakt k on k.id = a.kontakt_id
|
||||
left join aufgabe_kategorie g on g.id = a.kategorie_id
|
||||
@@ -327,7 +330,7 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
|
||||
|
||||
app.get("/api/terminplan", async () => {
|
||||
const e = await ladeEinstellungen();
|
||||
return terminplan(pool, { tage: e.arbeitstage });
|
||||
return terminplan(pool, { tage: e.arbeitstage }, e.stundenProTag);
|
||||
});
|
||||
|
||||
// Übernahme aus dem Projektplaner V70 (JSON-Sicherung), nur in ein leeres Programm
|
||||
|
||||
Reference in New Issue
Block a user