hotfix: ticket168996 Now ticket_doCmr ignore deliveryMethod #2279

Merged
guillermo merged 2 commits from ticket168996-hotfix into master 2024-04-11 12:42:45 +00:00
2 changed files with 37 additions and 42 deletions

View File

@ -1,5 +1,5 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doCmr`(vSelf INT)
BEGIN BEGIN
/** /**
* Crea u actualiza la información del CMR asociado con * Crea u actualiza la información del CMR asociado con
@ -29,7 +29,6 @@ BEGIN
JOIN province p ON p.id = a.provinceFk JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk 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 warehouse w ON w.id = t.warehouseFk
JOIN company com ON com.id = t.companyFk JOIN company com ON com.id = t.companyFk
JOIN client c2 ON c2.id = com.clientFk JOIN client c2 ON c2.id = com.clientFk
@ -38,12 +37,10 @@ BEGIN
LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN route r ON r.id = t.routeFk
LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN worker wo ON wo.id = r.workerFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN vehicle v ON v.id = r.vehicleFk
WHERE t.shipped BETWEEN util.yesterday() AND util.dayEnd(util.VN_CURDATE()) WHERE al.code IN ('PACKED', 'DELIVERED')
guillermo marked this conversation as resolved Outdated

traure tots sense tindre en compte les feches es un bon enfoque, no tardara cada vegada mes a medida que pasen els anys i tingam mes registres?

traure tots sense tindre en compte les feches es un bon enfoque, no tardara cada vegada mes a medida que pasen els anys i tingam mes registres?

No, perque li pases el ticket com a parametro i filtra per ixe, ademes, com Pepe vol procesar tots els tickets en REC_HOLANDA, necesite executar ixe proc per a tots els tickets, i en el where de temps no podía, tampoc fea falta.

No, perque li pases el ticket com a parametro i filtra per ixe, ademes, com Pepe vol procesar tots els tickets en REC_HOLANDA, necesite executar ixe proc per a tots els tickets, i en el where de temps no podía, tampoc fea falta.
AND al.code IN ('PACKED', 'DELIVERED')
AND co.code <> 'ES' AND co.code <> 'ES'
AND am.name <> 'ABONO' AND am.name <> 'ABONO'
AND w.code = 'ALG' AND w.code = 'ALG'
AND dm.code = 'DELIVERY'
AND t.id = vSelf AND t.id = vSelf
GROUP BY t.id; GROUP BY t.id;
@ -85,5 +82,5 @@ BEGIN
COMMIT; COMMIT;
DROP TEMPORARY TABLE tTicket; DROP TEMPORARY TABLE tTicket;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -98,40 +98,38 @@ module.exports = Self => {
let stmts = []; let stmts = [];
const stmt = new ParameterizedSQL(` const stmt = new ParameterizedSQL(`
SELECT * SELECT *
FROM ( FROM (
SELECT t.cmrFk, SELECT t.cmrFk,
t.id ticketFk, t.id ticketFk,
t.routeFk, t.routeFk,
co.country, co.country,
t.clientFk, t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms, IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped DATE(t.shipped) shipped
FROM ticket t FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.id = ts.stateFk JOIN state s ON s.id = ts.stateFk
JOIN alertLevel al ON al.id = s.alertLevel JOIN alertLevel al ON al.id = s.alertLevel
JOIN client c ON c.id = t.clientFk JOIN client c ON c.id = t.clientFk
JOIN address a ON a.id = t.addressFk JOIN address a ON a.id = t.addressFk
JOIN province p ON p.id = a.provinceFk JOIN province p ON p.id = a.provinceFk
JOIN country co ON co.id = p.countryFk JOIN country co ON co.id = p.countryFk
JOIN agencyMode am ON am.id = t.agencyModeFk 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 warehouse w ON w.id = t.warehouseFk LEFT JOIN (
LEFT JOIN ( SELECT td.ticketFk, d.id
SELECT td.ticketFk, d.id FROM ticketDms td
FROM ticketDms td JOIN dms d ON d.id = td.dmsFk
JOIN dms d ON d.id = td.dmsFk JOIN dmsType dt ON dt.id = d.dmsTypeFk
JOIN dmsType dt ON dt.id = d.dmsTypeFk WHERE dt.name = 'cmr'
WHERE dt.name = 'cmr' ) sub ON sub.ticketFk = t.id
) sub ON sub.ticketFk = t.id WHERE co.code <> 'ES'
WHERE co.code <> 'ES' AND am.name <> 'ABONO'
AND am.name <> 'ABONO' AND w.code = 'ALG'
AND w.code = 'ALG' AND t.cmrFk
AND dm.code = 'DELIVERY' ) sub
AND t.cmrFk `);
) sub
`);
stmt.merge(conn.makeSuffix(filter)); stmt.merge(conn.makeSuffix(filter));
const itemsIndex = stmts.push(stmt) - 1; const itemsIndex = stmts.push(stmt) - 1;