feat: refs #7685 delivery coordinates
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-07-09 10:01:32 +02:00
parent cb5c660e13
commit 4dcc8b02a5
3 changed files with 34 additions and 20 deletions

View File

@ -0,0 +1,30 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCorordinates`(
vTicketFk INT,
vLongitude INT,
vLatitude INT)
BEGIN
/**
* Actualiza las coordenadas de una direccion
*
* @param vTicketFk id del ticket
* @param vLongitude longitud de la direccion
* @param vLatitude latitud de la dirrecion
*/
DECLARE vAddressFK INT;
START TRANSACTION;
SELECT addressFK INTO vAddressFK
FROM ticket
WHERE id = vTicketFk
FOR UPDATE;
UPDATE address
SET longitude = vLongitude,
latitude = vLatitude
WHERE id = vAddressFK;
COMMIT;
END$$
DELIMITER ;

View File

@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeInsert
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN
THEN CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude);
UPDATE address
SET longitude = NEW.longitude,
latitude = NEW.latitude
WHERE id IN (
SELECT addressFK
FROM ticket
WHERE id = NEW.ticketFk
);
END IF; END IF;
END$$ END$$

View File

@ -4,16 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`delivery_beforeUpdate
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) THEN
THEN CALL address_updateCorordinates(NEW.ticketFk,NEW.longitude,NEW.latitude);
UPDATE address
SET longitude = NEW.longitude,
latitude = NEW.latitude
WHERE id IN (
SELECT addressFK
FROM ticket
WHERE id = NEW.ticketFk
);
END IF; END IF;
END$$ END$$