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; },