Merge pull request #14076 from chdecultot/pricing_rule

Missing parentheses in price list rate determination
This commit is contained in:
Manas Solanki 2018-05-16 14:55:32 +05:30 committed by GitHub
commit b81ece9ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,8 +111,8 @@ def apply_pricing_rule(args):
item_list = args.get("items") item_list = args.get("items")
args.pop("items") args.pop("items")
set_serial_nos_based_on_fifo = frappe.db.get_single_value("Stock Settings", set_serial_nos_based_on_fifo = frappe.db.get_single_value("Stock Settings",
"automatically_set_serial_nos_based_on_fifo") "automatically_set_serial_nos_based_on_fifo")
for item in item_list: for item in item_list:
@ -122,7 +122,7 @@ def apply_pricing_rule(args):
if set_serial_nos_based_on_fifo and not args.get('is_return'): if set_serial_nos_based_on_fifo and not args.get('is_return'):
out.append(get_serial_no_for_item(args_copy)) out.append(get_serial_no_for_item(args_copy))
return out return out
def get_serial_no_for_item(args): def get_serial_no_for_item(args):
from erpnext.stock.get_item_details import get_serial_no from erpnext.stock.get_item_details import get_serial_no
@ -143,7 +143,7 @@ def get_pricing_rule_for_item(args):
"name": args.name, "name": args.name,
"pricing_rule": None "pricing_rule": None
}) })
if args.ignore_pricing_rule or not args.item_code: if args.ignore_pricing_rule or not args.item_code:
if frappe.db.exists(args.doctype, args.name) and args.get("pricing_rule"): if frappe.db.exists(args.doctype, args.name) and args.get("pricing_rule"):
item_details = remove_pricing_rule_for_item(args.get("pricing_rule"), item_details) item_details = remove_pricing_rule_for_item(args.get("pricing_rule"), item_details)
@ -180,7 +180,7 @@ def get_pricing_rule_for_item(args):
item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
if pricing_rule.price_or_discount == "Price": if pricing_rule.price_or_discount == "Price":
item_details.update({ item_details.update({
"price_list_rate": (pricing_rule.price/flt(args.conversion_rate)) * args.conversion_factor or 1.0 \ "price_list_rate": (pricing_rule.price/flt(args.conversion_rate)) * (args.conversion_factor or 1.0) \
if args.conversion_rate else 0.0, if args.conversion_rate else 0.0,
"discount_percentage": 0.0 "discount_percentage": 0.0
}) })
@ -192,7 +192,7 @@ def get_pricing_rule_for_item(args):
return item_details return item_details
def remove_pricing_rule_for_item(pricing_rule, item_details): def remove_pricing_rule_for_item(pricing_rule, item_details):
pricing_rule = frappe.db.get_value('Pricing Rule', pricing_rule, pricing_rule = frappe.db.get_value('Pricing Rule', pricing_rule,
['price_or_discount', 'margin_type'], as_dict=1) ['price_or_discount', 'margin_type'], as_dict=1)
if pricing_rule and pricing_rule.price_or_discount == 'Discount Percentage': if pricing_rule and pricing_rule.price_or_discount == 'Discount Percentage':
item_details.discount_percentage = 0.0 item_details.discount_percentage = 0.0
@ -209,14 +209,14 @@ def remove_pricing_rule_for_item(pricing_rule, item_details):
def remove_pricing_rules(item_list): def remove_pricing_rules(item_list):
if isinstance(item_list, basestring): if isinstance(item_list, basestring):
item_list = json.loads(item_list) item_list = json.loads(item_list)
out = [] out = []
for item in item_list: for item in item_list:
item = frappe._dict(item) item = frappe._dict(item)
out.append(remove_pricing_rule_for_item(item.get("pricing_rule"), item)) out.append(remove_pricing_rule_for_item(item.get("pricing_rule"), item))
return out return out
def get_pricing_rules(args): def get_pricing_rules(args):
def _get_tree_conditions(parenttype, allow_blank=True): def _get_tree_conditions(parenttype, allow_blank=True):
field = frappe.scrub(parenttype) field = frappe.scrub(parenttype)