membershipworks: More thoroughly check if events are ready for an invoice
This commit is contained in:
parent
0f30358357
commit
31cc5312ad
@ -25,7 +25,7 @@ class EventInvoiceForm(forms.Form):
|
|||||||
if hasattr(self.event, "invoice") is not None:
|
if hasattr(self.event, "invoice") is not None:
|
||||||
raise forms.ValidationError("An invoice was already created!")
|
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(
|
raise forms.ValidationError(
|
||||||
"Event missing required information to generate invoice"
|
"Event missing required information to generate invoice"
|
||||||
)
|
)
|
||||||
|
@ -563,6 +563,18 @@ class EventExt(Event):
|
|||||||
return self.instructor.member == member
|
return self.instructor.member == member
|
||||||
return False
|
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:
|
class Meta:
|
||||||
verbose_name = "event"
|
verbose_name = "event"
|
||||||
ordering = ["-start"]
|
ordering = ["-start"]
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<a class="btn btn-primary"
|
<a class="btn btn-primary"
|
||||||
href="{% url 'membershipworks:event-invoice-pdf' event.invoice.pk %}">View PDF</a>
|
href="{% url 'membershipworks:event-invoice-pdf' event.invoice.pk %}">View PDF</a>
|
||||||
</div>
|
</div>
|
||||||
{% elif event.total_due_to_instructor is None %}
|
{% elif not event.ready_for_invoice %}
|
||||||
<p class="card-text text-center">
|
<p class="card-text text-center">
|
||||||
This event is missing required information to generate an invoice. Please contact us at <a href="mailto:info@claremontmakerspace.org">info@claremontmakerspace.org</a>.
|
This event is missing required information to generate an invoice. Please contact us at <a href="mailto:info@claremontmakerspace.org">info@claremontmakerspace.org</a>.
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user