From 1fe783cf0e7a46a9025911b3b98a86f6a26b1da4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Apr 2024 12:00:52 +0200 Subject: [PATCH] hotfix: ticket168996 Now ticket_doCmr ignore deliveryMethod --- db/routines/vn/procedures/ticket_doCmr.sql | 13 ++-- .../back/methods/route/getExternalCmrs.js | 66 +++++++++---------- 2 files changed, 37 insertions(+), 42 deletions(-) diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql index 5789d09de..61d8da5f9 100644 --- a/db/routines/vn/procedures/ticket_doCmr.sql +++ b/db/routines/vn/procedures/ticket_doCmr.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT) BEGIN /** * Crea u actualiza la informaciĆ³n del CMR asociado con @@ -29,7 +29,6 @@ BEGIN JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk @@ -38,12 +37,10 @@ BEGIN LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk - WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE()) - AND al.code IN ('PACKED', 'DELIVERED') + WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' AND w.code = 'ALG' - AND dm.code = 'DELIVERY' AND t.id = vSelf GROUP BY t.id; @@ -85,5 +82,5 @@ BEGIN COMMIT; DROP TEMPORARY TABLE tTicket; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/modules/route/back/methods/route/getExternalCmrs.js b/modules/route/back/methods/route/getExternalCmrs.js index 3fc9798b0..b8cd1041a 100644 --- a/modules/route/back/methods/route/getExternalCmrs.js +++ b/modules/route/back/methods/route/getExternalCmrs.js @@ -98,40 +98,38 @@ module.exports = Self => { let stmts = []; const stmt = new ParameterizedSQL(` - SELECT * - FROM ( - SELECT t.cmrFk, - t.id ticketFk, - t.routeFk, - co.country, - t.clientFk, - IF(sub.id, TRUE, FALSE) hasCmrDms, - DATE(t.shipped) shipped - FROM ticket t - JOIN ticketState ts ON ts.ticketFk = t.id - JOIN state s ON s.id = ts.stateFk - JOIN alertLevel al ON al.id = s.alertLevel - JOIN client c ON c.id = t.clientFk - JOIN address a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - JOIN warehouse w ON w.id = t.warehouseFk - LEFT JOIN ( - SELECT td.ticketFk, d.id - FROM ticketDms td - JOIN dms d ON d.id = td.dmsFk - JOIN dmsType dt ON dt.id = d.dmsTypeFk - WHERE dt.name = 'cmr' - ) sub ON sub.ticketFk = t.id - WHERE co.code <> 'ES' - AND am.name <> 'ABONO' - AND w.code = 'ALG' - AND dm.code = 'DELIVERY' - AND t.cmrFk - ) sub - `); + SELECT * + FROM ( + SELECT t.cmrFk, + t.id ticketFk, + t.routeFk, + co.country, + t.clientFk, + IF(sub.id, TRUE, FALSE) hasCmrDms, + DATE(t.shipped) shipped + FROM ticket t + JOIN ticketState ts ON ts.ticketFk = t.id + JOIN state s ON s.id = ts.stateFk + JOIN alertLevel al ON al.id = s.alertLevel + JOIN client c ON c.id = t.clientFk + JOIN address a ON a.id = t.addressFk + JOIN province p ON p.id = a.provinceFk + JOIN country co ON co.id = p.countryFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN warehouse w ON w.id = t.warehouseFk + LEFT JOIN ( + SELECT td.ticketFk, d.id + FROM ticketDms td + JOIN dms d ON d.id = td.dmsFk + JOIN dmsType dt ON dt.id = d.dmsTypeFk + WHERE dt.name = 'cmr' + ) sub ON sub.ticketFk = t.id + WHERE co.code <> 'ES' + AND am.name <> 'ABONO' + AND w.code = 'ALG' + AND t.cmrFk + ) sub + `); stmt.merge(conn.makeSuffix(filter)); const itemsIndex = stmts.push(stmt) - 1;