update ticket line discount until invoiced #1365
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-04-24 11:23:24 +02:00
parent 6747a80943
commit d88e2e81ca
1 changed files with 1 additions and 6 deletions

View File

@ -26,7 +26,6 @@ module.exports = Self => {
throw new UserError(`The value should be a number`); throw new UserError(`The value should be a number`);
let model = Self.app.models; let model = Self.app.models;
let thisTicketIsEditable = await model.Ticket.isEditable(params.editLines[0].ticketFk);
let ticket = await model.Ticket.find({ let ticket = await model.Ticket.find({
where: { where: {
id: params.editLines[0].ticketFk id: params.editLines[0].ticketFk
@ -40,13 +39,9 @@ module.exports = Self => {
fields: ['id', 'clientFk', 'refFk'] fields: ['id', 'clientFk', 'refFk']
}); });
let userId = ctx.req.accessToken.userId; if (ticket.refFk)
let isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant');
if ((!thisTicketIsEditable && !isSalesAssistant) || (ticket.refFk && isSalesAssistant))
throw new UserError(`The sales of this ticket can't be modified`); throw new UserError(`The sales of this ticket can't be modified`);
let componentToUse; let componentToUse;
let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'}); let usesMana = await model.WorkerMana.findOne({where: {workerFk: ticket[0].client().salesPersonFk}, fields: 'amount'});