Hi,
I have created a custom Doctype. named Internal Requisition to be used for the purpose of daily budgeting. It has an Item table of items to be requested. I have challenges in getting figures in the Amount column and Totaling the amount.Kindly assist.
You can do below and you can apply css style to move Total under column Amount.
cur_frm.cscript.mini_total = ()=> {
let total = 0 ;
let frm = cur_frm;
frm.doc.YOUR_FIELD_NAME.forEach((row)=>{
total += (typeof row.rate == "undefined"?0 : row.rate) * (typeof row.qty == "undefined"?0 : row.qty);
});
frm.fields_dict.YOUR_FIELD_NAME.grid.wrapper.find(".grid-upload").removeClass("hide").text("Total: "+ fmt_money(total,"USD"));
}
So you called cur_frm.cscript.mini_total();
2 Likes
Hi Magics,
I have tried this but It doesnt work… Could your please guide me step by step.
What’s your table field name?
Please try code below in custom script by call cur_frm.cscript.mini_total();
cur_frm.cscript.mini_total = ()=> {
let total = 0 ;
let frm = cur_frm;
frm.doc.expense_requisition_item.forEach((row)=>{
total += (row.rate || 0) * (row.qty || 0);
});
frm.fields_dict.expense_requisition_item.grid.wrapper.find(".grid-upload").removeClass("hide").text("Total: "+ fmt_money(total,"USD"));
}
1 Like