Hello i need some help with custom scrip, i have created a custom table with quantity and money denomination for sales register day closure it looks like this
Scrips to calculate the value total are:
frappe.ui.form.on(“Denominaciones”, “denominacion”, function(frm, cdt, cdn){
var d = locals[cdt][cdn];
frappe.model.set_value(d.doctype, d.name, “valor”, d.denominacion * d.cantidad);
});
and
frappe.ui.form.on(“Denominaciones”, “cantidad”, function(frm, cdt, cdn){
var d = locals[cdt][cdn];
frappe.model.set_value(d.doctype, d.name, “valor”, d.denominacion * d.cantidad);
});
What scrip should i use to get sum of all rows ( Valor ) value into a field called balance_real
I tried this scrip from another post without luck.
frappe.ui.form.on(“Denominaciones”, “cantidad”, function(frm, cdt, cdn){
var d = locals[cdt][cdn];
frappe.model.set_value(d.doctype, d.name, “valor”, d.denominacion * d.cantidad);
var total = 0;
frm.doc.denominaciones.forEach(function(d) { total += d.valor; });
frm.set_value(‘balance_real’, total);
});
Any help is much appreciated have a nice day…