Update tax_id fields of billing_addresses which belong to supplied user only
This commit is contained in:
		
					parent
					
						
							
								0d208d2bd9
							
						
					
				
			
			
				commit
				
					
						825e716625
					
				
			
		
					 1 changed files with 8 additions and 7 deletions
				
			
		| 
						 | 
					@ -197,15 +197,16 @@ def create_tax_id(stripe_customer_id, vat_number, type):
 | 
				
			||||||
    if not tax_id_obj:
 | 
					    if not tax_id_obj:
 | 
				
			||||||
        return tax_id_response
 | 
					        return tax_id_response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    b_addresses = BillingAddress.objects.filter(
 | 
					    stripe_customer = StripeCustomer.objects.get(stripe_customer_id)
 | 
				
			||||||
        vat_number=vat_number
 | 
					    billing_address_set = set()
 | 
				
			||||||
    )
 | 
					    for ho in stripe_customer.hostingorder_set.all():
 | 
				
			||||||
    for b_address in b_addresses:
 | 
					        if ho.billing_address.vat_number==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.stripe_tax_id = tax_id_obj.id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ub_addresses = UserBillingAddress.objects.filter(
 | 
					    ub_addresses = stripe_customer.user.billing_addresses.filter(
 | 
				
			||||||
        vat_number=vat_number
 | 
					        vat_number=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
 | 
				
			||||||
    return tax_id_obj
 | 
					    return tax_id_obj
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue