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