From 282fbf4b07740e14566f16d749b549239d7253a7 Mon Sep 17 00:00:00 2001 From: Devin Slauenwhite Date: Sat, 18 Dec 2021 16:03:16 -0500 Subject: [PATCH] fix: fetch correct selling price. --- erpnext/utilities/product.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/product.py b/erpnext/utilities/product.py index 1947c294da..0a45002422 100644 --- a/erpnext/utilities/product.py +++ b/erpnext/utilities/product.py @@ -68,6 +68,8 @@ def qty_from_all_warehouses(batch_info): return qty def get_price(item_code, price_list, customer_group, company, qty=1): + from erpnext.e_commerce.shopping_cart.cart import get_party + template_item_code = frappe.db.get_value("Item", item_code, "variant_of") if price_list: @@ -79,7 +81,8 @@ def get_price(item_code, price_list, customer_group, company, qty=1): filters={"price_list": price_list, "item_code": template_item_code}) if price: - pricing_rule = get_pricing_rule_for_item(frappe._dict({ + party = get_party() + pricing_rule_dict = frappe._dict({ "item_code": item_code, "qty": qty, "stock_qty": qty, @@ -90,7 +93,12 @@ def get_price(item_code, price_list, customer_group, company, qty=1): "conversion_rate": 1, "for_shopping_cart": True, "currency": frappe.db.get_value("Price List", price_list, "currency") - })) + }) + + if party and party.doctype == "Customer": + pricing_rule_dict.update({"customer": party.name}) + + pricing_rule = get_pricing_rule_for_item(pricing_rule_dict) price_obj = price[0] if pricing_rule: