Merge pull request 'MASTER_hotFix(monitor): fix left join salesFilter' (#1042) from hotFix_salesFilter_straight_join into master
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #1042 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
ee23e26104
|
@ -207,7 +207,7 @@ module.exports = Self => {
|
|||
LEFT JOIN province p ON p.id = a.provinceFk
|
||||
LEFT JOIN warehouse w ON w.id = t.warehouseFk
|
||||
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
STRAIGHT_JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.id = ts.stateFk
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk
|
||||
|
@ -227,7 +227,7 @@ module.exports = Self => {
|
|||
// Get client debt balance
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt');
|
||||
stmts.push(`
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT clientFk FROM tmp.filter`);
|
||||
|
@ -238,7 +238,7 @@ module.exports = Self => {
|
|||
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.tickets');
|
||||
stmt = new ParameterizedSQL(`
|
||||
CREATE TEMPORARY TABLE tmp.tickets
|
||||
CREATE TEMPORARY TABLE tmp.tickets
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT f.*, r.risk AS debt
|
||||
|
@ -268,10 +268,10 @@ module.exports = Self => {
|
|||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems');
|
||||
|
||||
stmt = new ParameterizedSQL(`
|
||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||
CREATE TEMPORARY TABLE tmp.sale_getProblems
|
||||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||
SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped
|
||||
FROM tmp.filter f
|
||||
LEFT JOIN alertLevel al ON al.id = f.alertLevel
|
||||
WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)
|
||||
|
@ -377,7 +377,7 @@ module.exports = Self => {
|
|||
const ticketsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push(
|
||||
`DROP TEMPORARY TABLE
|
||||
`DROP TEMPORARY TABLE
|
||||
tmp.filter,
|
||||
tmp.ticket_problems,
|
||||
tmp.sale_getProblems,
|
||||
|
|
|
@ -147,16 +147,12 @@ describe('SalesMonitor salesFilter()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
|
||||
const filter = {};
|
||||
const filter = {order: 'alertLevel ASC'};
|
||||
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
||||
const firstRow = result[0];
|
||||
const secondRow = result[1];
|
||||
const thirdRow = result[2];
|
||||
|
||||
expect(result.length).toEqual(12);
|
||||
expect(firstRow.state).toEqual('Entregado');
|
||||
expect(secondRow.state).toEqual('Entregado');
|
||||
expect(thirdRow.state).toEqual('Entregado');
|
||||
expect(firstRow.alertLevel).not.toEqual(0);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue