diff --git a/db/routines/vn/procedures/buy_clone.sql b/db/routines/vn/procedures/buy_clone.sql index bbf742b23..d3fbf888d 100644 --- a/db/routines/vn/procedures/buy_clone.sql +++ b/db/routines/vn/procedures/buy_clone.sql @@ -22,7 +22,6 @@ BEGIN containerFk, comissionValue, packageValue, - packageFk, price1, price2, price3, @@ -45,7 +44,6 @@ BEGIN b.containerFk, b.comissionValue, b.packageValue, - b.packageFk, b.price1, b.price2, b.price3, diff --git a/db/routines/vn/procedures/buy_cloneByBuy.sql b/db/routines/vn/procedures/buy_cloneByBuy.sql deleted file mode 100644 index 73e91a9df..000000000 --- a/db/routines/vn/procedures/buy_cloneByBuy.sql +++ /dev/null @@ -1,23 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_cloneByBuy`( - OUT vBuyClonedFk INT, - IN vSelf INT, - IN vEntryFk INT -) -BEGIN -/** - * Clone a buy to an entry - * - * @param OUT vBuyClonedFk The new cloned buy id - * @param vSelf The buy id to clone - * @param vEntryFk The destination entry id - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.buy - SELECT vSelf id; - - CALL buy_clone(vEntryFk); - SET vBuyClonedFk = LAST_INSERT_ID(); - - DROP TEMPORARY TABLE tmp.buy; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index e1fb08388..4ad6fcfa2 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -308,21 +308,79 @@ BEGIN WHERE id = vTargetItemShelvingFk; END IF; - CALL buy_cloneByBuy(vA1BuyFk, vLastBuyFk, vTargetEntryFk); - UPDATE buy - SET quantity = - LEAST(vQuantity,vCurrentVisible), - isIgnored = TRUE, - buyingValue = vBuyingValue - WHERE id = vA1BuyFk; - - CALL buy_cloneByBuy(vA2BuyFk, vLastBuyFk, vTargetEntryFk); - UPDATE buy - SET quantity = vQuantity, - isIgnored = TRUE, - buyingValue = vBuyingValue, - itemFk = vItemA2Fk - WHERE id = vA2BuyFk; - + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vTargetEntryFk, + itemFk, + - LEAST(vQuantity, vCurrentVisible), + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk + UNION + SELECT vTargetEntryFk, + vItemA2Fk, + vQuantity, + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + containerFk, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk; + INSERT INTO itemShelving ( itemFk, shelvingFk,