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`.`itemPlacementSupplyAiming`(
|
|
|
|
vShelvingCode VARCHAR(10),
|
|
|
|
vQuantity INT,
|
|
|
|
vItemFk INT
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
SELECT ish.itemFk,
|
|
|
|
ish.longName,
|
|
|
|
ish.size,
|
|
|
|
ish.subName,
|
|
|
|
ish.itemShelvingFk,
|
|
|
|
ish.shelving,
|
|
|
|
ish.stock,
|
2024-11-13 08:03:44 +00:00
|
|
|
LEAST(ish.stock,vQuantity) total,
|
2024-01-15 11:31:03 +00:00
|
|
|
CONCAT(
|
2024-11-13 08:03:44 +00:00
|
|
|
CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
|
2024-01-15 11:31:03 +00:00
|
|
|
' x ',
|
|
|
|
ish.packing,
|
|
|
|
IF (
|
2024-11-13 08:03:44 +00:00
|
|
|
LEAST(ish.stock, vQuantity) MOD ish.packing,
|
|
|
|
CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
|
2024-01-15 11:31:03 +00:00
|
|
|
''
|
|
|
|
),
|
|
|
|
' = ',
|
2024-11-13 08:03:44 +00:00
|
|
|
LEAST(ish.stock, vQuantity)
|
|
|
|
) proposal
|
|
|
|
FROM itemShelvingPlacementSupplyStock ish
|
|
|
|
WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
|
2024-01-15 11:31:03 +00:00
|
|
|
AND ish.itemFk = vItemFk;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|