8032-devToTest_2440 #3009
|
@ -1,8 +1,22 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`(
|
||||||
|
vDateFrom DATE,
|
||||||
|
vDateTo DATE
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
|
/**
|
||||||
DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY;
|
* Recalcula las mermas de un periodo.
|
||||||
|
*
|
||||||
|
* @param vDateFrom Fecha desde
|
||||||
|
* @param vDateTo Fecha hasta
|
||||||
|
*/
|
||||||
|
IF vDateFrom IS NULL THEN
|
||||||
|
SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF vDateTo IS NULL THEN
|
||||||
|
SET vDateTo = vDateFrom + INTERVAL 6 DAY;
|
||||||
|
END IF;
|
||||||
|
|
||||||
CALL cache.last_buy_refresh(FALSE);
|
CALL cache.last_buy_refresh(FALSE);
|
||||||
|
|
||||||
|
@ -56,6 +70,6 @@ BEGIN
|
||||||
JOIN vn.buy b ON b.id = lb.buy_id
|
JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
|
WHERE t.shipped BETWEEN vDateFrom AND vDateTo
|
||||||
AND w.isManaged
|
AND w.isManaged
|
||||||
GROUP BY i.id;
|
GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`()
|
||||||
|
BEGIN
|
||||||
|
CALL waste_addSales(NULL, NULL);
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -71,7 +71,10 @@ BEGIN
|
||||||
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN
|
IF NOT (NEW.travelFk <=> OLD.travelFk)
|
||||||
|
OR NOT (NEW.currencyFk <=> OLD.currencyFk)
|
||||||
|
OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN
|
||||||
|
|
||||||
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk);
|
SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
UPDATE bs.nightTask
|
||||||
|
SET `procedure` = 'waste_addSalesLauncher'
|
||||||
|
WHERE `procedure` = 'waste_addSales';
|
|
@ -0,0 +1 @@
|
||||||
|
GRANT EXECUTE ON PROCEDURE bs.waste_addSales TO buyerBoss;
|
Loading…
Reference in New Issue