diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e2194b8ada..872d45ae09 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -181,5 +181,6 @@ "This specie already exist": "Esta especie ya existe", "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", "None": "Ninguno", - "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada" + "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", + "This document already exists on this ticket": "Este documento ya existe en el ticket" } \ No newline at end of file diff --git a/modules/ticket/back/models/ticket-dms.js b/modules/ticket/back/models/ticket-dms.js index ddb338632e..9bceaae6eb 100644 --- a/modules/ticket/back/models/ticket-dms.js +++ b/modules/ticket/back/models/ticket-dms.js @@ -1,3 +1,11 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { require('../methods/ticket-dms/removeFile')(Self); + + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError('This document already exists on this ticket'); + return err; + }); }; diff --git a/modules/ticket/back/models/ticket-dms.json b/modules/ticket/back/models/ticket-dms.json index b7b24dce00..8bcff254c6 100644 --- a/modules/ticket/back/models/ticket-dms.json +++ b/modules/ticket/back/models/ticket-dms.json @@ -12,7 +12,7 @@ }, "properties": { "dmsFk": { - "type": "Number", + "type": "number", "id": true, "required": true }