fix: refs #8087 refs#8087 errores travel_moveRaids #3264
|
@ -10,8 +10,8 @@ BEGIN
|
||||||
* @param vIsRaid idRaid value
|
* @param vIsRaid idRaid value
|
||||||
* @param vDaysInForward daysInForward value
|
* @param vDaysInForward daysInForward value
|
||||||
*/
|
*/
|
||||||
IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN
|
IF NOT vIsRaid AND vDaysInForward THEN
|
||||||
CALL util.throw('The raid information is not correct');
|
CALL util.throw('If daysInForward has a value, the raid cannot be unchecked');
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -8,22 +8,15 @@ BEGIN
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vBuyerEmail VARCHAR(40);
|
DECLARE vBuyerEmail VARCHAR(40);
|
||||||
DECLARE vTravelLink TEXT;
|
DECLARE vTravelLink TEXT;
|
||||||
DECLARE vMailBody TEXT DEFAULT '';
|
DECLARE vMailBody TEXT;
|
||||||
|
DECLARE vDaysBetweenDates INT;
|
||||||
carlosap marked this conversation as resolved
Outdated
|
|||||||
|
DECLARE vSubject VARCHAR(30);
|
||||||
|
|
||||||
DECLARE vCur CURSOR FOR
|
DECLARE vTravels CURSOR FOR
|
||||||
SELECT GROUP_CONCAT(DISTINCT
|
SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'),
|
||||||
CONCAT('https://salix.verdnatura.es/#!/travel/',
|
buyerEmail
|
||||||
ttm.travelFk,
|
FROM tTravelToMove
|
||||||
'/summary ')
|
GROUP BY buyerEmail;
|
||||||
ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink,
|
|
||||||
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
|
||||||
FROM tTravelToMove ttm
|
|
||||||
JOIN entry e ON e.travelFk = ttm.travelFk
|
|
||||||
JOIN buy b ON b.entryFk = e.id
|
|
||||||
JOIN item i ON i.id = b.itemFk
|
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
|
||||||
JOIN account.user u ON u.id = it.workerFk
|
|
||||||
GROUP BY u.name;
|
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
@ -34,35 +27,50 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
CREATE OR REPLACE TEMPORARY TABLE tTravelToMove
|
||||||
SELECT id travelFk,
|
WITH travels AS (
|
||||||
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded
|
SELECT id,
|
||||||
FROM travel
|
CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink,
|
||||||
|
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded,
|
||||||
|
util.VN_CURDATE() - INTERVAL DATEDIFF(landed, shipped) + daysInForward DAY newShipped
|
||||||
|
FROM vn.travel
|
||||||
WHERE isRaid
|
WHERE isRaid
|
||||||
AND daysInForward;
|
AND daysInForward
|
||||||
|
)SELECT t.id,
|
||||||
|
t.travelLink,
|
||||||
|
t.newLanded,
|
||||||
|
t.newShipped,
|
||||||
|
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
||||||
|
FROM travels t
|
||||||
|
STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id
|
||||||
|
JOIN vn.buy b ON b.entryFk = e.id
|
||||||
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN account.user u ON u.id = it.workerFk
|
||||||
|
GROUP BY t.id;
|
||||||
|
|
||||||
START TRANSACTION;
|
START TRANSACTION;
|
||||||
|
|
||||||
UPDATE travel tr
|
UPDATE travel tr
|
||||||
JOIN tTravelToMove ttm ON ttm.travelFk = tr.id
|
JOIN tTravelToMove ttm ON ttm.id = tr.id
|
||||||
SET tr.landed = ttm.newLanded;
|
SET tr.landed = ttm.newLanded,
|
||||||
|
tr.shipped = ttm.newShipped;
|
||||||
|
|
||||||
OPEN vCur;
|
OPEN vTravels;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vCur INTO vTravelLink, vBuyerEmail;
|
FETCH vTravels INTO vTravelLink, vBuyerEmail;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL `vn`.`mail_insert`(
|
SET vSubject = 'Cambio de fecha en Redadas',
|
||||||
vBuyerEmail,
|
vMailBody = CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink);
|
||||||
'noreply@verdnatura.es',
|
|
||||||
'Cambio de fecha en Redadas',
|
CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody);
|
||||||
CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink));
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vCur;
|
CLOSE vTravels;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
DROP TEMPORARY TABLE tTravelToMove;
|
DROP TEMPORARY TABLE tTravelToMove;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -20,6 +20,10 @@ BEGIN
|
||||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN
|
||||||
|
CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
|
IF NOT (NEW.awbFk <=> OLD.awbFk)THEN
|
||||||
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
|
SELECT COUNT(*) INTO vHasAnyInvoiceBooked
|
||||||
FROM travel t
|
FROM travel t
|
||||||
|
|
Loading…
Reference in New Issue
vIsMovable