Sum fields in child table and show total in parentfield

Hi ,
i want to sum fields in the child table and show the total in the custom field in the parent. But the script ist working, maybe someone could help?

parent doctype name is: End of Week Report
parent total field is: gesamtzeit
child table name is: Zeiterfassungen
child table name in parent doctype is: zeiterfassungen1
column to be sum name in child table is: gesamtarbeitszeit

frappe.ui.form.on(‘End of Week Report’, {
validate: function(frm) {
gesamtzeit = 0;
$.each(frm.doc.zeiterfassungen1 , function(i, d) {
gesamtzeit += flt(d.gesamtarbeitszeit);
});
frm.doc.gesamtzeit = gesamtzeit;
}
});

Hi @reggaetuna,

Pleas check it.

Thank You!