From c9431e605e12898230576414a036808c78d138e6 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 27 Mar 2024 12:22:22 +0100 Subject: [PATCH] second proposals --- .../vn/procedures/boxPicking_print.sql | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/db/routines/vn/procedures/boxPicking_print.sql b/db/routines/vn/procedures/boxPicking_print.sql index 637fde2b9..6c890a3fd 100644 --- a/db/routines/vn/procedures/boxPicking_print.sql +++ b/db/routines/vn/procedures/boxPicking_print.sql @@ -25,7 +25,7 @@ BEGIN DECLARE vNewTicketFk INT; DECLARE vParkingCode VARCHAR(10); DECLARE vQuantity INT; - DECLARE vRest INT DEFAULT 0; + DECLARE vRemainder INT DEFAULT 0; DECLARE vRestSaleFk INT; DECLARE vShelving VARCHAR(10); DECLARE vTicketFk INT; @@ -43,19 +43,19 @@ BEGIN FROM sale s WHERE s.id = vSaleFk; - IF vRest THEN - UPDATE sale SET quantity = quantity - vRest WHERE id = vSaleFk; + IF vRemainder THEN + UPDATE sale SET quantity = quantity - vRemainder WHERE id = vSaleFk; - INSERT INTO vn.sale(ticketFk, itemFk, quantity, price, discount, concept) + INSERT INTO sale(ticketFk, itemFk, quantity, price, discount, concept) SELECT ticketFk, itemFk, vRest, price, discount, concept - FROM vn.sale + FROM sale WHERE id = vSaleFk; SET vRestSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent(saleFk, componentFk, value) + INSERT INTO saleComponent(saleFk, componentFk, value) SELECT vRestSaleFk, componentFk, value - FROM vn.saleComponent + FROM saleComponent WHERE saleFk = vSaleFk; END IF; @@ -65,16 +65,16 @@ w1: WHILE vQuantity >= vPacking DO SELECT sub.id INTO vItemShelvingFk - FROM vn.productionConfig pc + FROM productionConfig pc JOIN ( SELECT ish.id, - ish.visible - ifnull(SUM(iss.quantity),0) available, + ish.visible - IFNULL(SUM(iss.quantity),0) available, p.pickingOrder, ish.created - FROM vn.itemShelving ish - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.itemShelvingSale iss + FROM itemShelving ish + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + LEFT JOIN itemShelvingSale iss ON iss.itemShelvingFk = ish.id AND iss.created >= CURDATE() AND iss.isPicked = FALSE @@ -86,7 +86,7 @@ w1: WHILE vQuantity >= vPacking DO LIMIT 1; IF vItemShelvingFk THEN - INSERT INTO vn.itemShelvingSale + INSERT INTO itemShelvingSale SET itemShelvingFk = vItemShelvingFk, saleFk = vSaleFk, quantity = vPacking, @@ -95,7 +95,7 @@ w1: WHILE vQuantity >= vPacking DO SET vItemShelvingSaleFk = LAST_INSERT_ID(); - UPDATE vn.sale SET isPicked = FALSE WHERE id = vSaleFk; + UPDATE sale SET isPicked = FALSE WHERE id = vSaleFk; ELSE LEAVE w1; END IF; @@ -103,10 +103,10 @@ w1: WHILE vQuantity >= vPacking DO SET vNewTicketFk = NULL; SELECT MAX(t.id) INTO vNewTicketFk - FROM vn.ticket t - JOIN vn.ticketLastState tls ON tls.ticketFk = t.id + FROM ticket t + JOIN ticketLastState tls ON tls.ticketFk = t.id JOIN (SELECT addressFk, clientFk, date(shipped) shipped, warehouseFk - FROM vn.ticket + FROM ticket WHERE id = vTicketFk) tt ON tt.addressFk = t.addressFk AND tt.clientFk = t.clientFk @@ -115,7 +115,7 @@ w1: WHILE vQuantity >= vPacking DO WHERE tls.name = 'Encajado' ; IF ISNULL(vNewTicketFk) THEN - INSERT INTO vn.ticket( clientFk, + INSERT INTO ticket( clientFk, shipped, addressFk, agencyModeFk, @@ -145,7 +145,7 @@ w1: WHILE vQuantity >= vPacking DO priority, hasPriority, id - FROM vn.ticket + FROM ticket WHERE id = vTicketFk; SET vNewTicketFk = LAST_INSERT_ID(); @@ -175,16 +175,16 @@ w1: WHILE vQuantity >= vPacking DO SET vItemShelvingSaleFk_old = NULL; SELECT MAX(id) INTO vItemShelvingSaleFk_old - FROM vn.itemShelvingSale + FROM itemShelvingSale WHERE itemShelvingFk = vItemShelvingFk AND saleFk = vNewSaleFk; IF vItemShelvingSaleFk_old THEN - UPDATE vn.itemShelvingSale + UPDATE itemShelvingSale SET quantity = quantity + vPacking WHERE id = vItemShelvingSaleFk_old; - DELETE FROM vn.itemShelvingSale + DELETE FROM itemShelvingSale WHERE id = vItemShelvingSaleFk; SET vItemShelvingSaleFk = vItemShelvingSaleFk_old; @@ -194,16 +194,16 @@ w1: WHILE vQuantity >= vPacking DO WHERE id = vItemShelvingSaleFk; END IF; ELSE - INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, discount, price) + INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price) SELECT vNewTicketFk, itemFk, concept, vPacking, discount, price - FROM vn.sale + FROM sale WHERE id = vSaleFk; SET vNewSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge) + INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge) SELECT vNewSaleFk, componentFk, value, isGreuge - FROM vn.saleComponent + FROM saleComponent WHERE saleFk = vSaleFk; UPDATE itemShelvingSale @@ -211,16 +211,16 @@ w1: WHILE vQuantity >= vPacking DO WHERE id = vItemShelvingSaleFk; END IF; - INSERT IGNORE INTO vn.saleTracking(saleFk, isChecked, workerFk, stateFk) + INSERT IGNORE INTO saleTracking(saleFk, isChecked, workerFk, stateFk) SELECT vNewSaleFk, TRUE, vUserFk, id - FROM vn.state + FROM state WHERE code = 'PREPARED'; SELECT agencyModeFk INTO vAgencyModeFk FROM ticket WHERE id = vNewTicketFk; - INSERT INTO vn.expedition( + INSERT INTO expedition( agencyModeFk, ticketFk, freightItemFk, @@ -242,8 +242,8 @@ w1: WHILE vQuantity >= vPacking DO h.code, vPackingSiteFk, ps.monitorId, - IFNULL(vLastExpeditionTimeStamp, Now()), - Now() + IFNULL(vLastExpeditionTimeStamp, NOW()), + NOW() FROM packingSite ps JOIN host h ON h.id = ps.hostFk JOIN item i ON i.name = 'Shipping cost' @@ -252,7 +252,7 @@ w1: WHILE vQuantity >= vPacking DO SET vExpeditionFk = LAST_INSERT_ID(); - SET vLastExpeditionTimeStamp = Now(); + SET vLastExpeditionTimeStamp = NOW(); CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE); @@ -274,7 +274,7 @@ w1: WHILE vQuantity >= vPacking DO street = RIGHT(street, vMAxStreetLength) WHERE expeditionFk = vExpeditionFk; - DELETE FROM vn.sale + DELETE FROM sale WHERE quantity = 0 AND id = vSaleFk; END WHILE;