I want to verify if what I am seeing is intended or a bug. I have two selling pricing rules. The first rule is applied against all items in the product group “Products” for any amount with a markup of 40%. The second rule is also against all products in the “Products” pricing rule but for quantities of 10 or more with a markup of 35% and a threshold for notification of 80%. When I enter an order with a line item quantity of 8, I expect to receive a notification that the second rule will apply if the quantity is increased to 10. However, I do not see any notification.
When I trace the code I see that the following is where erpnext/erpnext/accounts/doctype/pricing_rule/utils.py
def filter_pricing_rules(args, pricing_rules, doc=None):
if not isinstance(pricing_rules, list):
pricing_rules = [pricing_rules]
...
if pricing_rules[0].apply_rule_on_other and not pricing_rules[0].mixed_conditions and doc:
pricing_rules = get_qty_and_rate_for_other_item(doc, pr_doc, pricing_rules, args) or []
else:
pricing_rules = filter_pricing_rules_for_qty_amount(stock_qty, amount, pricing_rules, args)
if not pricing_rules:
for d in original_pricing_rule:
if not d.threshold_percentage:
continue
msg = validate_quantity_and_amount_for_suggestion(
d, stock_qty, amount, args.get("item_code"), args.get("transaction_type")
)
if msg:
return {"suggestion": msg, "item_code": args.get("item_code")}
The issue is that the first pricing rule does apply and so the test for if not pricing_rules
is False. It appears that the only way to get a notification of a possible rule is to have no other rules apply.
Is this a bug or is it how it is intended?