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 24 additions and 1 deletions
Showing only changes of commit 7e415181c2 - Show all commits

View File

@ -36,6 +36,7 @@ BEGIN
DECLARE vIsTaxDataChecked BOOL;
DECLARE vAvailable INT;
DECLARE vItemPackingTypeFk VARCHAR(1);
DECLARE vCountDistinctItemPackingTypeFk INT;
DECLARE vDates CURSOR FOR
SELECT zgs.shipped, r.warehouseFk
@ -54,7 +55,7 @@ BEGIN
WHERE o.id = vSelf
AND r.warehouseFk = vWarehouseFk
AND r.amount
ORDER BY i.itemPackingTypeFk DESC;
ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!!
DECLARE vRows CURSOR FOR
SELECT r.id,
@ -155,6 +156,28 @@ BEGIN
LEAVE lDistinctItemPackingType;
END IF;
IF vItemPackingTypeFk IS NULL THEN
SELECT COUNT(*) INTO vCountDistinctItemPackingTypeFk
FROM tTicketByItemPackingType;
CASE
WHEN vCountDistinctItemPackingTypeFk = 1 THEN
INSERT INTO tTicketByItemPackingType
SET itemPackingTypeFk = vItemPackingTypeFk,
ticketFk = (SELECT ticketFk FROM tTicketByItemPackingType);
LEAVE lDistinctItemPackingType;
WHEN vCountDistinctItemPackingTypeFk > 1 THEN
INSERT INTO tTicketByItemPackingType
SET itemPackingTypeFk = vItemPackingTypeFk,
ticketFk = (
SELECT ticketFk
FROM tTicketByItemPackingType
WHERE itemPackingTypeFk = 'H'
);
LEAVE lDistinctItemPackingType;
END CASE;
END IF;
WITH tPrevia AS (
SELECT DISTINCT s.ticketFk
FROM vn.sale s