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:
@@ -8,6 +8,7 @@ import { type Abwesenheit, urlaubstage } from "../domain/personal.js";
|
||||
import { formatDatum, jahrVon } from "../domain/datum.js";
|
||||
import { anfang, ende } from "../domain/terminplan.js";
|
||||
import { kontoFuer, ladePersonal } from "./personal.js";
|
||||
import { mitNeuplanung } from "./terminplan.js";
|
||||
|
||||
type Abfrage = Pick<Pool, "query">;
|
||||
const Tag = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
||||
@@ -127,11 +128,14 @@ export function registriereUrlaub(app: FastifyInstance, pool: Pool, einstellunge
|
||||
app.post("/api/urlaub/:id/entscheidung", async (req) => {
|
||||
const { id } = z.object({ id: z.uuid() }).parse(req.params);
|
||||
const d = z.object({ status: z.enum(["genehmigt", "abgelehnt"]), antwort: z.string().trim().max(500).nullable().optional() }).parse(req.body);
|
||||
const e = await einstellungen();
|
||||
return transaktion(pool, req.wer!.anmeldename, async (c) => {
|
||||
const a = (await c.query("select status from abwesenheit where id = $1 and art = 'urlaub'", [id])).rows[0];
|
||||
if (!a) throw new Fehler(404, "Nicht gefunden");
|
||||
if (a.status !== "beantragt") throw new Fehler(409, `Der Antrag ist schon ${a.status}.`);
|
||||
return (await c.query("update abwesenheit set status = $2, antwort = $3 where id = $1 returning *", [id, d.status, d.antwort || null])).rows[0];
|
||||
// genehmigter Urlaub verlängert berechnete Vorgänge (T15)
|
||||
return (await mitNeuplanung(c, { tage: e.arbeitstage },
|
||||
async () => (await c.query("update abwesenheit set status = $2, antwort = $3 where id = $1 returning *", [id, d.status, d.antwort || null])).rows[0], [], e.stundenProTag)).ergebnis;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user