Toggle between line-wise discount percentage and overall discount percentage

Hi folks,
Regarding: Custom Script to validate in Sales Invoice.
Area: POS page
Behaviour: It works in such a way that you can either give line-wise item discount over overall discount but not both.

After that normal print settings and disabling of “pay button” and hiding of menu is not happening.

Please help, I am stuck in middle of this.

frappe.ui.form.on(‘Sales Invoice’, {
validate: function(frm) {
console.log(“Entered Sales Invoice doctype”)
$.each(frm.doc.items, function(i,d) {
console.log(“inside for loop”)
if(d.discount_percentage > 0 && frm.doc.additional_discount_percentage>0)
msgprint(‘Please give one of them’);
else if(d.discount_percentage > 0 && frm.doc.discount_amount>0)
msgprint(‘Please give one of them’);
frappe.validated = false;

Next sequence of actions such as print and new-pos , how to set it up?
Thanks in advance