Fixes in pricing rule testcases #565
This commit is contained in:
parent
ac1bc212ea
commit
98c2a052e5
@ -11,6 +11,8 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
from erpnext.stock.get_item_details import get_item_details
|
from erpnext.stock.get_item_details import get_item_details
|
||||||
from frappe import MandatoryError
|
from frappe import MandatoryError
|
||||||
|
|
||||||
|
frappe.db.sql("delete from `tabPricing Rule`")
|
||||||
|
|
||||||
test_record = {
|
test_record = {
|
||||||
"doctype": "Pricing Rule",
|
"doctype": "Pricing Rule",
|
||||||
"apply_on": "Item Code",
|
"apply_on": "Item Code",
|
||||||
@ -69,8 +71,8 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
self.assertEquals(details.get("discount_percentage"), 5)
|
self.assertEquals(details.get("discount_percentage"), 5)
|
||||||
|
|
||||||
frappe.db.sql("update `tabPricing Rule` set priority=NULL where campaign='_Test Campaign'")
|
frappe.db.sql("update `tabPricing Rule` set priority=NULL where campaign='_Test Campaign'")
|
||||||
details = get_item_details(args)
|
from erpnext.stock.get_item_details import MultiplePricingRuleConflict
|
||||||
self.assertEquals(details.get("discount_percentage"), 15)
|
self.assertRaises (MultiplePricingRuleConflict, get_item_details, args)
|
||||||
|
|
||||||
args.item_code = "_Test Item 2"
|
args.item_code = "_Test Item 2"
|
||||||
details = get_item_details(args)
|
details = get_item_details(args)
|
||||||
|
@ -7,6 +7,8 @@ from frappe import _, throw
|
|||||||
from frappe.utils import flt, cint, add_days
|
from frappe.utils import flt, cint, add_days
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
class MultiplePricingRuleConflict(frappe.ValidationError): pass
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(args):
|
def get_item_details(args):
|
||||||
"""
|
"""
|
||||||
@ -332,10 +334,9 @@ def filter_pricing_rules(args_dict, pricing_rules):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if len(pricing_rules) > 1:
|
if len(pricing_rules) > 1:
|
||||||
# pricing_rules = sorted(pricing_rules, key=lambda x: x[price_or_discount])
|
|
||||||
frappe.throw(_("Multiple Price Rule exists with same criteria, please resolve \
|
frappe.throw(_("Multiple Price Rule exists with same criteria, please resolve \
|
||||||
conflict by assigning priority. Price Rules: {0}")
|
conflict by assigning priority. Price Rules: {0}")
|
||||||
.format("\n".join([d.name for d in pricing_rules])))
|
.format("\n".join([d.name for d in pricing_rules])), MultiplePricingRuleConflict)
|
||||||
elif pricing_rules:
|
elif pricing_rules:
|
||||||
return pricing_rules[0]
|
return pricing_rules[0]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user