This commit is contained in:
parent
6747a80943
commit
d88e2e81ca
|
@ -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'});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue