2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3))
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Insert items of claim into itemShelving.
|
|
|
|
*
|
|
|
|
* @param vClaimFk The claim
|
|
|
|
* @param vShelvingFk The shelving
|
|
|
|
* @table tmp.buyUltimate
|
|
|
|
*/
|
|
|
|
DECLARE vWarehouseFk INT;
|
|
|
|
|
|
|
|
SELECT t.warehouseFk INTO vWarehouseFk
|
|
|
|
FROM claim c
|
|
|
|
JOIN ticket t ON t.id = c.ticketFk
|
|
|
|
WHERE c.id = vClaimFk;
|
|
|
|
|
|
|
|
CALL buyUltimate (vWarehouseFk, util.VN_CURDATE());
|
|
|
|
|
|
|
|
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
|
|
|
|
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible
|
|
|
|
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
|
|
|
|
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk
|
|
|
|
JOIN buy b ON b.id = bu.buyFk
|
|
|
|
WHERE c.id = vClaimFk;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|