We have payments_made and sp_outstanding_amount allow on submit field.
Outstanding commission amount is automatically calculated when we enter payments made detail.
In this case validate event not working, since we are updating document after submit.
I have solved this using,
frappe.ui.form.on("Sales Invoice", "payments_made", function(frm) {
if (frm.doc.payments_made > frm.doc.total_commission){
cur_frm.set_value("sp_outstanding_amount", 0);
cur_frm.set_value("payments_made", 0);
msgprint("Please check total commission.");
}
else if(frm.doc.payments_made <= frm.doc.total_commission) {
var comm = frm.doc.total_commission - frm.doc.payments_made;
cur_frm.set_value("sp_outstanding_amount", comm);
}
});