feat: refs #7902 Triggers vn.ticketRefund to control deleted tickets #2908
|
@ -0,0 +1,25 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketRefund_upsert`(
|
||||||
|
vRefundTicketFk INT,
|
||||||
|
vOriginalTicketFk INT
|
||||||
|
)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Common code for ticketRefund triggers
|
||||||
|
*
|
||||||
|
* @param vRefundTicketFk
|
||||||
|
* @param vOriginalTicketFk
|
||||||
|
*/
|
||||||
|
DECLARE vIsDeleted BOOL;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vIsDeleted
|
||||||
|
FROM ticket
|
||||||
|
WHERE id IN (vRefundTicketFk, vOriginalTicketFk)
|
||||||
|
AND isDeleted;
|
||||||
|
|
||||||
|
IF vIsDeleted THEN
|
||||||
|
CALL util.throw('The refund ticket cannot be deleted tickets');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInse
|
||||||
BEFORE INSERT ON `ticketRefund`
|
BEFORE INSERT ON `ticketRefund`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpda
|
||||||
BEFORE UPDATE ON `ticketRefund`
|
BEFORE UPDATE ON `ticketRefund`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue