7569_sendEmail #3387
|
@ -161,20 +161,21 @@ module.exports = Self => {
|
||||||
if (stateCode == 'DELIVERED' && ticket.priority) {
|
if (stateCode == 'DELIVERED' && ticket.priority) {
|
||||||
const orderState = await models.State.findOne({
|
const orderState = await models.State.findOne({
|
||||||
where: {code: 'DELIVERED'},
|
where: {code: 'DELIVERED'},
|
||||||
fields: ['id']
|
fields: ['order']
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const ticketIncorrect = await Self.rawSql(`
|
const ticketIncorrect = await Self.rawSql(`
|
||||||
SELECT t.id
|
SELECT tls.ticketFk
|
||||||
FROM ticket t
|
FROM ticketLastState tls
|
||||||
sergiodt marked this conversation as resolved
Outdated
|
|||||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
JOIN ticketTracking tt ON tt.id = tls.ticketTrackingFk
|
||||||
JOIN state s ON s.code = ts.code
|
JOIN ticket t ON t.id = tt.ticketFk
|
||||||
|
JOIN state s ON s.id = tt.stateFk
|
||||||
WHERE t.routeFk = ?
|
WHERE t.routeFk = ?
|
||||||
AND s.\`order\` < ?
|
AND s.\`order\` < ?
|
||||||
AND priority <(SELECT t.priority
|
AND priority <(SELECT t.priority
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
WHERE t.id = ?)`
|
WHERE t.id = ?)`
|
||||||
, [ticket.routeFk, orderState.id, ticket.id], myOptions);
|
, [ticket.routeFk, orderState.order, ticket.id], myOptions);
|
||||||
|
|
||||||
if (ticketIncorrect?.length > 0)
|
if (ticketIncorrect?.length > 0)
|
||||||
await sendMail(ticket.routeFk, ticket.id, ticket.zone().name);
|
await sendMail(ticket.routeFk, ticket.id, ticket.zone().name);
|
||||||
|
|
|
@ -60,7 +60,7 @@ describe('Ticket saveSign()', () => {
|
||||||
expect(ticketTrackingAfter.name).toBe('Entregado en parte');
|
expect(ticketTrackingAfter.name).toBe('Entregado en parte');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should send an email to notify that the delivery order is not correct', async() => {
|
fit('should send an email to notify that the delivery order is not correct', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
const ticketFk = 8;
|
const ticketFk = 8;
|
||||||
const priority = 5;
|
const priority = 5;
|
||||||
|
|
Loading…
Reference in New Issue
TAB