validate pricing rule discount with item max discount
This commit is contained in:
parent
9daca108b3
commit
4f6e31eb08
@ -19,6 +19,7 @@ class PricingRule(Document):
|
|||||||
self.validate_min_max_qty()
|
self.validate_min_max_qty()
|
||||||
self.cleanup_fields_value()
|
self.cleanup_fields_value()
|
||||||
self.validate_price_or_discount()
|
self.validate_price_or_discount()
|
||||||
|
self.validate_max_discount()
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
for field in ["apply_on", "applicable_for"]:
|
for field in ["apply_on", "applicable_for"]:
|
||||||
@ -61,6 +62,13 @@ class PricingRule(Document):
|
|||||||
if flt(self.get(frappe.scrub(field))) < 0:
|
if flt(self.get(frappe.scrub(field))) < 0:
|
||||||
throw(_("{0} can not be negative").format(field))
|
throw(_("{0} can not be negative").format(field))
|
||||||
|
|
||||||
|
def validate_max_discount(self):
|
||||||
|
if self.price_or_discount == "Discount Percentage" and self.item_code:
|
||||||
|
max_discount = frappe.db.get_value("Item", self.item_code, "max_discount")
|
||||||
|
if flt(self.discount_percentage) > max_discount:
|
||||||
|
throw(_("Max discount allowed for item: {0} is {1}%".format(self.item_code, max_discount)))
|
||||||
|
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user