From 99ef8a6010d400f2d43dfe48007955ae65d508b5 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 24 Sep 2019 14:23:21 +0200 Subject: [PATCH] #1719 claim.detail cambiar descuento falla --- modules/ticket/back/methods/ticket/isEditable.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/isEditable.js b/modules/ticket/back/methods/ticket/isEditable.js index c31d99304..766933d45 100644 --- a/modules/ticket/back/methods/ticket/isEditable.js +++ b/modules/ticket/back/methods/ticket/isEditable.js @@ -20,11 +20,12 @@ module.exports = Self => { }); Self.isEditable = async(ctx, id) => { - const accessToken = ctx.req.accessToken; - const userId = accessToken.userId; + const userId = ctx.req.accessToken.userId; + let state = await Self.app.models.TicketState.findOne({ where: {ticketFk: id} }); + let isProductionBoss = await Self.app.models.Account.hasRole(userId, 'productionBoss'); let alertLevel = state ? state.alertLevel : null; let ticket = await Self.app.models.Ticket.findById(id, { @@ -41,7 +42,7 @@ module.exports = Self => { const isDeleted = ticket && ticket.isDeleted; const isOnDelivery = (alertLevel && alertLevel > 0); - const isNotNormalClient = ticket && ticket.client().type().code == 'normal'; + const isNotNormalClient = ticket && ticket.client().type().code != 'normal'; const isInvoiced = ticket && ticket.refFk; if (!ticket || (isOnDelivery && isNotNormalClient && !isProductionBoss) || isInvoiced || isDeleted)