fix(Payroll): Exchange Rate not getting set in Salary Slip
This commit is contained in:
parent
52701dcbbc
commit
b2b12f303e
@ -74,43 +74,46 @@ 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");
|
||||
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()
|
||||
]);
|
||||
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) {
|
||||
frm.events.hide_loan_section(frm);
|
||||
frappe.call({
|
||||
method: "erpnext.setup.utils.get_exchange_rate",
|
||||
args: {
|
||||
from_currency: from_currency,
|
||||
to_currency: company_currency,
|
||||
},
|
||||
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", "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", "" );
|
||||
}
|
||||
if (frm.doc.currency) {
|
||||
var from_currency = frm.doc.currency;
|
||||
if (from_currency != company_currency) {
|
||||
frm.events.hide_loan_section(frm);
|
||||
frappe.call({
|
||||
method: "erpnext.setup.utils.get_exchange_rate",
|
||||
args: {
|
||||
from_currency: from_currency,
|
||||
to_currency: company_currency,
|
||||
},
|
||||
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", "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", "");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user