2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-13 08:06:00 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_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 a sales line
|
|
|
|
* @param vSelf Id sale
|
2024-04-16 15:01:14 +00:00
|
|
|
*/
|
|
|
|
DECLARE vItemFk INT;
|
|
|
|
DECLARE vWarehouseFk INT;
|
2024-05-03 08:19:05 +00:00
|
|
|
DECLARE vShipped DATE;
|
2024-04-16 15:01:14 +00:00
|
|
|
DECLARE vQuantity INT;
|
|
|
|
|
2024-05-03 08:19:05 +00:00
|
|
|
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity
|
|
|
|
INTO vItemFk, vWarehouseFk, vShipped, vQuantity
|
2024-04-16 15:01:14 +00:00
|
|
|
FROM sale s
|
|
|
|
JOIN ticket t ON t.id = s.ticketFk
|
|
|
|
WHERE s.id = vSelf;
|
|
|
|
|
2024-05-03 08:19:05 +00:00
|
|
|
CALL buyUltimate(vWarehouseFk, vShipped);
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-05-02 15:05:10 +00:00
|
|
|
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem
|
|
|
|
FROM tmp.buyUltimate bu
|
|
|
|
JOIN buy b ON b.id = bu.buyFk
|
|
|
|
WHERE bu.itemFk = vItemFk;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
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 ;
|