fix: refs #8087 refs#8087 errores travel_moveRaids
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
fc1e0672a4
commit
b0ee1f3e24
|
@ -0,0 +1,17 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`(
|
||||||
|
vIsRaid BOOL,
|
||||||
|
vDaysInForward INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Check if the values of isRaid and daysInforward are correct
|
||||||
|
*
|
||||||
|
* @param vIsRaid idRaid value
|
||||||
|
* @param vDaysInForward daysInForward value
|
||||||
|
*/
|
||||||
|
IF NOT vIsRaid AND vDaysInForward THEN
|
||||||
|
CALL util.throw('If daysInForward has a value, the raid cannot be unchecked');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -9,15 +9,14 @@ BEGIN
|
||||||
DECLARE vBuyerEmail VARCHAR(40);
|
DECLARE vBuyerEmail VARCHAR(40);
|
||||||
DECLARE vTravelLink TEXT;
|
DECLARE vTravelLink TEXT;
|
||||||
DECLARE vMailBody TEXT;
|
DECLARE vMailBody TEXT;
|
||||||
DECLARE vIsMovible BOOL;
|
DECLARE vDaysBetweenDates INT;
|
||||||
DECLARE vSubject VARCHAR(30);
|
DECLARE vSubject VARCHAR(30);
|
||||||
|
|
||||||
DECLARE vTravels CURSOR FOR
|
DECLARE vTravels CURSOR FOR
|
||||||
SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'),
|
SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'),
|
||||||
buyerEmail,
|
buyerEmail
|
||||||
isMovable
|
|
||||||
FROM tTravelToMove
|
FROM tTravelToMove
|
||||||
GROUP BY isMovable, buyerEmail;
|
GROUP BY buyerEmail;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
@ -32,17 +31,17 @@ BEGIN
|
||||||
SELECT id,
|
SELECT id,
|
||||||
CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink,
|
CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink,
|
||||||
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded,
|
util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded,
|
||||||
shipped <= util.VN_CURDATE() + INTERVAL daysInForward DAY isMovable
|
util.VN_CURDATE() - INTERVAL DATEDIFF(landed, shipped) + daysInForward DAY newShipped
|
||||||
FROM travel
|
FROM vn.travel
|
||||||
WHERE isRaid
|
WHERE isRaid
|
||||||
AND daysInForward
|
AND daysInForward
|
||||||
)SELECT t.*,
|
)SELECT t.*,
|
||||||
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
CONCAT(u.name, '@verdnatura.es') buyerEmail
|
||||||
FROM travels t
|
FROM travels t
|
||||||
STRAIGHT_JOIN entry e ON e.travelFk = t.id
|
STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id
|
||||||
JOIN buy b ON b.entryFk = e.id
|
JOIN vn.buy b ON b.entryFk = e.id
|
||||||
JOIN item i ON i.id = b.itemFk
|
JOIN vn.item i ON i.id = b.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
JOIN account.user u ON u.id = it.workerFk
|
JOIN account.user u ON u.id = it.workerFk
|
||||||
GROUP BY t.id;
|
GROUP BY t.id;
|
||||||
|
|
||||||
|
@ -50,28 +49,21 @@ BEGIN
|
||||||
|
|
||||||
UPDATE travel tr
|
UPDATE travel tr
|
||||||
JOIN tTravelToMove ttm ON ttm.id = tr.id
|
JOIN tTravelToMove ttm ON ttm.id = tr.id
|
||||||
SET tr.landed = ttm.newLanded
|
SET tr.landed = ttm.newLanded,
|
||||||
WHERE ttm.isMovable;
|
tr.shipped = ttm.newShipped;
|
||||||
|
|
||||||
OPEN vTravels;
|
OPEN vTravels;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vTravels INTO vTravelLink, vBuyerEmail, vIsMovible;
|
FETCH vTravels INTO vTravelLink, vBuyerEmail;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vIsMovible THEN
|
SET vSubject = 'Cambio de fecha en Redadas',
|
||||||
SET vSubject = 'Cambio de fecha en Redadas';
|
vMailBody = CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink);
|
||||||
SET vMailBody = 'Se ha movido los siguientes travels';
|
|
||||||
ELSE
|
|
||||||
SET vSubject = 'ERROR al cambiar la fecha en Redadas';
|
|
||||||
SET vMailBody = 'Ha ocurrido un error con las fechas al mover los siguiente travels';
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
SET vMailBody = CONCAT(vMailBody, ': \n\r ', vTravelLink);
|
|
||||||
|
|
||||||
CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody);
|
CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
|
@ -9,6 +9,10 @@ BEGIN
|
||||||
|
|
||||||
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk);
|
||||||
|
|
||||||
|
IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN
|
||||||
|
CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward);
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NEW.awbFk IS NOT NULL THEN
|
IF NEW.awbFk IS NOT NULL THEN
|
||||||
CALL travel_throwAwb(NEW.id);
|
CALL travel_throwAwb(NEW.id);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -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