diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py index 27179b26..6ae05d39 100644 --- a/datacenterlight/utils.py +++ b/datacenterlight/utils.py @@ -131,15 +131,30 @@ def check_otp(name, realm, token): return response.status_code -def validate_vat_number(stripe_customer_id, billing_address_id): - try: - billing_address = BillingAddress.objects.get(id=billing_address_id) - except BillingAddress.DoesNotExist as dne: - billing_address = None - logger.debug("BillingAddress does not exist for %s" % billing_address_id) - except BillingAddress.MultipleObjectsReturned as mor: - logger.debug("Multiple BillingAddress exist for %s" % billing_address_id) - billing_address = BillingAddress.objects.filter(billing_address_id).order_by('-id').first() +def validate_vat_number(stripe_customer_id, billing_address_id, + is_user_ba=False): + if is_user_ba: + try: + billing_address = UserBillingAddress.objects.get( + id=billing_address_id) + except UserBillingAddress.DoesNotExist as dne: + billing_address = None + logger.debug( + "UserBillingAddress does not exist for %s" % billing_address_id) + except UserBillingAddress.MultipleObjectsReturned as mor: + logger.debug( + "Multiple UserBillingAddress exist for %s" % billing_address_id) + billing_address = UserBillingAddress.objects.filter( + id=billing_address_id).order_by('-id').first() + else: + try: + billing_address = BillingAddress.objects.get(id=billing_address_id) + except BillingAddress.DoesNotExist as dne: + billing_address = None + logger.debug("BillingAddress does not exist for %s" % billing_address_id) + except BillingAddress.MultipleObjectsReturned as mor: + logger.debug("Multiple BillingAddress exist for %s" % billing_address_id) + billing_address = BillingAddress.objects.filter(id=billing_address_id).order_by('-id').first() if billing_address is not None: if billing_address.vat_number_validated_on: return { diff --git a/hosting/templates/hosting/settings.html b/hosting/templates/hosting/settings.html index 3ca0eee6..915bdaa0 100644 --- a/hosting/templates/hosting/settings.html +++ b/hosting/templates/hosting/settings.html @@ -26,6 +26,13 @@ {% for field in form %} {% bootstrap_field field show_label=False type='fields' bound_css_class='' %} {% endfor %} + {% if form.instance.vat_number %} + {% if form.instance.vat_validation_status == "verified" %} + + {% else %} + + {% endif %} + {% endif %}