From aad95e41a03f4335260f9a3bf27b89e24d3619da Mon Sep 17 00:00:00 2001 From: elsiosanchez Date: Mon, 7 Feb 2022 16:09:19 -0400 Subject: [PATCH] #1518 --- .../ADempiere/Form/PriceChecking/index.vue | 2 +- src/lang/ADempiere/en/index.js | 3 ++- src/lang/ADempiere/es/index.js | 3 ++- .../ADempiere/pointOfSales/point/actions.js | 19 ++++++++++++++----- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue index 54a184a2632..b005264404a 100644 --- a/src/components/ADempiere/Form/PriceChecking/index.vue +++ b/src/components/ADempiere/Form/PriceChecking/index.vue @@ -237,7 +237,7 @@ export default { formatPrice, formatQuantity, focusProductValue() { - if (!this.isEmptyValue(this.$refs.ProductValue[0])) { + if (!this.isEmptyValue(this.$refs.ProductValue[0]) && !this.isEmptyValue(this.$refs.ProductValue[0].$children[0]) && !this.isEmptyValue(this.$refs.ProductValue[0].$children[0].$children[0]) && !this.isEmptyValue(this.$refs.ProductValue[0].$children[0].$children[0].$children[1])) { this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus() } }, diff --git a/src/lang/ADempiere/en/index.js b/src/lang/ADempiere/en/index.js index c7fb3b64b8d..70aaa2ea99d 100644 --- a/src/lang/ADempiere/en/index.js +++ b/src/lang/ADempiere/en/index.js @@ -64,7 +64,8 @@ export default { recordLocked: 'This record has been locked', recordUnlocked: 'This record has been unlocked', noRoleAccess: 'With your current role and settings, you cannot view this information.', - errorPointOfSale: 'No point of sale selected' + errorPointOfSale: 'No point of sale selected', + emptyPos: 'This User has no Assigned POS Terminal' }, navbar: { badge: { diff --git a/src/lang/ADempiere/es/index.js b/src/lang/ADempiere/es/index.js index a3126e7a530..21f5b55e85d 100644 --- a/src/lang/ADempiere/es/index.js +++ b/src/lang/ADempiere/es/index.js @@ -64,7 +64,8 @@ export default { recordLocked: 'Este registro ha sido bloqueado', recordUnlocked: 'Este registro ha sido desbloqueado', noRoleAccess: 'Con su rol y configuración actuales, no puede ver esta información.', - errorPointOfSale: 'Sin punto de venta seleccionado' + errorPointOfSale: 'Sin punto de venta seleccionado', + emptyPos: 'Este Usuario no tiene Ningún Terminal de PDV Asignado' }, navbar: { badge: { diff --git a/src/store/modules/ADempiere/pointOfSales/point/actions.js b/src/store/modules/ADempiere/pointOfSales/point/actions.js index b0e4cb8fe92..78e3366112b 100644 --- a/src/store/modules/ADempiere/pointOfSales/point/actions.js +++ b/src/store/modules/ADempiere/pointOfSales/point/actions.js @@ -27,6 +27,7 @@ import { } from '@/api/ADempiere/form/point-of-sales.js' import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js' import { showMessage } from '@/utils/ADempiere/notification.js' +import language from '@/lang' /** * Pos Actions @@ -74,17 +75,25 @@ export default { }) .then(response => { pointOfSalesList = response.sellingPointsList - if (isEmptyValue(pos) && isEmptyValue(posToSet)) { + if (isEmptyValue(pos) && isEmptyValue(posToSet) && !isEmptyValue(pointOfSalesList)) { pos = pointOfSalesList.find(itemPOS => itemPOS.salesRepresentative.uuid === userUuid) } - if (isEmptyValue(pos)) { + if (isEmptyValue(pos) && !isEmptyValue(pointOfSalesList)) { pos = pointOfSalesList[0] } - if (!isEmptyValue(router.app._route.query.pos)) { - pos = response.sellingPointsList.find(point => point.id === parseInt(router.app._route.query.pos)) + if (!isEmptyValue(router.app._route.query.pos) && !isEmptyValue(pointOfSalesList)) { + pos = pointOfSalesList.find(point => point.id === parseInt(router.app._route.query.pos)) } commit('setPointOfSalesList', pointOfSalesList) - dispatch('setCurrentPOS', pos) + if (pos) { + dispatch('setCurrentPOS', pos) + } else { + showMessage({ + type: 'error', + message: language.t('notifications.emptyPos'), + showClose: true + }) + } }) .catch(error => { console.warn(`listPointOfSalesFromServer: ${error.message}. Code: ${error.code}.`)