More logging + improve ba string repr
This commit is contained in:
		
					parent
					
						
							
								064ea5be2f
							
						
					
				
			
			
				commit
				
					
						c6147c887c
					
				
			
		
					 2 changed files with 11 additions and 5 deletions
				
			
		|  | @ -201,7 +201,7 @@ def validate_vat_number(stripe_customer_id, billing_address_id, | |||
|                     is_user_ba=is_user_ba | ||||
|                 ) | ||||
|                 logger.debug("tax_id_obj = %s" % str(tax_id_obj)) | ||||
|                 logger.debug("Created tax_id %s" % tax_id_obj['response_object'].id) | ||||
|                 logger.debug("Created tax_id %s" % tax_id_obj.id) | ||||
|     else: | ||||
|         logger.debug("invalid billing address") | ||||
|         return { | ||||
|  | @ -252,23 +252,27 @@ def create_tax_id(stripe_customer_id, billing_address_id, type, | |||
|     tax_id_obj = tax_id_response.get('response_object') | ||||
| 
 | ||||
|     if not tax_id_obj: | ||||
|         logger.debug("Received none in tax_id_obj") | ||||
|         return tax_id_response | ||||
| 
 | ||||
|     try: | ||||
|         stripe_customer = StripeCustomer.objects.get(stripe_id=stripe_customer_id) | ||||
|         billing_address_set = set() | ||||
|         logger.debug("Updating billing address") | ||||
|         for ho in stripe_customer.hostingorder_set.all(): | ||||
|             if ho.billing_address.vat_number == billing_address.vat_number: | ||||
|                 billing_address_set.add(ho.billing_address) | ||||
|         for b_address in billing_address_set: | ||||
|             b_address.stripe_tax_id = tax_id_obj.id | ||||
|             b_address.save() | ||||
|             logger.debug("Updated billing_address %s" % str(b_address)) | ||||
| 
 | ||||
|         ub_addresses = stripe_customer.user.billing_addresses.filter( | ||||
|             vat_number=billing_address.vat_number) | ||||
|         for ub_address in ub_addresses: | ||||
|             ub_address.stripe_tax_id = tax_id_obj.id | ||||
|             ub_address.save() | ||||
|             logger.debug("Updated user_billing_address %s" % str(ub_address)) | ||||
|     except StripeCustomer.DoesNotExist as dne: | ||||
|         logger.debug("StripeCustomer %s does not exist" % stripe_customer_id) | ||||
|         billing_address.stripe_tax_id = tax_id_obj.id | ||||
|  |  | |||
|  | @ -24,9 +24,10 @@ class BaseBillingAddress(models.Model): | |||
| class BillingAddress(BaseBillingAddress): | ||||
|     def __str__(self): | ||||
|         if self.vat_number: | ||||
|             return "%s, %s, %s, %s, %s, %s" % ( | ||||
|             return "%s, %s, %s, %s, %s, %s %s %s" % ( | ||||
|                 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 | ||||
|             ) | ||||
|         else: | ||||
|             return "%s, %s, %s, %s, %s" % ( | ||||
|  | @ -41,9 +42,10 @@ class UserBillingAddress(BaseBillingAddress): | |||
| 
 | ||||
|     def __str__(self): | ||||
|         if self.vat_number: | ||||
|             return "%s, %s, %s, %s, %s, %s" % ( | ||||
|             return "%s, %s, %s, %s, %s, %s %s %s" % ( | ||||
|                 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 | ||||
|             ) | ||||
|         else: | ||||
|             return "%s, %s, %s, %s, %s" % ( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue