Fix empty vat number bug

This commit is contained in:
Nico Schottelius 2020-05-02 20:42:09 +02:00
parent 927fb20671
commit 7d708cfbb6

View file

@ -215,10 +215,11 @@ class BillingAddressViewSet(mixins.CreateModelMixin,
# Validate VAT numbers. # Validate VAT numbers.
country = serializer.validated_data["country"] country = serializer.validated_data["country"]
vat_number = serializer.validated_data["vat_number"]
# We ignore empty VAT numbers. # We ignore empty VAT numbers.
if vat_number != "": if 'vat_number' in serializer.validated_data and serializer.validated_data["vat_number"] != "":
vat_number = serializer.validated_data["vat_number"]
if not validate_vat(country, vat_number): if not validate_vat(country, vat_number):
return Response( return Response(
{'error': 'Malformed VAT number.'}, {'error': 'Malformed VAT number.'},