From 98886f422a6b79ad477ccec4cb0fbeec3f97ef45 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 23 Nov 2016 01:39:31 -0200 Subject: [PATCH 1/2] replace round by floor --- kfet/static/kfet/js/kfet.js | 2 +- kfet/templatetags/kfet_tags.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kfet/static/kfet/js/kfet.js b/kfet/static/kfet/js/kfet.js index dbfba0b2..026b0a9d 100644 --- a/kfet/static/kfet/js/kfet.js +++ b/kfet/static/kfet/js/kfet.js @@ -39,7 +39,7 @@ function amountDisplay(amount, is_cof=false, tri='') { function amountToUKF(amount, is_cof=false) { var coef_cof = is_cof ? 1 + settings['subvention_cof'] / 100 : 1; - return Math.round(amount * coef_cof * 10); + return Math.floor(amount * coef_cof * 10); } function isValidTrigramme(trigramme) { diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index bb8bce9f..2e177219 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -9,6 +9,7 @@ from django.utils.html import escape from django.utils.safestring import mark_safe from django.core.cache import cache from kfet.models import Settings +from math import floor import re register = template.Library() @@ -38,4 +39,4 @@ def highlight_clipper(clipper, q): def ukf(balance, is_cof): grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1 # float nécessaire car sinon problème avec le round de future.builtins - return round(float(balance * 10 * grant)) + return floor(float(balance * 10 * grant)) From 746f16f57d15f6732b4d1be0ff91a33704807bb2 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Wed, 23 Nov 2016 01:43:24 -0200 Subject: [PATCH 2/2] remove float --- kfet/templatetags/kfet_tags.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kfet/templatetags/kfet_tags.py b/kfet/templatetags/kfet_tags.py index 2e177219..f27f590e 100644 --- a/kfet/templatetags/kfet_tags.py +++ b/kfet/templatetags/kfet_tags.py @@ -38,5 +38,4 @@ def highlight_clipper(clipper, q): @register.filter() def ukf(balance, is_cof): grant = is_cof and (1 + Settings.SUBVENTION_COF() / 100) or 1 - # float nécessaire car sinon problème avec le round de future.builtins - return floor(float(balance * 10 * grant)) + return floor(balance * 10 * grant)