Vertragsstatus-Trigger: Datum beim Upload miterfassen
Beim automatischen Status-Wechsel wird jetzt auch das passende Datum gesetzt, damit Status und Datumsfeld konsistent sind (Cockpit-Warnung "Datum fehlt" verschwindet sofort nach Upload). Backend: - Upload-Handler für Kündigungsbestätigung(s-Optionen) nimmt optional `confirmationDate` aus multipart an, speichert als cancellationConfirmationDate / cancellationConfirmationOptionsDate. Fallback: heute (nur falls Feld noch leer war). - maybeActivateOnDeliveryConfirmation nimmt optional deliveryDate, setzt Contract.startDate falls leer. Fallback: heute. Frontend: - ContractDetail: neues kleines Modal beim Kündigungsbestätigungs-Upload fragt das Bestätigungs-Datum ab (Default: heute oder bereits gesetzter Wert). Der bestehende inline-Datums-Editor bleibt für spätere Korrekturen. - ContractDocumentsSection: Datums-Input erscheint conditional im Upload-Bereich, sobald Typ "Lieferbestätigung" gewählt ist. - SaveAttachmentModal (E-Mail-Anhang → Vertragsdokument): gleicher Datums-Input conditional für "Lieferbestätigung". - API-Methoden uploadCancellationConfirmation / uploadDocument / saveAttachmentAsContractDocument nehmen optional Datum entgegen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,7 @@ export default function SaveAttachmentModal({
|
||||
const [contractDocumentData, setContractDocumentData] = useState({
|
||||
documentType: CONTRACT_DOCUMENT_TYPES[0],
|
||||
notes: '',
|
||||
deliveryDate: new Date().toISOString().split('T')[0],
|
||||
});
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -130,9 +131,11 @@ export default function SaveAttachmentModal({
|
||||
|
||||
const saveContractDocumentMutation = useMutation({
|
||||
mutationFn: () => {
|
||||
const isDelivery = contractDocumentData.documentType.trim().toLowerCase() === 'lieferbestätigung';
|
||||
return cachedEmailApi.saveAttachmentAsContractDocument(emailId, attachmentFilename, {
|
||||
documentType: contractDocumentData.documentType,
|
||||
notes: contractDocumentData.notes || undefined,
|
||||
deliveryDate: isDelivery ? contractDocumentData.deliveryDate : undefined,
|
||||
});
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -164,6 +167,7 @@ export default function SaveAttachmentModal({
|
||||
setContractDocumentData({
|
||||
documentType: CONTRACT_DOCUMENT_TYPES[0],
|
||||
notes: '',
|
||||
deliveryDate: new Date().toISOString().split('T')[0],
|
||||
});
|
||||
onClose();
|
||||
};
|
||||
@@ -459,6 +463,23 @@ export default function SaveAttachmentModal({
|
||||
}
|
||||
placeholder="Optionale Anmerkungen..."
|
||||
/>
|
||||
|
||||
{contractDocumentData.documentType.trim().toLowerCase() === 'lieferbestätigung' && (
|
||||
<div className="p-3 bg-blue-50 border border-blue-200 rounded-lg">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Lieferdatum</label>
|
||||
<input
|
||||
type="date"
|
||||
value={contractDocumentData.deliveryDate}
|
||||
onChange={(e) =>
|
||||
setContractDocumentData({ ...contractDocumentData, deliveryDate: e.target.value })
|
||||
}
|
||||
className="block w-full max-w-[220px] px-3 py-2 border border-gray-300 rounded-lg text-sm"
|
||||
/>
|
||||
<p className="text-xs text-gray-600 mt-1">
|
||||
Falls der Vertrag noch auf Entwurf steht, wird er auf Aktiv gesetzt und dieses Datum als Vertragsbeginn übernommen.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user