Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
ID | ||||||||
0048562 | ||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||
defect | [Retail Modules] Web POS | major | always | 2022-02-09 11:48 | 2022-03-02 17:07 | |||
Reporter | joniturralde93 | View Status | public | |||||
Assigned To | ranjith_qualiantech_com | |||||||
Priority | urgent | Resolution | no change required | Fixed in Version | ||||
Status | closed | Fix in branch | Fixed in SCM revision | |||||
Projection | none | ETA | none | Target Version | ||||
OS | Any | Database | Any | Java version | ||||
OS Version | Database version | Ant version | ||||||
Product Version | SCM revision | |||||||
Merge Request Status | ||||||||
Review Assigned To | ||||||||
OBNetwork customer | Gold | |||||||
Support ticket | 35461 | |||||||
Regression level | ||||||||
Regression date | ||||||||
Regression introduced in release | ||||||||
Regression introduced by commit | ||||||||
Triggers an Emergency Pack | No | |||||||
Summary | 0048562: In barcodeScanHook, detect if the product has already been added in rfidWebSocket | |||||||
Description | From barcodeScanHook, we need to be able to detect if one product has already been added before in rfidWebSocket. We suggest setting this information so we can check it in the hook. For example, if rfidWebSocket actually executed the addProduct proccess, send the property "alreadyBeingAdded" to the hook. We want this because, in some cases, we need to add the product in barcodeScanHook, but we need to avoid it in case rfidWebSocket already did it | |||||||
Steps To Reproduce | - Just scan an RFID product tag - rfidWebSocket adds the product to the order - barcodeScanHook adds the same product again, as we don't have a way to know if it is a product read with RFID reader and it has been already added | |||||||
Proposed Solution | Set a property like "alreadyBeingAddedToOrder" that we can check in barcodeScanHook | |||||||
Tags | No tags attached. | |||||||
Attached Files | ![]() diff --git a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js index 44baf67..e567f4e 100644 --- a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js +++ b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2015-2020 Openbravo S.L.U. + * Copyright (C) 2015-2022 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -62,6 +62,10 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( if (scannedCode.startsWith('01') && scannedCode.substr(16, 2) === '21') { //RFID args.cancellation = true; + OB.MobileApp.model.receipt.set( + 'DECSCAddedProduct', + OB.MobileApp.model.receipt.get('DECSCAddedProduct') || [] + ); //search for the product + add product + set serial number var code = scannedCode.substr(3, 13); var sNumber = scannedCode.substr(18, 12); @@ -84,25 +88,20 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( function(data) { if (data.length > 0) { //looking for the same product with same serial number - for ( - i = 0; - i < OB.MobileApp.model.receipt.get('lines').length; - i++ - ) { - if ( - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('obposSerialNumber') === sNumber && - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('product') - .get('searchkey') === data.models[0].get('searchkey') - ) { - existingSerial = true; - break; - } - } + const existingAddedProduct = OB.MobileApp.model.receipt.get( + 'DECSCAddedProduct' + ); + const existingSerial = !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === data.models[0].get('searchkey') + ); + if (!existingSerial) { + existingAddedProduct.push({ + obposSerialNumber: sNumber, + searchkey: data.models[0].get('searchkey') + }); // Force to ungroup the product if readed using RFID data.models[0].set('groupProduct', false); OB.MobileApp.view.waterfall('onAddProduct', { @@ -115,6 +114,16 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( rfidScanCode: scannedCode, decscUPCEANUsed: code, decscRfidscancode: scannedCode + }, + callback: () => { + const index = existingAddedProduct.findIndex( + e => + e.obposSerialNumber === sNumber && + searchkey === data.models[0].get('searchkey') + ); + if (index > -1) { + existingAddedProduct.splice(index, 1); + } } }); } else { @@ -153,27 +162,20 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( function(data) { if (data.length > 0) { //looking for the same product with same serial number - for ( - i = 0; - i < OB.MobileApp.model.receipt.get('lines').length; - i++ - ) { - if ( - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('obposSerialNumber') === - sNumber && - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('product') - .get('searchkey') === - data.models[0].get('searchkey') - ) { - existingSerial = true; - break; - } - } + const existingAddedProduct = OB.MobileApp.model.receipt.get( + 'DECSCAddedProduct' + ); + const existingSerial = !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === data.models[0].get('searchkey') + ); + if (!existingSerial) { + existingAddedProduct.push({ + obposSerialNumber: sNumber, + searchkey: data.models[0].get('searchkey') + }); // Force to ungroup the product if readed using RFID data.models[0].set('groupProduct', false); OB.MobileApp.view.waterfall('onAddProduct', { @@ -186,6 +188,17 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( rfidScanCode: scannedCode, decscUPCEANUsed: code, decscRfidscancode: scannedCode + }, + callback: () => { + const index = existingAddedProduct.findIndex( + e => + e.obposSerialNumber === sNumber && + searchkey === + data.models[0].get('searchkey') + ); + if (index > -1) { + existingAddedProduct.splice(index, 1); + } } }); } else { ![]() diff --git a/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js b/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js index 3481f37a7..b99994101 100644 --- a/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js +++ b/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2015-2021 Openbravo S.L.U. + * Copyright (C) 2015-2022 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -10,7 +10,8 @@ /* global WebSocket, _ Backbone, DECUAUT */ OB.UTIL.RfidController = new Backbone.Model({ - connected: false + connected: false, + epcList: [] }); OB.UTIL.RfidController.isRfidConfigured = function() { @@ -121,11 +122,23 @@ OB.UTIL.RfidController.startRfidWebsocket = function startRfidWebsocket( }); } } + + if (OB.MobileApp.model.receipt) { + OB.MobileApp.model.receipt.get('lines').forEach(line => { + if (line.get('obposEpccode')) { + OB.UTIL.RfidController.get('epcList').push({ + epc: line.get('obposEpccode'), + upc: line.get('product').get('uPCEAN'), + serialNo: line.get('obposSerialNumber') + }); + } + }); + } }; // Called when a message is received from server OB.UTIL.RfidController.get('rfidWebsocket').onmessage = function(event) { - var data, ean, i, line; + var data, ean; if (event.data.startsWith('doNotReconnect')) { OB.UTIL.RfidController.get('rfidWebsocket').onclose = function() {}; OB.UTIL.RfidController.set('connected', false); @@ -444,17 +457,32 @@ OB.UTIL.RfidController.startRfidWebsocket = function startRfidWebsocket( 60) ); } - for (i = 0; i < OB.MobileApp.model.receipt.get('lines').length; i++) { - line = OB.MobileApp.model.receipt.get('lines').models[i]; - if ( - line.get('obposEpccode') === data.dataToSave.obposEpccode || - ('0' + line.get('product').get('uPCEAN') === data.gtin && - line.get('obposSerialNumber') === data.dataToSave.obposSerialNumber) - ) { - return; - } - } ean = data.gtin.substring(1, data.gtin.length).replace(/^0*/, ''); + OB.info( + '[RFID] EPC: ' + + data.dataToSave.obposEpccode + + ', UPC:' + + data.gtin + + ', SNo: ' + + data.dataToSave.obposSerialNumber + ); + const epcList = OB.UTIL.RfidController.get('epcList'); + if ( + epcList.find( + e => + e.epc === data.dataToSave.obposEpccode || + ('0' + e.upc === data.gtin && + e.serialNo === data.dataToSave.obposSerialNumber) + ) + ) { + OB.info('[RFID] EPC Skipped since addProduct event already triggered'); + return; + } + epcList.push({ + epc: data.dataToSave.obposEpccode, + upc: ean, + serialNo: data.dataToSave.obposSerialNumber + }); // We are checking if the scanned tag is a hard tag // In that case, call the supervisor and never add the product to the order var serialNumberWithoutZeroes = data.dataToSave.obposSerialNumber.replace( @@ -698,6 +726,11 @@ OB.UTIL.RfidController.addEpcLine = function(line, callback, errorCallback) { JSON.stringify(extra) ); } + OB.UTIL.RfidController.get('epcList').push({ + epc: line.get('obposEpccode'), + upc: line.attributes.product.get('uPCEAN'), + serialNo: line.get('obposSerialNumber') + }); OB.debug('addEpcLine sent, UUID: ' + uuid); }, function() { @@ -934,6 +967,7 @@ OB.UTIL.RfidController.eraseEpcOrder = function( ':' + JSON.stringify(extra) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('eraseEpcOrder sent, UUID: ' + uuid); }, function() { @@ -982,6 +1016,11 @@ OB.UTIL.RfidController.removeEpc = function(epc, callback, errorCallback) { OB.UTIL.RfidController.get('rfidWebsocket').send( 'removeEpcs:' + uuid + ':' + epc + ':' + JSON.stringify(extra) ); + const epcList = OB.UTIL.RfidController.get('epcList'); + const epcIndex = epcList.findIndex(e => e.epc === epc); + if (epcIndex > -1) { + epcList.splice(epcIndex, 1); + } OB.debug('removeEpc sent, UUID: ' + uuid); }, function() { @@ -1079,7 +1118,13 @@ OB.UTIL.RfidController.removeEpcLine = function(line, callback, errorCallback) { JSON.stringify(extra) ); } - + const epcList = OB.UTIL.RfidController.get('epcList'); + const epcIndex = epcList.findIndex( + e => e.epc === line.get('obposEpccode') + ); + if (epcIndex > -1) { + epcList.splice(epcIndex, 1); + } OB.debug('removeEpcLine sent UUID: ' + uuid); }, function() { @@ -1205,6 +1250,7 @@ OB.UTIL.RfidController.removeAllEpcs = function(callback, errorCallback) { OB.UTIL.RfidController.get('rfidWebsocket').send( 'removeAllEpcs:' + uuid + ':' + JSON.stringify(extra) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('removeAllEpcs sent, UUID: ' + uuid); }, function() { @@ -1278,6 +1324,7 @@ OB.UTIL.RfidController.processRemainingCodes = function( ':' + JSON.stringify(extra) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('add:processRemainingCodes sent, UUID: ' + uuid); }, function() { @@ -1337,6 +1384,7 @@ OB.UTIL.RfidController.processRemainingCodes = function( ':' + JSON.stringify(extra) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('remove processRemainingCodes sent, UUID: ' + uuid); }, function() { ![]() diff --git a/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js b/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js index 77b799772..eef476696 100644 --- a/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js +++ b/web/org.openbravo.retail.posterminal/js/utils/rfidWebsocket.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2015-2021 Openbravo S.L.U. + * Copyright (C) 2015-2022 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -10,7 +10,8 @@ /*global, WebSocket, _ Backbone */ OB.UTIL.RfidController = new Backbone.Model({ - connected: false + connected: false, + epcList: [] }); OB.UTIL.RfidController.isRfidConfigured = function() { @@ -99,11 +100,23 @@ OB.UTIL.RfidController.startRfidWebsocket = function startRfidWebsocket( } else { OB.UTIL.RfidController.disconnectRFIDDevice(); } + + if (OB.MobileApp.model.receipt) { + OB.MobileApp.model.receipt.get('lines').forEach(line => { + if (line.get('obposEpccode')) { + OB.UTIL.RfidController.get('epcList').push({ + epc: line.get('obposEpccode'), + upc: line.get('product').get('uPCEAN'), + serialNo: line.get('obposSerialNumber') + }); + } + }); + } }; // Called when a message is received from server OB.UTIL.RfidController.get('rfidWebsocket').onmessage = function(event) { - var data, ean, i, line; + var data, ean; if (event.data.startsWith('doNotReconnect')) { OB.UTIL.RfidController.get('rfidWebsocket').onclose = function() {}; OB.UTIL.RfidController.set('connected', false); @@ -131,17 +144,32 @@ OB.UTIL.RfidController.startRfidWebsocket = function startRfidWebsocket( 60) ); } - for (i = 0; i < OB.MobileApp.model.receipt.get('lines').length; i++) { - line = OB.MobileApp.model.receipt.get('lines').models[i]; - if ( - line.get('obposEpccode') === data.dataToSave.obposEpccode || - ('0' + line.get('product').get('uPCEAN') === data.gtin && - line.get('obposSerialNumber') === data.dataToSave.obposSerialNumber) - ) { - return; - } - } ean = data.gtin.substring(1, data.gtin.length); + OB.info( + '[RFID] EPC: ' + + data.dataToSave.obposEpccode + + ', UPC:' + + data.gtin + + ', SNo: ' + + data.dataToSave.obposSerialNumber + ); + const epcList = OB.UTIL.RfidController.get('epcList'); + if ( + epcList.find( + e => + e.epc === data.dataToSave.obposEpccode || + ('0' + e.upc === data.gtin && + e.serialNo === data.dataToSave.obposSerialNumber) + ) + ) { + OB.info('[RFID] EPC Skipped since addProduct event already triggered'); + return; + } + epcList.push({ + epc: data.dataToSave.obposEpccode, + upc: ean, + serialNo: data.dataToSave.obposSerialNumber + }); OB.UTIL.RfidController.get('barcodeActionHandler').findProductByBarcode( ean, function(product, attrs, addProductCallback) { @@ -205,6 +233,11 @@ OB.UTIL.RfidController.addEpcLine = function(line, callback, errorCallback) { OB.UTIL.RfidController.get('rfidWebsocket').send( 'addEpcs:' + uuid + ':' + line.get('obposEpccode') ); + OB.UTIL.RfidController.get('epcList').push({ + epc: line.get('obposEpccode'), + upc: line.attributes.product.get('uPCEAN'), + serialNo: line.get('obposSerialNumber') + }); OB.debug('addEpcLine sent, UUID: ' + uuid); }, function() { @@ -245,6 +278,7 @@ OB.UTIL.RfidController.eraseEpcOrder = function( ':' + epcCodes.substring(0, epcCodes.length - 1) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('eraseEpcOrder sent, UUID: ' + uuid); }, function() { @@ -272,6 +306,11 @@ OB.UTIL.RfidController.removeEpc = function(epc, callback, errorCallback) { OB.UTIL.RfidController.get('rfidWebsocket').send( 'removeEpcs:' + uuid + ':' + epc ); + const epcList = OB.UTIL.RfidController.get('epcList'); + const epcIndex = epcList.findIndex(e => e.epc === epc); + if (epcIndex > -1) { + epcList.splice(epcIndex, 1); + } OB.debug('removeEpc sent, UUID: ' + uuid); }, function() { @@ -298,6 +337,13 @@ OB.UTIL.RfidController.removeEpcLine = function(line, callback, errorCallback) { OB.UTIL.RfidController.get('rfidWebsocket').send( 'removeEpcs:' + uuid + ':' + line.get('obposEpccode') ); + const epcList = OB.UTIL.RfidController.get('epcList'); + const epcIndex = epcList.findIndex( + e => e.epc === line.get('obposEpccode') + ); + if (epcIndex > -1) { + epcList.splice(epcIndex, 1); + } OB.debug('removeEpcLine sent UUID: ' + uuid); }, function() { @@ -348,6 +394,7 @@ OB.UTIL.RfidController.removeAllEpcs = function(callback, errorCallback) { OB.UTIL.RfidController.waitForAck( function(uuid) { OB.UTIL.RfidController.get('rfidWebsocket').send('removeAllEpcs:' + uuid); + OB.UTIL.RfidController.set('epcList', []); OB.debug('removeAllEpcs sent, UUID: ' + uuid); }, function() { @@ -393,6 +440,7 @@ OB.UTIL.RfidController.processRemainingCodes = function( ':' + epcCodesToAdd.substring(0, epcCodesToAdd.length - 1) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('add:processRemainingCodes sent, UUID: ' + uuid); }, function() { @@ -423,6 +471,7 @@ OB.UTIL.RfidController.processRemainingCodes = function( ':' + epcCodesToErase.substring(0, epcCodesToErase.length - 1) ); + OB.UTIL.RfidController.set('epcList', []); OB.debug('remove processRemainingCodes sent, UUID: ' + uuid); }, function() { ![]() diff --git a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js index e567f4e..5fbda49 100644 --- a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js +++ b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js @@ -24,7 +24,6 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( uPCEAN, itemCode, searchkey, - existingSerial, hasDecimals = false; if (OB.Format.defaultDecimalSymbol === ',') { hasDecimals = /(?:,.{1,5})$/; @@ -35,7 +34,14 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( var regCardNumber = /^(209[0-9]{10})$/g; let requiredCalculateReceipt = false; - + OB.info( + '[Hook] OBPOS_BarcodeScan EPC: ' + + args.attrs.obposEpccode + + ', UPC:' + + args.code + + ', SNo: ' + + args.attrs.obposSerialNumber + ); switch (scannedCode.length) { case 13: //Loyalty card 1st since is the most common @@ -119,7 +125,7 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const index = existingAddedProduct.findIndex( e => e.obposSerialNumber === sNumber && - searchkey === data.models[0].get('searchkey') + e.searchkey === data.models[0].get('searchkey') ); if (index > -1) { existingAddedProduct.splice(index, 1); @@ -128,6 +134,10 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( }); } else { OB.UTIL.showError(OB.I18N.getLabel('DECSC_AlreadyIn')); + OB.info( + '[Hook] OBPOS_BarcodeScan Skipped addProduct since already added. EPC: ' + + args.attrs.obposEpccode + ); } } else { OB.Dal.findUsingCache( @@ -193,7 +203,7 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const index = existingAddedProduct.findIndex( e => e.obposSerialNumber === sNumber && - searchkey === + e.searchkey === data.models[0].get('searchkey') ); if (index > -1) { @@ -205,6 +215,10 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( OB.UTIL.showError( OB.I18N.getLabel('DECSC_AlreadyIn') ); + OB.info( + '[Hook] OBPOS_BarcodeScan Skipped addProduct since already added. EPC: ' + + args.attrs.obposEpccode + ); } } else { //call unknown item @@ -216,34 +230,47 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( }, function(found) { if (found.length !== 0) { - for ( - i = 0; - i < - OB.MobileApp.model.receipt.get('lines') - .length; - i++ - ) { - if ( - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('obposSerialNumber') === - sNumber && - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('product') - .get('searchkey') === + //looking for the same product with same serial number + const existingAddedProduct = OB.MobileApp.model.receipt.get( + 'DECSCAddedProduct' + ); + const existingSerial = !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === found.models[0].get('searchkey') - ) { - existingSerial = true; - break; - } - } + ); if (!existingSerial) { - DECUNK.UTIL.callToUnkownItem(code, args); + existingAddedProduct.push({ + obposSerialNumber: sNumber, + searchkey: found.models[0].get('searchkey') + }); + const callback = () => { + const index = existingAddedProduct.findIndex( + e => + e.obposSerialNumber === sNumber && + e.searchkey === + found.models[0].get('searchkey') + ); + if (index > -1) { + existingAddedProduct.splice(index, 1); + } + }; + DECUNK.UTIL.callToUnkownItem( + code, + args, + false, + callback, + callback + ); } else { OB.UTIL.showError( OB.I18N.getLabel('DECSC_AlreadyIn') ); + OB.info( + '[Hook] OBPOS_BarcodeScan Skipped addProduct since already added. EPC: ' + + args.attrs.obposEpccode + ); } } else { OB.UTIL.showError( @@ -277,32 +304,46 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( }, function(found) { if (found.length !== 0) { - for ( - i = 0; - i < OB.MobileApp.model.receipt.get('lines').length; - i++ - ) { - if ( - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('obposSerialNumber') === - sNumber && - OB.MobileApp.model.receipt - .get('lines') - .models[i].get('product') - .get('searchkey') === - found.models[0].get('searchkey') - ) { - existingSerial = true; - break; - } - } + //looking for the same product with same serial number + const existingAddedProduct = OB.MobileApp.model.receipt.get( + 'DECSCAddedProduct' + ); + const existingSerial = !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === found.models[0].get('searchkey') + ); if (!existingSerial) { - DECUNK.UTIL.callToUnkownItem(code, args); + existingAddedProduct.push({ + obposSerialNumber: sNumber, + searchkey: found.models[0].get('searchkey') + }); + const callback = () => { + const index = existingAddedProduct.findIndex( + e => + e.obposSerialNumber === sNumber && + e.searchkey === + found.models[0].get('searchkey') + ); + if (index > -1) { + existingAddedProduct.splice(index, 1); + } + }; + DECUNK.UTIL.callToUnkownItem( + code, + args, + false, + callback, + callback + ); } else { OB.UTIL.showError( OB.I18N.getLabel('DECSC_AlreadyIn') ); + OB.info( + '[Hook] OBPOS_BarcodeScan Skipped addProduct since already added. EPC: ' + + args.attrs.obposEpccode + ); } } else { OB.UTIL.showError( ![]() diff --git a/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js b/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js index c97916a..95e2970 100644 --- a/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js +++ b/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js @@ -1,6 +1,6 @@ /* ************************************************************************************ - * Copyright (C) 2017-2020 Openbravo S.L.U. + * Copyright (C) 2017-2022 Openbravo S.L.U. * Licensed under the Openbravo Commercial License version 1.0 * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html * or in the legal folder of this module distribution. @@ -54,10 +54,11 @@ DECUNK.UTIL = { errorCallback ) { var callToAddProduct = function(found, code, args) { - var attrs = args.attrs || {}, - existingSerial = false, - receipt = OB.MobileApp.model.receipt, - i; + var attrs = args.attrs || {}; + OB.MobileApp.model.receipt.set( + 'DECUNKAddedProduct', + OB.MobileApp.model.receipt.get('DECUNKAddedProduct') || [] + ); //If we end in this flow we should ensure that we are sending the rfidscan & decscUPCEANUsed. If empty will be the code after applying 20/21 rules if (!attrs.rfidScanCode) { attrs.rfidScanCode = code; @@ -70,29 +71,46 @@ DECUNK.UTIL = { attrs.obposSerialNumber = args.code.substr(18, 12); } //This check should be done before adding the product to ensure that we have all the properties - for (i = 0; i < receipt.get('lines').length; i++) { - if ( - receipt.get('lines').models[i].get('obposSerialNumber') === - attrs.obposSerialNumber && - receipt - .get('lines') - .models[i].get('product') - .get('searchkey') === found.models[0].get('searchkey') - ) { - existingSerial = true; - break; - } - } + const existingAddedProduct = OB.MobileApp.model.receipt.get( + 'DECUNKAddedProduct' + ); + const existingSerial = !!existingAddedProduct.find( + e => + e.obposSerialNumber === attrs.obposSerialNumber && + e.searchkey === found.models[0].get('searchkey') + ); if (!existingSerial) { + existingAddedProduct.push({ + obposSerialNumber: attrs.obposSerialNumber, + searchkey: found.models[0].get('searchkey') + }); OB.MobileApp.view.waterfall('onAddProduct', { product: found.models[0], qty: args.qty, options: null, - attrs: attrs + attrs: attrs, + callback: () => { + const index = existingAddedProduct.findIndex( + e => + e.obposSerialNumber === attrs.obposSerialNumber && + e.searchkey === found.models[0].get('searchkey') + ); + if (index > -1) { + existingAddedProduct.splice(index, 1); + } + if (callback && callback instanceof Function) { + callback(); + } + } }); - } - if (callback && callback instanceof Function) { - callback(); + } else { + if (callback && callback instanceof Function) { + callback(); + } + OB.info( + '[Unknown Item] searchByItemCode Skipped addProduct since already added. searchKey: ' + + found.models[0].get('searchkey') + ); } }, goToUnknown = function() { @@ -131,7 +149,19 @@ DECUNK.UTIL = { } ); }, - callToUnkownItem: function(code, args, avoidExecutionUnknown) { - DECUNK.UTIL.searchByItemCode(code, args, avoidExecutionUnknown); + callToUnkownItem: function( + code, + args, + avoidExecutionUnknown, + callback, + errorCallback + ) { + DECUNK.UTIL.searchByItemCode( + code, + args, + avoidExecutionUnknown, + callback, + errorCallback + ); } }; ![]() diff --git a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js index 5fbda49..8e8c80d 100644 --- a/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js +++ b/web/com.openbravo.decathlon.retail.scancustomizations/js/barcodeScanHook.js @@ -97,11 +97,20 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const existingAddedProduct = OB.MobileApp.model.receipt.get( 'DECSCAddedProduct' ); - const existingSerial = !!existingAddedProduct.find( - e => - e.obposSerialNumber === sNumber && - e.searchkey === data.models[0].get('searchkey') - ); + const existingSerial = + !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === data.models[0].get('searchkey') + ) || + OB.MobileApp.model.receipt + .get('lines') + .models.find( + l => + l.get('obposSerialNumber') === sNumber && + l.get('product').get('searchkey') === + data.models[0].get('searchkey') + ); if (!existingSerial) { existingAddedProduct.push({ @@ -175,11 +184,20 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const existingAddedProduct = OB.MobileApp.model.receipt.get( 'DECSCAddedProduct' ); - const existingSerial = !!existingAddedProduct.find( - e => - e.obposSerialNumber === sNumber && - e.searchkey === data.models[0].get('searchkey') - ); + const existingSerial = + !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === data.models[0].get('searchkey') + ) || + OB.MobileApp.model.receipt + .get('lines') + .models.find( + l => + l.get('obposSerialNumber') === sNumber && + l.get('product').get('searchkey') === + data.models[0].get('searchkey') + ); if (!existingSerial) { existingAddedProduct.push({ @@ -234,12 +252,22 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const existingAddedProduct = OB.MobileApp.model.receipt.get( 'DECSCAddedProduct' ); - const existingSerial = !!existingAddedProduct.find( - e => - e.obposSerialNumber === sNumber && - e.searchkey === - found.models[0].get('searchkey') - ); + const existingSerial = + !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === + found.models[0].get('searchkey') + ) || + OB.MobileApp.model.receipt + .get('lines') + .models.find( + l => + l.get('obposSerialNumber') === + sNumber && + l.get('product').get('searchkey') === + found.models[0].get('searchkey') + ); if (!existingSerial) { existingAddedProduct.push({ obposSerialNumber: sNumber, @@ -308,11 +336,20 @@ OB.UTIL.HookManager.registerHook('OBPOS_BarcodeScan', function( const existingAddedProduct = OB.MobileApp.model.receipt.get( 'DECSCAddedProduct' ); - const existingSerial = !!existingAddedProduct.find( - e => - e.obposSerialNumber === sNumber && - e.searchkey === found.models[0].get('searchkey') - ); + const existingSerial = + !!existingAddedProduct.find( + e => + e.obposSerialNumber === sNumber && + e.searchkey === found.models[0].get('searchkey') + ) || + OB.MobileApp.model.receipt + .get('lines') + .models.find( + l => + l.get('obposSerialNumber') === sNumber && + l.get('product').get('searchkey') === + found.models[0].get('searchkey') + ); if (!existingSerial) { existingAddedProduct.push({ obposSerialNumber: sNumber, ![]() diff --git a/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js b/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js index 95e2970..3af355d 100644 --- a/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js +++ b/web/com.openbravo.decathlon.retail.unknownitem/js/decUnknownUtils.js @@ -74,11 +74,20 @@ DECUNK.UTIL = { const existingAddedProduct = OB.MobileApp.model.receipt.get( 'DECUNKAddedProduct' ); - const existingSerial = !!existingAddedProduct.find( - e => - e.obposSerialNumber === attrs.obposSerialNumber && - e.searchkey === found.models[0].get('searchkey') - ); + const existingSerial = + !!existingAddedProduct.find( + e => + e.obposSerialNumber === attrs.obposSerialNumber && + e.searchkey === found.models[0].get('searchkey') + ) || + OB.MobileApp.model.receipt + .get('lines') + .models.find( + l => + l.get('obposSerialNumber') === attrs.obposSerialNumber && + l.get('product').get('searchkey') === + found.models[0].get('searchkey') + ); if (!existingSerial) { existingAddedProduct.push({ obposSerialNumber: attrs.obposSerialNumber, | |||||||
![]() |
||||||||
|
![]() |
|
(0135148) ranjith_qualiantech_com (viewer) 2022-02-21 06:39 |
Attached patch for 19Q3 |
![]() |
|||
Date Modified | Username | Field | Change |
2022-02-09 11:48 | joniturralde93 | New Issue | |
2022-02-09 11:48 | joniturralde93 | Assigned To | => Retail |
2022-02-09 11:48 | joniturralde93 | OBNetwork customer | => Gold |
2022-02-09 11:48 | joniturralde93 | Support ticket | => 35461 |
2022-02-09 11:48 | joniturralde93 | Triggers an Emergency Pack | => No |
2022-02-09 11:55 | jorgewederago | Issue Monitored: jorgewederago | |
2022-02-09 19:46 | rqueralta | Assigned To | Retail => rqueralta |
2022-02-09 19:46 | rqueralta | Status | new => scheduled |
2022-02-10 08:19 | marvintm | Assigned To | rqueralta => ranjith_qualiantech_com |
2022-02-15 12:19 | ranjith_qualiantech_com | File Added: 48562_pi_posterminal.diff | |
2022-02-15 12:19 | ranjith_qualiantech_com | File Added: 48562_19Q3_posterminal.diff | |
2022-02-15 12:20 | ranjith_qualiantech_com | File Added: 48562_19Q3_decathlonscancustomizations.diff | |
2022-02-15 14:47 | ranjith_qualiantech_com | File Deleted: 48562_pi_posterminal.diff | |
2022-02-15 14:48 | ranjith_qualiantech_com | File Deleted: 48562_19Q3_posterminal.diff | |
2022-02-15 14:48 | ranjith_qualiantech_com | File Added: 48562_19Q3_posterminal.diff | |
2022-02-15 14:48 | ranjith_qualiantech_com | File Added: 48562_pi_posterminal.diff | |
2022-02-21 06:39 | ranjith_qualiantech_com | Note Added: 0135148 | |
2022-02-21 06:39 | ranjith_qualiantech_com | Status | scheduled => resolved |
2022-02-21 06:39 | ranjith_qualiantech_com | Resolution | open => fixed |
2022-02-21 07:30 | marvintm | Status | resolved => new |
2022-02-21 07:30 | marvintm | Resolution | fixed => open |
2022-02-21 07:31 | marvintm | Status | new => closed |
2022-02-21 07:31 | marvintm | Resolution | open => no change required |
2022-02-24 15:42 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_decathlonscancustomizations_devbranch_v2_ontop_of_lastpatch.diff | |
2022-02-24 15:43 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_retail.unknownitem_master.diff | |
2022-02-24 15:45 | ranjith_qualiantech_com | File Deleted: 48562_DKT_19Q3_decathlonscancustomizations_devbranch_v2_ontop_of_lastpatch.diff | |
2022-02-24 15:57 | ranjith_qualiantech_com | File Deleted: 48562_DKT_19Q3_retail.unknownitem_master.diff | |
2022-02-24 16:04 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_decathlonscancustomizations_devbranch_v2_ontop_of_lastpatch.diff | |
2022-02-24 16:04 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_retail.unknownitem_master.diff | |
2022-02-28 09:10 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_decathlon.scancustomizations_devbranch_v3_ontop_of_lastpatch.diff | |
2022-02-28 09:10 | ranjith_qualiantech_com | File Added: 48562_DKT_19Q3_retail.unknownitem_devbranch_v3_ontop_of_lastpatch.diff | |
2022-03-02 17:07 | ranjith_qualiantech_com | Relationship added | related to 0046677 |
Copyright © 2000 - 2009 MantisBT Group |