#1329 ticket.services validation
gitea/salix/dev This commit has test failures Details

This commit is contained in:
Bernat 2019-04-23 11:25:49 +02:00
parent 5501ff8f4f
commit 75c9d1122c
2 changed files with 14 additions and 1 deletions

View File

@ -81,5 +81,6 @@
"This client can't be invoiced": "Este cliente no puede ser facturado",
"This ticket can't be invoiced": "Este ticket no puede ser facturado",
"That item is not available on that day": "El item no esta disponible para esa fecha",
"That item doesn't exists": "That item doesn't exists"
"That item doesn't exists": "That item doesn't exists",
"You cannot add services to an invoiced ticket": "No puedes añadir servicios a un ticket facturado"
}

View File

@ -0,0 +1,12 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.observe('before save', async ctx => {
if (ctx.isNewInstance) {
let ticketId = ctx.instance.ticketFk;
let ticket = await Self.app.models.Ticket.findById(ticketId);
if (ticket.refFk)
throw new UserError('You cannot add services to an invoiced ticket');
}
});
};