mirror of
https://github.com/ae-utbm/sith.git
synced 2026-06-13 11:39:25 +00:00
apply review comments
This commit is contained in:
+1
-23
@@ -66,29 +66,7 @@ if TYPE_CHECKING:
|
||||
|
||||
|
||||
class BaseEbouticBasketForm(BaseBasketForm):
|
||||
def _check_enough_money(self, *args, **kwargs):
|
||||
# Disable money check
|
||||
...
|
||||
|
||||
def _check_refills(self):
|
||||
"""Check that this basket won't put customer balance above the limit."""
|
||||
refill_type_id = settings.SITH_COUNTER_PRODUCTTYPE_REFILLING
|
||||
total_refill = sum(
|
||||
f.price.amount * f.cleaned_data["quantity"]
|
||||
for f in self.forms
|
||||
if f.price.product.product_type_id == refill_type_id
|
||||
)
|
||||
total_other = sum(
|
||||
f.price.amount * f.cleaned_data["quantity"]
|
||||
for f in self.forms
|
||||
if f.price.product.product_type_id != refill_type_id
|
||||
)
|
||||
limit = settings.SITH_ACCOUNT_MAX_MONEY
|
||||
if (total_refill - total_other + self.customer.amount) > limit:
|
||||
raise ValidationError(
|
||||
_("There cannot be more than %(money)d€ on an AE account")
|
||||
% {"money": limit}
|
||||
)
|
||||
min_result_balance = None # user can pay by card, so no minimum enforced
|
||||
|
||||
|
||||
EbouticBasketForm = forms.formset_factory(
|
||||
|
||||
Reference in New Issue
Block a user