From d91a979e2545f6394d6fc3a0f00abe176f5113c4 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 12 Nov 2025 13:14:53 +0300 Subject: [PATCH] Features: 1) Simplify `save` method by removing validation logic tied to `config`. Fixes: 1) Remove unused import for `constance.config`. Extra: 1) Minor cleanup in `save` method for improved readability. --- engine/payments/models.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/engine/payments/models.py b/engine/payments/models.py index ca7843ea..50b71961 100644 --- a/engine/payments/models.py +++ b/engine/payments/models.py @@ -1,6 +1,5 @@ from datetime import datetime, time -from constance import config from django.conf import settings from django.contrib.postgres.indexes import GinIndex from django.db.models import ( @@ -48,17 +47,10 @@ class Transaction(NiceModel): ) def save(self, **kwargs): - if self.amount != 0.0 and ( - (config.PAYMENT_GATEWAY_MINIMUM <= self.amount <= config.PAYMENT_GATEWAY_MAXIMUM) - or (config.PAYMENT_GATEWAY_MINIMUM == 0 and config.PAYMENT_GATEWAY_MAXIMUM == 0) - ): - if len(str(self.amount).split(".")[1]) > 2: + if len(str(self.amount).split(".")[1]) > 2: self.amount = round(self.amount, 2) - super().save(**kwargs) - return self - raise ValueError( - _(f"transaction amount must fit into {config.PAYMENT_GATEWAY_MINIMUM}-{config.PAYMENT_GATEWAY_MAXIMUM}") - ) + super().save(**kwargs) + return self class Meta: verbose_name = _("transaction")