Merge pull request #6547 from rohitwaghchaure/pos_issue_for_wildcard_seacrh

[Fix] POS wildcard search for customers, items.
This commit is contained in:
Nabin Hait 2016-10-05 15:43:45 +05:30 committed by GitHub
commit 55c328348f

View File

@ -15,13 +15,11 @@ frappe.pages['pos'].refresh = function(wrapper) {
window.onbeforeunload = function () { window.onbeforeunload = function () {
return wrapper.pos.beforeunload() return wrapper.pos.beforeunload()
} }
wrapper.pos.on_refresh_page()
} }
erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
init: function(wrapper){ init: function(wrapper){
this.load = true;
this.page = wrapper.page; this.page = wrapper.page;
this.wrapper = $(wrapper).find('.page-content'); this.wrapper = $(wrapper).find('.page-content');
this.set_indicator(); this.set_indicator();
@ -31,17 +29,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.si_docs = this.get_doc_from_localstorage(); this.si_docs = this.get_doc_from_localstorage();
}, },
on_refresh_page: function() {
var me = this;
if(this.load){
this.load = false;
}else if(this.connection_status){
this.onload();
}else{
this.create_new();
}
},
beforeunload: function(e){ beforeunload: function(e){
if(this.connection_status == false && frappe.get_route()[0] == "pos"){ if(this.connection_status == false && frappe.get_route()[0] == "pos"){
e = e || window.event; e = e || window.event;
@ -359,11 +346,14 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
get_customers: function(key){ get_customers: function(key){
var me = this; var me = this;
key = key.toLowerCase().trim() key = key.toLowerCase().trim()
var re = new RegExp('%', 'g');
var reg = new RegExp(key.replace(re, '\\w*\\s*[a-zA-Z0-9]*'))
if(key){ if(key){
return $.grep(this.customers, function(data) { return $.grep(this.customers, function(data) {
if(data.name.toLowerCase().match(key) if(reg.test(data.name.toLowerCase())
|| data.customer_name.toLowerCase().match(key) || reg.test(data.customer_name.toLowerCase())
|| (data.customer_group && data.customer_group.toLowerCase().match(key))){ || (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
return data return data
} }
}) })
@ -431,7 +421,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
}) })
} }
key = this.search.$input.val().toLowerCase(); key = this.search.$input.val().toLowerCase();
var re = new RegExp('%', 'g');
var reg = new RegExp(key.replace(re, '\\w*\\s*[a-zA-Z0-9]*'))
search_status = true search_status = true
if(key){ if(key){
@ -447,8 +439,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
} else if(item.barcode == me.search.$input.val()) { } else if(item.barcode == me.search.$input.val()) {
search_status = false; search_status = false;
return item.barcode == me.search.$input.val(); return item.barcode == me.search.$input.val();
} else if((item.item_code.toLowerCase().match(key)) || } else if(reg.test(item.item_code.toLowerCase()) || reg.test(item.description.toLowerCase()) ||
(item.item_name.toLowerCase().match(key)) || (item.item_group.toLowerCase().match(key))) { reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase()) ){
return true return true
} }
} }