Browse Source

Merge branch 'refill_balance' into 'dev'

[cotisations] Replace Float by Decimal everywhere

See merge request federez/re2o!323
docker_basic_support
klafyvel 7 years ago
parent
commit
3db4f837a4
  1. 2
      cotisations/forms.py
  2. 2
      cotisations/models.py
  3. 4
      cotisations/payment_methods/balance/models.py

2
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=[]

2
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

4
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.")
)

Loading…
Cancel
Save