Neuer Vertragsstatus "Gekuendigt / bestaetigt" + Kuendigungs-Workflow

Bisheriges "Gekuendigt" (CANCELLED) umbenannt in "Gekuendigt / Bestaetigung
abwarten" und wird jetzt automatisch gesetzt, sobald ein Kuendigungsschreiben
hochgeladen wird. Neuer Status CANCELLED_CONFIRMED ("Gekuendigt / bestaetigt")
wird automatisch gesetzt, sobald ein Kuendigungsbestaetigungsdatum vorliegt
(Dokument fuellt das Datum oder manuell) + Vertragsende = Kuendigungsdatum.

Schema: Enum-Wert CANCELLED_CONFIRMED + Migration (idempotentes MODIFY COLUMN);
Daten-Migration hebt bestehende CANCELLED (alte Logik: nur bei Bestaetigung
gesetzt) auf CANCELLED_CONFIRMED.

Backend: neue Trigger maybeMarkAwaitingConfirmationOnLetter (Schreiben->CANCELLED)
im Upload-Handler; maybeCancelOnCancellationConfirmation setzt jetzt
CANCELLED_CONFIRMED (auch aus CANCELLED). Cockpit-Semantik mitgewandert
(Fristen-Skip/"beendet" fuer CANCELLED_CONFIRMED; Ladeliste + Kuendigungs-
bestaetigungs-Filter erweitert).

Frontend: Labels/Farben/Status-Erklaerungen + Status-Dropdown in ContractList,
ContractDetail, ContractForm, ContractDetailModal, CustomerDetail
(CANCELLED orange "abwarten", CANCELLED_CONFIRMED rot).

Verifiziert: tsc+build gruen; Schreiben->CANCELLED, Bestaetigung->
CANCELLED_CONFIRMED+Enddatum; Daten-Migration idempotent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-13 18:14:34 +02:00
co-authored by Claude Opus 4.8
parent a5b8922dd0
commit fc3131059b
14 changed files with 150 additions and 33 deletions
+9 -4
View File
@@ -14,7 +14,7 @@ import {
} from '../utils/accessControl.js';
import { validateOptionalIsoDate } from '../utils/sanitize.js';
import { validateUploadedFile } from '../middleware/uploadFileTypeValidator.js';
import { maybeCancelOnCancellationConfirmation } from '../services/contractStatusScheduler.service.js';
import { maybeCancelOnCancellationConfirmation, maybeMarkAwaitingConfirmationOnLetter } from '../services/contractStatusScheduler.service.js';
import { deleteFileAbsolute, deleteUploadByRelativePath } from '../utils/fileCleanup.js';
// Pentest 56.1 (HIGH, 2026-06-01): Upload-Endpoints prüften nur die
@@ -691,12 +691,17 @@ async function handleContractDocumentUpload(
data: updateData,
});
// Wenn eine Kündigungsbestätigung (nicht "Optionen") hochgeladen wurde:
// Vertrag ACTIVE → CANCELLED und Vertragsende = Kündigungsdatum.
// "Optionen" ist für Vertrags-Änderungen gedacht, nicht für echte Kündigungen.
// Kündigungsbestätigung (nicht "Optionen") hochgeladen → Vertrag auf
// "Gekündigt / bestätigt" (CANCELLED_CONFIRMED) + Vertragsende = Kündigungs-
// datum. "Optionen" ist für Vertrags-Änderungen gedacht, nicht für Kündigungen.
if (fieldName === 'cancellationConfirmationPath') {
await maybeCancelOnCancellationConfirmation(contractId, req);
}
// Kündigungsschreiben hochgeladen → Vertrag auf "Gekündigt / Bestätigung
// abwarten" (CANCELLED), sofern noch nicht (bestätigt) gekündigt.
if (fieldName === 'cancellationLetterPath') {
await maybeMarkAwaitingConfirmationOnLetter(contractId, req);
}
res.json({
success: true,