membershipworks: Provide details when an event is not ready for invoice

This commit is contained in:
Adam Goldsmith 2024-11-25 13:37:50 -05:00
parent d12ac8f568
commit fd26e2b17d
2 changed files with 26 additions and 10 deletions

View File

@ -613,18 +613,26 @@ class EventExt(Event):
return self.instructor.member == member return self.instructor.member == member
return False return False
@property
def missing_for_invoice(self) -> list[str]:
reasons = {
"Missing instructor": self.instructor is None,
"Instructor not linked to a member": (
self.instructor is not None and self.instructor.member is None
),
"Missing materials fee": self.materials_fee is None,
"Materials fee is not 0 and materials_fee_included_in_price not defined": (
self.materials_fee != 0 and self.materials_fee_included_in_price is None
),
"total_due_to_instructor is None (this can have several causes)": (
self.total_due_to_instructor is None
),
}
return [k for k, v in reasons.items() if v]
@property @property
def ready_for_invoice(self) -> bool: def ready_for_invoice(self) -> bool:
return ( return len(self.missing_for_invoice) == 0
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
)
if TYPE_CHECKING: if TYPE_CHECKING:

View File

@ -38,6 +38,14 @@
{% elif not event.ready_for_invoice %} {% 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>.
{% if perms.membershipworks.view_event %}
<div>
<h5>Issues:</h5>
<ul>
{{ event.missing_for_invoice|unordered_list }}
</ul>
</div>
{% endif %}
</p> </p>
{% elif user_is_instructor %} {% elif user_is_instructor %}
<form method="post" class="card-text"> <form method="post" class="card-text">