From d850692cadc38e4eac7fbcdefcfe42d1bec18786 Mon Sep 17 00:00:00 2001 From: panic-coder Date: Tue, 7 Jan 2020 16:44:50 +0530 Subject: [PATCH] fix bar code scan and validations while search --- .../stock-orders/complete/complete.component.ts | 9 +++++---- .../orders/stock-orders/fulfill/fulfill.component.ts | 5 +++-- .../orders/stock-orders/receive/receive.component.ts | 4 ++-- common/models/stock-order-lineitem-model.js | 12 ++++++------ nginx.warehouse.conf | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/admin/src/app/home/orders/stock-orders/complete/complete.component.ts b/admin/src/app/home/orders/stock-orders/complete/complete.component.ts index 228d60bd..72b59a17 100644 --- a/admin/src/app/home/orders/stock-orders/complete/complete.component.ts +++ b/admin/src/app/home/orders/stock-orders/complete/complete.component.ts @@ -24,6 +24,7 @@ export class CompleteComponent implements OnInit { public totalLineItems: number; public sortAscending = true; public sortColumn = 'productModelSku'; + public searchSKUText = ''; constructor(private orgModelApi: OrgModelApi, private _route: ActivatedRoute, @@ -50,8 +51,8 @@ export class CompleteComponent implements OnInit { limit = 100; skip = 0; } - if (!productModelIds && productModelIds.length) { - this.searchSKUText = '' + if ((productModelIds !== undefined && productModelIds !== null) && (!productModelIds && productModelIds.length > 0)) { + this.searchSKUText = ''; } let sortOrder = this.sortAscending ? 'ASC' : 'DESC'; let whereFilter = { @@ -82,8 +83,8 @@ export class CompleteComponent implements OnInit { let countFilter = { reportModelId: this.order.id }; - if (productModelId) - countFilter['productModelId'] = productModelId; + if (productModelIds && productModelIds.length) + countFilter['productModelId'] = {inq: productModelIds}; this.loading = true; let fetchLineItems = combineLatest( this.orgModelApi.getStockOrderLineitemModels(this.userProfile.orgModelId, filter), diff --git a/admin/src/app/home/orders/stock-orders/fulfill/fulfill.component.ts b/admin/src/app/home/orders/stock-orders/fulfill/fulfill.component.ts index a44ccdb5..17335bec 100644 --- a/admin/src/app/home/orders/stock-orders/fulfill/fulfill.component.ts +++ b/admin/src/app/home/orders/stock-orders/fulfill/fulfill.component.ts @@ -91,7 +91,7 @@ export class FulfillComponent implements OnInit { limit = 100; skip = 0; } - if (!productModelIds && productModelIds.length) { + if ((productModelIds !== undefined && productModelIds !== null) && (!productModelIds && productModelIds.length > 0)) { this.searchSKUText = '' } let sortOrder = this.sortAscending ? 'ASC' : 'DESC'; @@ -157,7 +157,7 @@ export class FulfillComponent implements OnInit { limit = 100; skip = 0; } - if (!productModelIds && productModelIds.length) { + if ((productModelIds !== undefined && productModelIds !== null) && (!productModelIds && productModelIds.length > 0)) { this.searchSKUText = '' } let sortOrder = this.sortAscending ? 'ASC' : 'DESC'; @@ -397,6 +397,7 @@ export class FulfillComponent implements OnInit { */ barcodeSearchSKU($event: any) { if (this.enableBarcode && this.searchSKUText !== '') { + console.log("this.searchSKUText : ",this.searchSKUText); this.searchAndIncrementProduct(this.searchSKUText); $event.target.select(); } diff --git a/admin/src/app/home/orders/stock-orders/receive/receive.component.ts b/admin/src/app/home/orders/stock-orders/receive/receive.component.ts index 5e02c41a..773946e3 100644 --- a/admin/src/app/home/orders/stock-orders/receive/receive.component.ts +++ b/admin/src/app/home/orders/stock-orders/receive/receive.component.ts @@ -95,7 +95,7 @@ export class ReceiveComponent implements OnInit, OnDestroy { limit = 100; skip = 0; } - if (!productModelIds && productModelIds.length) { + if ((productModelIds !== undefined && productModelIds !== null) && (!productModelIds && productModelIds.length > 0)) { this.searchSKUText = '' } let sortOrder = this.sortAscending ? 'ASC' : 'DESC'; @@ -160,7 +160,7 @@ export class ReceiveComponent implements OnInit, OnDestroy { limit = 100; skip = 0; } - if (!productModelIds && productModelIds.length) { + if ((productModelIds !== undefined && productModelIds !== null) && (!productModelIds && productModelIds.length > 0)) { this.searchSKUText = '' } let sortOrder = this.sortAscending ? 'ASC' : 'DESC'; diff --git a/common/models/stock-order-lineitem-model.js b/common/models/stock-order-lineitem-model.js index 127f4e1f..2ea0bfc8 100644 --- a/common/models/stock-order-lineitem-model.js +++ b/common/models/stock-order-lineitem-model.js @@ -35,13 +35,13 @@ module.exports = function (StockOrderLineitemModel) { force, options }); - let searchPattern = new RegExp(productSku, 'i'); + // let searchPattern = new RegExp(productSku, 'i'); + var pattern = new RegExp('.*'+productSku+'.*', "i"); /* case-insensitive RegExp search */ + var filterData = pattern.toString(); return StockOrderLineitemModel.app.models.ProductModel.findOne({ where: { - orgModelId, - sku: { - like: searchPattern - } + orgModelId: orgModelId, + sku: { "regexp": filterData } } }) .catch(function (error) { @@ -151,7 +151,7 @@ module.exports = function (StockOrderLineitemModel) { }); return Promise.all([Promise.resolve({showDiscrepancyAlert: true}), Promise.resolve(orderLineItem.id)]); } - }else { + } else { logger.debug({ functionName: 'scanBarcodeStockOrder', message: 'Force "true" received will increment forcefully', diff --git a/nginx.warehouse.conf b/nginx.warehouse.conf index 66ba46cb..1ee85eed 100644 --- a/nginx.warehouse.conf +++ b/nginx.warehouse.conf @@ -13,7 +13,7 @@ upstream notification-service { } server { listen 80 default; - server_name _; + server_name shrey.shoppinpal.com; # configure real ip if anyone using CloudFlare set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22;