refactor: #6585 Deleted transaction ticket_doCmr

This commit is contained in:
Guillermo Bonet 2024-05-07 13:03:50 +02:00
parent e44568ff4b
commit 2adf96cb37
1 changed files with 4 additions and 11 deletions

View File

@ -7,7 +7,7 @@ BEGIN
*
* @param vSelf El id del ticket
*/
DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT;
DECLARE vCmrFk INT;
SELECT cmrFk INTO vCmrFk
FROM ticket
WHERE id = vSelf;
@ -44,8 +44,6 @@ BEGIN
AND t.id = vSelf
GROUP BY t.id;
START TRANSACTION;
IF vCmrFk THEN
UPDATE cmr c
JOIN tTicket t
@ -58,8 +56,6 @@ BEGIN
c.ead = t.landed
WHERE id = vCmrFk;
ELSE
SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
INSERT INTO cmr (
senderInstruccions,
truckPlate,
@ -71,16 +67,13 @@ BEGIN
)
SELECT * FROM tTicket;
SELECT MAX(id) INTO vCurrentCmrFk FROM cmr;
IF vPreviousCmrFk <> vCurrentCmrFk THEN
IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN
UPDATE ticket
SET cmrFk = vCurrentCmrFk
WHERE id = vSelf;
WHERE id = LAST_INSERT_ID();
END IF;
END IF;
COMMIT;
DROP TEMPORARY TABLE tTicket;
END$$
DELIMITER ;