From 4830ef2c5acdd8552b2cb1cf326f9c9578076ebe Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 20 Feb 2024 11:39:38 +0000 Subject: [PATCH] Handle the BizBA only submitted case on incomplete page. --- users/models.py | 49 +++++++++++++++------------ users/templates/users/incomplete.html | 9 +++-- users/views.py | 7 +++- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/users/models.py b/users/models.py index dfde7a4..28dda9e 100644 --- a/users/models.py +++ b/users/models.py @@ -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): """ diff --git a/users/templates/users/incomplete.html b/users/templates/users/incomplete.html index 252e3da..137dd76 100644 --- a/users/templates/users/incomplete.html +++ b/users/templates/users/incomplete.html @@ -81,7 +81,7 @@

{% endif %} - {% if business_state == "pending" or business_state == "approved" %} + {% if business_state == "pending" or business_state == "approved" or business_state == "ba_pending" %}
@@ -96,6 +96,11 @@

{% 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 %} @@ -140,7 +145,7 @@

{% endif %}