Skip to content

Commit

Permalink
fix: batch number search on pos (#45209)
Browse files Browse the repository at this point in the history
* fix: price of items with batch number not having seperate item price on pos search bar

* fix: introduced batch number based sorting
  • Loading branch information
diptanilsaha authored Jan 13, 2025
1 parent eea0eff commit e529f82
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions erpnext/selling/page/point_of_sale/point_of_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def search_by_term(search_term, warehouse, price_list):
}

if batch_no:
price_filters["batch_no"] = batch_no
price_filters["batch_no"] = ["in", [batch_no, ""]]

price = frappe.get_list(
doctype="Item Price",
Expand All @@ -74,15 +74,25 @@ def search_by_term(search_term, warehouse, price_list):

def __sort(p):
p_uom = p.get("uom")
p_batch = p.get("batch_no")
batch_no = item.get("batch_no")

if batch_no and p_batch and p_batch == batch_no:
if p_uom == item.get("uom"):
return 0
elif p_uom == item.get("stock_uom"):
return 1
else:
return 2

if p_uom == item.get("uom"):
return 0
return 3
elif p_uom == item.get("stock_uom"):
return 1
return 4
else:
return 2
return 5

# sort by fallback preference. always pick exact uom match if available
# sort by fallback preference. always pick exact uom and batch number match if available
price = sorted(price, key=__sort)

if len(price) > 0:
Expand Down

0 comments on commit e529f82

Please sign in to comment.