fixes: Incorrect currency value while pasting from excel sheets for other countries.
This commit is contained in:
parent
4d10138acb
commit
4b2d91b295
4 changed files with 22 additions and 8 deletions
|
|
@ -7,5 +7,10 @@ frappe.ui.form.on('Currency', {
|
|||
if(!frm.doc.enabled) {
|
||||
frm.set_intro(__("This Currency is disabled. Enable to use in transactions"));
|
||||
}
|
||||
},
|
||||
|
||||
after_save(frm) {
|
||||
if (frm.doc.enabled)
|
||||
locals[':Currency'][frm.doc.name] = Object.assign(frm.doc, { doctype: ':Currency' });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
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(",", "");
|
||||
if (typeof value ==='string' && value.match(/^[0-9+-/* ]+$/)) {
|
||||
// Removes seperator
|
||||
value = strip_number_groups(value, this.get_number_format());
|
||||
|
||||
try {
|
||||
return eval(value);
|
||||
} catch (e) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
// If not string
|
||||
return value;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
frappe.ui.form.ControlFloat = frappe.ui.form.ControlInt.extend({
|
||||
parse: function(value) {
|
||||
value = this.eval_expression(value);
|
||||
return isNaN(parseFloat(value)) ? null : flt(value, this.get_precision());
|
||||
// For #'###.## number format, if we enter 45'00 then it gets parsed as 45.00
|
||||
// becoz number format isn't provided to flt()
|
||||
return isNaN(parseFloat(value)) ? null : flt(value, this.get_precision(), this.get_number_format());
|
||||
},
|
||||
|
||||
format_for_input: function(value) {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,10 @@ function get_currency_symbol(currency) {
|
|||
}
|
||||
|
||||
function get_number_format(currency) {
|
||||
return (frappe.boot && frappe.boot.sysdefaults && frappe.boot.sysdefaults.number_format) || "#,###.##";
|
||||
let format = null;
|
||||
if (currency) format = frappe.model.get_value(":Currency", currency, "number_format");
|
||||
|
||||
return format || (frappe.boot && frappe.boot.sysdefaults && frappe.boot.sysdefaults.number_format) || "#,###.##";
|
||||
}
|
||||
|
||||
function get_number_format_info(format) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue