validation message for dup entry

This commit is contained in:
Carlos Jimenez Ruiz 2021-06-28 13:30:49 +02:00
parent 0e47cf72e4
commit e2ff3ff17f
3 changed files with 11 additions and 2 deletions

View File

@ -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"
}

View File

@ -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;
});
};

View File

@ -12,7 +12,7 @@
},
"properties": {
"dmsFk": {
"type": "Number",
"type": "number",
"id": true,
"required": true
}