I added below Client Script to validate Rate in Sales Invoice is not less than Price List Rate, but I want to add a condition to run this validation if Update Stock is checked. How to do that?
frappe.ui.form.on("Sales Invoice", "validate", function(frm){
$.each(frm.doc.items, function(idx, item){
if(item.price_list_rate > item.rate) {
msgprint(__("Rate of " + item.item_name + " cannot be less than Price List Rate"));
validated = false;
}
});
});