refs #6184 saveCmr #1788
|
@ -70,21 +70,17 @@ module.exports = Self => {
|
|||
};
|
||||
|
||||
const dms = await models.TicketDms.findOne({
|
||||
where: {
|
||||
ticketFk: ticketId
|
||||
},
|
||||
include: [
|
||||
{
|
||||
where: {ticketFk: ticketId},
|
||||
include: [{
|
||||
guillermo marked this conversation as resolved
Outdated
|
||||
relation: 'dms',
|
||||
fields: ['id'],
|
||||
scope: {
|
||||
relation: 'dmsType',
|
||||
where: {
|
||||
code: 'cmr'
|
||||
scope: {
|
||||
where: {code: 'cmr'}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, myOptions);
|
||||
|
||||
if (!dms) throw new UserError('Cmr file does not exist');
|
||||
|
|
|
@ -59,18 +59,18 @@ module.exports = Self => {
|
|||
|
||||
async function hasSignDms(ticketId) {
|
||||
const ticketDms = await models.TicketDms.findOne({
|
||||
where: {
|
||||
ticketFk: ticketId
|
||||
},
|
||||
fields: ['dmsFk'],
|
||||
include: [{
|
||||
where: {ticketFk: ticketId},
|
||||
include: [
|
||||
{
|
||||
relation: 'dms',
|
||||
fields: ['id'],
|
||||
scope: {
|
||||
where: {dmsType: dmsTypeTicket.id}
|
||||
where: {dmsTypeFk: dmsTypeTicket.id}
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
}, myOptions);
|
||||
if (ticketDms.dms().id) return true;
|
||||
if (ticketDms.dms()?.id) return true;
|
||||
}
|
||||
|
||||
async function createGestDoc(id) {
|
||||
|
@ -133,9 +133,9 @@ module.exports = Self => {
|
|||
if (await ticket.isSigned)
|
||||
throw new UserError('Ticket is already signed');
|
||||
|
||||
if (location) setLocation(ticketId);
|
||||
if (location) await setLocation(ticketId);
|
||||
if (!await hasSignDms(ticketId))
|
||||
createGestDoc(ticketId);
|
||||
await createGestDoc(ticketId);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
|
||||
const deliveryState = await models.State.findOne({
|
||||
|
|
Loading…
Reference in New Issue
Si solo se usa una vez params se puede poner directamente el objeto o si se quiere variable poner inmediatamente arriba asi facilita la lectura