2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`clean`()
|
|
|
|
BEGIN
|
2024-01-25 16:33:54 +00:00
|
|
|
|
|
|
|
DECLARE vOneYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
|
|
|
|
DECLARE vTwoYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
|
|
|
|
DECLARE vThreeYearAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 3 YEAR;
|
|
|
|
DECLARE vFourYearsAgo DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
|
2024-01-15 11:31:03 +00:00
|
|
|
DECLARE vEighteenMonths DATE DEFAULT util.VN_CURDATE() - INTERVAL 18 MONTH;
|
|
|
|
|
|
|
|
DELETE FROM clientNewBorn
|
|
|
|
WHERE lastShipped < vOneYearAgo;
|
|
|
|
|
|
|
|
DELETE FROM ventas
|
|
|
|
WHERE fecha < vFourYearsAgo;
|
|
|
|
|
|
|
|
DELETE FROM payMethodClient
|
|
|
|
WHERE dated < vOneYearAgo;
|
|
|
|
|
|
|
|
DELETE FROM payMethodClientEvolution
|
|
|
|
WHERE dated < vFourYearsAgo;
|
|
|
|
|
|
|
|
DELETE FROM salesByclientSalesPerson
|
|
|
|
WHERE dated < vFourYearsAgo;
|
|
|
|
|
|
|
|
DELETE FROM m3
|
|
|
|
WHERE fecha < vTwoYearAgo;
|
|
|
|
|
|
|
|
DELETE FROM salesByItemTypeDay
|
|
|
|
WHERE dated < vThreeYearAgo;
|
|
|
|
|
|
|
|
DELETE FROM waste
|
|
|
|
WHERE MAKEDATE(`year`, 1) + INTERVAL (`week` - 1) WEEK + INTERVAL 1 DAY < vEighteenMonths;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|