2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`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);
|
|
|
|
|
2024-06-27 11:01:42 +00:00
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
|
|
|
(INDEX(saleFk, isProblemCalcNeeded))
|
|
|
|
SELECT s.id saleFk ,
|
|
|
|
MOD(s.quantity, b.`grouping`) hasProblem,
|
|
|
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
2024-04-16 15:01:14 +00:00
|
|
|
FROM ticket t
|
2024-05-22 12:50:45 +00:00
|
|
|
JOIN sale s ON s.ticketFk = t.id
|
2024-04-16 15:01:14 +00:00
|
|
|
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');
|
|
|
|
|
2024-05-22 12:50:45 +00:00
|
|
|
DROP TEMPORARY TABLE tmp.sale;
|
2024-05-02 15:05:10 +00:00
|
|
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
2024-04-16 15:01:14 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|