refactor: refs #6453 order_confirmWithUser #2694

Merged
guillermo merged 16 commits from 6453-orderConfirm into dev 2024-08-02 10:15:00 +00:00
1 changed files with 6 additions and 3 deletions
Showing only changes of commit 6ad3d5a5eb - Show all commits

View File

@ -15,6 +15,7 @@ BEGIN
DECLARE vDone BOOL;
DECLARE vWarehouseFk INT;
DECLARE vShipment DATE;
DECLARE vShipmentDayEnd DATE;
guillermo marked this conversation as resolved Outdated

si es dayend deu ser DATETIME

si es dayend deu ser DATETIME
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