7430_devToTest #2490
|
@ -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
|
||||
|
@ -57,9 +55,7 @@ BEGIN
|
|||
c.supplierFk = t.supplierFk,
|
||||
c.ead = t.landed
|
||||
WHERE id = vCmrFk;
|
||||
ELSE
|
||||
SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
|
||||
|
||||
ELSE
|
||||
INSERT INTO cmr (
|
||||
senderInstruccions,
|
||||
truckPlate,
|
||||
|
@ -70,17 +66,14 @@ BEGIN
|
|||
ead
|
||||
)
|
||||
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
|
||||
SET cmrFk = LAST_INSERT_ID()
|
||||
WHERE id = vSelf;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
DROP TEMPORARY TABLE tTicket;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -7,6 +7,8 @@ BEGIN
|
|||
UPDATE expedition
|
||||
SET hasNewRoute = TRUE
|
||||
WHERE ticketFk = NEW.id;
|
||||
|
||||
CALL ticket_doCmr(NEW.id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue