From 9ead1e0a016fdd1e02889085108896c981b9adbb Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Fri, 13 May 2022 10:18:22 -0400 Subject: [PATCH] Bug 30139: Same fix for the other javascript moneyFormat function This patch makes javascript moneyFormat function in paycollect.tt consistent with the one in pay.tt Signed-off-by: Katrin Fischer --- .../prog/en/modules/members/paycollect.tt | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index b153e3b91a..e97f92d212 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -476,28 +476,29 @@ var newValue = textObj.value; var decAmount = ""; var dolAmount = ""; - var decFlag = false; + var dolFlag = false; var aChar = ""; - for(i=0; i < newValue.length; i++) { - aChar = newValue.substring(i, i+1); - if (aChar >= "0" && aChar <= "9") { - if(decFlag) { - decAmount = "" + decAmount + aChar; + for(var i = newValue.length; 0 < i; i--) { + aChar = newValue.substring(i-1, i); + if ("0" <= aChar && aChar <= "9") { + if(dolFlag) { + dolAmount = "" + aChar + dolAmount; } else { - dolAmount = "" + dolAmount + aChar; + decAmount = "" + aChar + decAmount; } } - if (aChar == ".") { - if (decFlag) { - dolAmount = ""; - break; - } - decFlag = true; + if (aChar == "." || aChar == ",") { + dolFlag = true; } } + if (!dolFlag) { + dolAmount = decAmount; + decAmount = ""; + } + if (dolAmount == "") { dolAmount = "0"; } -- 2.30.2