fix: refs #7844 salesFilter and tmp.ticket_problems.totalProblems

This commit is contained in:
Guillermo Bonet 2024-09-03 13:29:01 +02:00
parent 0c3349dc03
commit 790a44c62a
4 changed files with 17 additions and 5 deletions

View File

@ -38,7 +38,7 @@ BEGIN
(isFreezed) +
(hasRisk) +
(hasTicketRequest) +
(isTaxDataChecked) +
(!isTaxDataChecked) +
(hasComponentLack) +
(itemDelay IS NOT NULL) +
(isTooLittle) +

View File

@ -218,8 +218,8 @@ describe('SalesMonitor salesFilter()', () => {
const firstTicket = result.shift();
const secondTicket = result.shift();
expect(firstTicket.totalProblems).toEqual(4);
expect(secondTicket.totalProblems).toEqual(4);
expect(firstTicket.totalProblems).toEqual(3);
expect(secondTicket.totalProblems).toEqual(3);
await tx.rollback();
} catch (e) {

View File

@ -306,6 +306,12 @@ module.exports = Self => {
stmts.push(stmt);
stmts.push('CALL ticket_getProblems(FALSE)');
stmt = new ParameterizedSQL(`
UPDATE tmp.ticket_problems
SET risk = IF(hasRisk AND risk > 0, risk, 0)
`);
stmts.push(stmt);
stmt = new ParameterizedSQL(`
SELECT f.*, tp.*
FROM tmp.filter f

View File

@ -158,10 +158,16 @@ module.exports = Self => {
stmts.push(stmt);
stmts.push('CALL ticket_getProblems(FALSE)');
stmt = new ParameterizedSQL(`
UPDATE tmp.ticket_problems
SET risk = IF(hasRisk AND risk > 0, risk, 0)
`);
stmts.push(stmt);
stmt = new ParameterizedSQL(`
SELECT f.*, tp.*
FROM tmp.filter f
LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id
FROM tmp.filter f
LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id
`);
if (args.problems != undefined && (!args.originDated && !args.futureDated))