Gutschriften/Kuendigung: DRAFT-endDate-Schutz + Belege staff-only

Pentest R138 Hygiene + neue Vorgaben:

1) endDate wird bei DRAFT-Vertraegen NICHT mehr gesetzt (Entwurf = nur
   Vorlage). Nur Status wurde vorher geschont, endDate zog trotzdem mit.

2) Ueberweisungsbelege (credit-note-receipts) sind jetzt reine
   Mitarbeiter/Admin-Downloads: neuer FileOwner-kind 'contract-staff'
   blockt Portal-Kunden im fileDownload-Controller. Das generierte
   Gutschrift-PDF (credit-notes) bleibt vertragsbasiert -> der
   besitzende Kunde darf seine eigene Gutschrift laden.

Bereits vorher abgesichert (bestaetigt): Kunden koennen keine
Gutschriften anlegen (blockPortal) und keine Belege hochladen
(Portal-403 im Upload).

Verifiziert: DRAFT haelt endDate; Beleg-Owner=contract-staff,
PDF-Owner=contract.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-08 21:29:43 +02:00
co-authored by Claude Opus 4.8
parent 8169c74d8e
commit 0f51a1cc3b
3 changed files with 30 additions and 8 deletions
@@ -201,7 +201,13 @@ export async function maybeCancelOnCancellationConfirmation(
}
// Vertragsende = Kündigungsdatum (Bestätigungsdatum), falls vorhanden.
if (c.cancellationConfirmationDate && asDay(c.endDate) !== asDay(c.cancellationConfirmationDate)) {
// NICHT bei DRAFT: ein Entwurf ist nur eine Vorlage und bekommt kein
// berechnetes Vertragsende (Pentest R138, Hygiene-Punkt).
if (
c.status !== 'DRAFT' &&
c.cancellationConfirmationDate &&
asDay(c.endDate) !== asDay(c.cancellationConfirmationDate)
) {
updateData.endDate = c.cancellationConfirmationDate;
changes.endDate = { vorher: asDay(c.endDate), nachher: asDay(c.cancellationConfirmationDate) };
}