Merge branch 'main' into storefront-nuxt
This commit is contained in:
commit
ddb12b75c4
1 changed files with 3 additions and 11 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue