Auto-Vertragsstatus: nightly EXPIRED + Kündigungsbestätigung → CANCELLED
- Neuer Scheduler (02:00 + Catch-up 60s nach Start): alle ACTIVE-Verträge mit endDate < heute werden auf EXPIRED umgestellt. Audit-Log pro Vertrag. - Upload cancellationConfirmationPath: Vertrag wechselt von ACTIVE → CANCELLED (mit Audit-Log). "Options"-Upload triggert bewusst nicht, da für Vertragsänderungen gedacht, nicht für echte Kündigungen. - Keine neuen Statuswerte. "Kündigung gesendet vs. bestätigt" bleibt über die getrennten Felder cancellationSentDate / cancellationConfirmationDate lesbar, Status bleibt bis zur Bestätigung auf ACTIVE. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -569,6 +569,25 @@ async function handleContractDocumentUpload(
|
||||
data: { [fieldName]: relativePath },
|
||||
});
|
||||
|
||||
// Wenn eine Kündigungsbestätigung (nicht "Optionen") hochgeladen wurde und
|
||||
// der Vertrag noch ACTIVE ist → auf CANCELLED umstellen + Audit-Log.
|
||||
// "Optionen" ist für Vertrags-Änderungen gedacht, nicht für echte Kündigungen.
|
||||
if (fieldName === 'cancellationConfirmationPath' && contract.status === 'ACTIVE') {
|
||||
await prisma.contract.update({
|
||||
where: { id: contractId },
|
||||
data: { status: 'CANCELLED' },
|
||||
});
|
||||
await logChange({
|
||||
req,
|
||||
action: 'UPDATE',
|
||||
resourceType: 'Contract',
|
||||
resourceId: contractId.toString(),
|
||||
label: `Vertrag ${contract.contractNumber} automatisch auf CANCELLED gesetzt (Kündigungsbestätigung hochgeladen)`,
|
||||
details: { vorher: 'ACTIVE', nachher: 'CANCELLED', trigger: 'cancellationConfirmation-Upload' },
|
||||
customerId: contract.customerId,
|
||||
});
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user