diff --git a/db/routines/vn/procedures/boxPicking_print.sql b/db/routines/vn/procedures/boxPicking_print.sql index 0d34ed056..637fde2b9 100644 --- a/db/routines/vn/procedures/boxPicking_print.sql +++ b/db/routines/vn/procedures/boxPicking_print.sql @@ -1,8 +1,6 @@ -DROP PROCEDURE IF EXISTS vn.boxPicking_print; - DELIMITER $$ $$ -CREATE PROCEDURE vn.boxPicking_print( +CREATE OR REPLACE PROCEDURE vn.sale_boxPickingPrint( IN vPrinterFk INT, IN vSaleFk INT, IN vPacking INT, @@ -12,10 +10,9 @@ CREATE PROCEDURE vn.boxPicking_print( IN vPackingSiteFk INT) BEGIN /** Splits a line of sale to a different ticket and prints the transport sticker - * */ DECLARE vAgencyModeFk INT; - DECLARE vConcept VARCHAR(20); + DECLARE vConcept VARCHAR(30); DECLARE vExpeditionFk INT; DECLARE vItemFk INT; DECLARE vItemShelvingFk INT; @@ -64,7 +61,7 @@ BEGIN w1: WHILE vQuantity >= vPacking DO - SET vItemShelvingFk = 0; + SET vItemShelvingFk = NULL; SELECT sub.id INTO vItemShelvingFk @@ -103,7 +100,7 @@ w1: WHILE vQuantity >= vPacking DO LEAVE w1; END IF; - SET vNewTicketFk = 0; + SET vNewTicketFk = NULL; SELECT MAX(t.id) INTO vNewTicketFk FROM vn.ticket t @@ -117,7 +114,7 @@ w1: WHILE vQuantity >= vPacking DO AND t.warehouseFk = tt.warehouseFk WHERE tls.name = 'Encajado' ; - IF vNewTicketFk = 0 THEN + IF ISNULL(vNewTicketFk) THEN INSERT INTO vn.ticket( clientFk, shipped, addressFk, @@ -163,7 +160,7 @@ w1: WHILE vQuantity >= vPacking DO UPDATE itemShelving SET visible = visible - vPacking WHERE id = vItemShelvingFk; - SET vNewSaleFk = 0; + SET vNewSaleFk = NULL; SELECT MAX(id) INTO vNewSaleFk FROM sale @@ -175,7 +172,7 @@ w1: WHILE vQuantity >= vPacking DO SET quantity = quantity + vPacking WHERE id = vNewSaleFk; - SET vItemShelvingSaleFk_old = 0; + SET vItemShelvingSaleFk_old = NULL; SELECT MAX(id) INTO vItemShelvingSaleFk_old FROM vn.itemShelvingSale @@ -245,8 +242,8 @@ w1: WHILE vQuantity >= vPacking DO h.code, vPackingSiteFk, ps.monitorId, - started = IFNULL(vLastExpeditionTimeStamp, Now()), - ended = Now() + IFNULL(vLastExpeditionTimeStamp, Now()), + Now() FROM packingSite ps JOIN host h ON h.id = ps.hostFk JOIN item i ON i.name = 'Shipping cost' @@ -266,15 +263,15 @@ w1: WHILE vQuantity >= vPacking DO JOIN parking p ON p.id = sh.parkingFk WHERE ish.id = vItemShelvingFk; - UPDATE dipole.expedition_PrintOut SET - isPrinted = FALSE, - itemFk = vItemFk, - quantity = vPacking, - longName = vConcept, - shelvingFk = vShelving, - parkingCode = vParkingCode, - phone = RIGHT(phone,vMaxPhoneLength), - street = RIGHT(street, vMAxStreetLength) + UPDATE dipole.expedition_PrintOut + SET isPrinted = FALSE, + itemFk = vItemFk, + quantity = vPacking, + longName = vConcept, + shelvingFk = vShelving, + parkingCode = vParkingCode, + phone = RIGHT(phone,vMaxPhoneLength), + street = RIGHT(street, vMAxStreetLength) WHERE expeditionFk = vExpeditionFk; DELETE FROM vn.sale