diff --git a/services/db/install/changes/1.2-CHECK/10-ACL.sql b/services/db/install/changes/1.2-CHECK/10-ACL.sql index e9e0adde6..6063d398e 100644 --- a/services/db/install/changes/1.2-CHECK/10-ACL.sql +++ b/services/db/install/changes/1.2-CHECK/10-ACL.sql @@ -3,3 +3,6 @@ INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission` INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (120, 'Travel', '*', 'WRITE', 'ALLOW', 'role', 'buyer'); INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (121, 'Item', 'regularize', '*', 'ALLOW', 'role', 'employee'); INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES (122, 'TicketRequest', '*', '*', 'ALLOW', 'role', 'employee'); +INSERT INTO `salix`.`fieldAcl` (`model`, `property`, `actionType`, `role`) VALUES('TicketRequest', '*', '*', 'salesPerson'); +UPDATE `salix`.`ACL` SET model='TicketRequest', property='*', accessType='*', permission='ALLOW', principalType='ROLE', principalId='salesPerson' WHERE id=122; +INSERT INTO `salix`.`fieldAcl` (`model`, `property`, `actionType`,`role`) VALUES ('ClaimBeginning','*','*','salesAssistant'); \ No newline at end of file diff --git a/services/db/install/changes/1.2-CHECK/15.last_buy_refresh.sql b/services/db/install/changes/1.2-CHECK/15.last_buy_refresh.sql new file mode 100644 index 000000000..c2fe41d52 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/15.last_buy_refresh.sql @@ -0,0 +1,50 @@ +USE `cache`; +DROP procedure IF EXISTS `last_buy_refresh`; + +DELIMITER $$ +USE `cache`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `last_buy_refresh`(vRefresh BOOL) +proc: BEGIN +/** + * Crea o actualiza la cache con la última compra y fecha de cada + * artículo hasta ayer. Para obtener la última compra hasta una fecha + * determinada utilizar el procedimiento vn2008.item_last_buy_(). + * + * @param vRefresh %TRUE para forzar el recálculo de la cache + **/ + DECLARE vCalc INT; + DECLARE started DATE; + DECLARE ended DATE; + DECLARE vLastRefresh DATE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + CALL cache_calc_unlock (vCalc); + RESIGNAL; + END; + + CALL cache_calc_start (vCalc, vRefresh, 'last_buy', NULL); + + IF !vRefresh + THEN + LEAVE proc; + END IF; + + -- TODO: ¿Se puede usar la fecha del ultimo inventario? + SET started = vn2008.date_inv();-- TIMESTAMPADD(DAY, -90, CURDATE()); + SET ended = CURDATE(); -- TIMESTAMPADD(DAY, -1, CURDATE()); + + CALL vn.buyUltimateFromInterval(NULL, started, ended); + + DELETE FROM last_buy; + + INSERT INTO last_buy (item_id, warehouse_id, buy_id, landing) + SELECT itemFk, warehouseFk, buyFk, landed + FROM tmp.buyUltimateFromInterval; + + DROP TEMPORARY TABLE tmp.buyUltimateFromInterval; + CALL cache_calc_end (vCalc); +END$$ + +DELIMITER ; +