Print case where CustomUser is not found in the datbase from Stripe customer id

This commit is contained in:
PCoder 2023-12-27 20:36:59 +05:30
parent 94a81fc976
commit 4d3da3387a

View file

@ -90,6 +90,7 @@ class Command(BaseCommand):
vat_rate = subscription.get("tax_percent", "") vat_rate = subscription.get("tax_percent", "")
c_user = CustomUser.objects.get( c_user = CustomUser.objects.get(
id=StripeCustomer.objects.filter(stripe_id=stripe_customer_id)[0].user.id) id=StripeCustomer.objects.filter(stripe_id=stripe_customer_id)[0].user.id)
if c_user:
customer_name = c_user.name.encode('utf-8') customer_name = c_user.name.encode('utf-8')
customer_email = c_user.email customer_email = c_user.email
items = subscription.get("items", {}).get("data", []) items = subscription.get("items", {}).get("data", [])
@ -110,6 +111,8 @@ class Command(BaseCommand):
"amount": amount_in_chf, "amount": amount_in_chf,
"vat_rate": vat_rate # Fill in VAT rate if available "vat_rate": vat_rate # Fill in VAT rate if available
}) })
else:
print("No customuser for %s %s" % (stripe_customer_id, subscription_id))
if MAKE_MODIFS: if MAKE_MODIFS: