Merge pull request 'fix: updateAvailable refs #6861' (!3015) from 6861-ItemShelvingSaleAvailable into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #3015
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
Sergio De la torre 2024-09-25 04:53:47 +00:00
commit 2ba16e92fb
7 changed files with 11 additions and 93 deletions

View File

@ -1,8 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clearShelvingList`(vShelvingFk VARCHAR(8))
BEGIN
UPDATE vn.itemShelving
SET visible = 0
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci;
END$$
DELIMITER ;

View File

@ -1,58 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22))
BEGIN
DECLARE vItemFk INT;
SELECT vn.barcodeToItem(vBarcode) INTO vItemFk;
SELECT itemFk INTO vItemFk
FROM vn.buy b
WHERE b.id = vItemFk;
IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk);
INSERT INTO vn.shelving(`code`, parkingFk)
SELECT vShelvingFk, id
FROM vn.parking
WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci;
END IF;
IF (SELECT COUNT(*) FROM vn.itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking) = 1 THEN
UPDATE vn.itemShelving
SET visible = visible+vQuantity,
created = vCreated
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking;
ELSE
CALL cache.last_buy_refresh(FALSE);
INSERT INTO itemShelving( itemFk,
shelvingFk,
visible,
created,
`grouping`,
packing,
packagingFk)
SELECT vItemFk,
vShelvingFk,
vQuantity,
vCreated,
IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`,
IF(vPacking = 0, b.packing, vPacking) packing,
IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging
FROM vn.item i
LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN vn.buy b ON b.id = lb.buy_id
WHERE i.id = vItemFk;
END IF;
END$$
DELIMITER ;

View File

@ -1,20 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT)
BEGIN
INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk,
itemPlacementSupplyFk,
quantity,
userFk)
VALUES (vItemShelvingFk,
vItemPlacementSupplyFk,
vQuantity,
getUser());
UPDATE vn.itemShelving
SET visible = visible - vQuantity
WHERE id = vItemShelvingFk;
END$$
DELIMITER ;

View File

@ -18,7 +18,8 @@ BEGIN
getUser());
UPDATE itemShelving
SET visible = visible - vQuantity
SET visible = visible - vQuantity,
available = available - vQuantity
WHERE id = vItemShelvingFk;
UPDATE vn.saleTracking

View File

@ -6,12 +6,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfCons
)
BEGIN
/**
* Leave the indicated amount on the shelf
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
* @param vShelvingFk id of the shelf where the item is located.
* @param vShelvingFk id of the shelve where the item is located.
* @param vItemFk article of which the self-consumption ticket is to be created.
* @param vQuantity amount that will stay on the shelf
* @param vQuantity amount that will stay on the shelve
*/
DECLARE vVisible INT;
DECLARE vClientFk INT;
@ -80,7 +80,8 @@ BEGIN
WHERE id = vItemFk;
UPDATE itemShelving
SET visible = IF(id = vItemShelvingFk, vQuantity, 0)
SET visible = IF(id = vItemShelvingFk, vQuantity, 0),
available = IF(id = vItemShelvingFk, vQuantity, 0)
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;

View File

@ -31,7 +31,8 @@ BEGIN
IF vNewItemShelvingFk THEN
UPDATE itemShelving ish
JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk
SET ish.visible = ish.visible + ish2.visible
SET ish.visible = ish.visible + ish2.visible,
ish.available = ish.available + ish2.available
WHERE ish.id = vNewItemShelvingFk;
DELETE FROM itemShelving

View File

@ -303,7 +303,8 @@ BEGIN
WHERE id = vTargetItemShelvingFk;
ELSE
UPDATE itemShelving
SET visible = vCurrentVisible - vQuantity
SET visible = vCurrentVisible - vQuantity,
available = GREATEST(0, available - vQuantity)
WHERE id = vTargetItemShelvingFk;
END IF;