From f385b9a8a3da9702998a7c7204212084b9fe6498 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Aug 2024 07:12:29 +0200 Subject: [PATCH] feat: refs #7818 entry_splitByShelving --- db/routines/vn/procedures/entry_splitByShelving.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index f46278e5a..9f09ed5be 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -15,7 +15,7 @@ BEGIN DECLARE cur CURSOR FOR SELECT bb.id buyFk, - FLOOR(ish.visible / ish.packing) ishStickers, + LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers FROM itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers @@ -23,7 +23,6 @@ BEGIN WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - AND bb.stickers >= FLOOR(ish.visible / ish.packing) WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci AND NOT ish.isSplit GROUP BY ish.id;