Fix Greek VAT IDs

This commit is contained in:
Raphael Michel
2019-09-10 09:46:00 +02:00
parent 12b1f7d90e
commit 21451db412
3 changed files with 10 additions and 4 deletions

View File

@@ -27,7 +27,7 @@ from pretix.base.forms.widgets import (
TimePickerWidget, UploadedFileWidget, TimePickerWidget, UploadedFileWidget,
) )
from pretix.base.models import InvoiceAddress, Question, QuestionOption from pretix.base.models import InvoiceAddress, Question, QuestionOption
from pretix.base.models.tax import EU_COUNTRIES from pretix.base.models.tax import EU_COUNTRIES, cc_to_vat_prefix
from pretix.base.settings import ( from pretix.base.settings import (
COUNTRIES_WITH_STATE_IN_ADDRESS, PERSON_NAME_SCHEMES, COUNTRIES_WITH_STATE_IN_ADDRESS, PERSON_NAME_SCHEMES,
PERSON_NAME_TITLE_GROUPS, PERSON_NAME_TITLE_GROUPS,
@@ -491,7 +491,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
if self.validate_vat_id and self.instance.vat_id_validated and 'vat_id' not in self.changed_data: if self.validate_vat_id and self.instance.vat_id_validated and 'vat_id' not in self.changed_data:
pass pass
elif self.validate_vat_id and data.get('is_business') and data.get('country') in EU_COUNTRIES and data.get('vat_id'): elif self.validate_vat_id and data.get('is_business') and data.get('country') in EU_COUNTRIES and data.get('vat_id'):
if data.get('vat_id')[:2] != str(data.get('country')): if data.get('vat_id')[:2] != cc_to_vat_prefix(str(data.get('country'))):
raise ValidationError(_('Your VAT ID does not match the selected country.')) raise ValidationError(_('Your VAT ID does not match the selected country.'))
try: try:
result = vat_moss.id.validate(data.get('vat_id')) result = vat_moss.id.validate(data.get('vat_id'))

View File

@@ -85,6 +85,12 @@ EU_CURRENCIES = {
} }
def cc_to_vat_prefix(country_code):
if country_code == 'GR':
return 'EL'
return country_code
class TaxRule(LoggedModel): class TaxRule(LoggedModel):
event = models.ForeignKey('Event', related_name='tax_rules', on_delete=models.CASCADE) event = models.ForeignKey('Event', related_name='tax_rules', on_delete=models.CASCADE)
name = I18nCharField( name = I18nCharField(

View File

@@ -41,7 +41,7 @@ from pretix.base.models import (
from pretix.base.models.orders import ( from pretix.base.models.orders import (
OrderFee, OrderPayment, OrderPosition, OrderRefund, OrderFee, OrderPayment, OrderPosition, OrderRefund,
) )
from pretix.base.models.tax import EU_COUNTRIES from pretix.base.models.tax import EU_COUNTRIES, cc_to_vat_prefix
from pretix.base.payment import PaymentException from pretix.base.payment import PaymentException
from pretix.base.services import tickets from pretix.base.services import tickets
from pretix.base.services.export import export from pretix.base.services.export import export
@@ -983,7 +983,7 @@ class OrderCheckVATID(OrderView):
'specified.')) 'specified.'))
return redirect(self.get_order_url()) return redirect(self.get_order_url())
if ia.vat_id[:2] != str(ia.country): if ia.vat_id[:2] != cc_to_vat_prefix(str(ia.country)):
messages.error(self.request, _('Your VAT ID does not match the selected country.')) messages.error(self.request, _('Your VAT ID does not match the selected country.'))
return redirect(self.get_order_url()) return redirect(self.get_order_url())