6755-restoreRefactor #2158

Merged
carlossa merged 20 commits from 6755-restoreRefactor into dev 2024-03-14 08:56:10 +00:00
1 changed files with 13 additions and 4 deletions
Showing only changes of commit 2e4a5029b8 - Show all commits

View File

@ -38,6 +38,15 @@ module.exports = Self => {
order: 'creationDate DESC'
}, myOptions);
const ticketOG = await models.Ticket.findById(id, {
include: [{
relation: 'client',
scope: {
fields: ['id', 'salesPersonFk']
}
}]
}, myOptions);
console.log('id', id);
console.log('ticket', ticket);
const now = Date.vnNew();
@ -48,7 +57,7 @@ module.exports = Self => {
throw new UserError(`You can only restore a ticket within the first hour after deletion`);
// Send notification to salesPerson
const salesPersonId = ticket.client().salesPersonFk;
const salesPersonId = ticketOG.client().salesPersonFk;
if (salesPersonId) {
const url = await Self.app.models.Url.getUrl();
const message = $t(`I have restored the ticket id`, {
@ -59,12 +68,12 @@ module.exports = Self => {
}
const fullYear = Date.vnNew().getFullYear();
const newShipped = ticket.shipped;
const newLanded = ticket.landed;
const newShipped = ticketOG.shipped;
const newLanded = ticketOG.landed;
newShipped.setFullYear(fullYear);
newLanded.setFullYear(fullYear);
return ticket.updateAttributes({
return ticketOG.updateAttributes({
shipped: newShipped,
landed: newLanded,
isDeleted: false