fix: refs #6861 duplicatedTicketsInReserve #3053

Merged
sergiodt merged 3 commits from 6861-itemShelvingSaleDelete into master 2024-10-08 05:41:56 +00:00
2 changed files with 52 additions and 3 deletions
Showing only changes of commit bbcf71619c - Show all commits

View File

@ -46,7 +46,7 @@ BEGIN
LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE t.id = vParamFk
AND t.shipped >= vYesterday
UNION ALL
UNION
SELECT t.id ticketFk,
IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
am.name agencyName,
@ -67,7 +67,7 @@ BEGIN
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
LEFT JOIN observation ob ON ob.ticketFk = t.id
WHERE tc.collectionFk = vParamFk
UNION ALL
UNION
SELECT sg.ticketFk,
NULL `level`,
am.name agencyName,
@ -84,6 +84,7 @@ BEGIN
LEFT JOIN observation ob ON ob.ticketFk = t.id
LEFT JOIN vn.client c ON c.id = t.clientFk
WHERE sc.id = vParamFk
AND t.shipped >= vYesterday;
AND t.shipped >= vYesterday
GROUP BY ticketFk;
END$$
DELIMITER ;

View File

@ -0,0 +1,48 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_deleteAdded`(
vSelf INT(11)
)
proc: BEGIN
/**
* Borra una reservea devolviendo la cantidad al itemShelving
*
* @param vSelf Identificador del itemShelvingSale
*/
DECLARE vSaleFk INT;
DECLARE vHasSalesPicked BOOL;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
sergiodt marked this conversation as resolved Outdated
Outdated
Review

Sobra una tabulación de BEGIN a END.

Sobra una tabulación de `BEGIN` a `END`.
SELECT iss.saleFk INTO vSaleFk
FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
WHERE iss.id = vSelf AND s.isAdded ;
sergiodt marked this conversation as resolved Outdated
Outdated
Review
  • Mover START TRANSACTION antes del SELECT
  • Añadir FOR UPDATE
  • Quitar espacio antes de punto y coma
- Mover `START TRANSACTION` antes del `SELECT` - Añadir `FOR UPDATE` - Quitar espacio antes de punto y coma
IF vSaleFk IS NULL THEN
CALL util.throw('The sale can not be deleted');
END IF;
SELECT COUNT(*) INTO vHasSalesPicked
FROM itemShelvingSale
WHERE saleFk = vSaleFk AND isPicked;
IF vHasSalesPicked THEN
CALL util.throw('The sale can not be deleted with sales picked');
sergiodt marked this conversation as resolved Outdated
Outdated
Review

A sale with picked sales cannot be deleted

_A sale with picked sales cannot be deleted_
END IF;
START TRANSACTION;
UPDATE itemShelvingSale iss
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
SET ish.available = ish.available + iss.quantity
WHERE iss.saleFk = vSaleFk;
DELETE FROM sale WHERE id = vSaleFk;
COMMIT;
END$$
DELIMITER ;