fix: refs #7564 Ticket volume item cost
This commit is contained in:
parent
55df919076
commit
4a102d315d
|
@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
|
|||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the volume ticket
|
||||
* Update the volume ticket.
|
||||
*
|
||||
* @param vSelf Ticket id
|
||||
*/
|
||||
|
|
|
@ -4,26 +4,36 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeIte
|
|||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the volume tickets of item
|
||||
* Update the volume of tickets containing the item.
|
||||
*
|
||||
* @param vSelf Ticket id
|
||||
* @param vItemFk Item id
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTicket
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume
|
||||
DECLARE vTicket INT;
|
||||
DECLARE vDone BOOL;
|
||||
|
||||
DECLARE vTickets CURSOR FOR
|
||||
SELECT DISTINCT t.id
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN itemCost ic ON ic.itemFk = s.itemFk
|
||||
AND ic.warehouseFk = t.warehouseFk
|
||||
WHERE s.itemFk = vItemFk
|
||||
AND t.shipped >= util.VN_CURDATE()
|
||||
GROUP BY t.id;
|
||||
AND t.refFk IS NULL;
|
||||
|
||||
UPDATE ticket t
|
||||
JOIN tTicket tt ON tt.id = t.id
|
||||
SET t.volume = tt.volume;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
DROP TEMPORARY TABLE tTicket;
|
||||
OPEN vTickets;
|
||||
l: LOOP
|
||||
FETCH vTickets INTO vTicket;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL ticket_setVolume(vTicket);
|
||||
|
||||
END LOOP l;
|
||||
CLOSE vTickets;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue