2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate`
|
|
|
|
AFTER UPDATE ON `client`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
2024-06-20 12:27:11 +00:00
|
|
|
IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
2024-04-17 11:21:27 +00:00
|
|
|
UPDATE `address` SET isDefaultAddress = FALSE
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE clientFk = NEW.id;
|
|
|
|
|
2024-04-17 11:21:27 +00:00
|
|
|
UPDATE `address` SET isDefaultAddress = TRUE
|
|
|
|
WHERE id = NEW.defaultAddressFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
2024-06-20 12:27:11 +00:00
|
|
|
|
|
|
|
IF NEW.id <> OLD.id
|
|
|
|
OR NOT (NEW.provinceFk <=> OLD.provinceFk)
|
|
|
|
OR NOT (NEW.socialName <=> OLD.socialName)
|
|
|
|
OR NOT (NEW.street <=> OLD.street)
|
|
|
|
OR NOT (NEW.accountingAccount <=> OLD.accountingAccount)
|
|
|
|
OR NOT (NEW.isVies <=> OLD.isVies)
|
|
|
|
OR NOT (NEW.fi <=> OLD.fi)
|
|
|
|
OR NOT (NEW.postcode <=> OLD.postcode)
|
|
|
|
OR NOT (NEW.city <=> OLD.city)
|
|
|
|
OR NOT (NEW.countryFk <=> OLD.countryFk)
|
|
|
|
OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk)
|
|
|
|
OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk)
|
|
|
|
OR NOT (NEW.email <=> OLD.email)
|
|
|
|
OR NOT (NEW.iban <=> OLD.iban)
|
|
|
|
OR NOT (NEW.phone <=> OLD.phone)
|
|
|
|
OR NOT (NEW.mobile <=> OLD.mobile) THEN
|
|
|
|
|
|
|
|
UPDATE sage.clientSupplier
|
|
|
|
SET isSync = FALSE
|
|
|
|
WHERE idClientSupplier IN (NEW.id, OLD.id)
|
|
|
|
AND `type` = 'C';
|
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|