diff --git a/modules/ticket/back/methods/ticket/restore.js b/modules/ticket/back/methods/ticket/restore.js index c92f8767e..c85efb1c8 100644 --- a/modules/ticket/back/methods/ticket/restore.js +++ b/modules/ticket/back/methods/ticket/restore.js @@ -33,12 +33,15 @@ module.exports = Self => { fields: ['originFk', 'creationDate', 'newInstance'] }, myOptions); + console.log('ticket', ticket); const now = Date.vnNew(); - const maxDate = new Date(ticket.updated); + const maxDate = new Date(ticket.creationDate); maxDate.setHours(maxDate.getHours() + 1); - if (now > maxDate) - throw new UserError(`You can only restore a ticket within the first hour after deletion`); + if (ticket.newInstance.includes('isDeleted: true')) { + if (now > maxDate) + throw new UserError(`You can only restore a ticket within the first hour after deletion`); + } // Send notification to salesPerson const salesPersonId = ticket.client().salesPersonFk;