29 lines
791 B
SQL
29 lines
791 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_updateIsChecked`(vSaleFK INT, vIsChecked BOOL, vIsScanned BOOL)
|
|
BEGIN
|
|
|
|
/**
|
|
* Actualiza el estado del campo vn.saleTracking.isChecked y elimina las lineas de vn.itemShelving
|
|
* si procede, en el caso de las preparaciones previas, por usuario
|
|
*
|
|
* @param vSaleFk Identificador de vn.sale
|
|
* @param vIsChecked Estado del registro
|
|
*/
|
|
|
|
UPDATE vn.saleTracking st
|
|
JOIN vn.state s ON s.id = st.stateFk AND s.code = 'PREVIOUS_PREPARATION'
|
|
SET st.isChecked = vIsChecked,
|
|
st.isScanned = vIsScanned
|
|
WHERE st.saleFk = vSaleFK
|
|
AND st.workerFk = account.myUser_getId();
|
|
|
|
IF vIsChecked = FALSE THEN
|
|
|
|
DELETE FROM vn.itemShelvingSale
|
|
WHERE saleFk = vSaleFK;
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
DELIMITER ;
|