Hi! I have a Doctype call “Viaticos” with a chil table call “Rendiciones”. I have a field in the Doctype “gastos_con_tarjeta” where I want to sum the column “total_pagado” of the child table. But, I want to sum just the rows of the child table that in another column call “tipo_de_gasto” have the value “Combustible”. The Custom Script I have sum all the rows, how can I make it?
frappe.ui.form.on(“Rendicion”, {
entrada_de_pago:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.tarjeta.forEach(function(d) { total += d.total_pagado; });
frm.set_value(“gastos_con_tarjeta”, total);
refresh_field(“gastos_con_tarjeta”);
},
tarjeta_remove:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.tarjeta.forEach(function(d) { total += d.total_pagado; });
frm.set_value(“gastos_con_tarjeta”, total);
refresh_field(“gastos_con_tarjeta”);
}
});