refactor: refs #6453 Major changes
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2024-07-10 11:26:45 +02:00
parent a1d3d2f2f8
commit 7e415181c2
1 changed files with 24 additions and 1 deletions

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