0.29.0: Rauten und Meilensteine auf Freitag nach Freigabe, Auslastung Team oben fest
Some checks failed
Prüfung / tests (push) Has been cancelled
Prüfung / container (push) Has been cancelled

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-22 08:51:45 +00:00
parent ba34664c02
commit e1b0406289
12 changed files with 94 additions and 29 deletions

View File

@@ -188,14 +188,14 @@ export async function baueApp(o: Optionen): Promise<FastifyInstance> {
async function versatzAusDatum(c: Client, tabelle: string, daten: Record<string, unknown>, id?: string): Promise<void> {
const feld = DATUM_FELD[tabelle];
if (!feld || typeof daten[feld] !== "string" || daten.bezug_tage !== undefined) return;
const alt = id ? (await c.query(`select vorgang_id, bezug_art from ${tabelle} where id = $1`, [id])).rows[0] : undefined;
const alt = id ? (await c.query(`select vorgang_id, bezug_art, freitag from ${tabelle} where id = $1`, [id])).rows[0] : undefined;
const vid = (daten.vorgang_id !== undefined ? daten.vorgang_id : alt?.vorgang_id) as string | null | undefined;
if (!vid) return;
const v = (await c.query("select id, start, dauer, freitage from vorgang where id = $1", [vid])).rows[0];
if (!v) return;
const e = await ladeEinstellungen();
const art = (daten.bezug_art ?? alt?.bezug_art ?? "EE") as BezugArt;
daten.bezug_tage = bezugsTage({ ...v, dauer: Number(v.dauer) }, art, daten[feld] as string, { tage: e.arbeitstage });
daten.bezug_tage = bezugsTage({ ...v, dauer: Number(v.dauer) }, art, daten[feld] as string, { tage: e.arbeitstage }, (daten.freitag ?? alt?.freitag) as boolean | undefined);
}
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;

View File

@@ -0,0 +1,5 @@
-- Raten, Ausgaben und Aufgaben auf einem Freitag (Henning 22.10.2026): nach Rückfrage freigegeben, dann zählt
-- ihr Versatz zum Vorgang auch Freitage mit und sie bleibt auf dem Freitag liegen.
alter table zahlung add column freitag boolean not null default false;
alter table kosten add column freitag boolean not null default false;
alter table aufgabe add column freitag boolean not null default false;

View File

@@ -354,6 +354,7 @@ export const TABELLEN: Tabelle[] = [
zahlungsziel_tage: z.number().int().min(0).nullable().optional(),
bezug_art: z.enum(["AA", "EE"]).optional(),
bezug_tage: z.number().int().min(-500).max(500).optional(),
freitag: z.boolean().optional(),
rest: z.boolean().optional(),
}),
},
@@ -374,6 +375,7 @@ export const TABELLEN: Tabelle[] = [
vorgang_id: id.nullable().optional(),
bezug_art: z.enum(["AA", "EE"]).optional(),
bezug_tage: z.number().int().min(-500).max(500).optional(),
freitag: z.boolean().optional(),
// aus dem Einsatz eines Subunternehmers; false = von Hand geändert, rechnet sich nicht mehr neu
automatisch: z.boolean().optional(),
}),
@@ -416,6 +418,7 @@ export const TABELLEN: Tabelle[] = [
vorgang_id: id.nullable().optional(),
bezug_art: z.enum(["AA", "EE"]).optional(),
bezug_tage: z.number().int().min(-500).max(500).optional(),
freitag: z.boolean().optional(),
}),
},
// Stufe 2: Personal (M1, M8, M4, M10)

View File

@@ -82,11 +82,11 @@ export async function bezuegeNachziehen(c: Client, woche: Arbeitswoche): Promise
["aufgabe", "faellig_am", "x.erledigt_am is null"],
];
for (const [tabelle, feld, offen] of teile) {
const r = await c.query<{ id: string; datum: string | null; bezug_art: BezugArt; bezug_tage: number; vid: string; start: string; dauer: number; freitage: string[] }>(
`select x.id, x.${feld} as datum, x.bezug_art, x.bezug_tage, v.id as vid, v.start, v.dauer, v.freitage
const r = await c.query<{ id: string; datum: string | null; bezug_art: BezugArt; bezug_tage: number; freitag: boolean; vid: string; start: string; dauer: number; freitage: string[] }>(
`select x.id, x.${feld} as datum, x.bezug_art, x.bezug_tage, x.freitag, v.id as vid, v.start, v.dauer, v.freitage
from ${tabelle} x join vorgang v on v.id = x.vorgang_id where ${offen}`);
for (const z of r.rows) {
const soll = bezugsTermin({ id: z.vid, start: z.start, dauer: Number(z.dauer), freitage: z.freitage }, z.bezug_art, Number(z.bezug_tage), woche);
const soll = bezugsTermin({ id: z.vid, start: z.start, dauer: Number(z.dauer), freitage: z.freitage }, z.bezug_art, Number(z.bezug_tage), woche, z.freitag);
if (soll !== z.datum) await c.query(`update ${tabelle} set ${feld} = $2 where id = $1`, [z.id, soll]);
}
}
@@ -112,12 +112,12 @@ export async function terminplan(pool: Pool, woche: Arbeitswoche, stundenProTag
from besetzung b left join kontakt k on k.id = b.kontakt_id left join kolonne ko on ko.id = b.kolonne_id order by b.angelegt_am`),
pool.query(`select k.id, k.name, k.firma, k.rolle, s.kolonnengroesse from kontakt k left join subunternehmer s on s.kontakt_id = k.id
where k.rolle in ('mitarbeiter', 'subunternehmer') order by k.rolle, k.name`),
pool.query("select id, projekt_id, vorgang_id, bezug_art, bezug_tage, art, bezeichnung, netto, termin, status, rest, reihenfolge from zahlung order by reihenfolge, termin"),
pool.query("select id, projekt_id, vorgang_id, bezug_art, bezug_tage, freitag, art, bezeichnung, netto, termin, status, rest, reihenfolge from zahlung order by reihenfolge, termin"),
// Sicherheitseinbehalte werden erst nach der Gewährleistung fällig und gehören nicht in den Bauablauf
pool.query(`select id, projekt_id, vorgang_id, bezug_art, bezug_tage, art, bezeichnung, netto, termin, status, automatisch from kosten
pool.query(`select id, projekt_id, vorgang_id, bezug_art, bezug_tage, freitag, art, bezeichnung, netto, termin, status, automatisch from kosten
where besetzung_teil is distinct from 'einbehalt' order by termin, bezeichnung`),
// Aufgaben eines Projekts stehen im Terminplan in dessen Abschnitt „Aufgaben“
pool.query(`select a.id, a.projekt_id, a.vorgang_id, a.bezug_art, a.bezug_tage, a.text, a.faellig_am, a.erledigt_am, a.kategorie_id, g.name as kategorie
pool.query(`select a.id, a.projekt_id, a.vorgang_id, a.bezug_art, a.bezug_tage, a.freitag, a.text, a.faellig_am, a.erledigt_am, a.kategorie_id, g.name as kategorie
from aufgabe a left join aufgabe_kategorie g on g.id = a.kategorie_id where a.projekt_id is not null
order by a.faellig_am nulls last, a.angelegt_am`),
pool.query(`select o.id, o.name, o.aktiv, o.leitung_kontakt_id, coalesce(array_agg(m.kontakt_id order by m.angelegt_am) filter (where m.kontakt_id is not null), '{}') as mitglieder