refactor: refs #6453 Major changes
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
a1d3d2f2f8
commit
7e415181c2
|
@ -36,6 +36,7 @@ BEGIN
|
||||||
DECLARE vIsTaxDataChecked BOOL;
|
DECLARE vIsTaxDataChecked BOOL;
|
||||||
DECLARE vAvailable INT;
|
DECLARE vAvailable INT;
|
||||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||||
|
DECLARE vCountDistinctItemPackingTypeFk INT;
|
||||||
|
|
||||||
DECLARE vDates CURSOR FOR
|
DECLARE vDates CURSOR FOR
|
||||||
SELECT zgs.shipped, r.warehouseFk
|
SELECT zgs.shipped, r.warehouseFk
|
||||||
|
@ -54,7 +55,7 @@ BEGIN
|
||||||
WHERE o.id = vSelf
|
WHERE o.id = vSelf
|
||||||
AND r.warehouseFk = vWarehouseFk
|
AND r.warehouseFk = vWarehouseFk
|
||||||
AND r.amount
|
AND r.amount
|
||||||
ORDER BY i.itemPackingTypeFk DESC;
|
ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!!
|
||||||
|
|
||||||
DECLARE vRows CURSOR FOR
|
DECLARE vRows CURSOR FOR
|
||||||
SELECT r.id,
|
SELECT r.id,
|
||||||
|
@ -155,6 +156,28 @@ BEGIN
|
||||||
LEAVE lDistinctItemPackingType;
|
LEAVE lDistinctItemPackingType;
|
||||||
END IF;
|
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 (
|
WITH tPrevia AS (
|
||||||
SELECT DISTINCT s.ticketFk
|
SELECT DISTINCT s.ticketFk
|
||||||
FROM vn.sale s
|
FROM vn.sale s
|
||||||
|
|
Loading…
Reference in New Issue