Hi,
I would like to validate that Item Rate in Sales Invoice is not less than Item Price in Master (not Price List Rate fetched in Sales Invoice Item table) according to Default Price List set in Customer Group under which the customer is added. So, I added the following code:
frappe.ui.form.on("Sales Invoice", "validate", function(frm){
$.each(frm.doc.items || [], function(i, row){
if(frappe.db.get_value('Item Price',{'batch_no': row.batch_no, 'item_code': row.item_code, 'price_list_rate': frappe.db.get_value('Customer Group', frappe.db.get_value('Customer', frm.doc.customer, 'customer_group'), 'default_price_list')}, 'price_list_rate') > row.rate) {
msgprint(__("Rate of " + row.item_name + " cannot be less than Price List Rate"));
validated = false;
}
});
});
But, unfortunately, it doesn’t work. Where is the wrong in the code? Can someone help in this respect?