diff --git a/membershipworks/forms.py b/membershipworks/forms.py index 9432c0c..8655ba8 100644 --- a/membershipworks/forms.py +++ b/membershipworks/forms.py @@ -25,7 +25,7 @@ class EventInvoiceForm(forms.Form): if hasattr(self.event, "invoice") is not None: raise forms.ValidationError("An invoice was already created!") - if self.event.total_due_to_instructor is None: + if not self.event.ready_for_invoice: raise forms.ValidationError( "Event missing required information to generate invoice" ) diff --git a/membershipworks/models.py b/membershipworks/models.py index b599b59..d03816d 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -563,6 +563,18 @@ class EventExt(Event): return self.instructor.member == member return False + def ready_for_invoice(self) -> bool: + return ( + self.instructor is not None + and self.instructor.member is not None + and self.materials_fee is not None + and ( + self.materials_fee_included_in_price is not None + or self.materials_fee == 0 + ) + and self.total_due_to_instructor is not None + ) + class Meta: verbose_name = "event" ordering = ["-start"] diff --git a/membershipworks/templates/membershipworks/event_detail.dj.html b/membershipworks/templates/membershipworks/event_detail.dj.html index 78d247f..bcfc7bd 100644 --- a/membershipworks/templates/membershipworks/event_detail.dj.html +++ b/membershipworks/templates/membershipworks/event_detail.dj.html @@ -27,7 +27,7 @@ View PDF - {% elif event.total_due_to_instructor is None %} + {% elif not event.ready_for_invoice %}
This event is missing required information to generate an invoice. Please contact us at info@claremontmakerspace.org.