This commit is contained in:
2023-11-20 21:26:14 +00:00
parent 2ff9b47983
commit 39247b3e46
13 changed files with 36 additions and 24 deletions

View File

@@ -91,13 +91,12 @@ class BillCreateForm(forms.ModelForm):
def clean(self):
cleaned_data = super().clean()
amount = cleaned_data.get("amount")
# amount = cleaned_data.get("amount")
resolution = cleaned_data.get("resolution_text")
payer = cleaned_data.get("payer")
name = cleaned_data.get("name_text")
iban = cleaned_data.get("iban_text")
bic = cleaned_data.get("bic_text")
only_digital = cleaned_data.get("only_digital")
file_field = cleaned_data.get("file_field")
@@ -106,20 +105,20 @@ class BillCreateForm(forms.ModelForm):
if resolution != "":
try:
Resolution.objects.get(id=resolution)
except:
except Exception:
raise ValidationError(
f"Es gibt keinen Beschluss mit dieser ID. (Eingegebene ID: {resolution})"
)
# check that amount is valid because invalid amount is a NoneType.
'''
"""
if amount:
if amount > 30 and resolution == "":
raise ValidationError(
"Die Beschlussnummer fehlt, weil der Betrag über 30€ beträgt "
f"(Betrag: {amount}€)."
)
'''
"""
if payer == "M":
if name == "" or iban == "":
@@ -133,7 +132,7 @@ class BillCreateForm(forms.ModelForm):
cleaned_data["bic_text"] = ""
if only_digital and file_field is None:
raise ValidationError(f"Digitale Rechnung fehlt.")
raise ValidationError("Digitale Rechnung fehlt.")
return cleaned_data