#1719 claim.detail cambiar descuento falla

This commit is contained in:
Carlos Jimenez Ruiz 2019-09-24 14:23:21 +02:00
parent d56c7ff540
commit 99ef8a6010
1 changed files with 4 additions and 3 deletions

View File

@ -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)