test: Pricing rule test for transactions

This commit is contained in:
Deepesh Garg 2022-04-07 13:20:53 +05:30
parent a6e26cce87
commit 22e8ae9dac

View File

@ -35,10 +35,11 @@ class PricingRule(Document):
self.margin_rate_or_amount = 0.0 self.margin_rate_or_amount = 0.0
def validate_duplicate_apply_on(self): def validate_duplicate_apply_on(self):
field = apply_on_dict.get(self.apply_on) if self.apply_on != "Transaction":
values = [d.get(frappe.scrub(self.apply_on)) for d in self.get(field) if field] field = apply_on_dict.get(self.apply_on)
if len(values) != len(set(values)): values = [d.get(frappe.scrub(self.apply_on)) for d in self.get(field) if field]
frappe.throw(_("Duplicate {0} found in the table").format(self.apply_on)) if len(values) != len(set(values)):
frappe.throw(_("Duplicate {0} found in the table").format(self.apply_on))
def validate_mandatory(self): def validate_mandatory(self):
for apply_on, field in apply_on_dict.items(): for apply_on, field in apply_on_dict.items():