7863-devToTest_2434 #2852
|
@ -15,6 +15,7 @@ BEGIN
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vShipment DATE;
|
DECLARE vShipment DATE;
|
||||||
|
DECLARE vShipmentDayEnd DATE;
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
DECLARE vNotes VARCHAR(255);
|
DECLARE vNotes VARCHAR(255);
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
|
@ -123,13 +124,15 @@ BEGIN
|
||||||
LEAVE lDates;
|
LEAVE lDates;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SET vShipmentDayEnd = util.dayEnd(vShipment);
|
||||||
|
|
||||||
-- Busca un ticket libre disponible
|
-- Busca un ticket libre disponible
|
||||||
WITH tPrevia AS (
|
WITH tPrevia AS (
|
||||||
SELECT DISTINCT s.ticketFk
|
SELECT DISTINCT s.ticketFk
|
||||||
FROM vn.sale s
|
FROM vn.sale s
|
||||||
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment)
|
WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
||||||
)
|
)
|
||||||
SELECT t.id INTO vTicketFk
|
SELECT t.id INTO vTicketFk
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
|
@ -139,7 +142,7 @@ BEGIN
|
||||||
JOIN hedera.`order` o ON o.address_id = t.addressFk
|
JOIN hedera.`order` o ON o.address_id = t.addressFk
|
||||||
AND t.warehouseFk = vWarehouseFk
|
AND t.warehouseFk = vWarehouseFk
|
||||||
AND o.date_send = t.landed
|
AND o.date_send = t.landed
|
||||||
AND DATE(t.shipped) = vShipment
|
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
||||||
WHERE o.id = vSelf
|
WHERE o.id = vSelf
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
AND tp.ticketFk IS NULL
|
AND tp.ticketFk IS NULL
|
||||||
|
@ -165,7 +168,7 @@ BEGIN
|
||||||
JOIN vn.item i ON i.id = s.itemFk
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
JOIN tItemPackingTypeOrder ipto
|
JOIN tItemPackingTypeOrder ipto
|
||||||
WHERE t.refFk IS NULL
|
WHERE t.refFk IS NULL
|
||||||
AND DATE(t.shipped) = vShipment
|
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
||||||
AND t.warehouseFk = vWarehouseFk
|
AND t.warehouseFk = vWarehouseFk
|
||||||
AND t.addressFk = ipto.address_id
|
AND t.addressFk = ipto.address_id
|
||||||
GROUP BY t.id
|
GROUP BY t.id
|
||||||
|
|
Loading…
Reference in New Issue