fix: rate auto changing from 3.9 to 39 (#8560)

* fix: rate auto changing from 3.9 to 39

* fix: codacy
This commit is contained in:
rohitwaghchaure 2019-10-07 19:10:05 +05:30 committed by mergify[bot]
parent 86263e05f4
commit f2f49ef3bb

View file

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