Let a planned absence be called off

The old refusal read: "Diese Abwesenheit ist noch nicht wirksam. Sie muss
über den Vorgang selbst abgebrochen werden." There was no such way. The
row sat in the file, the scheduled change kept running toward its date,
and nothing could stop either one.

That is not hypothetical. One person went absent in July, came back in
August, and still has a second return booked for the first of September
— recorded while they were already working again. The guard added
yesterday stops a third from being written; it does not remove the one
that exists.

Absences are called off whole, not field by field. For a planned
contract change the scheduled payload gets the affected fields lifted
out of it and runs on with the rest; an absence has no fields in that
map, and half an absence is not a thing anyone means. So the whole
scheduled change is cancelled, and what it had already noted on the
person goes with it: the date they were to be away from, the date they
were to come back on. Left behind, the profile would show an absence
with no event behind it. If the absence is still running, the return
date planned when it began applies again.

The link between the row and the scheduled change had to exist first —
start_karenz and record_karenz_return now record it. Existing rows get
it backfilled, but only where one running change of that kind falls on
that person and that day. Where two would match, the row keeps refusing:
guessing which process to cancel is worse than refusing to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 11:44:21 +02:00
parent 861c47b757
commit 16216c5537
5 changed files with 525 additions and 15 deletions

View File

@@ -28,8 +28,13 @@ type Eintrag = {
/** Die Vorgänge, die sich zurücknehmen und berichtigen lassen. */
const KORRIGIERBAR: HistoryEventType[] = ["Stammdatenänderung", "Vertragsänderung", "Karenz", "Rückkehr"];
/** Abwesenheit und Rückkehr haben eigene Vorgänge, auch für die Zukunft. */
const NUR_WIRKSAM: HistoryEventType[] = ["Karenz", "Rückkehr"];
/**
* Abwesenheit und Rückkehr werden anders zurückgenommen als der Rest: aus
* einer geplanten Vertragsänderung nimmt man einzelne Felder heraus, eine
* geplante Abwesenheit fällt ganz. Beides steht in delete_history_entry;
* hier zählt nur, dass für diese beiden keine Feldwerte nötig sind.
*/
const OHNE_FELDWERTE: HistoryEventType[] = ["Karenz", "Rückkehr"];
export function darfKorrigiertWerden(eintrag: Eintrag, heute: string, alle: Eintrag[] = []): KorrekturUrteil {
if (eintrag.event_type === "Eintritt") {
@@ -56,13 +61,6 @@ export function darfKorrigiertWerden(eintrag: Eintrag, heute: string, alle: Eint
};
}
if (NUR_WIRKSAM.includes(eintrag.event_type) && eintrag.event_date > heute) {
return {
erlaubt: false,
grund: "Diese Abwesenheit ist noch nicht wirksam. Sie muss über den Vorgang selbst abgebrochen werden.",
};
}
// Noch nicht wirksam: das geht, aber nur mit Bezug auf den geplanten
// Vorgang. Zeilen aus der Zeit vor dieser Verknüpfung haben keinen — sie
// liessen sich nur über Person und Datum zuordnen, und das ist nicht
@@ -76,6 +74,11 @@ export function darfKorrigiertWerden(eintrag: Eintrag, heute: string, alle: Eint
};
}
// Eine geplante Abwesenheit hat keine Feldwerte — sie fällt als Ganzes.
if (eintrag.event_date > heute && OHNE_FELDWERTE.includes(eintrag.event_type)) {
return { erlaubt: true };
}
if (!eintrag.changes || eintrag.changes.length === 0) {
return {
erlaubt: false,