Make VAT number a part of billing address
This commit is contained in:
parent
c9de757bc7
commit
f566aa8a2e
8 changed files with 11 additions and 32 deletions
|
@ -32,11 +32,10 @@
|
|||
{{billing_address.cardholder_name}}<br>
|
||||
{{billing_address.street_address}}, {{billing_address.postal_code}}<br>
|
||||
{{billing_address.city}}, {{billing_address.country}}
|
||||
{% if request.user.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{request.user.vat_number}}
|
||||
{% if billing_address.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{billing_address.vat_number}}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
</p>
|
||||
</address>
|
||||
</div>
|
||||
|
@ -211,4 +210,4 @@
|
|||
{% trans "Some problem encountered. Please try again later." as err_msg %}
|
||||
var create_vm_error_message = '{{err_msg|safe}}';
|
||||
</script>
|
||||
{%endblock%}
|
||||
{%endblock%}
|
||||
|
|
|
@ -254,9 +254,6 @@ class PaymentOrderView(FormView):
|
|||
billing_address_form = BillingAddressForm(
|
||||
instance=self.request.user.billing_addresses.first()
|
||||
)
|
||||
billing_address_form.fields['vat_number'].initial = (
|
||||
self.request.user.vat_number
|
||||
)
|
||||
user = self.request.user
|
||||
if hasattr(user, 'stripecustomer'):
|
||||
stripe_customer = user.stripecustomer
|
||||
|
@ -491,9 +488,6 @@ class PaymentOrderView(FormView):
|
|||
customer = StripeCustomer.get_or_create(
|
||||
email=this_user.get('email'), token=token
|
||||
)
|
||||
request.user.vat_number = address_form.cleaned_data.get(
|
||||
"vat_number")
|
||||
request.user.save()
|
||||
else:
|
||||
user_email = address_form.cleaned_data.get('email')
|
||||
user_name = address_form.cleaned_data.get('name')
|
||||
|
@ -949,11 +943,6 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
'user': custom_user.id
|
||||
})
|
||||
|
||||
# Customer is created, we save his VAT Number
|
||||
custom_user.vat_number = request.session.get(
|
||||
'billing_address_data').get("vat_number")
|
||||
custom_user.save()
|
||||
|
||||
if 'generic_payment_type' in request.session:
|
||||
stripe_cus = StripeCustomer.objects.filter(
|
||||
stripe_id=stripe_api_cus_id
|
||||
|
@ -964,6 +953,7 @@ class OrderConfirmationView(DetailView, FormView):
|
|||
city=billing_address_data['city'],
|
||||
postal_code=billing_address_data['postal_code'],
|
||||
country=billing_address_data['country']
|
||||
vat_number=billing_address_data['vat_number']
|
||||
)
|
||||
billing_address.save()
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
{{invoice.order.billing_address.postal_code}}<br>
|
||||
{{invoice.order.billing_address.city}},
|
||||
{{invoice.order.billing_address.country}}
|
||||
{% if invoice.customer.user.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{invoice.customer.user.vat_number}}
|
||||
{% if invoice.order.billing_address.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{invoice.order.billing_address.vat_number}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
|
|
@ -67,8 +67,8 @@
|
|||
{{billing_address.cardholder_name}}<br>
|
||||
{{billing_address.street_address}}, {{billing_address.postal_code}}<br>
|
||||
{{billing_address.city}}, {{billing_address.country}}
|
||||
{% if user.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{user.vat_number}}
|
||||
{% if billing_address.vat_number %}
|
||||
<br/>{% trans "VAT Number" %} {{billing_address.vat_number}}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
|
|
@ -549,12 +549,9 @@ class SettingsView(LoginRequiredMixin, FormView):
|
|||
Check if the user already saved contact details. If so, then show
|
||||
the form populated with those details, to let user change them.
|
||||
"""
|
||||
|
||||
bill_form = form_class(
|
||||
return form_class(
|
||||
instance=self.request.user.billing_addresses.first(),
|
||||
**self.get_form_kwargs())
|
||||
bill_form.fields['vat_number'].initial = self.request.user.vat_number
|
||||
return bill_form
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(SettingsView, self).get_context_data(**kwargs)
|
||||
|
@ -630,9 +627,6 @@ class SettingsView(LoginRequiredMixin, FormView):
|
|||
instance=self.request.user.billing_addresses.first(),
|
||||
data=billing_address_data)
|
||||
billing_address_user_form.save()
|
||||
self.request.user.vat_number = billing_address_data.get(
|
||||
"vat_number")
|
||||
self.request.user.save()
|
||||
msg = _("Billing address updated successfully")
|
||||
messages.add_message(request, messages.SUCCESS, msg)
|
||||
else:
|
||||
|
@ -705,7 +699,7 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
|||
'city': current_billing_address.city,
|
||||
'postal_code': current_billing_address.postal_code,
|
||||
'country': current_billing_address.country,
|
||||
'vat_number': self.request.user.vat_number
|
||||
'vat_number': current_billing_address.vat_number
|
||||
}
|
||||
})
|
||||
return form_kwargs
|
||||
|
@ -790,8 +784,6 @@ class PaymentVMView(LoginRequiredMixin, FormView):
|
|||
reverse('hosting:payment') + '#payment_error')
|
||||
request.session['token'] = token
|
||||
request.session['billing_address_data'] = billing_address_data
|
||||
owner.vat_number = billing_address_data.get("vat_number")
|
||||
owner.save()
|
||||
self.request.session['order_confirm_url'] = "{url}?{query_params}".format(
|
||||
url=reverse('hosting:order-confirmation'),
|
||||
query_params='page=payment')
|
||||
|
|
|
@ -117,8 +117,6 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
|||
name = models.CharField(max_length=50, validators=[validate_name])
|
||||
email = models.EmailField(unique=True)
|
||||
username = models.CharField(max_length=60, unique=True, null=True)
|
||||
vat_number = models.CharField(max_length=100, default="")
|
||||
|
||||
validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0)
|
||||
in_ldap = models.BooleanField(default=False)
|
||||
# By default, we initialize the validation_slug with appropriate value
|
||||
|
|
|
@ -120,7 +120,6 @@ class EditCreditCardForm(forms.Form):
|
|||
class BillingAddressForm(forms.ModelForm):
|
||||
token = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||
card = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||
vat_number = forms.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
model = BillingAddress
|
||||
|
|
|
@ -13,6 +13,7 @@ class BaseBillingAddress(models.Model):
|
|||
city = models.CharField(max_length=50)
|
||||
postal_code = models.CharField(max_length=50)
|
||||
country = CountryField()
|
||||
vat_number = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
Loading…
Reference in a new issue