diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 601a26f5b..551b544b6 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -226,5 +226,6 @@ "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked", - "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", + "You can only have one PDA": "You can only have one PDA" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77e707590..4a7e1505c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -357,6 +357,7 @@ "This workCenter is already assigned to this agency": "Este centro de trabajo ya está asignado a esta agencia", "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", - "This PDA is already assigned to another user": "This PDA is already assigned to another user", - "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", + "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", + "You can only have one PDA": "Solo puedes tener un PDA" } \ No newline at end of file diff --git a/modules/worker/back/models/device-production-user.js b/modules/worker/back/models/device-production-user.js index 81af484d3..8eead58e0 100644 --- a/modules/worker/back/models/device-production-user.js +++ b/modules/worker/back/models/device-production-user.js @@ -3,6 +3,9 @@ module.exports = Self => { Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`This PDA is already assigned to another user`); + + if (err.code === 'ER_SIGNAL_EXCEPTION' && err.sqlMessage === 'You can only have one active PDA') + return new UserError(err.sqlMessage); return err; }); };