diff --git a/src/pretix/base/models/tax.py b/src/pretix/base/models/tax.py index 34bbd93d1a..8971af632f 100644 --- a/src/pretix/base/models/tax.py +++ b/src/pretix/base/models/tax.py @@ -23,6 +23,7 @@ import json from decimal import Decimal from django.core.exceptions import ValidationError +from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.utils.formats import localize from django.utils.translation import gettext_lazy as _, pgettext @@ -149,7 +150,15 @@ class TaxRule(LoggedModel): rate = models.DecimalField( max_digits=10, decimal_places=2, - verbose_name=_("Tax rate") + validators=[ + MaxValueValidator( + limit_value=Decimal("100.00"), + ), + MinValueValidator( + limit_value=Decimal("0.00"), + ), + ], + verbose_name=_("Tax rate"), ) price_includes_tax = models.BooleanField( verbose_name=_("The configured product prices include the tax amount"), diff --git a/src/pretix/control/forms/event.py b/src/pretix/control/forms/event.py index dd50e5b9d0..0885e03d6c 100644 --- a/src/pretix/control/forms/event.py +++ b/src/pretix/control/forms/event.py @@ -34,6 +34,7 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under the License. +from decimal import Decimal from urllib.parse import urlencode, urlparse from django import forms @@ -135,6 +136,8 @@ class EventWizardBasicsForm(I18nModelForm): help_text=_("Do you need to pay sales tax on your tickets? In this case, please enter the applicable tax rate " "here in percent. If you have a more complicated tax situation, you can add more tax rates and " "detailed configuration later."), + max_value=Decimal("100.00"), + min_value=Decimal("0.00"), required=False )