Set vat validation status in more places

This commit is contained in:
PCoder 2019-12-26 19:55:28 +05:30
parent a5c7865811
commit fcdabd8dc3
2 changed files with 9 additions and 4 deletions

View file

@ -266,6 +266,7 @@ def create_tax_id(stripe_customer_id, billing_address_id, type,
billing_address_set.add(ho.billing_address) billing_address_set.add(ho.billing_address)
for b_address in billing_address_set: for b_address in billing_address_set:
b_address.stripe_tax_id = tax_id_obj.id b_address.stripe_tax_id = tax_id_obj.id
b_address.vat_validation_status = tax_id_obj.verification.status
b_address.save() b_address.save()
logger.debug("Updated billing_address %s" % str(b_address)) logger.debug("Updated billing_address %s" % str(b_address))
@ -273,10 +274,12 @@ def create_tax_id(stripe_customer_id, billing_address_id, type,
vat_number=billing_address.vat_number) vat_number=billing_address.vat_number)
for ub_address in ub_addresses: for ub_address in ub_addresses:
ub_address.stripe_tax_id = tax_id_obj.id ub_address.stripe_tax_id = tax_id_obj.id
ub_address.vat_validation_status = tax_id_obj.verification.status
ub_address.save() ub_address.save()
logger.debug("Updated user_billing_address %s" % str(ub_address)) logger.debug("Updated user_billing_address %s" % str(ub_address))
except StripeCustomer.DoesNotExist as dne: except StripeCustomer.DoesNotExist as dne:
logger.debug("StripeCustomer %s does not exist" % stripe_customer_id) logger.debug("StripeCustomer %s does not exist" % stripe_customer_id)
billing_address.stripe_tax_id = tax_id_obj.id billing_address.stripe_tax_id = tax_id_obj.id
billing_address.vat_validation_status = tax_id_obj.verification.status
billing_address.save() billing_address.save()
return tax_id_obj return tax_id_obj

View file

@ -26,10 +26,11 @@ class BaseBillingAddress(models.Model):
class BillingAddress(BaseBillingAddress): class BillingAddress(BaseBillingAddress):
def __str__(self): def __str__(self):
if self.vat_number: if self.vat_number:
return "%s, %s, %s, %s, %s, %s %s %s" % ( return "%s, %s, %s, %s, %s, %s %s %s %s" % (
self.cardholder_name, self.street_address, self.city, self.cardholder_name, self.street_address, self.city,
self.postal_code, self.country, self.vat_number, self.postal_code, self.country, self.vat_number,
self.stripe_tax_id, self.vat_number_validated_on self.stripe_tax_id, self.vat_number_validated_on,
self.vat_validation_status
) )
else: else:
return "%s, %s, %s, %s, %s" % ( return "%s, %s, %s, %s, %s" % (
@ -44,10 +45,11 @@ class UserBillingAddress(BaseBillingAddress):
def __str__(self): def __str__(self):
if self.vat_number: if self.vat_number:
return "%s, %s, %s, %s, %s, %s %s %s" % ( return "%s, %s, %s, %s, %s, %s %s %s %s" % (
self.cardholder_name, self.street_address, self.city, self.cardholder_name, self.street_address, self.city,
self.postal_code, self.country, self.vat_number, self.postal_code, self.country, self.vat_number,
self.stripe_tax_id, self.vat_number_validated_on self.stripe_tax_id, self.vat_number_validated_on,
self.vat_validation_status
) )
else: else:
return "%s, %s, %s, %s, %s" % ( return "%s, %s, %s, %s, %s" % (