7569_sendEmail #3387

Merged
sergiodt merged 3 commits from 7569_sendEmail into master 2025-01-28 10:26:50 +00:00
2 changed files with 8 additions and 7 deletions
Showing only changes of commit 79ea19a360 - Show all commits

View File

@ -161,20 +161,21 @@ module.exports = Self => {
if (stateCode == 'DELIVERED' && ticket.priority) {
const orderState = await models.State.findOne({
where: {code: 'DELIVERED'},
fields: ['id']
fields: ['order']
}, myOptions);
const ticketIncorrect = await Self.rawSql(`
SELECT t.id
FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.code = ts.code
SELECT tls.ticketFk
FROM ticketLastState tls
sergiodt marked this conversation as resolved Outdated

TAB

TAB
JOIN ticketTracking tt ON tt.id = tls.ticketTrackingFk
JOIN ticket t ON t.id = tt.ticketFk
JOIN state s ON s.id = tt.stateFk
WHERE t.routeFk = ?
AND s.\`order\` < ?
AND priority <(SELECT t.priority
FROM ticket t
WHERE t.id = ?)`
, [ticket.routeFk, orderState.id, ticket.id], myOptions);
, [ticket.routeFk, orderState.order, ticket.id], myOptions);
if (ticketIncorrect?.length > 0)
await sendMail(ticket.routeFk, ticket.id, ticket.zone().name);

View File

@ -60,7 +60,7 @@ describe('Ticket saveSign()', () => {
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 ticketFk = 8;
const priority = 5;