34 lines
823 B
SQL
34 lines
823 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`(
|
|
vSelf INT
|
|
)
|
|
BEGIN
|
|
/**
|
|
* Update the rounding problem for the sales lines of a ticket
|
|
*
|
|
* @param vSelf Id de ticket
|
|
*/
|
|
DECLARE vWarehouseFk INT;
|
|
DECLARE vDated DATE;
|
|
|
|
SELECT warehouseFk, shipped
|
|
INTO vWarehouseFk, vDated
|
|
FROM ticket
|
|
WHERE id = vSelf;
|
|
|
|
CALL buyUltimate(vWarehouseFk, vDated);
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
|
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
|
|
FROM ticket t
|
|
JOIN sale s ON s.ticketFk = tl.ticketFk
|
|
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
|
JOIN buy b ON b.id = bu.buyFk
|
|
WHERE t.id = vSelf;
|
|
|
|
CALL sale_setProblem('hasRounding');
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
|
END$$
|
|
DELIMITER ; |