This commit is contained in:
parent
5531639027
commit
690d935429
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT,vWithWarehouse BOOLEAN)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT)
|
||||||
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,
|
||||||
IF(vWithWarehouse, warehouseFk, NULL),
|
warehouseFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
landed,
|
landed,
|
||||||
zoneFk,
|
zoneFk,
|
||||||
|
|
|
@ -2,53 +2,54 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_CloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE done INT DEFAULT FALSE;
|
DECLARE done INT DEFAULT FALSE;
|
||||||
DECLARE vOldSaleFk INT;
|
DECLARE vOldSaleFk INT;
|
||||||
DECLARE vNewSaleFk INT;
|
DECLARE vNewSaleFk INT;
|
||||||
|
|
||||||
DECLARE cur1 CURSOR FOR
|
DECLARE cur1 CURSOR FOR
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM vn.sale
|
FROM sale
|
||||||
WHERE ticketFk = vTicketFk;
|
WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||||
|
|
||||||
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
||||||
|
|
||||||
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
|
CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
|
||||||
|
|
||||||
UPDATE vn.ticket
|
UPDATE ticket
|
||||||
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
||||||
shipped = vNewShipped
|
shipped = vNewShipped,
|
||||||
WHERE id = vNewTicketFk;
|
warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
|
||||||
|
WHERE id = vNewTicketFk;
|
||||||
|
|
||||||
OPEN cur1;
|
OPEN cur1;
|
||||||
|
|
||||||
read_loop: LOOP
|
read_loop: LOOP
|
||||||
|
|
||||||
FETCH cur1 INTO vOldSaleFk;
|
FETCH cur1 INTO vOldSaleFk;
|
||||||
|
|
||||||
IF done THEN
|
IF done THEN
|
||||||
LEAVE read_loop;
|
LEAVE read_loop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
||||||
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
||||||
FROM vn.sale
|
FROM sale
|
||||||
WHERE id = vOldSaleFk;
|
WHERE id = vOldSaleFk;
|
||||||
|
|
||||||
SELECT max(id) INTO vNewSaleFk
|
SELECT max(id) INTO vNewSaleFk
|
||||||
FROM vn.sale
|
FROM sale
|
||||||
WHERE ticketFk = vNewTicketFk;
|
WHERE ticketFk = vNewTicketFk;
|
||||||
|
|
||||||
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
|
INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
|
||||||
SELECT vNewSaleFk, componentFk, value, isGreuge
|
SELECT vNewSaleFk, componentFk, value, isGreuge
|
||||||
FROM vn.saleComponent
|
FROM saleComponent
|
||||||
WHERE saleFk = vOldSaleFk;
|
WHERE saleFk = vOldSaleFk;
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE cur1;
|
CLOSE cur1;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue