I want a situation whereby as each item is being selected, they’re automatically calculated, and the total sum of value is populated at the Grand Total field.
Here is my script to achieve this:
frm.compute_total = function(frm, row){
var total = 0;
//loop through the child table
frm.doc.lease_item.forEach(d=>{
total = total + d.amount;
console.log(total);
frm.set_value('grand_total', total);
//Demand Notice Item Child Table
frappe.ui.form.on('Lease Item', {
lease_item: function(frm, cdt, cdn){
// grab the entire record
let row = locals[cdt][cdn];
frm.check_lease_items_duplicate(frm, row, row.lease_item);
frm.compute_total(frm, row);
},
This shows that the script is working, however, "frm.set_value(‘grand_total’, total) doesn’t seem to set the value. I am confused as to what to do next.
Code below is not working, kindly help
frappe.ui.form.on(‘Purchase Order Item’, {
refresh(frm) {
// self.doc.qty_to_received = flt(self.doc.stock_qty)-flt(self.doc.received_qty)
}
})
frappe.ui.form.on(‘Purchase Order Item’, {
refresh(frm)
{frm.doc.qty_to_received = (flt(frm.doc.stock_qty)-flt(frm.doc.received_qty));}
});
But its not working. Any suggestion kindly