2024-01-31 06:11:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_unpicked`(
|
2024-01-31 06:11:03 +00:00
|
|
|
vSelf INT(11)
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving
|
|
|
|
*
|
|
|
|
* @param vSelf Identificador del itemShelvingSale
|
|
|
|
*/
|
|
|
|
DECLARE vSaleFk INT;
|
|
|
|
DECLARE vReservedQuantity INT;
|
|
|
|
DECLARE vIsSaleGroup BOOL;
|
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
|
|
|
ROLLBACK;
|
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
|
|
|
IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN
|
|
|
|
CALL util.throw('Reserva no completada');
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE)
|
|
|
|
INTO vSaleFk, vReservedQuantity, vIsSaleGroup
|
|
|
|
FROM itemShelvingSale ish
|
|
|
|
LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk
|
|
|
|
WHERE ish.id = vSelf;
|
|
|
|
|
2024-04-15 11:03:27 +00:00
|
|
|
/*IF vIsSaleGroup THEN
|
2024-01-31 06:11:03 +00:00
|
|
|
CALL util.throw('Can not unpicked a sale group');
|
2024-04-15 11:03:27 +00:00
|
|
|
END IF;*/
|
2024-01-31 06:11:03 +00:00
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
|
|
|
|
UPDATE itemShelvingSale
|
|
|
|
SET isPicked = FALSE
|
|
|
|
WHERE id = vSelf;
|
|
|
|
|
|
|
|
UPDATE sale s
|
|
|
|
JOIN itemShelvingSale ish ON ish.saleFk = s.id
|
|
|
|
SET s.isPicked = FALSE
|
|
|
|
WHERE ish.id = vSelf;
|
|
|
|
|
|
|
|
UPDATE itemShelvingSale iss
|
|
|
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
|
|
|
SET ish.visible = ish.visible + iss.quantity
|
|
|
|
WHERE iss.id = vSelf;
|
|
|
|
|
|
|
|
CALL saleTracking_new(
|
|
|
|
vSaleFk,
|
|
|
|
FALSE,
|
|
|
|
vReservedQuantity,
|
|
|
|
`account`.`myUser_getId`(),
|
|
|
|
NULL,
|
|
|
|
'ON_PREPARATION',
|
|
|
|
TRUE);
|
|
|
|
COMMIT;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|