This commit is contained in:
parent
782563f67d
commit
344427da45
|
@ -80,11 +80,19 @@ module.exports = Self => {
|
||||||
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions);
|
const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions);
|
||||||
promises.push(expeditionUpdated);
|
promises.push(expeditionUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
await models.Ticket.updateAll({id: ticket.id}, {packages: promises.length}, myOptions);
|
||||||
|
const state = await models.State.findOne({
|
||||||
|
where: {code: 'PACKED'}
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
await models.Ticket.state(ctx, {
|
||||||
|
ticketFk: ticket.id,
|
||||||
|
stateFk: state.id,
|
||||||
|
userFk: ctx.req.accessToken.userId
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
||||||
return ticket;
|
return ticket;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
|
|
Loading…
Reference in New Issue