Skip to content

Commit

Permalink
Handle the BizBA only submitted case on incomplete page.
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg committed Feb 20, 2024
1 parent 565e6e8 commit 4830ef2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 25 deletions.
49 changes: 27 additions & 22 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,33 @@ def is_own_business_account_pending_validation(self):
log.debug(f"Own business account for user: {self.id} is not pending")
return False

# def has_valid_driver_profile(self):
# """
# This method checks whether the driver has a valid full driver profile.
#
# If you are displaying a reminder about this, you should check
# has_pending_driver_profile() first and preferentially display
# the message that would go with that instead.
#
# :return: True if there are billing accounts without a valid driver profile, else False.
# """
# log.debug(f"Checking if user {self.id} has a valid full driver profile")
# driver_profiles = self.driver_profiles.instance_of("FullDriverProfile").filter(
# approved_to_drive=True,
# expires_at__gt=timezone.now(),
# )
#
# log.debug(f"User {self.id} has {driver_profiles.count()} valid full driver profiles")
#
# if driver_profiles.count() > 0:
# return True
#
# return False
def is_own_business_billing_account_pending_validation(self):
log.debug(f"Checking if own business biling account is pending for user: {self.id}")

# First check for a business billing account that's been approved.
business_billing_account = self.owned_billing_accounts.filter(
~Q(approved_at=None),
account_type="b",
).first()

if business_billing_account is not None:
log.debug(
f"There's an already approved business billing account id {business_billing_account.id} for user {self.id}"
)
return False

# Next check if there's an unapproved one that's complete
business_billing_account = None
business_billing_accounts = self.owned_billing_accounts.filter(
approved_at=None,
account_type="b",
)

for b in business_billing_accounts:
if b.complete:
return True

return False

def has_pending_driver_profile(self):
"""
Expand Down
9 changes: 7 additions & 2 deletions users/templates/users/incomplete.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h3 class="text-lg leading-6 font-medium text-gray-900">
</div>
{% endif %}

{% if business_state == "pending" or business_state == "approved" %}
{% if business_state == "pending" or business_state == "approved" or business_state == "ba_pending" %}
<div class="rounded-md bg-teal-100 p-4 sm:mx-6">
<div class="flex">
<div class="flex-shrink-0">
Expand All @@ -96,6 +96,11 @@ <h3 class="text-lg leading-6 font-medium text-gray-900">
{% if business_state == "pending" %}
Thank you, your business details have been submitted and will soon be reviewed
by a member of the GoEV team. This typically takes around 2 working days.
{% elif business_state == "ba_pending" %}
Thank you, your business billing details have been submitted and will soon be
reviewed by a member of the GoEV team. This typically takes around 2 working days.
In the meantime, you can invite other people as drivers on your account, or fill
out your own driver details by clicking "Create business account" below.
{% else %}
Thank you, your business details have been submitted and approved.
{% endif %}
Expand Down Expand Up @@ -140,7 +145,7 @@ <h3 class="text-lg leading-6 font-medium text-gray-900">
{% endif %}
</div>
<div class="mt-5 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
{% if business_state == 'incomplete' %}
{% if business_state == 'incomplete' or business_state == "ba_pending" %}
<a href="{% url 'billing_create_account' 'business' %}?initial">
<button type="button"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:text-sm">
Expand Down
7 changes: 6 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def incomplete(request):
personal_state = "pending"

business_state = "incomplete"
# TODO: Calculate business state
if user.is_own_business_account_validated():
business_state = "approved"
elif user.is_own_business_account_pending_validation():
business_state = "pending"
elif user.is_own_business_billing_account_pending_validation():
business_state = "ba_pending"

context = {
"personal_state": personal_state,
Expand Down

0 comments on commit 4830ef2

Please sign in to comment.