feat: refs #6951 create procedure
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
819bc7a56d
commit
5531639027
|
@ -2,54 +2,10 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE done INT DEFAULT FALSE;
|
|
||||||
DECLARE vNewTicketFk INT;
|
DECLARE vNewTicketFk INT;
|
||||||
DECLARE vOldSaleFk INT;
|
|
||||||
DECLARE vNewSaleFk INT;
|
|
||||||
|
|
||||||
DECLARE cur1 CURSOR FOR
|
CALL ticket_CloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk);
|
||||||
SELECT id
|
SELECT vNewTicketFk;
|
||||||
FROM vn.sale
|
|
||||||
WHERE ticketFk = vTicketFk;
|
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
|
||||||
|
|
||||||
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
|
||||||
|
|
||||||
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
|
|
||||||
|
|
||||||
UPDATE vn.ticket
|
|
||||||
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
|
||||||
shipped = vNewShipped
|
|
||||||
WHERE id = vNewTicketFk;
|
|
||||||
|
|
||||||
OPEN cur1;
|
|
||||||
|
|
||||||
read_loop: LOOP
|
|
||||||
|
|
||||||
FETCH cur1 INTO vOldSaleFk;
|
|
||||||
|
|
||||||
IF done THEN
|
|
||||||
LEAVE read_loop;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
|
||||||
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
|
||||||
FROM vn.sale
|
|
||||||
WHERE id = vOldSaleFk;
|
|
||||||
|
|
||||||
SELECT max(id) INTO vNewSaleFk
|
|
||||||
FROM vn.sale
|
|
||||||
WHERE ticketFk = vNewTicketFk;
|
|
||||||
|
|
||||||
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
|
|
||||||
SELECT vNewSaleFk, componentFk, value, isGreuge
|
|
||||||
FROM vn.saleComponent
|
|
||||||
WHERE saleFk = vOldSaleFk;
|
|
||||||
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
CLOSE cur1;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT,vWithWarehouse BOOLEAN)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Clona el contenido de un ticket en otro
|
* Clona el contenido de un ticket en otro
|
||||||
|
@ -32,7 +32,7 @@ BEGIN
|
||||||
addressFk,
|
addressFk,
|
||||||
agencyModeFk,
|
agencyModeFk,
|
||||||
nickname,
|
nickname,
|
||||||
warehouseFk,
|
IF(vWithWarehouse, warehouseFk, NULL),
|
||||||
companyFk,
|
companyFk,
|
||||||
landed,
|
landed,
|
||||||
zoneFk,
|
zoneFk,
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
DECLARE done INT DEFAULT FALSE;
|
||||||
|
DECLARE vOldSaleFk INT;
|
||||||
|
DECLARE vNewSaleFk INT;
|
||||||
|
|
||||||
|
DECLARE cur1 CURSOR FOR
|
||||||
|
SELECT id
|
||||||
|
FROM vn.sale
|
||||||
|
WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||||
|
|
||||||
|
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
||||||
|
|
||||||
|
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
|
||||||
|
|
||||||
|
UPDATE vn.ticket
|
||||||
|
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
||||||
|
shipped = vNewShipped
|
||||||
|
WHERE id = vNewTicketFk;
|
||||||
|
|
||||||
|
OPEN cur1;
|
||||||
|
|
||||||
|
read_loop: LOOP
|
||||||
|
|
||||||
|
FETCH cur1 INTO vOldSaleFk;
|
||||||
|
|
||||||
|
IF done THEN
|
||||||
|
LEAVE read_loop;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
||||||
|
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
||||||
|
FROM vn.sale
|
||||||
|
WHERE id = vOldSaleFk;
|
||||||
|
|
||||||
|
SELECT max(id) INTO vNewSaleFk
|
||||||
|
FROM vn.sale
|
||||||
|
WHERE ticketFk = vNewTicketFk;
|
||||||
|
|
||||||
|
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
|
||||||
|
SELECT vNewSaleFk, componentFk, value, isGreuge
|
||||||
|
FROM vn.saleComponent
|
||||||
|
WHERE saleFk = vOldSaleFk;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
CLOSE cur1;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
Loading…
Reference in New Issue