feat: refs #6453 Minor changes
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-29 12:36:08 +02:00
parent e53b12d51b
commit 6ad3d5a5eb
1 changed files with 6 additions and 3 deletions

View File

@ -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