2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-11-13 08:03:44 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(
|
|
|
|
vClaimFk INT,
|
|
|
|
vShelvingCode VARCHAR(10)
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Insert items of claim into itemShelving.
|
|
|
|
*
|
|
|
|
* @param vClaimFk The claim
|
2024-11-13 08:03:44 +00:00
|
|
|
* @param vShelvingCode The shelving code
|
2024-01-15 11:31:03 +00:00
|
|
|
* @table tmp.buyUltimate
|
|
|
|
*/
|
|
|
|
DECLARE vWarehouseFk INT;
|
2024-11-13 08:03:44 +00:00
|
|
|
DECLARE vShelvingFk INT;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
SELECT t.warehouseFk INTO vWarehouseFk
|
|
|
|
FROM claim c
|
|
|
|
JOIN ticket t ON t.id = c.ticketFk
|
|
|
|
WHERE c.id = vClaimFk;
|
|
|
|
|
2024-11-13 08:03:44 +00:00
|
|
|
SELECT id INTO vShelvingFk
|
|
|
|
FROM shelving
|
|
|
|
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
|
|
|
|
|
2024-07-16 16:44:24 +00:00
|
|
|
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
|
2024-11-13 08:03:44 +00:00
|
|
|
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
|
2024-01-15 11:31:03 +00:00
|
|
|
FROM claim c
|
|
|
|
JOIN claimBeginning cb ON c.id = cb.claimFk
|
|
|
|
JOIN sale s ON s.id = cb.saleFk
|
|
|
|
JOIN ticket t ON t.id = s.ticketFk
|
2024-11-13 08:03:44 +00:00
|
|
|
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
|
|
|
AND bu.warehouseFk = t.warehouseFk
|
2024-01-15 11:31:03 +00:00
|
|
|
JOIN buy b ON b.id = bu.buyFk
|
|
|
|
WHERE c.id = vClaimFk;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|