diff --git a/app/stiftung/forms.py b/app/stiftung/forms.py index 311e155..529de31 100644 --- a/app/stiftung/forms.py +++ b/app/stiftung/forms.py @@ -998,11 +998,22 @@ class DestinataerUnterstuetzungForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - # Make faellig_am read-only for automatically generated quarterly payments + # Make faellig_am disabled for automatically generated quarterly payments + self.is_auto_generated = False if self.instance and self.instance.pk and self.instance.beschreibung: if "Vierteljährliche Unterstützung" in self.instance.beschreibung and "(automatisch erstellt)" in self.instance.beschreibung: - self.fields['faellig_am'].widget.attrs['readonly'] = True + self.is_auto_generated = True + self.fields['faellig_am'].disabled = True self.fields['faellig_am'].help_text = "Fälligkeitsdatum wird automatisch basierend auf Quartal berechnet" + + def clean(self): + cleaned_data = super().clean() + + # For auto-generated payments, preserve the original due date + if self.is_auto_generated and self.instance and self.instance.pk: + cleaned_data['faellig_am'] = self.instance.faellig_am + + return cleaned_data class DestinataerNotizForm(forms.ModelForm):