# Daten auf Mahnung automatisch berechnen ```JavaScript frappe.ui.form.on('Dunning', { validate(frm) { // your code here frm.set_value('sub_sum',frm.doc.outstanding_amount+frm.doc.interest_amount) }, refresh(frm) { if (frm.doc.docstatus===1 && !frm.doc.sub_sum) { frm.set_value('sub_sum',frm.doc.outstanding_amount+frm.doc.interest_amount) } let due_date = new Date(frm.doc.posting_date) due_date.setDate(due_date.getDate()+14); frm.set_value('dunning_due_date',due_date) } }) ```