refactor(ticketTracking.create): refs #6366 unify Ticket.state ticketTracking.create i vn.ticket_setState #1838

Merged
pablone merged 11 commits from 6366-unifyTicketChangeState into dev 2024-01-09 07:00:19 +00:00
2 changed files with 2 additions and 7 deletions
Showing only changes of commit e9773b3885 - Show all commits

View File

@ -136,8 +136,6 @@ module.exports = Self => {
code: 'DELIVERED'
}
}, options);
if (!deliveryState)
throw new UserError('The DELIVERED state does not exist');
pablone marked this conversation as resolved
Review

Este if no el acabe de vore.

Este if no el acabe de vore.
await models.Ticket.state(ctx, {
ticketFk: ticketId,

View File

@ -58,13 +58,10 @@ module.exports = Self => {
fields: ['stateFk']
}, myOptions);
const oldStateAllowed = ticketState ?
await models.State.isEditable(ctx, ticketState.stateFk, myOptions) :
false;
const oldStateAllowed = ticketState && await models.State.isEditable(ctx, ticketState.stateFk, myOptions);
const newStateAllowed = await models.State.isEditable(ctx, params.stateFk, myOptions);
if (!((!ticketState || oldStateAllowed == true) && newStateAllowed == true))
if ((ticketState && !oldStateAllowed) || !newStateAllowed)
throw new UserError(`You don't have enough privileges`, 'ACCESS_DENIED');
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
pablone marked this conversation as resolved
Review

Crec que queda mes simple com:
if ((ticketState && !oldStateAllowed) || !newStateAllowed)

Crec que queda mes simple com: if ((ticketState && !oldStateAllowed) || !newStateAllowed)