max amount for counter refills

This commit is contained in:
imperosol
2026-06-07 14:28:21 +02:00
parent f6f31af975
commit 5e553d91a8
6 changed files with 60 additions and 33 deletions
+8
View File
@@ -881,6 +881,14 @@ class Refilling(models.Model):
return False
return user.is_owner(self.counter) and self.payment_method != "CARD"
def clean(self):
super().clean()
if self.amount + self.customer.amount > settings.SITH_ACCOUNT_MAX_MONEY:
raise ValidationError(
_("There cannot be more than %(money)d€ on an AE account")
% {"money": settings.SITH_ACCOUNT_MAX_MONEY}
)
def delete(self, *args, **kwargs):
self.customer.amount -= self.amount
self.customer.save()