From 5c8e90fde886465c66df4034487a27f464c83218 Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Tue, 2 Oct 2018 02:22:04 +0200 Subject: [PATCH] [cotisations] Replace Float by Decimal everywhere --- cotisations/forms.py | 2 +- cotisations/models.py | 2 +- cotisations/payment_methods/balance/models.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cotisations/forms.py b/cotisations/forms.py index 5ada2fa0..01e52756 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -233,7 +233,7 @@ class RechargeForm(FormRevMixin, Form): """ Form used to refill a user's balance """ - value = forms.FloatField( + value = forms.DecimalField( label=_("Amount"), min_value=0.01, validators=[] diff --git a/cotisations/models.py b/cotisations/models.py index e05330bc..ed98094d 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -83,7 +83,7 @@ class BaseInvoice(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): ).aggregate( total=models.Sum( models.F('prix')*models.F('number'), - output_field=models.FloatField() + output_field=models.DecimalField() ) )['total'] or 0 diff --git a/cotisations/payment_methods/balance/models.py b/cotisations/payment_methods/balance/models.py index b4c82556..221cca3e 100644 --- a/cotisations/payment_methods/balance/models.py +++ b/cotisations/payment_methods/balance/models.py @@ -73,7 +73,7 @@ class BalancePayment(PaymentMethodMixin, models.Model): """ user = invoice.user total_price = invoice.prix_total() - if float(user.solde) - float(total_price) < self.minimum_balance: + if user.solde - total_price < self.minimum_balance: messages.error( request, _("Your balance is too low for this operation.") @@ -106,7 +106,7 @@ class BalancePayment(PaymentMethodMixin, models.Model): balance. """ return ( - float(user.solde) - float(price) >= self.minimum_balance, + user.solde - price >= self.minimum_balance, _("Your balance is too low for this operation.") )