Custom script how to update child table row

I’m trying to automatically calculate the total sum in an invoice per row for all items. The problem is that I cannot get the user interface to update the price. I’m trying the following:


frappe.ui.form.on('Invoice Product', "item_code",
	function (frm, cdt, cdn) {
		
		var item = locals[cdt][cdn];
               alert(item.total) //Default value shown
               //Do magic

	       item.total = xyz //This change is not visible on the ui
	}
)

How do I refresh the change of the total value to the ui?
Also is there a way to run this handler on change of any of the child table fields instead of just copy pasting this code to each of those fields?

have you been able to solve this ?

@Abdullah_A_Ansari can you try this
frappe.model.set_value(‘Invoice Product’,item.name,‘total’,xyz)