fix(Payroll): Exchange Rate not getting set in Salary Slip

This commit is contained in:
Rucha Mahabal 2021-03-25 14:48:08 +05:30
parent 52701dcbbc
commit b2b12f303e

View File

@ -74,21 +74,25 @@ frappe.ui.form.on("Salary Slip", {
if (!frm.doc.letter_head && company.default_letter_head) {
frm.set_value('letter_head', company.default_letter_head);
}
},
currency: function(frm) {
frm.trigger("set_dynamic_labels");
},
set_dynamic_labels: function(frm) {
var company_currency = frm.doc.company? erpnext.get_currency(frm.doc.company): frappe.defaults.get_default("currency");
if (frm.doc.employee && frm.doc.currency) {
frappe.run_serially([
() => frm.events.set_exchange_rate(frm, company_currency),
() => frm.events.change_form_labels(frm, company_currency),
() => frm.events.change_grid_labels(frm),
() => frm.refresh_fields()
]);
}
},
set_exchange_rate: function(frm, company_currency) {
if (frm.doc.docstatus === 0) {
if (frm.doc.currency) {
var from_currency = frm.doc.currency;
if (from_currency != company_currency) {
@ -101,16 +105,15 @@ frappe.ui.form.on("Salary Slip", {
},
callback: function(r) {
frm.set_value("exchange_rate", flt(r.message));
frm.set_df_property('exchange_rate', 'hidden', 0);
frm.set_df_property("exchange_rate", "hidden", 0);
frm.set_df_property("exchange_rate", "description", "1 " + frm.doc.currency
+ " = [?] " + company_currency);
}
});
} else {
frm.set_value("exchange_rate", 1.0);
frm.set_df_property('exchange_rate', 'hidden', 1);
frm.set_df_property("exchange_rate", "description", "" );
}
frm.set_df_property("exchange_rate", "hidden", 1);
frm.set_df_property("exchange_rate", "description", "");
}
}
},