Hello,
The math operation works perfectly.
frappe.ui.form.on("Sales Order", "meses", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, "valor_sin_intereses", Math.round(d.pagos / ((d.interes_anual / 100) / 12) * ( 1 - Math.pow(1 + ((d.interes_anual / 100) / 12),-d.meses))) + d.enganche);
refresh_field("valor_sin_intereses");
});
The issue is that I repeated that script to refresh the result at “valor_sin_intereses” on changes…
frappe.ui.form.on("Sales Order", "interes_anual", function(frm, cdt, cdn) {...
frappe.ui.form.on("Sales Order", "pagos", function(frm, cdt, cdn) {...
frappe.ui.form.on("Sales Order", "enganche", function(frm, cdt, cdn) {...
But it actually only refresh the value in “valor_sin_intereses” when I make changes at “d.meses” field. Is there a best way to do this?