From f2f49ef3bba16d1c46bfb60e59d88018387ed43d Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 7 Oct 2019 19:10:05 +0530 Subject: [PATCH] fix: rate auto changing from 3.9 to 39 (#8560) * fix: rate auto changing from 3.9 to 39 * fix: codacy --- .../js/frappe/form/controls/currency.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/frappe/public/js/frappe/form/controls/currency.js b/frappe/public/js/frappe/form/controls/currency.js index 1961985117..5f893c9495 100644 --- a/frappe/public/js/frappe/form/controls/currency.js +++ b/frappe/public/js/frappe/form/controls/currency.js @@ -1,12 +1,23 @@ frappe.ui.form.ControlCurrency = frappe.ui.form.ControlFloat.extend({ eval_expression: function(value) { if (typeof value === 'string' - && value.match(/^[0-9+-/* ]+$/) - // paresFloat('1,44,000') returns 1.0 - // 1,44,000 are being passed when we paste rows from excel sheet to a table - && value.includes(',')) { - return value.replace(",", ""); + && value.match(/^[0-9+-/* ]+$/)) { + if (value.includes(',')) { + // paresFloat('1,44,000') returns 1.0 + // 1,44,000 are being passed when we paste rows from excel sheet to a table) + + const regex = new RegExp("\\,", "g"); + value = value.replace(regex, ""); + } + + try { + return eval(value); + } catch (e) { + return value; + } } + + // If not string return value; },