Auto-Vertragsstatus: Lieferbestätigung hochladen → DRAFT auf ACTIVE
Ergänzung zum Cancellation-Trigger: wenn ein ContractDocument mit documentType "Lieferbestätigung" hochgeladen wird und der Vertrag aktuell DRAFT ist, wird er automatisch auf ACTIVE gesetzt (+ Audit-Log). Greift an beiden Upload-Pfaden: - POST /api/contracts/:id/documents (Direkt-Upload via ContractDetail) - POST /api/emails/:id/attachments/:filename/save-as-contract-document (Email-Anhang als Vertragsdokument speichern) Vergleich case-insensitive + getrimmt auf "lieferbestätigung". Andere Typen (Auftragsformular etc.) lösen keinen Wechsel aus. Nicht-DRAFT- Verträge (ACTIVE/CANCELLED/EXPIRED/DEACTIVATED) bleiben unverändert. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import * as authorizationService from '../services/authorization.service.js';
|
||||
import { ApiResponse, AuthRequest } from '../types/index.js';
|
||||
import { logChange } from '../services/audit.service.js';
|
||||
import { canAccessContract } from '../utils/accessControl.js';
|
||||
import { maybeActivateOnDeliveryConfirmation } from '../services/contractStatusScheduler.service.js';
|
||||
|
||||
export async function getContracts(req: AuthRequest, res: Response): Promise<void> {
|
||||
try {
|
||||
@@ -494,6 +495,9 @@ export async function uploadContractDocument(req: AuthRequest, res: Response): P
|
||||
customerId: contract?.customerId,
|
||||
});
|
||||
|
||||
// Falls Lieferbestätigung + Vertrag DRAFT → automatisch auf ACTIVE
|
||||
await maybeActivateOnDeliveryConfirmation(contractId, documentType, req);
|
||||
|
||||
res.status(201).json({ success: true, data: doc } as ApiResponse);
|
||||
} catch (error) {
|
||||
res.status(400).json({
|
||||
|
||||
Reference in New Issue
Block a user