Hello fellows,
How can I calculate a total budget against a particular cost center or project?
For instance I have added several rows in my budget, now I was to get the total amount from all rows,
Please help on how to achieve that?
Thanks.
Hello fellows,
How can I calculate a total budget against a particular cost center or project?
For instance I have added several rows in my budget, now I was to get the total amount from all rows,
Thanks.
Budget doctype
Budget Account doctype
I know it might require custom script to achieve this, but I don’t know how.
can I get at-least an example anyone?
Thanks.
hi @deatram,
Create Total Amount field in your Parent doctype, (After Table.)
And Try below script,
frappe.ui.form.on("Budget Account", "budget_amount", function(frm, cdt, cdn) {
var acc = frm.doc.accounts;
var total = 0;
for(var i in acc) {
total = total + acc[i].budget_amount;
}
frm.set_value("total_amount",total);
});
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.
hello @rushikesherp .thank you very much it worked. I can now see my total budget
@shahid thank you too
i have seen other add this script at the end.
refresh_field(“total_budget”);
What does the line of script do?
to immediate update the total budget once you add new budget account.