#1329 fix test and fixtures, update ticket-service
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-04-24 07:43:11 +02:00
parent a6fa9f98fb
commit 94480a8189
4 changed files with 10 additions and 8 deletions

View File

@ -1217,9 +1217,10 @@ INSERT INTO `vn`.`ticketRequest`(`id`, `description`, `requesterFk`, `atenderFk`
INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxClassFk`, `ticketFk`)
VALUES
(1, 'delivery charge', 1, 2.00, 1, 1),
(2, 'training course', 1, 10.00, 1, 2),
(3, 'delivery charge', 1, 5.50, 1, 11);
(1, 'Documentos', 1, 2.00, 1, 1),
(2, 'Porte Agencia', 1, 10.00, 1, 2),
(3, 'Documentos', 1, 5.50, 1, 11),
(4, 'Documentos', 1, 2.00, 1, 9);
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)

View File

@ -7,7 +7,7 @@ describe('Ticket services path', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult('1')
.accessToSearchResult(9)
.accessToSection('ticket.card.service');
});

View File

@ -82,5 +82,5 @@
"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",
"You cannot add services to an invoiced ticket": "No puedes añadir servicios a un ticket facturado"
"You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado"
}

View File

@ -2,11 +2,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 changes = ctx.currentInstance || ctx.instance;
if (changes) {
let ticketId = changes.ticketFk;
let ticket = await Self.app.models.Ticket.findById(ticketId);
if (ticket.refFk)
throw new UserError('You cannot add services to an invoiced ticket');
throw new UserError('You cannot add or modify services to an invoiced ticket');
}
});
};