ChildTable calculation field

I used this code for calculation field on doctype
i want to apply this code on child table called Maintenance Schedule Checklist on parent doctype called Maintenance Schedule , the table name in parent doctype called lines

frappe.ui.form.on('Maintenance Schedule Checklist', {

validate: function(frm) {
	frm.trigger("estimated_cost_amount")
},
estimated_cost_rate: function(frm) {
	frm.trigger("estimated_cost_amount")
},
quantity: function(frm) {
	frm.trigger("estimated_cost_amount")
},

estimated_cost_amount:function(frm){
if (frm.doc.quantity && frm.doc.estimated_cost_rate){
    frm.set_value('estimated_cost_amount',flt(frm.doc.quantity) * flt(frm.doc.estimated_cost_rate))
}
},
frappe.ui.form.on('Maintenance Schedule Checklistt', {
	field_1: function(frm, cdt, cdn) {
		cur_frm.cscript.calculate_values(frm, cdt, cdn);
	},
	field_2: function(frm, cdt, cdn) {
		cur_frm.cscript.calculate_values(frm, cdt, cdn);
	}
})

cur_frm.cscript.calculate_values = function(frm, cdt, cdn){
   quantity_of_milk_in_kg child = locals[cdt][cdn];
	if(child.field_1){
		frappe.model.set_value(cdt, cdn, "field_3", flt(child.field_1 / 1.03,3));
	}
	else{
		frappe.model.set_value(cdt, cdn, "field_3", 0);
	}
}
2 Likes

Thanks , its working