#6951 create ticket_cloneAll #2120
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
/**
|
||||
* Clona el contenido de un ticket en otro
|
||||
|
@ -32,7 +32,7 @@ BEGIN
|
|||
addressFk,
|
||||
agencyModeFk,
|
||||
nickname,
|
||||
IF(vWithWarehouse, warehouseFk, NULL),
|
||||
warehouseFk,
|
||||
companyFk,
|
||||
landed,
|
||||
zoneFk,
|
||||
|
|
|
@ -8,18 +8,19 @@ BEGIN
|
|||
|
||||
DECLARE cur1 CURSOR FOR
|
||||
SELECT id
|
||||
FROM vn.sale
|
||||
FROM 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);
|
||||
CALL ticket_Clone(vTicketFk, vNewTicketFk, vWithWarehouse);
|
||||
|
||||
UPDATE vn.ticket
|
||||
UPDATE ticket
|
||||
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
||||
shipped = vNewShipped
|
||||
shipped = vNewShipped,
|
||||
warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
|
||||
WHERE id = vNewTicketFk;
|
||||
|
||||
OPEN cur1;
|
||||
|
@ -32,18 +33,18 @@ BEGIN
|
|||
LEAVE read_loop;
|
||||
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
|
||||
FROM vn.sale
|
||||
FROM sale
|
||||
WHERE id = vOldSaleFk;
|
||||
|
||||
SELECT max(id) INTO vNewSaleFk
|
||||
FROM vn.sale
|
||||
FROM sale
|
||||
WHERE ticketFk = vNewTicketFk;
|
||||
|
||||
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
|
||||
INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
|
||||
SELECT vNewSaleFk, componentFk, value, isGreuge
|
||||
FROM vn.saleComponent
|
||||
FROM saleComponent
|
||||
WHERE saleFk = vOldSaleFk;
|
||||
|
||||
END LOOP;
|
||||
|
|
Loading…
Reference in New Issue