From 82118ae93315b82e3c4e7498e623d8ca8baec17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 25 Jun 2024 19:30:59 +0200 Subject: [PATCH 1/3] Hotfix ticketStateUpdate to ticket_setState --- db/routines/vn/procedures/ticket_DelayTruckSplit.sql | 10 +++++----- db/routines/vn/procedures/ticket_cloneWeekly.sql | 2 +- db/routines/vn/procedures/ticket_split.sql | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql index c7de6a984..14720ffc2 100644 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`(vTicketFk INT) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`(vTicketFk INT) BEGIN /** * Splita las lineas de ticket que no estan ubicadas @@ -50,8 +50,8 @@ BEGIN SET s.ticketFk = vNewTicketFk; END IF; - CALL ticketStateUpdate(vNewTicketFk, 'FIXING'); + CALL ticket_setState(vNewTicketFk, 'FIXING'); DROP TEMPORARY TABLE tmp.SalesToSplit; -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index 6bceb2fdf..18a33ac14 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -189,7 +189,7 @@ BEGIN IF NOT vIsDuplicateMail THEN CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); END IF; - CALL ticketStateUpdate (vNewTicket, 'FIXING'); + CALL ticket_setState(vNewTicket, 'FIXING'); ELSE CALL ticketCalculateClon(vNewTicket, vTicketFk); END IF; diff --git a/db/routines/vn/procedures/ticket_split.sql b/db/routines/vn/procedures/ticket_split.sql index 172f6829a..01eb4d8b9 100644 --- a/db/routines/vn/procedures/ticket_split.sql +++ b/db/routines/vn/procedures/ticket_split.sql @@ -69,7 +69,7 @@ proc:BEGIN s.concept = CONCAT('(s) ', s.concept) WHERE sts.ticketFk = vTicketFk; - CALL vn.ticketStateUpdate(vTicketFutureFk, 'FIXING'); + CALL ticket_setState(vTicketFutureFk, 'FIXING'); SELECT "new" message,vTicketFutureFk ticketFuture; END$$ From 5bcdc579784e99824625a00e7c2466afbbd1e1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 25 Jun 2024 19:33:54 +0200 Subject: [PATCH 2/3] Hotfix ticketStateUpdate to ticket_setState --- db/routines/vn/procedures/ticket_split.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/ticket_split.sql b/db/routines/vn/procedures/ticket_split.sql index 01eb4d8b9..07e0329ea 100644 --- a/db/routines/vn/procedures/ticket_split.sql +++ b/db/routines/vn/procedures/ticket_split.sql @@ -18,7 +18,7 @@ proc:BEGIN WHERE ticketFk = vTicketFk; SELECT count(*) INTO vTotalLines - FROM vn.sale s + FROM sale s WHERE s.ticketFk = vTicketFk; SET vHasFullProblem = (vTotalLines = vProblemLines); @@ -26,7 +26,7 @@ proc:BEGIN -- Ticket completo IF vHasFullProblem THEN - UPDATE vn.ticket + UPDATE ticket SET landed = vDated + INTERVAL 1 DAY, shipped = vDated, nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) @@ -40,7 +40,7 @@ proc:BEGIN -- Ticket a futuro existe IF vTicketFutureFk THEN - UPDATE vn.sale s + UPDATE sale s JOIN tmp.salesToSplit ss ON s.id = ss.saleFk SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) @@ -52,10 +52,10 @@ proc:BEGIN END IF; -- Ticket nuevo - CALL vn.ticket_Clone(vTicketFk, vTicketFutureFk); + CALL ticket_Clone(vTicketFk, vTicketFutureFk); - UPDATE vn.ticket t - JOIN vn.productionConfig pc + UPDATE ticket t + JOIN productionConfig pc SET t.routeFk = IF(t.shipped = vDated , t.routeFk, NULL), t.landed = vDated + INTERVAL 1 DAY, t.shipped = vDated, @@ -63,7 +63,7 @@ proc:BEGIN t.zoneFk = pc.defaultZone WHERE t.id = vTicketFutureFk; - UPDATE vn.sale s + UPDATE sale s JOIN tmp.salesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) From 75486ae743af847d801e1dde4cf11b3b19c69911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 25 Jun 2024 19:47:22 +0200 Subject: [PATCH 3/3] Hotfix ticketStateUpdate to ticket_setState --- .../vn/procedures/ticket_DelayTruckSplit.sql | 4 +- .../vn/procedures/ticket_cloneWeekly.sql | 68 ++++++++++++------- db/routines/vn/procedures/ticket_split.sql | 32 ++++----- 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql index 14720ffc2..3e5195d9c 100644 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`(vTicketFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`( + vTicketFk INT +) BEGIN /** * Splita las lineas de ticket que no estan ubicadas diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index 18a33ac14..764e72254 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly`(vDateFrom DATE, vDateTo DATE) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly`( + vDateFrom DATE, + vDateTo DATE +) BEGIN DECLARE vIsDone BOOL; DECLARE vLanding DATE; @@ -39,9 +42,16 @@ BEGIN DECLARE vIsDuplicateMail BOOL; DECLARE vSubject VARCHAR(150); DECLARE vMessage TEXT; - + SET vIsDone = FALSE; - FETCH rsTicket INTO vTicketFk,vClientFk, vWarehouseFk, vCompanyFk, vAddressFk, vAgencyModeFk,vShipment; + FETCH rsTicket INTO + vTicketFk, + vClientFk, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + vShipment; IF vIsDone THEN LEAVE myLoop; @@ -67,7 +77,7 @@ BEGIN AND isDefaultAddress; END IF; - CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk,FALSE); + CALL zone_getLanded(vShipment, vAddressFk, vAgencyModeFk, vWarehouseFk, FALSE); SET vLanding = NULL; SELECT landed INTO vLanding FROM tmp.zoneGetLanded LIMIT 1; @@ -88,16 +98,22 @@ BEGIN SET clonedFrom = vTicketFk WHERE id = vNewTicket; - INSERT INTO sale (ticketFk, itemFk, concept, quantity, price, - discount, priceFixed, isPriceFixed) + INSERT INTO sale (ticketFk, + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed) SELECT vNewTicket, - saleOrig.itemFk, - saleOrig.concept, - saleOrig.quantity, - saleOrig.price, - saleOrig.discount, - saleOrig.priceFixed, - saleOrig.isPriceFixed + saleOrig.itemFk, + saleOrig.concept, + saleOrig.quantity, + saleOrig.price, + saleOrig.discount, + saleOrig.priceFixed, + saleOrig.isPriceFixed FROM sale saleOrig WHERE saleOrig.ticketFk = vTicketFk; @@ -123,20 +139,20 @@ BEGIN ,attenderFk, ticketFk) SELECT description, - ordered, - shipped, - quantity, - price, - itemFk, - clientFk, - response, - total, - buyed, - requesterFk, - attenderFk, - vNewTicket + ordered, + shipped, + quantity, + price, + itemFk, + clientFk, + response, + total, + buyed, + requesterFk, + attenderFk, + vNewTicket FROM ticketRequest - WHERE ticketFk =vTicketFk; + WHERE ticketFk =vTicketFk; SELECT id INTO vSalesPersonFK FROM observationType diff --git a/db/routines/vn/procedures/ticket_split.sql b/db/routines/vn/procedures/ticket_split.sql index 07e0329ea..9a359b83f 100644 --- a/db/routines/vn/procedures/ticket_split.sql +++ b/db/routines/vn/procedures/ticket_split.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_split`(vTicketFk INT, vTicketFutureFk INT, vDated DATE) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_split`( + vTicketFk INT, + vTicketFutureFk INT, + vDated DATE +) proc:BEGIN /** * Mueve las lineas con problemas a otro ticket existente o a uno nuevo. @@ -17,7 +21,7 @@ proc:BEGIN FROM tmp.salesToSplit WHERE ticketFk = vTicketFk; - SELECT count(*) INTO vTotalLines + SELECT COUNT(*) INTO vTotalLines FROM sale s WHERE s.ticketFk = vTicketFk; @@ -25,52 +29,48 @@ proc:BEGIN -- Ticket completo IF vHasFullProblem THEN - UPDATE ticket - SET landed = vDated + INTERVAL 1 DAY, + SET landed = vDated + INTERVAL 1 DAY, shipped = vDated, - nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname ) + nickname = CONCAT('(',DAY(util.VN_CURDATE()),') ', nickname) WHERE id = vTicketFk; - SELECT "moved" message, NULL ticketFuture; + SELECT 'moved' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket a futuro existe IF vTicketFutureFk THEN - UPDATE sale s - JOIN tmp.salesToSplit ss ON s.id = ss.saleFk + JOIN tmp.salesToSplit ss ON s.id = ss.saleFk SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE ss.ticketFk = vTicketFk; - SELECT "future" message, NULL ticketFuture; + SELECT 'future' message, NULL ticketFuture; LEAVE proc; - END IF; -- Ticket nuevo CALL ticket_Clone(vTicketFk, vTicketFutureFk); UPDATE ticket t - JOIN productionConfig pc + JOIN productionConfig pc SET t.routeFk = IF(t.shipped = vDated , t.routeFk, NULL), - t.landed = vDated + INTERVAL 1 DAY, + t.landed = vDated + INTERVAL 1 DAY, t.shipped = vDated, t.agencyModeFk = pc.defautlAgencyMode, t.zoneFk = pc.defaultZone WHERE t.id = vTicketFutureFk; - + UPDATE sale s - JOIN tmp.salesToSplit sts ON sts.saleFk = s.id + JOIN tmp.salesToSplit sts ON sts.saleFk = s.id SET s.ticketFk = vTicketFutureFk, s.concept = CONCAT('(s) ', s.concept) WHERE sts.ticketFk = vTicketFk; CALL ticket_setState(vTicketFutureFk, 'FIXING'); - SELECT "new" message,vTicketFutureFk ticketFuture; + SELECT 'new' message, vTicketFutureFk ticketFuture; END$$ DELIMITER ;