From 860499db82342f67382c947d1dcce5d93718fd96 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Jan 2022 08:28:57 +0100 Subject: [PATCH 1/2] refactor(ticket): add more text in error when change zone --- loopback/locale/es.json | 2 +- .../ticket/back/methods/ticket/componentUpdate.js | 13 ++++++++++--- .../ticket/back/methods/ticket/priceDifference.js | 6 ++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index cff5f652e..3206565cc 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -96,7 +96,7 @@ "This postcode already exists": "Este código postal ya existe", "Concept cannot be blank": "El concepto no puede quedar en blanco", "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona", + "You don't have privileges to change the zone or for those paramteres there are most than of one shipping option, talk to agencies": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 515689649..6bf9955c7 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -112,10 +112,17 @@ module.exports = Self => { const isProductionBoss = await models.Account.hasRole(userId, 'productionBoss', myOptions); if (!isProductionBoss) { - const zoneShipped = await models.Agency.getShipped(args.landed, args.addressFk, args.agencyModeFk, args.warehouseFk, myOptions); + const zoneShipped = await models.Agency.getShipped( + args.landed, + args.addressFk, + args.agencyModeFk, + args.warehouseFk, + myOptions); - if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) - throw new UserError(`You don't have privileges to change the zone`); + if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) { + throw new UserError(`You don't have privileges to change the zone + or for those paramteres there are most than of one shipping option, talk to agencies`); + } } const originalTicket = await models.Ticket.findOne({ diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 2456d3de0..3f70695a8 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -81,8 +81,10 @@ module.exports = Self => { args.warehouseId, myOptions); - if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) - throw new UserError(`You don't have privileges to change the zone`); + if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) { + throw new UserError(`You don't have privileges to change the zone + or for those paramteres there are most than of one shipping option, talk to agencies`); + } } const items = await models.Sale.find({ From 5462af91ee11d726a99d1480b81669160116affd Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 10 Jan 2022 11:38:02 +0100 Subject: [PATCH 2/2] extract to variable --- loopback/locale/es.json | 2 +- modules/ticket/back/methods/ticket/componentUpdate.js | 6 ++++-- modules/ticket/back/methods/ticket/priceDifference.js | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 3206565cc..37cb8f7d9 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -96,7 +96,7 @@ "This postcode already exists": "Este código postal ya existe", "Concept cannot be blank": "El concepto no puede quedar en blanco", "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone or for those paramteres there are most than of one shipping option, talk to agencies": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", + "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", diff --git a/modules/ticket/back/methods/ticket/componentUpdate.js b/modules/ticket/back/methods/ticket/componentUpdate.js index 6bf9955c7..53e5fedc8 100644 --- a/modules/ticket/back/methods/ticket/componentUpdate.js +++ b/modules/ticket/back/methods/ticket/componentUpdate.js @@ -120,8 +120,10 @@ module.exports = Self => { myOptions); if (!zoneShipped || zoneShipped.zoneFk != args.zoneFk) { - throw new UserError(`You don't have privileges to change the zone - or for those paramteres there are most than of one shipping option, talk to agencies`); + const error = `You don't have privileges to change the zone or + for these parameters there are more than one shipping options, talk to agencies`; + + throw new UserError(error); } } diff --git a/modules/ticket/back/methods/ticket/priceDifference.js b/modules/ticket/back/methods/ticket/priceDifference.js index 3f70695a8..1856cb08f 100644 --- a/modules/ticket/back/methods/ticket/priceDifference.js +++ b/modules/ticket/back/methods/ticket/priceDifference.js @@ -82,8 +82,10 @@ module.exports = Self => { myOptions); if (!zoneShipped || zoneShipped.zoneFk != args.zoneId) { - throw new UserError(`You don't have privileges to change the zone - or for those paramteres there are most than of one shipping option, talk to agencies`); + const error = `You don't have privileges to change the zone or + for these parameters there are more than one shipping options, talk to agencies`; + + throw new UserError(error); } }