diff --git a/k4ever/transaction/models.py b/k4ever/transaction/models.py index 5108374..e5bab0f 100644 --- a/k4ever/transaction/models.py +++ b/k4ever/transaction/models.py @@ -6,6 +6,7 @@ from django.db.models.deletion import SET_NULL from django.db.models.signals import pre_delete from decimal import Decimal +from validator import validate_notZero class TransactionType(models.Model): """ Type for a :class:`Transaction`. States how the money has @@ -22,7 +23,7 @@ class Transaction(models.Model): user = models.ForeignKey(User) transactionType = models.ForeignKey(TransactionType, verbose_name='Typ') dateTime = models.DateTimeField(auto_now_add=True) - amount = models.DecimalField(max_digits=8, decimal_places=2, validators=[MinValueValidator(Decimal("0.01"))]) + amount = models.DecimalField(max_digits=8, decimal_places=2, validators=[validate_notZero]) checked = models.BooleanField(default=False) diff --git a/k4ever/transaction/validator.py b/k4ever/transaction/validator.py new file mode 100644 index 0000000..d704ab8 --- /dev/null +++ b/k4ever/transaction/validator.py @@ -0,0 +1,7 @@ +from django.core.exceptions import ValidationError +from decimal import Decimal + + +def validate_notZero(value): + if value == Decimal("0.0") : + raise ValidationError(u'%s is not an real number\{0.00}' % value)