refs #6755 fix restore
This commit is contained in:
parent
a14ab90d5a
commit
2e4a5029b8
|
@ -38,6 +38,15 @@ module.exports = Self => {
|
||||||
order: 'creationDate DESC'
|
order: 'creationDate DESC'
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
|
const ticketOG = await models.Ticket.findById(id, {
|
||||||
|
include: [{
|
||||||
|
relation: 'client',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'salesPersonFk']
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
console.log('id', id);
|
console.log('id', id);
|
||||||
console.log('ticket', ticket);
|
console.log('ticket', ticket);
|
||||||
const now = Date.vnNew();
|
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`);
|
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 = ticketOG.client().salesPersonFk;
|
||||||
if (salesPersonId) {
|
if (salesPersonId) {
|
||||||
const url = await Self.app.models.Url.getUrl();
|
const url = await Self.app.models.Url.getUrl();
|
||||||
const message = $t(`I have restored the ticket id`, {
|
const message = $t(`I have restored the ticket id`, {
|
||||||
|
@ -59,12 +68,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullYear = Date.vnNew().getFullYear();
|
const fullYear = Date.vnNew().getFullYear();
|
||||||
const newShipped = ticket.shipped;
|
const newShipped = ticketOG.shipped;
|
||||||
const newLanded = ticket.landed;
|
const newLanded = ticketOG.landed;
|
||||||
newShipped.setFullYear(fullYear);
|
newShipped.setFullYear(fullYear);
|
||||||
newLanded.setFullYear(fullYear);
|
newLanded.setFullYear(fullYear);
|
||||||
|
|
||||||
return ticket.updateAttributes({
|
return ticketOG.updateAttributes({
|
||||||
shipped: newShipped,
|
shipped: newShipped,
|
||||||
landed: newLanded,
|
landed: newLanded,
|
||||||
isDeleted: false
|
isDeleted: false
|
||||||
|
|
Loading…
Reference in New Issue