[minor] fixes in validate selling price
This commit is contained in:
parent
535462fc20
commit
e9747a8a6e
@ -164,14 +164,18 @@ class SellingController(StockController):
|
||||
frappe.throw(_("Maxiumm discount for Item {0} is {1}%").format(d.item_code, discount))
|
||||
|
||||
def validate_selling_price(self):
|
||||
def throw_message(item_name, rate, ref_rate_field):
|
||||
frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""")
|
||||
.format(item_name, ref_rate_field, rate))
|
||||
|
||||
if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"):
|
||||
return
|
||||
|
||||
for it in self.get("items"):
|
||||
last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.name, ["last_purchase_rate", "is_stock_item"])
|
||||
last_purchase_rate, is_stock_item = frappe.db.get_value("Item", it.item_code, ["last_purchase_rate", "is_stock_item"])
|
||||
|
||||
if flt(it.base_rate) < flt(last_purchase_rate):
|
||||
throw(it.name, last_purchase_rate, "last purchase rate")
|
||||
throw_message(it.item_name, last_purchase_rate, "last purchase rate")
|
||||
|
||||
last_valuation_rate = frappe.db.sql("""
|
||||
SELECT valuation_rate FROM `tabStock Ledger Entry` WHERE item_code = %s
|
||||
@ -182,9 +186,6 @@ class SellingController(StockController):
|
||||
if is_stock_item and flt(it.base_rate) < flt(last_valuation_rate):
|
||||
throw_message(it.name, last_valuation_rate, "valuation rate")
|
||||
|
||||
def throw_message(item_name, rate, ref_rate_field):
|
||||
frappe.throw(_("""Selling price for item {0} is lower than its {1}. Selling price should be atleast {2}""")
|
||||
.format(item_name, ref_rate_field, rate))
|
||||
|
||||
def get_item_list(self):
|
||||
il = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user