From d809b2595aa798706560447b8ccbf5b0b70695f6 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 28 Sep 2021 11:20:57 +0200 Subject: [PATCH] Pretty money function is invalid in Javascript: it mays display an additional euro Signed-off-by: Yohann D'ANELLO --- note_kfet/static/js/base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/note_kfet/static/js/base.js b/note_kfet/static/js/base.js index e642d15c..39b2216d 100644 --- a/note_kfet/static/js/base.js +++ b/note_kfet/static/js/base.js @@ -7,8 +7,8 @@ * @returns {string} */ function pretty_money (value) { - if (value % 100 === 0) { return (value < 0 ? '- ' : '') + Math.round(Math.abs(value) / 100) + ' €' } else { - return (value < 0 ? '- ' : '') + Math.round(Math.abs(value) / 100) + '.' + + if (value % 100 === 0) { return (value < 0 ? '- ' : '') + Math.floor(Math.abs(value) / 100) + ' €' } else { + return (value < 0 ? '- ' : '') + Math.floor(Math.abs(value) / 100) + '.' + (Math.abs(value) % 100 < 10 ? '0' : '') + (Math.abs(value) % 100) + ' €' } }