From b644eb34bfe41bbfe7bc6c63af5652e241c7fd68 Mon Sep 17 00:00:00 2001 From: bohwaz Date: Fri, 17 Dec 2021 14:17:59 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20calcul=20de=20la=20somme=20des=20=C3=A9l?= =?UTF-8?q?=C3=A9ments=20en=20direct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/_js.tpl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/templates/_js.tpl b/templates/_js.tpl index 5508ae6..301ddae 100644 --- a/templates/_js.tpl +++ b/templates/_js.tpl @@ -4,10 +4,14 @@ function updateSum(){ var total = 0; e = document.querySelectorAll('input[name="prix[]"]'); - e.forEach( function sum(item, index){ - total = total + Number(item.value); + e.forEach((item) => { + if (!item.value) { + return; + } + + total += g.getMoneyAsInt(item.value); }); - document.getElementById('total').innerHTML = total.toFixed(2); + document.getElementById('total').innerHTML = g.formatMoney(total); } (function () { @@ -21,6 +25,7 @@ this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); updateSum(); }; + newdiv.getElementsByTagName('input')[0].onkeyup = updateSum; document.getElementById('Lines').appendChild(newdiv); } plus();