Skip to content

Commit

Permalink
Merge pull request frappe#45006 from diptanilsaha/fix-price_list_rate…
Browse files Browse the repository at this point in the history
…-for-pos-search-term

fix: pos search by term items price
  • Loading branch information
ruthra-kumar authored Jan 6, 2025
2 parents c7370e2 + 2beb485 commit 03abde6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 9 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 @@ -58,13 +58,17 @@ def search_by_term(search_term, warehouse, price_list):
item_stock_qty = item_stock_qty // item.get("conversion_factor", 1)
item.update({"actual_qty": item_stock_qty})

price_filters = {
"price_list": price_list,
"item_code": item_code,
}

if batch_no:
price_filters["batch_no"] = batch_no

price = frappe.get_list(
doctype="Item Price",
filters={
"price_list": price_list,
"item_code": item_code,
"batch_no": batch_no,
},
filters=price_filters,
fields=["uom", "currency", "price_list_rate", "batch_no"],
)

Expand Down
9 changes: 6 additions & 3 deletions erpnext/selling/page/point_of_sale/pos_item_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,16 @@ erpnext.PointOfSale.ItemSelector = class {
}

filter_items({ search_term = "" } = {}) {
const selling_price_list = this.events.get_frm().doc.selling_price_list;

if (search_term) {
search_term = search_term.toLowerCase();

// memoize
this.search_index = this.search_index || {};
if (this.search_index[search_term]) {
const items = this.search_index[search_term];
this.search_index[selling_price_list] = this.search_index[selling_price_list] || {};
if (this.search_index[selling_price_list][search_term]) {
const items = this.search_index[selling_price_list][search_term];
this.items = items;
this.render_item_list(items);
this.auto_add_item && this.items.length == 1 && this.add_filtered_item_to_cart();
Expand All @@ -346,7 +349,7 @@ erpnext.PointOfSale.ItemSelector = class {
// eslint-disable-next-line no-unused-vars
const { items, serial_no, batch_no, barcode } = message;
if (search_term && !barcode) {
this.search_index[search_term] = items;
this.search_index[selling_price_list][search_term] = items;
}
this.items = items;
this.render_item_list(items);
Expand Down

0 comments on commit 03abde6

Please sign in to comment.