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`.`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-06-27 11:01:42 +00:00
|
|
|
DECLARE vIsProblemCalcNeeded BOOL;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
2024-06-27 11:01:42 +00:00
|
|
|
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id)
|
|
|
|
INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded
|
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
|
|
|
|
2024-05-22 12:50:45 +00:00
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
2024-06-27 11:01:42 +00:00
|
|
|
SELECT vSelf saleFk,
|
|
|
|
MOD(vQuantity, b.`grouping`) hasProblem,
|
|
|
|
vIsProblemCalcNeeded isProblemCalcNeeded
|
2024-05-02 15:05:10 +00:00
|
|
|
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');
|
|
|
|
|
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 ;
|