salix/db/routines/vn/procedures/itemPlacementSupplyAiming.sql

35 lines
1007 B
MySQL
Raw Normal View History

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
)
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,
CONCAT(
2024-11-13 08:03:44 +00:00
CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
' 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-11-13 08:03:44 +00:00
LEAST(ish.stock, vQuantity)
) proposal
FROM itemShelvingPlacementSupplyStock ish
WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
AND ish.itemFk = vItemFk;
END$$
DELIMITER ;