2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`ticketComponentUpdate`(
|
2024-01-15 11:31:03 +00:00
|
|
|
vTicketFk INT,
|
2024-01-25 16:33:54 +00:00
|
|
|
vClientFk INT,
|
|
|
|
vAgencyModeFk INT,
|
|
|
|
vAddressFk INT,
|
|
|
|
vWarehouseFk TINYINT,
|
|
|
|
vCompanyFk SMALLINT,
|
|
|
|
vShipped DATETIME,
|
|
|
|
vLanded DATE,
|
|
|
|
vIsDeleted BOOLEAN,
|
|
|
|
vHasToBeUnrouted BOOLEAN,
|
|
|
|
vOption VARCHAR(25))
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
2024-01-25 16:33:54 +00:00
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
2024-01-15 11:31:03 +00:00
|
|
|
ROLLBACK;
|
2024-01-25 16:33:54 +00:00
|
|
|
RESIGNAL;
|
2024-01-15 11:31:03 +00:00
|
|
|
END;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
2024-01-25 16:33:54 +00:00
|
|
|
|
|
|
|
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
UPDATE ticket t
|
|
|
|
JOIN address a ON a.id = vAddressFk
|
|
|
|
SET t.nickname = a.nickname
|
|
|
|
WHERE t.id = vTicketFk;
|
2024-01-25 16:33:54 +00:00
|
|
|
END IF;
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
UPDATE ticket t
|
|
|
|
SET
|
|
|
|
t.clientFk = vClientFk,
|
|
|
|
t.agencyModeFk = vAgencyModeFk,
|
|
|
|
t.addressFk = vAddressFk,
|
|
|
|
t.warehouseFk = vWarehouseFk,
|
2024-01-25 16:33:54 +00:00
|
|
|
t.companyFk = vCompanyFk,
|
2024-01-15 11:31:03 +00:00
|
|
|
t.landed = vLanded,
|
|
|
|
t.shipped = vShipped,
|
2024-01-25 16:33:54 +00:00
|
|
|
t.isDeleted = vIsDeleted
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE
|
|
|
|
t.id = vTicketFk;
|
2024-01-25 16:33:54 +00:00
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
IF vHasToBeUnrouted THEN
|
|
|
|
UPDATE ticket t SET t.routeFk = NULL
|
|
|
|
WHERE t.id = vTicketFk;
|
2024-01-25 16:33:54 +00:00
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-01-25 16:33:54 +00:00
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
|
|
|
|
CREATE TEMPORARY TABLE tmp.sale
|
|
|
|
(PRIMARY KEY (saleFk))
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT id AS saleFk, vWarehouseFk warehouseFk
|
|
|
|
FROM sale s WHERE s.ticketFk = vTicketFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-01-25 16:33:54 +00:00
|
|
|
CALL ticketComponentUpdateSale (vOption);
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.sale;
|
2024-01-15 11:31:03 +00:00
|
|
|
COMMIT;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|