Compare commits

...

2 Commits

Author SHA1 Message Date
Robert Ferrús b29053e850 Merge pull request 'feat: refs #8211 route_afterUpdate' (!3218) from 8211-hotFixRoute_afterUpdate into master
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #3218
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
2024-11-19 11:05:30 +00:00
Robert Ferrús 7b5e474d24 feat: refs #8211 route_afterUpdate
gitea/salix/pipeline/pr-master This commit looks good Details
2024-11-19 11:15:57 +01:00
1 changed files with 7 additions and 6 deletions

View File

@ -2,18 +2,18 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate` CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`route_afterUpdate`
AFTER UPDATE ON `route` AFTER UPDATE ON `route`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN IF IFNULL(NEW.gestdocFk,0) <> IFNULL(OLD.gestdocFk,0) AND NEW.gestdocFk > 0 THEN
-- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets -- JGF 09/09/14 cuando se añade un gestdoc a una ruta, se le asigna automagicamente a todos sus Tickets
-- Inserta el gestdoc en todos los tickets de la ruta -- Inserta el gestdoc en todos los tickets de la ruta
INSERT INTO ticketDms(ticketFk,dmsFk) INSERT INTO ticketDms(ticketFk,dmsFk)
SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id SELECT id, NEW.gestdocFk FROM ticket WHERE routeFk = NEW.id
ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk; ON DUPLICATE KEY UPDATE dmsFk = NEW.gestdocFk;
-- Update del firmado -- Update del firmado
UPDATE ticket t UPDATE ticket t
JOIN ticketDms tg ON t.id = tg.ticketFk JOIN ticketDms tg ON t.id = tg.ticketFk
SET isSigned = 1 WHERE t.routeFk = NEW.id; SET isSigned = 1 WHERE t.routeFk = NEW.id;
END IF; END IF;
@ -21,7 +21,8 @@ BEGIN
OR !(NEW.kmEnd <=> OLD.kmEnd) OR !(NEW.kmEnd <=> OLD.kmEnd)
OR !(NEW.workerFk <=> OLD.workerFk) OR !(NEW.workerFk <=> OLD.workerFk)
OR !(NEW.m3 <=> OLD.m3) OR !(NEW.m3 <=> OLD.m3)
OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)THEN OR !(NEW.agencyModeFk <=> OLD.agencyModeFk)
OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN
CALL route_calcCommission(NEW.id); CALL route_calcCommission(NEW.id);
END IF; END IF;