How can I calculate total budget allocated

Dear Deatram,

Shahid responded faster than me. However, Here’s the script:

frappe.ui.form.on(“Budget Account”, “budget_amount”, function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_budget = 0;
$.each(frm.doc.accounts || [], function(i, d) {
total_budget += flt(d.budget_amount);
});
frm.set_value(“total_budget”,total_budget);
});

Apply this on the budget doctype on custom script form and you’re good to go. A word of warning, This will not update any past data. Will work just fine on the new entries.

1 Like