Use correct billingaddress

This commit is contained in:
PCoder 2019-12-26 14:19:07 +05:30
parent 364f5599e6
commit 9aff248d31
1 changed files with 24 additions and 9 deletions

View File

@ -199,7 +199,22 @@ def validate_vat_number(stripe_customer_id, billing_address_id,
}
def create_tax_id(stripe_customer_id, billing_address_id, type):
def create_tax_id(stripe_customer_id, billing_address_id, type,
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: