Event creation: Prevent accidentally creating events without tax rate (#4623)

* Event creation: Prevent accidentally creating events without tax rate

* Update src/pretix/control/forms/event.py

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Fix tests

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2024-11-19 16:14:56 +01:00
committed by GitHub
parent fe6fc8df32
commit 5896ca0197
3 changed files with 22 additions and 1 deletions

View File

@@ -136,6 +136,11 @@ class EventWizardBasicsForm(I18nModelForm):
choices=settings.LANGUAGES,
label=_("Default language"),
)
no_taxes = forms.BooleanField(
label=_("I don't want to specify taxes now"),
help_text=_("You can always configure tax rates later."),
required=False,
)
tax_rate = forms.DecimalField(
label=_("Sales tax rate"),
help_text=_("Do you need to pay sales tax on your tickets? In this case, please enter the applicable tax rate "
@@ -223,6 +228,11 @@ class EventWizardBasicsForm(I18nModelForm):
raise ValidationError({
'timezone': _('Your default locale must be specified.')
})
if not data.get("no_taxes") and not data.get("tax_rate"):
raise ValidationError({
'tax_rate': _('You have not specified a tax rate. If you do not want us to compute sales taxes, please '
'check "Do not use taxes" above.')
})
# change timezone
zone = ZoneInfo(data.get('timezone'))

View File

@@ -41,7 +41,10 @@
{% endif %}
{% include "pretixcontrol/event/fragment_geodata.html" %}
{% bootstrap_field form.currency layout="control" %}
{% bootstrap_field form.tax_rate addon_after="%" layout="control" %}
{% bootstrap_field form.no_taxes layout="control" %}
<div data-display-dependency="#{{ form.no_taxes.id_for_label }}" data-inverse>
{% bootstrap_field form.tax_rate addon_after="%" layout="control" %}
</div>
</fieldset>
<fieldset>
<legend>{% trans "Display settings" %}</legend>

View File

@@ -763,6 +763,7 @@ class EventsTest(SoupTest):
'basics-location_1': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start': '2016-11-01 10:00:00',
@@ -792,6 +793,7 @@ class EventsTest(SoupTest):
'basics-location_1': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start_0': '2016-11-01',
@@ -888,6 +890,7 @@ class EventsTest(SoupTest):
'basics-location_1': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start_0': '2016-11-01',
@@ -1073,6 +1076,7 @@ class EventsTest(SoupTest):
'basics-location_0': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'UTC',
'basics-presale_start_0': '',
@@ -1121,6 +1125,7 @@ class EventsTest(SoupTest):
'basics-location_0': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'UTC',
'basics-presale_start_0': '',
@@ -1171,6 +1176,7 @@ class EventsTest(SoupTest):
'basics-location_0': 'Hamburg',
'basics-currency': 'EUR',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start_0': '2016-11-01',
@@ -1200,6 +1206,7 @@ class EventsTest(SoupTest):
'basics-location_0': 'Hamburg',
'basics-currency': '$',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start_0': '2016-11-01',
@@ -1229,6 +1236,7 @@ class EventsTest(SoupTest):
'basics-location_0': 'Hamburg',
'basics-currency': 'ASD',
'basics-tax_rate': '',
'basics-no_taxes': 'on',
'basics-locale': 'en',
'basics-timezone': 'Europe/Berlin',
'basics-presale_start_0': '2016-11-01',