From c72d08e8b976159b64031d64ded8207182b459b8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 6 Sep 2017 14:16:51 +0530 Subject: [PATCH] Added indicator to show stock is available or not --- erpnext/selling/page/point_of_sale/point_of_sale.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js index c52b55a6cb..9cd2a49912 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -603,10 +603,16 @@ class POSCart { update_item(item) { const $item = this.$cart_items.find(`[data-item-code="${item.item_code}"]`); + if(item.qty > 0) { + const indicator_class = item.actual_qty >= item.qty ? 'green' : 'red'; + const remove_class = indicator_class == 'green' ? 'red' : 'green'; + $item.find('.quantity input').val(item.qty); $item.find('.discount').text(item.discount_percentage + '%'); $item.find('.rate').text(format_currency(item.rate, this.frm.doc.currency)); + $item.addClass(indicator_class); + $item.removeClass(remove_class); } else { $item.remove(); } @@ -614,8 +620,9 @@ class POSCart { get_item_html(item) { const rate = format_currency(item.rate, this.frm.doc.currency); + const indicator_class = item.actual_qty >= item.qty ? 'green' : 'red'; return ` -
+
${item.item_name}
@@ -929,7 +936,7 @@ class POSItems { get_item_html(item) { const price_list_rate = format_currency(item.price_list_rate, this.currency); - const { item_code, item_name, item_image, item_stock=0} = item; + const { item_code, item_name, item_image} = item; const item_title = item_name || item_code; const template = ` @@ -939,7 +946,6 @@ class POSItems { ${item_title} -

(${__(item_stock)})