This commit is contained in:
parent
974827443c
commit
6ef7760498
|
@ -37,23 +37,23 @@ BEGIN
|
||||||
WHERE t.id = vTicketFk;
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
CALL cache.available_refresh(
|
CALL cache.available_refresh(
|
||||||
vCacheAvailableFk,
|
vCacheAvailableFk,
|
||||||
FALSE,
|
FALSE,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
util.VN_CURDATE());
|
util.VN_CURDATE());
|
||||||
|
|
||||||
SELECT available INTO vAvailable
|
SELECT available INTO vAvailable
|
||||||
FROM cache.available
|
FROM cache.available
|
||||||
WHERE calc_id = vCacheAvailableFk
|
WHERE calc_id = vCacheAvailableFk
|
||||||
AND item_id = vItemFk;
|
AND item_id = vItemFk;
|
||||||
|
|
||||||
IF vAvailable < vQuantity THEN
|
IF vAvailable < vQuantity THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
ELSE
|
ELSE
|
||||||
SELECT `name`,
|
SELECT `name`,
|
||||||
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name)
|
||||||
INTO vItemName, vConcept
|
INTO vItemName, vConcept
|
||||||
FROM item
|
FROM item
|
||||||
WHERE id = vItemFk;
|
WHERE id = vItemFk;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
@ -69,7 +69,7 @@ BEGIN
|
||||||
|
|
||||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
CALL sale_calculateComponent(vSaleFk, NULL);
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -78,13 +78,13 @@ BEGIN
|
||||||
IF vHasThrow THEN
|
IF vHasThrow THEN
|
||||||
CALL util.throw("There is no available for the selected item");
|
CALL util.throw("There is no available for the selected item");
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vSaleGroupFk THEN
|
IF vSaleGroupFk THEN
|
||||||
INSERT INTO saleGroupDetail
|
INSERT INTO saleGroupDetail
|
||||||
SET saleFk = vSaleFk,
|
SET saleFk = vSaleFk,
|
||||||
saleGroupFk = vSaleGroupFk;
|
saleGroupFk = vSaleGroupFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -18,8 +18,9 @@ proc: BEGIN
|
||||||
DECLARE vReservedQuantity INT;
|
DECLARE vReservedQuantity INT;
|
||||||
DECLARE vOutStanding INT;
|
DECLARE vOutStanding INT;
|
||||||
DECLARE vUserFk INT;
|
DECLARE vUserFk INT;
|
||||||
DECLARE vTotalReservedQuantity INT;
|
DECLARE vTotalReservedQuantity INT;
|
||||||
DECLARE vSaleQuantity INT;
|
DECLARE vSaleQuantity INT;
|
||||||
|
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
|
||||||
|
|
||||||
DECLARE vItemShelvingAvailable CURSOR FOR
|
DECLARE vItemShelvingAvailable CURSOR FOR
|
||||||
SELECT ish.id itemShelvingFk,
|
SELECT ish.id itemShelvingFk,
|
||||||
|
@ -29,7 +30,7 @@ proc: BEGIN
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
JOIN parking p ON p.id = sh.parkingFk
|
||||||
JOIN sector sc ON sc.id = p.sectorFk
|
JOIN sector sc ON sc.id = p.sectorFk
|
||||||
JOIN productionConfig pc
|
JOIN productionConfig pc
|
||||||
WHERE s.id = vSaleFk
|
WHERE s.id = vSaleFk
|
||||||
AND NOT sc.isHideForPickers
|
AND NOT sc.isHideForPickers
|
||||||
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
||||||
|
@ -44,15 +45,15 @@ proc: BEGIN
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vIsRequiredTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vIsRequiredTx);
|
||||||
|
|
||||||
SELECT id INTO vSaleFk
|
SELECT id INTO vSaleFk
|
||||||
FROM sale
|
FROM sale
|
||||||
WHERE id = vSaleFk
|
WHERE id = vSaleFk
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
|
||||||
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
|
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
|
||||||
|
@ -65,7 +66,7 @@ proc: BEGIN
|
||||||
WHERE s.id = vSaleFk;
|
WHERE s.id = vSaleFk;
|
||||||
|
|
||||||
IF vOutStanding <= 0 THEN
|
IF vOutStanding <= 0 THEN
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
LEAVE proc;
|
LEAVE proc;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ proc: BEGIN
|
||||||
IF vTotalReservedQuantity <> vSaleQuantity THEN
|
IF vTotalReservedQuantity <> vSaleQuantity THEN
|
||||||
CALL util.debugAdd('itemShelvingSale_addBySale',
|
CALL util.debugAdd('itemShelvingSale_addBySale',
|
||||||
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
|
CONCAT(vSaleFk, ' - ', vSaleQuantity,' - ', vTotalReservedQuantity,'-', vOutStanding,'-', account.myUser_getId()));
|
||||||
|
|
||||||
UPDATE sale
|
UPDATE sale
|
||||||
SET quantity = vTotalReservedQuantity
|
SET quantity = vTotalReservedQuantity
|
||||||
WHERE id = vSaleFk;
|
WHERE id = vSaleFk;
|
||||||
|
@ -93,7 +94,7 @@ proc: BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT id INTO vItemShelvingFk
|
SELECT id INTO vItemShelvingFk
|
||||||
FROM itemShelving
|
FROM itemShelving
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
FOR UPDATE;
|
FOR UPDATE;
|
||||||
|
@ -102,19 +103,19 @@ proc: BEGIN
|
||||||
SET vOutStanding = vOutStanding - vReservedQuantity;
|
SET vOutStanding = vOutStanding - vReservedQuantity;
|
||||||
|
|
||||||
IF vReservedQuantity > 0 THEN
|
IF vReservedQuantity > 0 THEN
|
||||||
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
CALL util.debugAdd('itemShelvingSale_addBySale_reservedQuantity',
|
||||||
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
CONCAT(vSaleFk, ' - ', vReservedQuantity, ' - ', vOutStanding, account.myUser_getId()));
|
||||||
INSERT INTO itemShelvingSale(
|
INSERT INTO itemShelvingSale(
|
||||||
itemShelvingFk,
|
itemShelvingFk,
|
||||||
saleFk,
|
saleFk,
|
||||||
quantity,
|
quantity,
|
||||||
userFk,
|
userFk,
|
||||||
isPicked)
|
isPicked)
|
||||||
SELECT vItemShelvingFk,
|
SELECT vItemShelvingFk,
|
||||||
vSaleFk,
|
vSaleFk,
|
||||||
vReservedQuantity,
|
vReservedQuantity,
|
||||||
vUserFk,
|
vUserFk,
|
||||||
FALSE;
|
FALSE;
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET available = available - vReservedQuantity
|
SET available = available - vReservedQuantity
|
||||||
|
@ -123,6 +124,6 @@ proc: BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vItemShelvingAvailable;
|
CLOSE vItemShelvingAvailable;
|
||||||
COMMIT;
|
CALL util.tx_commit(vIsRequiredTx);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
Loading…
Reference in New Issue