refs #6755 fix restore

This commit is contained in:
Carlos Satorres 2024-03-05 14:24:32 +01:00
parent 16fc446b85
commit 70096e7a76
1 changed files with 6 additions and 3 deletions

View File

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