refs #6184 saveCmr #1788
|
@ -59,16 +59,18 @@ module.exports = Self => {
|
||||||
|
|
||||||
async function hasSignDms(ticketId) {
|
async function hasSignDms(ticketId) {
|
||||||
const ticketDms = await models.TicketDms.findOne({
|
const ticketDms = await models.TicketDms.findOne({
|
||||||
where: {ticketFk: ticketId},
|
where: {
|
||||||
|
ticketFk: ticketId
|
||||||
|
},
|
||||||
fields: ['dmsFk'],
|
fields: ['dmsFk'],
|
||||||
include: [{
|
include: [{
|
||||||
relation: 'dms',
|
relation: 'dms',
|
||||||
where: {
|
scope: {
|
||||||
dmsType: dmsTypeTicket.id
|
where: {dmsType: dmsTypeTicket.id}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
if (ticketDms) return true;
|
if (ticketDms.dms().id) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createGestDoc(id) {
|
async function createGestDoc(id) {
|
||||||
|
@ -132,7 +134,8 @@ module.exports = Self => {
|
||||||
throw new UserError('Ticket is already signed');
|
throw new UserError('Ticket is already signed');
|
||||||
|
|
||||||
if (location) setLocation(ticketId);
|
if (location) setLocation(ticketId);
|
||||||
if (!await hasSignDms(ticketId)) createGestDoc(ticketId);
|
if (!await hasSignDms(ticketId))
|
||||||
|
createGestDoc(ticketId);
|
||||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||||
|
|
||||||
const deliveryState = await models.State.findOne({
|
const deliveryState = await models.State.findOne({
|
||||||
|
|
Loading…
Reference in New Issue