2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-13 07:54:27 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`(
|
2024-04-16 15:01:14 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-05-02 16:13:12 +00:00
|
|
|
* Update the rounding problem for the sales lines of a ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
*
|
|
|
|
* @param vSelf Id de ticket
|
|
|
|
*/
|
|
|
|
DECLARE vWarehouseFk INT;
|
|
|
|
DECLARE vDated DATE;
|
|
|
|
|
2024-05-03 12:03:26 +00:00
|
|
|
SELECT warehouseFk, shipped
|
2024-04-16 15:01:14 +00:00
|
|
|
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;
|
2024-05-02 15:05:10 +00:00
|
|
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
2024-04-16 15:01:14 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|