mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 20:59:11 +00:00
fix: Auto Insert Item Price If Missing when discount & blank UOM (#31168)
* fix: Auto Insert Item Price If Missing when discount and blank UOM fixes wrong item price insert when discount is used and adds uom=stock_uom instead of blank as price is converted to stock uom * unit tests added for item with discount I have added test for auto_insert_price where discount is used. * unit test issue fixed fixed make_sales_order as some of the test that depended on it were failing due to passing of incorrect parameters. Co-authored-by: Ankush Menat <me@ankush.dev>
This commit is contained in:
@@ -353,6 +353,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
"has_batch_no": item.has_batch_no,
|
||||
"batch_no": args.get("batch_no"),
|
||||
"uom": args.uom,
|
||||
"stock_uom": item.stock_uom,
|
||||
"min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "",
|
||||
"qty": flt(args.qty) or 1.0,
|
||||
"stock_qty": flt(args.qty) or 1.0,
|
||||
@@ -365,7 +366,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
"net_rate": 0.0,
|
||||
"net_amount": 0.0,
|
||||
"discount_percentage": 0.0,
|
||||
"discount_amount": 0.0,
|
||||
"discount_amount": flt(args.discount_amount) or 0.0,
|
||||
"supplier": get_default_supplier(args, item_defaults, item_group_defaults, brand_defaults),
|
||||
"update_stock": args.get("update_stock")
|
||||
if args.get("doctype") in ["Sales Invoice", "Purchase Invoice"]
|
||||
@@ -823,7 +824,9 @@ def insert_item_price(args):
|
||||
):
|
||||
if frappe.has_permission("Item Price", "write"):
|
||||
price_list_rate = (
|
||||
args.rate / args.get("conversion_factor") if args.get("conversion_factor") else args.rate
|
||||
(args.rate + args.discount_amount) / args.get("conversion_factor")
|
||||
if args.get("conversion_factor")
|
||||
else (args.rate + args.discount_amount)
|
||||
)
|
||||
|
||||
item_price = frappe.db.get_value(
|
||||
@@ -849,6 +852,7 @@ def insert_item_price(args):
|
||||
"item_code": args.item_code,
|
||||
"currency": args.currency,
|
||||
"price_list_rate": price_list_rate,
|
||||
"uom": args.stock_uom,
|
||||
}
|
||||
)
|
||||
item_price.insert()
|
||||
|
||||
Reference in New Issue
Block a user