fix: price list with 0 value are ignored (bp #26655)
* fix: price list with 0 value are ignored Steps to reproduce: 1. Create 2 item price for two different supplier. One of them should be zero. 2. Create PO 3. Add supplier with non-zero price and add item. 4. change supplier. Price won't change. If price was non-zero it would've changed. Root cause: falsiness check instead of null value check is used for checking if price list value exists. 0 is evaluated as false. * refactor: make get_price_list_rate function pure (cherry picked from commit 16d4de5130097bc2dfdc7e073f1e13f0a22481d1) Co-authored-by: Ankush <ankush@iwebnotes.com>
This commit is contained in:
parent
3dfbf19e8f
commit
210441d9b5
@ -717,9 +717,8 @@ def get_bom_item_rate(args, bom_doc):
|
||||
"ignore_conversion_rate": True
|
||||
})
|
||||
item_doc = frappe.get_cached_doc("Item", args.get("item_code"))
|
||||
out = frappe._dict()
|
||||
get_price_list_rate(bom_args, item_doc, out)
|
||||
rate = out.price_list_rate
|
||||
price_list_data = get_price_list_rate(bom_args, item_doc)
|
||||
rate = price_list_data.price_list_rate
|
||||
|
||||
return rate
|
||||
|
||||
|
@ -74,8 +74,7 @@ def get_item_details(args, doc=None, for_validate=False, overwrite_warehouse=Tru
|
||||
|
||||
update_party_blanket_order(args, out)
|
||||
|
||||
|
||||
get_price_list_rate(args, item, out)
|
||||
out.update(get_price_list_rate(args, item))
|
||||
|
||||
if args.customer and cint(args.is_pos):
|
||||
out.update(get_pos_profile_item_details(args.company, args, update_data=True))
|
||||
@ -638,7 +637,10 @@ def get_default_supplier(args, item, item_group, brand):
|
||||
or item_group.get("default_supplier")
|
||||
or brand.get("default_supplier"))
|
||||
|
||||
def get_price_list_rate(args, item_doc, out):
|
||||
def get_price_list_rate(args, item_doc, out=None):
|
||||
if out is None:
|
||||
out = frappe._dict()
|
||||
|
||||
meta = frappe.get_meta(args.parenttype or args.doctype)
|
||||
|
||||
if meta.get_field("currency") or args.get('currency'):
|
||||
@ -651,17 +653,17 @@ def get_price_list_rate(args, item_doc, out):
|
||||
if meta.get_field("currency"):
|
||||
validate_conversion_rate(args, meta)
|
||||
|
||||
price_list_rate = get_price_list_rate_for(args, item_doc.name) or 0
|
||||
price_list_rate = get_price_list_rate_for(args, item_doc.name)
|
||||
|
||||
# variant
|
||||
if not price_list_rate and item_doc.variant_of:
|
||||
if price_list_rate is None and item_doc.variant_of:
|
||||
price_list_rate = get_price_list_rate_for(args, item_doc.variant_of)
|
||||
|
||||
# insert in database
|
||||
if not price_list_rate:
|
||||
if price_list_rate is None:
|
||||
if args.price_list and args.rate:
|
||||
insert_item_price(args)
|
||||
return {}
|
||||
return out
|
||||
|
||||
out.price_list_rate = flt(price_list_rate) * flt(args.plc_conversion_rate) \
|
||||
/ flt(args.conversion_rate)
|
||||
@ -671,6 +673,8 @@ def get_price_list_rate(args, item_doc, out):
|
||||
out.update(get_last_purchase_details(item_doc.name,
|
||||
args.name, args.conversion_rate))
|
||||
|
||||
return out
|
||||
|
||||
def insert_item_price(args):
|
||||
"""Insert Item Price if Price List and Price List Rate are specified and currency is the same"""
|
||||
if frappe.db.get_value("Price List", args.price_list, "currency", cache=True) == args.currency \
|
||||
@ -1073,9 +1077,8 @@ def apply_price_list(args, as_doc=False):
|
||||
}
|
||||
|
||||
def apply_price_list_on_item(args):
|
||||
item_details = frappe._dict()
|
||||
item_doc = frappe.get_doc("Item", args.item_code)
|
||||
get_price_list_rate(args, item_doc, item_details)
|
||||
item_details = get_price_list_rate(args, item_doc)
|
||||
|
||||
item_details.update(get_pricing_rule_for_item(args, item_details.price_list_rate))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user