From 5e86f67b377f008717ecaa1bbe4dc87509ab73e8 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Mon, 2 Mar 2020 08:18:41 +0100 Subject: [PATCH] dbtest workerTimeControCheck --- .../00-workerTimeControlCheck.sql | 182 ++ .../10161-postValentineDay/00-zoneEvent.sql | 2 - db/dump/dumpedFixtures.sql | 34 +- db/dump/fixtures.sql | 43 +- db/dump/structure.sql | 2657 ++++++++--------- db/tests/vn/workerTimeControlCheck.spec.js | 398 +++ 6 files changed, 1892 insertions(+), 1424 deletions(-) create mode 100644 db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql delete mode 100644 db/changes/10161-postValentineDay/00-zoneEvent.sql create mode 100644 db/tests/vn/workerTimeControlCheck.spec.js diff --git a/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql new file mode 100644 index 000000000..19cd9c4e9 --- /dev/null +++ b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql @@ -0,0 +1,182 @@ + +DROP procedure IF EXISTS `vn`.`workerTimeControl_check`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`workerTimeControl_check`(vUserFk INT, vTabletFk VARCHAR(100), vTimed DATETIME) +BEGIN + +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekMaxBreak INT; + DECLARE vWeekScope INT; + DECLARE vWeekMaxScope INT; + DECLARE vDayStayMax INT; + DECLARE vAskInOut INT; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vDepartmentFk INT; + DECLARE vTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vBody VARCHAR(255) DEFAULT NULL; + + IF (vTimed IS NULL) THEN + SET vTimed = NOW(); + END IF; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax, weekMaxBreak, weekMaxScope, askInOut + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax, vWeekMaxBreak, vWeekMaxScope, vAskInOut + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + direction = 'out'; + + SELECT email INTO vTo + FROM vn.worker w + WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); + + SELECT CONCAT(firstName,' ',lastName) INTO vUserName + FROM vn.worker w + WHERE w.id = vUserFk; + + -- VERIFICAR CONTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk AND + b.date_start <= CURDATE() AND + IFNULL(b.date_end,CURDATE()) >= CURDATE() + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No hay un contrato en vigor"); + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + IF ( SELECT COUNT(*) + FROM vn.tabletDepartment td + JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk + WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk + ) = 0 THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("No perteneces a este departamento."); + END IF; + END IF; + + SELECT IFNULL(dayBreak, vDayBreak) INTO vDayBreak + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql. business_labour bl ON b.business_id = bl.business_id + JOIN postgresql.professional_category pc ON bl.professional_category_id = pc.professional_category_id + WHERE p.id_trabajador = vUserFk AND + b.date_start <= DATE(vTimed) AND + IFNULL(b.date_end, DATE(vTimed)) >= DATE(vTimed); + -- VERIFICAR DESCANSO DIARIO + -- 12 / 9 horas dependiendo del valor de vDayBreak + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vDayBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT("Descansos ", FORMAT(vDayBreak/3600,0) ," h")); + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk AND + timed >= vLastIn + ) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw("Dias con fichadas impares"); + END IF; + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() AND + cs.isAllowedToWork = FALSE AND + w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(vCalendarStateType); + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekScope SECOND)); + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((vTimed - INTERVAL vWeekMaxScope SECOND)); + DROP TEMPORARY TABLE tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekMaxBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (vTimed - INTERVAL vWeekMaxScope SECOND) AND + userFk= vUserFk AND + direction IN ('in','out') + ORDER BY timed ASC; + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastOut) < vWeekMaxBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.throw(CONCAT( "Descansos ", FORMAT(vWeekMaxBreak/3600,0) ," h")); + END IF; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos ", FORMAT(vWeekBreak/3600,0) ," h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + CALL util.warn(CONCAT( "Descansos ", FORMAT(vWeekBreak/3600,0) ," h")); + END IF; + DROP TEMPORARY TABLE tmp.trash; + + -- Preguntar dirección de la fichada + IF UNIX_TIMESTAMP(vTimed) - UNIX_TIMESTAMP(vLastIn) >= vAskInOut AND (SELECT MOD(COUNT(*),2) + FROM vn.workerTimeControl WHERE userFk = vUserFk AND timed >= vLastIn) THEN + CALL util.warn("AskInOut"); + END IF ; +END$$ + +DELIMITER ; diff --git a/db/changes/10161-postValentineDay/00-zoneEvent.sql b/db/changes/10161-postValentineDay/00-zoneEvent.sql deleted file mode 100644 index 1554afbec..000000000 --- a/db/changes/10161-postValentineDay/00-zoneEvent.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `vn`.`zoneEvent` -ADD COLUMN m3Max DECIMAL(10,2) UNSIGNED NULL DEFAULT NULL AFTER bonus; \ No newline at end of file diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 74290b451..acdd3ea14 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -23,7 +23,7 @@ USE `util`; LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'10140',0,'production',NULL); +INSERT INTO `config` VALUES (1,'10160',0,'production',NULL); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:24 USE `account`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(67,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(50,21),(30,22),(5,33),(34,33),(15,35),(41,35),(50,35),(52,35),(65,35),(69,35),(49,36),(61,36),(17,37),(38,37),(60,37),(67,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(69,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(0,67),(0,69),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(9,67),(9,69),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,18),(50,21),(50,35),(50,36),(50,44),(50,47),(50,49),(50,50),(50,53),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,35),(60,36),(60,37),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66),(66,67),(66,69),(67,1),(67,2),(67,3),(67,5),(67,6),(67,11),(67,13),(67,18),(67,21),(67,33),(67,37),(67,53),(67,67),(69,1),(69,2),(69,3),(69,6),(69,11),(69,35),(69,47),(69,69); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -119,7 +119,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(58,'CreditClassification','*','*','ALLOW','ROLE','insurance'),(60,'CreditInsurance','*','*','ALLOW','ROLE','insurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','READ','ALLOW','ROLE','employee'),(66,'TicketTracking','*','READ','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','WRITE','ALLOW','ROLE','deliveryBoss'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'),(78,'TicketTracking','*','WRITE','ALLOW','ROLE','production'),(79,'TicketTracking','changeState','*','ALLOW','ROLE','employee'),(80,'Sale','removes','*','ALLOW','ROLE','employee'),(81,'Sale','moveToTicket','*','ALLOW','ROLE','employee'),(82,'Sale','updateQuantity','*','ALLOW','ROLE','employee'),(83,'Sale','updatePrice','*','ALLOW','ROLE','employee'),(84,'Sale','updateDiscount','*','ALLOW','ROLE','employee'),(85,'SaleTracking','*','READ','ALLOW','ROLE','employee'),(86,'Order','*','*','ALLOW','ROLE','employee'),(87,'OrderRow','*','*','ALLOW','ROLE','employee'),(88,'ClientContact','*','*','ALLOW','ROLE','employee'),(89,'Sale','moveToNewTicket','*','ALLOW','ROLE','employee'),(90,'Sale','reserve','*','ALLOW','ROLE','employee'),(91,'TicketWeekly','*','READ','ALLOW','ROLE','employee'),(94,'Agency','landsThatDay','*','ALLOW','ROLE','employee'),(96,'ClaimEnd','*','READ','ALLOW','ROLE','employee'),(97,'ClaimEnd','*','WRITE','ALLOW','ROLE','salesAssistant'),(98,'ClaimBeginning','*','*','ALLOW','ROLE','employee'),(99,'ClaimDevelopment','*','READ','ALLOW','ROLE','employee'),(100,'ClaimDevelopment','*','WRITE','ALLOW','ROLE','salesAssistant'),(101,'Claim','*','*','ALLOW','ROLE','employee'),(102,'Claim','createFromSales','*','ALLOW','ROLE','employee'),(103,'ClaimEnd','importTicketSales','WRITE','ALLOW','ROLE','salesAssistant'),(104,'Item','*','WRITE','ALLOW','ROLE','marketingBoss'),(105,'ItemBarcode','*','WRITE','ALLOW','ROLE','marketingBoss'),(106,'ItemBotanical','*','WRITE','ALLOW','ROLE','marketingBoss'),(107,'ItemNiche','*','WRITE','ALLOW','ROLE','marketingBoss'),(108,'ItemPlacement','*','WRITE','ALLOW','ROLE','marketingBoss'),(109,'UserConfig','*','*','ALLOW','ROLE','employee'),(110,'Bank','*','READ','ALLOW','ROLE','employee'),(111,'ClientLog','*','READ','ALLOW','ROLE','employee'),(112,'Defaulter','*','READ','ALLOW','ROLE','employee'),(113,'ClientRisk','*','READ','ALLOW','ROLE','employee'),(114,'Receipt','*','READ','ALLOW','ROLE','employee'),(115,'Receipt','*','WRITE','ALLOW','ROLE','administrative'),(116,'BankEntity','*','*','ALLOW','ROLE','employee'),(117,'ClientSample','*','*','ALLOW','ROLE','employee'),(118,'WorkerTeam','*','*','ALLOW','ROLE','salesPerson'),(119,'Travel','*','READ','ALLOW','ROLE','employee'),(120,'Travel','*','WRITE','ALLOW','ROLE','buyer'),(121,'Item','regularize','*','ALLOW','ROLE','employee'),(122,'TicketRequest','*','*','ALLOW','ROLE','employee'),(123,'Worker','*','*','ALLOW','ROLE','employee'),(124,'Client','confirmTransaction','WRITE','ALLOW','ROLE','administrative'),(125,'Agency','getAgenciesWithWarehouse','*','ALLOW','ROLE','employee'),(126,'Client','activeWorkersWithRole','*','ALLOW','ROLE','employee'),(127,'TicketLog','*','READ','ALLOW','ROLE','employee'),(129,'TicketService','*','*','ALLOW','ROLE','employee'),(130,'Expedition','*','WRITE','ALLOW','ROLE','packager'),(131,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(132,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(133,'ItemTag','*','WRITE','ALLOW','ROLE','marketingBoss'),(135,'ZoneGeo','*','READ','ALLOW','ROLE','employee'),(136,'ZoneCalendar','*','READ','ALLOW','ROLE','employee'),(137,'ZoneIncluded','*','READ','ALLOW','ROLE','employee'),(138,'LabourHoliday','*','READ','ALLOW','ROLE','employee'),(139,'LabourHolidayLegend','*','READ','ALLOW','ROLE','employee'),(140,'LabourHolidayType','*','READ','ALLOW','ROLE','employee'),(141,'Zone','*','*','ALLOW','ROLE','deliveryBoss'),(142,'ZoneCalendar','*','WRITE','ALLOW','ROLE','deliveryBoss'),(143,'ZoneIncluded','*','*','ALLOW','ROLE','deliveryBoss'),(144,'Stowaway','*','*','ALLOW','ROLE','employee'),(145,'Ticket','getPossibleStowaways','READ','ALLOW','ROLE','employee'),(147,'UserConfigView','*','*','ALLOW','ROLE','employee'),(148,'UserConfigView','*','*','ALLOW','ROLE','employee'),(149,'Sip','*','READ','ALLOW','ROLE','employee'),(150,'Sip','*','WRITE','ALLOW','ROLE','hr'),(151,'Department','*','READ','ALLOW','ROLE','employee'),(152,'Department','*','WRITE','ALLOW','ROLE','hr'),(153,'Route','*','READ','ALLOW','ROLE','employee'),(154,'Route','*','WRITE','ALLOW','ROLE','delivery'),(155,'WorkerCalendar','*','READ','ALLOW','ROLE','hr'),(156,'WorkerLabour','*','READ','ALLOW','ROLE','hr'),(157,'WorkerCalendar','absences','READ','ALLOW','ROLE','employee'),(158,'ItemTag','*','WRITE','ALLOW','ROLE','accessory'),(160,'TicketServiceType','*','READ','ALLOW','ROLE','employee'),(161,'TicketConfig','*','READ','ALLOW','ROLE','employee'),(162,'InvoiceOut','delete','WRITE','ALLOW','ROLE','invoicing'),(163,'InvoiceOut','book','WRITE','ALLOW','ROLE','invoicing'),(164,'InvoiceOut','regenerate','WRITE','ALLOW','ROLE','invoicing'),(165,'TicketDms','*','READ','ALLOW','ROLE','employee'),(167,'Worker','isSubordinate','READ','ALLOW','ROLE','employee'),(168,'Worker','mySubordinates','READ','ALLOW','ROLE','employee'),(169,'WorkerTimeControl','filter','READ','ALLOW','ROLE','employee'),(170,'WorkerTimeControl','addTime','WRITE','ALLOW','ROLE','employee'),(171,'TicketServiceType','*','WRITE','ALLOW','ROLE','administrative'),(172,'Sms','*','READ','ALLOW','ROLE','employee'),(173,'Sms','send','WRITE','ALLOW','ROLE','employee'),(174,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(175,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(176,'Device','*','*','ALLOW','ROLE','employee'),(177,'Device','*','*','ALLOW','ROLE','employee'),(178,'WorkerTimeControl','*','*','ALLOW','ROLE','employee'),(179,'ItemLog','*','READ','ALLOW','ROLE','employee'),(180,'RouteLog','*','READ','ALLOW','ROLE','employee'),(181,'Dms','removeFile','WRITE','ALLOW','ROLE','employee'),(182,'Dms','uploadFile','WRITE','ALLOW','ROLE','employee'),(183,'Dms','downloadFile','READ','ALLOW','ROLE','employee'),(184,'Client','uploadFile','WRITE','ALLOW','ROLE','employee'),(185,'ClientDms','removeFile','WRITE','ALLOW','ROLE','employee'),(186,'ClientDms','*','READ','ALLOW','ROLE','employee'),(187,'Ticket','uploadFile','WRITE','ALLOW','ROLE','employee'),(188,'TicketDms','removeFile','WRITE','ALLOW','ROLE','employee'),(189,'TicketDms','*','READ','ALLOW','ROLE','employee'),(190,'Route','updateVolume','WRITE','ALLOW','ROLE','deliveryBoss'),(191,'Agency','getLanded','READ','ALLOW','ROLE','employee'),(192,'Agency','getShipped','READ','ALLOW','ROLE','employee'),(194,'Postcode','*','WRITE','ALLOW','ROLE','employee'),(195,'Ticket','addSale','WRITE','ALLOW','ROLE','employee'),(196,'Dms','updateFile','WRITE','ALLOW','ROLE','employee'),(197,'Dms','*','READ','ALLOW','ROLE','employee'),(198,'ClaimDms','removeFile','WRITE','ALLOW','ROLE','employee'),(199,'ClaimDms','*','READ','ALLOW','ROLE','employee'),(200,'Claim','uploadFile','WRITE','ALLOW','ROLE','employee'),(201,'Sale','updateConcept','WRITE','ALLOW','ROLE','employee'),(202,'Claim','updateClaimAction','WRITE','ALLOW','ROLE','salesAssistant'),(203,'UserPhone','*','*','ALLOW','ROLE','employee'),(204,'WorkerDms','removeFile','WRITE','ALLOW','ROLE','hr'),(205,'WorkerDms','*','READ','ALLOW','ROLE','hr'),(206,'Chat','*','*','ALLOW','ROLE','employee'),(207,'Chat','sendMessage','*','ALLOW','ROLE','employee'),(208,'Sale','recalculatePrice','WRITE','ALLOW','ROLE','employee'),(209,'Ticket','recalculateComponents','WRITE','ALLOW','ROLE','employee'),(211,'TravelLog','*','READ','ALLOW','ROLE','buyer'),(212,'Thermograph','*','*','ALLOW','ROLE','buyer'),(213,'TravelThermograph','*','*','ALLOW','ROLE','buyer'),(214,'Entry','*','*','ALLOW','ROLE','buyer'),(215,'TicketWeekly','*','WRITE','ALLOW','ROLE','buyer'),(216,'TravelThermograph','*','READ','ALLOW','ROLE','employee'),(217,'CustomsAgent','*','*','ALLOW','ROLE','employee'),(218,'Intrastat','*','*','ALLOW','ROLE','buyer'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -227,7 +227,7 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL),(110,'','Envase',1,0,NULL,NULL,NULL),(111,'','Nº piezas',1,0,NULL,NULL,NULL),(112,'','Uso',1,0,NULL,'cm',NULL); +INSERT INTO `tag` VALUES (1,'color','Color',0,0,'ink',NULL,NULL),(2,'','Forma',1,0,NULL,NULL,NULL),(3,'','Material',1,0,NULL,NULL,NULL),(4,'','Longitud',1,1,NULL,'mm',NULL),(5,'','Diámetro',1,1,NULL,'mm',NULL),(6,'','Perímetro',1,1,NULL,'mm',NULL),(7,'','Ancho de la base',1,1,NULL,'mm',NULL),(8,'','Altura',1,1,NULL,'mm',NULL),(9,'','Volumen',1,1,NULL,'ml',NULL),(10,'','Densidad',1,1,NULL,NULL,NULL),(11,'','Calidad',1,0,NULL,NULL,NULL),(12,'','Textura',1,0,NULL,NULL,NULL),(13,'','Material del mango',1,0,NULL,NULL,NULL),(14,'','Compra mínima',1,0,NULL,NULL,NULL),(15,'','Nº pétalos',1,1,NULL,NULL,NULL),(16,'','Ancho',1,1,NULL,'mm',NULL),(18,'','Profundidad',1,1,NULL,'mm',NULL),(19,'','Largo',1,1,NULL,'mm',NULL),(20,'','Ancho superior',1,1,NULL,'mm',NULL),(21,'','Ancho inferior',1,1,NULL,'mm',NULL),(22,'','Gramaje',1,1,NULL,'g',NULL),(23,'stems','Tallos',1,1,NULL,NULL,NULL),(24,'','Estado',1,0,NULL,NULL,NULL),(25,'','Color principal',0,0,'ink',NULL,NULL),(26,'','Color secundario',0,0,'ink',NULL,NULL),(27,'','Longitud(cm)',1,1,NULL,'cm',NULL),(28,'','Diámetro base',1,1,'','mm',NULL),(29,'','Colección',1,0,NULL,NULL,NULL),(30,'','Uds / caja',1,1,NULL,NULL,NULL),(31,'','Contenido',1,0,NULL,NULL,NULL),(32,'','Peso',1,1,NULL,'g',NULL),(33,'','Grosor',1,1,NULL,'mm',NULL),(34,'','Marca',1,0,NULL,NULL,NULL),(35,'origin','Origen',0,0,'origin',NULL,NULL),(36,'','Proveedor',1,0,NULL,NULL,NULL),(37,'producer','Productor',0,0,'producer',NULL,NULL),(38,'','Duración',1,1,NULL,'s',NULL),(39,'','Flor',1,0,NULL,NULL,NULL),(40,'','Soporte',1,0,NULL,NULL,NULL),(41,'','Tamaño flor',1,0,NULL,NULL,NULL),(42,'','Apertura',1,0,NULL,NULL,NULL),(43,'','Tallo',1,0,NULL,NULL,NULL),(44,'','Nº hojas',1,1,NULL,NULL,NULL),(45,'','Dimensiones',1,0,NULL,NULL,NULL),(46,'','Diámetro boca',1,1,NULL,'mm',NULL),(47,'','Nº flores',1,1,NULL,NULL,NULL),(48,'','Uds / paquete',1,1,NULL,NULL,NULL),(49,'','Maceta',1,1,NULL,'cm',NULL),(50,'','Textura flor',1,0,NULL,NULL,NULL),(51,'','Textura hoja',1,0,NULL,NULL,NULL),(52,'','Tipo de IVA',1,0,NULL,NULL,NULL),(53,'','Tronco',1,0,NULL,NULL,NULL),(54,'','Hoja',1,0,NULL,NULL,NULL),(55,'','Formato',1,0,NULL,NULL,NULL),(56,'','Genero',1,0,NULL,NULL,NULL),(57,'','Especie',1,0,NULL,NULL,NULL),(58,'','Variedad',1,0,NULL,NULL,NULL),(59,'','Medida grande',1,0,NULL,NULL,NULL),(60,'','Medida mediano',1,0,NULL,NULL,NULL),(61,'','Medida pequeño',1,0,NULL,NULL,NULL),(62,'','Medida pequeño',1,0,NULL,NULL,NULL),(63,'','Recipiente interior',1,0,NULL,NULL,NULL),(64,'','Material secundario',1,0,NULL,NULL,NULL),(65,'','Colores',1,0,NULL,NULL,NULL),(66,'','Referencia',1,0,NULL,NULL,NULL),(67,'','Categoria',1,0,NULL,NULL,NULL),(68,'','Amb',1,0,NULL,NULL,NULL),(69,'','Anchura',1,1,NULL,'cm',NULL),(70,'','Hueco interior',1,0,NULL,NULL,NULL),(71,'','Tamaño',1,0,NULL,NULL,NULL),(72,'','Color botón',1,0,NULL,NULL,NULL),(73,'','Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'','Obtentor',1,0,NULL,NULL,NULL),(75,'','Longitud del brote',1,0,NULL,NULL,NULL),(76,'','Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'','Madera de',1,0,NULL,NULL,NULL),(78,'','Unidad de venta',1,0,NULL,NULL,NULL),(79,'','Temporal',1,0,NULL,NULL,NULL),(80,'','Gramaje/tallo',1,1,NULL,'g',NULL),(81,'','Peso/paquete',1,1,NULL,'g',NULL),(82,'','Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'','Nº planchas',1,1,NULL,NULL,NULL),(84,'','Nº páginas',1,1,NULL,NULL,NULL),(85,'','Editorial',1,0,NULL,NULL,NULL),(86,'','Idioma',1,0,NULL,NULL,NULL),(87,'','Fecha publicación',1,0,NULL,NULL,NULL),(88,'','Cubierta',1,0,NULL,NULL,NULL),(89,'','Encuadernación',1,0,NULL,NULL,NULL),(90,'','Autor',1,0,NULL,NULL,NULL),(91,'','Envoltorio',1,0,NULL,NULL,NULL),(92,'','Nombre temporal',1,0,NULL,NULL,NULL),(93,'','Modelo',1,0,NULL,NULL,NULL),(94,'','Producto',1,0,NULL,NULL,NULL),(95,'','Título',1,0,NULL,NULL,NULL),(96,'','Tomo',1,0,NULL,NULL,NULL),(97,'','Articulo',1,0,NULL,NULL,NULL),(98,'','Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'','Edad',1,0,NULL,NULL,NULL),(100,'','Agotado',1,0,NULL,NULL,NULL),(101,'','Altura con asa',1,1,NULL,'cm',NULL),(102,'','Nº tallos',1,1,NULL,NULL,NULL),(103,'','Cultivo',1,0,NULL,NULL,NULL),(104,'','Sabor',1,0,NULL,NULL,NULL),(105,'','Talla',1,0,NULL,NULL,NULL),(106,'','Calibre',1,1,NULL,NULL,NULL),(107,'','Dulzura',1,1,NULL,'bx',NULL),(108,'','Piezas',1,0,NULL,NULL,NULL),(109,'','Altura con patas',1,0,NULL,NULL,NULL),(110,'','Envase',1,0,NULL,NULL,NULL),(111,'','Nº piezas',1,0,NULL,NULL,NULL),(112,'','Uso',1,0,NULL,'cm',NULL),(113,'','Color luz',1,0,NULL,NULL,NULL),(114,'','Capacidad',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; @@ -277,7 +277,7 @@ UNLOCK TABLES; LOCK TABLES `ticketUpdateAction` WRITE; /*!40000 ALTER TABLE `ticketUpdateAction` DISABLE KEYS */; -INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket'),(3,'Convertir en maná'); +INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','changePrice'),(3,'Convertir en maná','turnInMana'); /*!40000 ALTER TABLE `ticketUpdateAction` ENABLE KEYS */; UNLOCK TABLES; @@ -287,7 +287,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0),(2,'Libre',1,0,'FREE',NULL,2,0,0,0,0),(3,'OK',3,0,'OK',3,28,1,0,0,0),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0,0,0,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0),(24,'Encadenado',3,0,'CHAINED',4,24,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0),(2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,1),(3,'OK',3,0,'OK',3,28,1,0,0,0,1),(4,'Impreso',4,1,'PRINTED',2,29,1,0,1,0,0),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0,0,0,2,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0),(7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,1),(8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0),(9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0),(10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0,1,0,0,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0,0,0,0,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1,0,0,0,0),(21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0,0,0,0,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1,0,0,0,0),(24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0),(25,'Embarcando',3,0,'BOARDING',5,25,0,0,0,0,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0,0,0,1,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0),(28,'Previa OK',3,1,'OK PREVIOUS',3,28,1,0,0,1,1),(29,'Previa Impreso',4,1,'PRINTED PREVIOUS',2,29,1,0,1,1,0),(30,'Embarcado',4,0,'BOARD',5,30,0,0,0,2,0); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -297,7 +297,7 @@ UNLOCK TABLES; LOCK TABLES `sample` WRITE; /*!40000 ALTER TABLE `sample` DISABLE KEYS */; -INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,'0'),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,'0'),(3,'Cred_Up','Notificación de aumento de crédito',0,'0'),(4,'Cred_down','Notificación de reducción de crédito',0,'0'),(5,'Pet_CC','Petición de datos bancarios B2B',0,'0'),(6,'SolCredito','Solicitud de crédito',0,'0'),(7,'LeyPago','Ley de pagos',0,'0'),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,'0'),(9,'nueva_alta','Documento de nueva alta de cliente',0,'0'),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,'0'),(11,'setup_printer','Email de instalación de impresora',0,'0'),(12,'client-welcome','Bienvenida como nuevo cliente',1,'0'),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,'0'),(14,'sepa-core','Solicitud de domiciliación bancaria',1,'1'),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,'1'),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,'1'),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,'1'); +INSERT INTO `sample` VALUES (1,'Carta_1','Aviso inicial por saldo deudor',0,0,1),(2,'Carta_2','Reiteracion de aviso por saldo deudor',0,0,1),(3,'Cred_Up','Notificación de aumento de crédito',0,0,1),(4,'Cred_down','Notificación de reducción de crédito',0,0,1),(5,'Pet_CC','Petición de datos bancarios B2B',0,0,1),(6,'SolCredito','Solicitud de crédito',0,0,1),(7,'LeyPago','Ley de pagos',0,0,1),(8,'Pet_CC_Core','Petición de datos bancarios CORE',0,0,1),(9,'nueva_alta','Documento de nueva alta de cliente',0,0,1),(10,'client_welcome','Email de bienvenida para nuevo cliente',0,0,1),(11,'setup_printer','Email de instalación de impresora',0,0,1),(12,'client-welcome','Bienvenida como nuevo cliente',1,0,1),(13,'printer-setup','Instalación y configuración de impresora de coronas',1,0,1),(14,'sepa-core','Solicitud de domiciliación bancaria',1,1,0),(15,'letter-debtor-st','Aviso inicial por saldo deudor',1,1,1),(16,'letter-debtor-nd','Aviso reiterado por saldo deudor',1,1,1),(17,'client-lcr','Email de solicitud de datos bancarios LCR',0,1,1); /*!40000 ALTER TABLE `sample` ENABLE KEYS */; UNLOCK TABLES; @@ -307,7 +307,7 @@ UNLOCK TABLES; LOCK TABLES `department` WRITE; /*!40000 ALTER TABLE `department` DISABLE KEYS */; -INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,24,NULL,72,230,3,11,0,0,0,4,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',25,26,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',27,48,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',49,50,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',51,52,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',53,54,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',55,56,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',57,58,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',59,60,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',61,62,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',63,64,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',65,66,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',67,68,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',69,70,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',71,72,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',73,74,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',28,29,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',75,76,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',77,78,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',79,80,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',30,31,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',81,82,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',83,84,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',85,86,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',87,88,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',89,90,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',42,43,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',44,45,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',46,47,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'); +INSERT INTO `department` VALUES (1,'VERDNATURA',1,2,763,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(22,'COMPRAS',3,4,NULL,72,596,2,5,0,0,0,0,NULL,'/',NULL),(23,'CAMARA',5,6,NULL,72,604,2,6,1,0,0,0,NULL,'/',NULL),(31,'INFORMATICA',7,8,NULL,72,127,3,9,0,0,0,0,NULL,'/','informatica'),(34,'CONTABILIDAD',9,10,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(35,'FINANZAS',11,12,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(36,'LABORAL',13,14,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(37,'PRODUCCION',15,42,NULL,72,230,3,11,0,0,0,13,NULL,'/',NULL),(38,'SACADO',16,17,NULL,72,230,4,14,1,0,1,0,37,'/37/',NULL),(39,'ENCAJADO',18,19,NULL,72,230,4,12,1,0,1,0,37,'/37/',NULL),(41,'ADMINISTRACION',43,44,NULL,72,599,3,8,0,0,0,0,NULL,'/',NULL),(43,'VENTAS',45,66,NULL,0,NULL,NULL,NULL,0,0,0,10,NULL,'/',NULL),(44,'GERENCIA',67,68,NULL,72,300,2,7,0,0,0,0,NULL,'/',NULL),(45,'LOGISTICA',69,70,NULL,72,596,3,19,0,0,0,0,NULL,'/',NULL),(46,'REPARTO',20,21,NULL,72,659,3,10,0,0,1,0,37,'/37/',NULL),(48,'ALMACENAJE',71,72,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(49,'PROPIEDAD',73,74,NULL,72,1008,1,1,0,0,0,0,NULL,'/',NULL),(52,'CARGA AEREA',75,76,NULL,72,163,4,28,0,0,0,0,NULL,'/',NULL),(53,'MARKETING Y COMUNICACIÓN',77,78,NULL,72,1238,0,0,0,0,0,0,NULL,'/',NULL),(54,'ORNAMENTALES',79,80,NULL,72,433,3,21,0,0,0,0,NULL,'/',NULL),(55,'TALLER NATURAL',81,82,NULL,72,695,2,23,0,0,0,0,NULL,'/',NULL),(56,'TALLER ARTIFICIAL',83,84,NULL,72,1780,2,24,0,0,0,0,NULL,'/',NULL),(58,'CAMPOS',85,86,NULL,72,225,2,2,0,0,0,0,NULL,'/',NULL),(59,'MANTENIMIENTO',87,88,NULL,72,1907,4,16,0,0,0,0,NULL,'/',NULL),(60,'RECLAMACIONES',89,90,NULL,72,563,3,20,0,0,0,0,NULL,'/',NULL),(61,'VNH',91,92,NULL,73,1297,3,17,0,0,0,0,NULL,'/',NULL),(63,'VENTAS FRANCIA',46,47,NULL,72,277,2,27,0,0,1,0,43,'/43/',NULL),(66,'VERDNAMADRID',93,94,NULL,72,163,3,18,0,0,0,0,NULL,'/',NULL),(68,'COMPLEMENTOS',95,96,NULL,72,617,3,26,1,0,0,0,NULL,'/',NULL),(69,'VERDNABARNA',97,98,NULL,74,432,3,22,0,0,0,0,NULL,'/',NULL),(77,'PALETIZADO',22,23,NULL,72,230,4,15,1,0,1,0,37,'/37/',NULL),(80,'EQUIPO J VALLES',48,49,NULL,72,693,3,4,0,0,1,0,43,'/43/','jvp_equipo'),(86,'LIMPIEZA',99,100,NULL,72,599,0,0,0,0,0,0,NULL,'/',NULL),(89,'COORDINACION',101,102,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(90,'TRAILER',103,104,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(91,'ARTIFICIAL',105,106,NULL,0,NULL,NULL,NULL,1,0,0,0,NULL,'/',NULL),(92,'EQUIPO SILVERIO',50,51,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','sdc_equipo'),(93,'CONFECCION',107,108,NULL,0,NULL,NULL,NULL,0,0,0,0,NULL,'/',NULL),(94,'EQUIPO J BROCAL',52,53,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jes_equipo'),(95,'EQUIPO C ZAMBRANO',54,55,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','czg_equipo'),(96,'EQUIPO C LOPEZ',56,57,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','cla_equipo'),(97,'EQUIPO D SARRION',58,59,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','dsr_equipo'),(98,'EQUIPO RODRIGO',60,61,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','rhr_equipo'),(99,'EQUIPO MANOLI',62,63,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','man_equipo'),(101,'EQUIPO J IBAÑEZ',64,65,NULL,0,NULL,NULL,NULL,0,0,1,0,43,'/43/','jmi_equipo'),(102,'EQ ROJO FV RUBEN C',24,25,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(103,'EQ AZUL FV A FOLQUES',26,27,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(104,'EQ AMARILLO FV NORMAN G',28,29,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(105,'EQ MORADO FV MATOU',30,31,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(106,'EQ VERDE PCA KEVIN GIMENEZ',32,33,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(107,'EQ NARANJA PCA RUBEN ZANON',34,35,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(109,'EQ MARRON PCA JC ESTELLES',36,37,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(110,'EQ ROSA PCA J BONDIA',38,39,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL),(111,'EQ REPONEDOR CAJAS',40,41,NULL,0,NULL,NULL,NULL,0,0,1,0,37,'/37/',NULL); /*!40000 ALTER TABLE `department` ENABLE KEYS */; UNLOCK TABLES; @@ -340,7 +340,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:25 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -378,7 +378,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:05 +-- Dump completed on 2020-02-27 13:26:26 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -436,7 +436,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:06 +-- Dump completed on 2020-02-27 13:26:26 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.28, for osx10.15 (x86_64) -- @@ -491,7 +491,7 @@ UNLOCK TABLES; LOCK TABLES `professional_category` WRITE; /*!40000 ALTER TABLE `professional_category` DISABLE KEYS */; -INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5),(2,'Encargados',3,1,27.5),(4,'Comprador',3,1,27.5),(5,'Aux Administracion',NULL,1,27.5),(6,'Of Administracion',3,1,27.5),(7,'Jefe Administracion',2,1,27.5),(8,'Informatico',3,1,27.5),(9,'Directivo',1,0,27.5),(10,'Aux Ventas',4,1,27.5),(11,'Vendedor',4,1,27.5),(12,'Jefe de Ventas',4,0,27.5),(13,'Repartidor',5,1,27.5),(14,'Aprendices',NULL,1,27.5),(15,'Técnicos',2,1,27.5),(16,'Aux Florista',5,1,27.5),(17,'Florista',4,1,27.5),(18,'Jefe Floristas',2,1,27.5),(19,'Técnico marketing',3,1,27.5),(20,'Auxiliar marketing',4,1,27.5),(21,'Aux Informática',4,1,27.5),(22,'Peón agrícola',5,1,27.5),(23,'Oficial mantenimiento',4,1,27.5),(24,'Aux mantenimiento',5,1,27.5),(25,'Mozo Aeropuerto',5,1,27.5),(26,'Coordinador',2,1,27.5),(28,'Aux Logistica',4,1,27.5),(29,'Oficial Logistica',3,1,27.5),(30,'Subencargado',4,1,27.5),(31,'Conductor +3500kg',NULL,1,NULL); +INSERT INTO `professional_category` VALUES (1,'Mozos',5,1,27.5,NULL),(2,'Encargados',3,1,27.5,NULL),(4,'Comprador',3,1,27.5,NULL),(5,'Aux Administracion',NULL,1,27.5,NULL),(6,'Of Administracion',3,1,27.5,NULL),(7,'Jefe Administracion',2,1,27.5,NULL),(8,'Informatico',3,1,27.5,NULL),(9,'Directivo',1,0,27.5,NULL),(10,'Aux Ventas',4,1,27.5,NULL),(11,'Vendedor',4,1,27.5,NULL),(12,'Jefe de Ventas',4,0,27.5,NULL),(13,'Repartidor',5,1,27.5,NULL),(14,'Aprendices',NULL,1,27.5,NULL),(15,'Técnicos',2,1,27.5,NULL),(16,'Aux Florista',5,1,27.5,NULL),(17,'Florista',4,1,27.5,NULL),(18,'Jefe Floristas',2,1,27.5,NULL),(19,'Técnico marketing',3,1,27.5,NULL),(20,'Auxiliar marketing',4,1,27.5,NULL),(21,'Aux Informática',4,1,27.5,NULL),(22,'Peón agrícola',5,1,27.5,NULL),(23,'Oficial mantenimiento',4,1,27.5,NULL),(24,'Aux mantenimiento',5,1,27.5,NULL),(25,'Mozo Aeropuerto',5,1,27.5,NULL),(26,'Coordinador',2,1,27.5,NULL),(28,'Aux Logistica',4,1,27.5,NULL),(29,'Oficial Logistica',3,1,27.5,NULL),(30,'Subencargado',4,1,27.5,NULL),(31,'Conductor +3500kg',NULL,1,27.5,32400),(32,'Oficial 1ª',NULL,1,27.5,NULL),(33,'Oficial 2ª',NULL,1,27.5,NULL),(34,'Supervisor',NULL,1,27.5,NULL); /*!40000 ALTER TABLE `professional_category` ENABLE KEYS */; UNLOCK TABLES; @@ -524,4 +524,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:06 +-- Dump completed on 2020-02-27 13:26:27 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 2f3a9378d..3dff43eb7 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -39,8 +39,8 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active` FROM `account`.`role` WHERE id <> 20 ORDER BY id; -INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) - SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 +INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`, `email`) + SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9, 'test@nightmare.es' FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; @@ -68,13 +68,13 @@ INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`, (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'), (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'en'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `email`) VALUES - (106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106), - (107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107), - (108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108), - (109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109), - (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110); + (106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106, 'test@nightmare.es'), + (107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107, 'test@nightmare.es'), + (108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108, 'test@nightmare.es'), + (109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109, 'test@nightmare.es'), + (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110, 'test@nightmare.es'); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`) VALUES @@ -1580,6 +1580,13 @@ INSERT INTO `postgresql`.`business_labour`(`business_id`, `notes`, `department_i SELECT b.business_id, NULL, 23, 1, 0, 1, 1, 1, 1 FROM `postgresql`.`business` `b`; +UPDATE `postgresql`.`business_labour` bl + JOIN `postgresql`.`business` b ON b.business_id = bl.business_id + JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id + JOIN `postgresql`.`person` p ON p.person_id = pr.person_id + SET bl.`professional_category_id` = 31 + WHERE p.`Id_trabajador` = 110; + INSERT INTO `postgresql`.`media`(`media_id`, `media_type_id`, `value`, `sort`) VALUES (1, 10, 600123321, 0), @@ -1951,9 +1958,9 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`) (2, 'Normal'), (3, 'Baja'); -INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`) +INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`, `weekMaxBreak`, `weekMaxScope`, `askInOut`) VALUES - (1, 43200, 129600, 734400, 43200, 50400); + (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); @@ -1973,11 +1980,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms` (`code`, `name`) +REPLACE INTO `vn`.`incoterms`(`code`, `name`) VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent` (`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), - (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); \ No newline at end of file + (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); + +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) + VALUES + (1, 23), + (2, 1); + +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES + ('1', 'TEST', 'ON THE FIXTURES', '0'), + ('2', 'DEV', 'OTHER TABLET', '0'); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 35cb82fd4..c008cb055 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1948,6 +1948,22 @@ CREATE TABLE `compradores_evolution` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorStats` +-- + +DROP TABLE IF EXISTS `conveyorStats`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorStats` ( + `created` datetime NOT NULL, + `saturacion` int(11) DEFAULT NULL, + `velocidad` int(11) DEFAULT NULL, + `rutas` int(11) DEFAULT NULL, + PRIMARY KEY (`created`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `defaulter` -- @@ -8028,7 +8044,8 @@ CREATE TABLE `supplyResponse` ( `MarketFormCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), - KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' + KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n', + KEY `supplyResponse_Ix1` (`Item_ArticleCode`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11896,7 +11913,8 @@ BEGIN * * @param vSelf The order identifier */ - CALL order_confirmWithUser(vSelf, account.userGetId()); + DECLARE vUser INT DEFAULT account.userGetId(); + CALL order_confirmWithUser(vSelf, vUser); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -14833,6 +14851,8 @@ CREATE TABLE `calendar_state` ( `permissionRate` decimal(3,2) DEFAULT NULL, `code` varchar(45) DEFAULT NULL, `isAllowedToWork` tinyint(4) NOT NULL DEFAULT '0', + `isPrintable` tinyint(1) NOT NULL DEFAULT '0', + `discountRate` decimal(3,2) DEFAULT NULL, PRIMARY KEY (`calendar_state_id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15038,6 +15058,7 @@ CREATE TABLE `professional_category` ( `professional_levels_id` int(11) DEFAULT NULL, `fichajes` tinyint(4) NOT NULL DEFAULT '1', `holiday_days` decimal(3,1) DEFAULT NULL, + `dayBreak` int(11) DEFAULT NULL, PRIMARY KEY (`professional_category_id`), UNIQUE KEY `professional_category_name_category_key` (`category_name`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8; @@ -17626,6 +17647,43 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `procNoOverlap` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`jenkins`@`172.16.%.%` PROCEDURE `procNoOverlap`(procName VARCHAR(255)) + SQL SECURITY INVOKER +proc: BEGIN +/** + * call procedure without overlap + */ + DECLARE vIsChanged BOOL; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK(procName); + RESIGNAL; + END; + + IF !GET_LOCK(procName, 0) THEN + LEAVE proc; + END IF; + + CALL exec(CONCAT('CALL ', procName)); + + DO RELEASE_LOCK(procName); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `proc_changedPrivs` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -17979,6 +18037,8 @@ CREATE TABLE `address` ( `latitude` decimal(11,7) DEFAULT NULL, `codPosOld` char(5) COLLATE utf8_unicode_ci DEFAULT NULL, `isEqualizated` tinyint(1) DEFAULT NULL, + `customsAgentFk` int(11) DEFAULT NULL, + `incotermsFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Id_cliente` (`clientFk`), @@ -17987,10 +18047,14 @@ CREATE TABLE `address` ( KEY `telefono` (`phone`), KEY `movil` (`mobile`), KEY `CODPOSTAL` (`postalCode`), + KEY `address_customsAgentFk_idx` (`customsAgentFk`), + KEY `address_incotermsFk_idx` (`incotermsFk`), CONSTRAINT `address_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, + CONSTRAINT `address_customsAgentFk` FOREIGN KEY (`customsAgentFk`) REFERENCES `customsAgent` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, - CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE + CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, + CONSTRAINT `address_incotermsFk` FOREIGN KEY (`incotermsFk`) REFERENCES `incoterms` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -19462,6 +19526,48 @@ CREATE TABLE `clientManaCache` ( CONSTRAINT `cliente_fk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_INSERT` AFTER INSERT ON `clientManaCache` FOR EACH ROW +BEGIN + IF NEW.clientFk = 7157 THEN + INSERT INTO mail(sender, replyTo, `subject`, body) + SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`clientManaCache_AFTER_UPDATE` AFTER UPDATE ON `clientManaCache` FOR EACH ROW +BEGIN + IF NEW.clientFk = 7157 THEN + INSERT INTO mail(sender, replyTo, `subject`, body) + SELECT 'carlosap@verdnatura.es','carlosap@verdnatura.es','Mana cliente 7157 ', CONCAT(current_user(), USER()); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; -- -- Temporary table structure for view `clientManaCache__` @@ -20121,6 +20227,7 @@ CREATE TABLE `conveyorExpedition` ( `x` int(11) NOT NULL DEFAULT '1', `y` int(11) NOT NULL DEFAULT '1', `routeFk` int(11) NOT NULL, + `isBuilt` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`expeditionFk`), KEY `conveyorExpedition_fk1_idx` (`conveyorFk`), KEY `conveyorExpedition_fk2_idx` (`conveyorBuildingClassFk`), @@ -20129,6 +20236,21 @@ CREATE TABLE `conveyorExpedition` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorMode` +-- + +DROP TABLE IF EXISTS `conveyorMode`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorMode` ( + `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `saturacion` int(11) NOT NULL, + `gap` int(11) NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `conveyorType` -- @@ -20473,6 +20595,25 @@ CREATE TABLE `currency` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `customsAgent` +-- + +DROP TABLE IF EXISTS `customsAgent`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `customsAgent` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `fiscalName` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `street` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `nif` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, + `phone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `email` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `nif_UNIQUE` (`nif`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `dayMinute` -- @@ -20880,6 +21021,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Table structure for table `dmsRecover` +-- + +DROP TABLE IF EXISTS `dmsRecover`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `dmsRecover` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ticketFk` int(11) DEFAULT NULL, + `sign` text COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`), + KEY `ticketFk_idx` (`ticketFk`), + CONSTRAINT `ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `dmsType` -- @@ -21823,45 +21981,59 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayDetail` +-- Temporary table structure for view `holidayDetail__` -- -DROP TABLE IF EXISTS `holidayDetail`; -/*!50001 DROP VIEW IF EXISTS `holidayDetail`*/; +DROP TABLE IF EXISTS `holidayDetail__`; +/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayDetail` AS SELECT +/*!50001 CREATE VIEW `holidayDetail__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayLegend` +-- Temporary table structure for view `holidayLegend__` -- -DROP TABLE IF EXISTS `holidayLegend`; -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +DROP TABLE IF EXISTS `holidayLegend__`; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayLegend` AS SELECT +/*!50001 CREATE VIEW `holidayLegend__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayType` +-- Temporary table structure for view `holidayType__` -- -DROP TABLE IF EXISTS `holidayType`; -/*!50001 DROP VIEW IF EXISTS `holidayType`*/; +DROP TABLE IF EXISTS `holidayType__`; +/*!50001 DROP VIEW IF EXISTS `holidayType__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayType` AS SELECT +/*!50001 CREATE VIEW `holidayType__` AS SELECT 1 AS `id`, 1 AS `name`, 1 AS `rgb`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `incoterms` +-- + +DROP TABLE IF EXISTS `incoterms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `incoterms` ( + `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Internacional Commercial Terms'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ink` -- @@ -22324,7 +22496,7 @@ CREATE TABLE `item` ( `image` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `inkFk` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, `niche` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `intrastatFk` int(8) unsigned zerofill DEFAULT NULL, + `intrastatFk` int(8) unsigned zerofill NOT NULL DEFAULT '06039010', `hasMinPrice` tinyint(1) NOT NULL DEFAULT '0', `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `isOnOffer` tinyint(4) NOT NULL DEFAULT '0', @@ -22990,9 +23162,7 @@ CREATE TABLE `itemShelving` ( DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_INSERT` BEFORE INSERT ON `itemShelving` FOR EACH ROW BEGIN - SET NEW.userFk = account.userGetId(); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23008,11 +23178,9 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`z-developer`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE` BEFORE UPDATE ON `itemShelving` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemShelving_BEFORE_UPDATE` BEFORE UPDATE ON `itemShelving` FOR EACH ROW BEGIN - SET NEW.userFk = account.userGetId(); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23638,6 +23806,19 @@ CREATE TABLE `labourTree` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `lastHourProduction` +-- + +DROP TABLE IF EXISTS `lastHourProduction`; +/*!50001 DROP VIEW IF EXISTS `lastHourProduction`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `lastHourProduction` AS SELECT + 1 AS `warehouseFk`, + 1 AS `m3`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `lastTopClaims` -- @@ -25076,6 +25257,7 @@ CREATE TABLE `route` ( `m3` decimal(10,1) unsigned DEFAULT NULL, `description` text COLLATE utf8_unicode_ci, `zoneFk` int(11) DEFAULT NULL, + `priority` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), @@ -25090,6 +25272,26 @@ CREATE TABLE `route` ( /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`route_AFTER_INSERT` AFTER INSERT ON `route` FOR EACH ROW +BEGIN + IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN + CALL util.throw ('KmEnd menor que kmStart'); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ; @@ -25104,7 +25306,11 @@ BEGIN FROM vn.saleVolume s JOIN vn.ticket t ON s.ticketFk = t.id WHERE t.routeFk = NEW.id); - END IF; + END IF; + + IF NEW.kmEnd < NEW.kmStart AND NEW.kmEnd <> 0 THEN + CALL util.throw ('KmEnd menor que kmStart'); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25200,7 +25406,6 @@ CREATE TABLE `routeGate` ( `lastScanned` datetime DEFAULT NULL, `ready` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`deviceId`), - UNIQUE KEY `routeFk_UNIQUE` (`routeFk`), KEY `routeGate_fk1_idx` (`gateAreaFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -25478,7 +25683,7 @@ CREATE TABLE `saleComponent` ( `saleFk` int(11) NOT NULL, `componentFk` int(11) NOT NULL, `value` double NOT NULL, - `isGreuge` tinyint(4) NOT NULL DEFAULT '0', + `isGreuge` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Indica si ya se ha tenido en cuenta para calcular el greuge', `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`saleFk`,`componentFk`), KEY `fk_mov_comp_idx` (`componentFk`), @@ -25488,14 +25693,14 @@ CREATE TABLE `saleComponent` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `saleFreight` +-- Temporary table structure for view `saleFreight__` -- -DROP TABLE IF EXISTS `saleFreight`; -/*!50001 DROP VIEW IF EXISTS `saleFreight`*/; +DROP TABLE IF EXISTS `saleFreight__`; +/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `saleFreight` AS SELECT +/*!50001 CREATE VIEW `saleFreight__` AS SELECT 1 AS `ticketFk`, 1 AS `clientFk`, 1 AS `routeFk`, @@ -25504,8 +25709,7 @@ SET character_set_client = utf8; 1 AS `companyFk`, 1 AS `shipped`, 1 AS `price`, - 1 AS `freight`, - 1 AS `volume`*/; + 1 AS `freight`*/; SET character_set_client = @saved_cs_client; -- @@ -25635,7 +25839,45 @@ SET character_set_client = utf8; 1 AS `volume`, 1 AS `physicalWeight`, 1 AS `weight`, - 1 AS `physicalVolume`*/; + 1 AS `physicalVolume`, + 1 AS `freight`, + 1 AS `zoneFk`, + 1 AS `clientFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `saleVolume__` +-- + +DROP TABLE IF EXISTS `saleVolume__`; +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `saleVolume__` AS SELECT + 1 AS `ticketFk`, + 1 AS `saleFk`, + 1 AS `litros`, + 1 AS `routeFk`, + 1 AS `shipped`, + 1 AS `volume`, + 1 AS `physicalWeight`, + 1 AS `weight`, + 1 AS `physicalVolume`, + 1 AS `freight`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `sale_freightComponent` +-- + +DROP TABLE IF EXISTS `sale_freightComponent`; +/*!50001 DROP VIEW IF EXISTS `sale_freightComponent`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `sale_freightComponent` AS SELECT + 1 AS `ticketFk`, + 1 AS `amount`, + 1 AS `shipped`*/; SET character_set_client = @saved_cs_client; -- @@ -25649,8 +25891,9 @@ CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(20) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, - `isVisible` tinyint(4) NOT NULL DEFAULT '1', - `hasCompany` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `isVisible` tinyint(1) unsigned NOT NULL DEFAULT '1', + `hasCompany` tinyint(1) unsigned NOT NULL DEFAULT '0', + `hasPreview` tinyint(1) unsigned NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26048,6 +26291,7 @@ CREATE TABLE `state` ( `isPicked` tinyint(1) NOT NULL DEFAULT '0', `isPreparable` tinyint(1) NOT NULL DEFAULT '0', `semaphore` int(11) NOT NULL DEFAULT '0', + `isPrintable` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -26244,7 +26488,7 @@ CREATE TABLE `tabletDepartment` ( `departmentFk` int(11) NOT NULL, PRIMARY KEY (`tabletFk`,`departmentFk`), KEY `departmentFk_idx` (`departmentFk`), - CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `departmentFk` FOREIGN KEY (`departmentFk`) REFERENCES `department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -26462,6 +26706,8 @@ CREATE TABLE `ticket` ( `isDeleted` tinyint(2) NOT NULL DEFAULT '0', `zoneFk` int(11) DEFAULT NULL, `collectionFk` int(11) DEFAULT NULL, + `zonePrice` decimal(10,2) DEFAULT NULL, + `zoneBonus` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`id`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Consigna` (`addressFk`), @@ -26535,9 +26781,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -27192,6 +27438,7 @@ DROP TABLE IF EXISTS `ticketUpdateAction`; CREATE TABLE `ticketUpdateAction` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla pondremos las distintas opciones que se ofrecen al comecial o al cliente al cambiar alguno de los parametros básicos de un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28089,6 +28336,7 @@ CREATE TABLE `workerDocument` ( `id` int(11) NOT NULL AUTO_INCREMENT, `worker` int(10) unsigned DEFAULT NULL, `document` int(11) DEFAULT NULL, + `isReadableByWorker` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Indica si el empleado tiene permiso para acceder al documento', PRIMARY KEY (`id`), KEY `workerDocument_ibfk_1` (`worker`), KEY `workerDocument_ibfk_2` (`document`), @@ -28368,6 +28616,9 @@ CREATE TABLE `workerTimeControlParams` ( `weekScope` int(11) NOT NULL, `dayWorkMax` int(11) NOT NULL, `dayStayMax` int(11) NOT NULL, + `weekMaxBreak` int(11) NOT NULL, + `weekMaxScope` int(11) NOT NULL, + `askInOut` int(11) NOT NULL COMMENT 'Tiempo desde la última fichada que determinará si se pregunta al usuario por la dirección de la fichada', PRIMARY KEY (`id`) ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='All values in seconds'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -28743,6 +28994,7 @@ CREATE TABLE `zoneEvent` ( `travelingDays` int(11) DEFAULT NULL, `price` decimal(10,2) DEFAULT NULL, `bonus` decimal(10,2) DEFAULT NULL, + `m3Max` decimal(10,2) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `zoneFk` (`zoneFk`), CONSTRAINT `zoneEvent_ibfk_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -28882,6 +29134,25 @@ CREATE TABLE `zoneWarehouse` ( ) ENGINE=InnoDBDEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `zone_ETD` +-- + +DROP TABLE IF EXISTS `zone_ETD`; +/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `zone_ETD` AS SELECT + 1 AS `zoneFk`, + 1 AS `HoraTeórica`, + 1 AS `volumenTotal`, + 1 AS `volumenPendiente`, + 1 AS `velocidad`, + 1 AS `HoraPráctica`, + 1 AS `minutesLess`, + 1 AS `etc`*/; +SET character_set_client = @saved_cs_client; + -- -- Dumping events for database 'vn' -- @@ -29266,6 +29537,8 @@ CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse`(vWarehouse INT, vAgencyMode INT) RETURNS decimal(10,3) DETERMINISTIC BEGIN + + -- OBSOLETO usar catalog_componentReverse JGF 2020-02-26 DECLARE vGeneralInflationCoeficient INT; DECLARE vVerdnaturaVolumeBox BIGINT; DECLARE vClientFk INT; @@ -29278,107 +29551,8 @@ BEGIN DECLARE vItem INT DEFAULT 98; DECLARE vItemCarryBox INT; - SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox - INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox - FROM bionicConfig; + CALL util.throw('Obsoleto hablar con Informática'); - SELECT clientFk INTO vClientFk FROM address WHERE id = vAddress; - - -- Creamos la tabla tmp.bionicComponent - DROP TEMPORARY TABLE IF EXISTS tmp.bionicComponent; - CREATE TEMPORARY TABLE tmp.bionicComponent( - `warehouseFk` smallint(5) unsigned NOT NULL, - `itemFk` int(11) NOT NULL, - `componentFk` int(10) unsigned NOT NULL, - `value` decimal(10,4) NOT NULL, - UNIQUE KEY `itemWarehouseComponent` (`itemFk`,`warehouseFk`,`componentFk`) USING HASH, - KEY `itemWarehouse` (`itemFk`,`warehouseFk`) USING BTREE - ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - -- Margin - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, id, vMargin - FROM component - WHERE code = vComponentMargin; - - -- Recobro - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, c.id, ROUND(LEAST(cr.recobro,0.25), 3) - FROM bi.claims_ratio cr - JOIN component c ON c.code = vComponentRecovery - WHERE cr.Id_Cliente = vClientFk AND cr.recobro > 0.009; - - -- Componente de maná automático, en función del maná acumulado por el comercial. - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, co.id, ROUND(ms.prices_modifier_rate, 3) - FROM client c - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - JOIN component co ON co.code = vComponentMana - WHERE ms.prices_modifier_activated AND c.id = vClientFk LIMIT 1; - - -- Reparto - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, co.id, vGeneralInflationCoeficient - * ROUND( - vM3 - * az.price - * az.inflation - / vVerdnaturaVolumeBox, 4 - ) - FROM agencyMode ag - JOIN address a ON a.id = vAddress AND ag.id = vAgencyMode - JOIN agencyProvince ap ON ap.agencyFk = ag.agencyFk - AND ap.warehouseFk = vWarehouse AND ap.provinceFk = a.provinceFk - JOIN agencyModeZone az ON az.agencyModeFk = vAgencyMode - AND az.zone = ap.zone AND az.itemFk = 71 AND az.warehouseFk = vWarehouse - JOIN component co ON co.code = vComponentPort; - - -- Coste - SELECT vRetailedPrice - SUM(`value`) INTO vComponentCostValue - FROM tmp.bionicComponent; - - INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) - SELECT vWarehouse, vItem, id,vComponentCostValue - FROM component - WHERE code = vComponentCost; - - RETURN vComponentCostValue; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `bionicCalcReverse__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `bionicCalcReverse__`(vWarehouse INT, - vMargin DECIMAL(10,3), - vRetailedPrice DECIMAL(10,3), - vM3 DECIMAL(10,3), - vAddress INT, - vAgencyMode INT) RETURNS decimal(10,3) - DETERMINISTIC -BEGIN - DECLARE vGeneralInflationCoeficient INT; - DECLARE vVerdnaturaVolumeBox BIGINT; - DECLARE vClientFk INT; - DECLARE vComponentRecovery VARCHAR(50) DEFAULT 'debtCollection'; - DECLARE vComponentMana VARCHAR(50) DEFAULT 'autoMana'; - DECLARE vComponentPort VARCHAR(50) DEFAULT 'delivery'; - DECLARE vComponentMargin VARCHAR(50) DEFAULT 'margin'; - DECLARE vComponentCost VARCHAR(50) DEFAULT 'purchaseValue'; - DECLARE vComponentCostValue DECIMAL(10,2); - DECLARE vItem INT DEFAULT 98; - DECLARE vItemCarryBox INT; - SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox FROM bionicConfig; @@ -30045,7 +30219,7 @@ BEGIN l: LOOP SELECT workerSubstitute INTO vWorkerSubstituteFk FROM sharingCart - WHERE vDated BETWEEN started AND ended + WHERE curdate() BETWEEN started AND ended AND workerFk = vSalesPersonFk ORDER BY id LIMIT 1; @@ -31172,17 +31346,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `hasZone` */; +/*!50003 DROP FUNCTION IF EXISTS `hasZone__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `hasZone`(vLanded DATE, vAddress INT, vAgencyModeFk INT) RETURNS tinyint(1) +CREATE DEFINER=`root`@`%` FUNCTION `hasZone__`(vLanded DATE, vAddress INT, vAgencyModeFk INT) RETURNS tinyint(1) DETERMINISTIC BEGIN DECLARE vHasZone BOOLEAN DEFAULT FALSE; @@ -32523,6 +32697,75 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `workerTimeControl_addDirection` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `workerTimeControl_addDirection`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) + DETERMINISTIC +BEGIN + DECLARE vDirection VARCHAR(6); + DECLARE vLastIn DATETIME; + DECLARE vDayStayMax INT; + DECLARE vHasDirectionOut INT; + DECLARE vLastInsertedId INT; + + SELECT dayStayMax INTO vDayStayMax + FROM workerTimeControlParams; + + SELECT timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; + + IF vDirection = 'out' THEN + + SELECT MAX(timed) INTO vLastIn + FROM workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in' + AND timed < vTimed; + + UPDATE workerTimeControl wtc + SET wtc.direction = 'middle' + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vLastIn AND vTimed; + + ELSE IF vDirection = 'in' THEN + + SELECT COUNT(*) INTO vHasDirectionOut + FROM workerTimeControl wtc + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + UPDATE workerTimeControl wtc + SET wtc.direction = IF (vHasDirectionOut,'middle','out') + WHERE userFk = vUserFk + AND direction = 'in' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + END IF; + END IF; + + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) + VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); + + SET vLastInsertedId = LAST_INSERT_ID(); + + CALL workerTimeControlSOWP(vUserFk, vTimed); + + RETURN vLastInsertedId; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `worker_isWorking` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35283,239 +35526,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get_beta` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get_beta`(vCollectionFk INT) -BEGIN - - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vWarehouseAliasFk INT; - - SELECT t.warehouseFk, w.aliasFk - INTO vWarehouseFk, vWarehouseAliasFk - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - LIMIT 1; - - CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.parked; - CREATE TEMPORARY TABLE tmp.parked - ENGINE MEMORY - SELECT s.itemFk, 0 as quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - UPDATE tmp.parked pk - JOIN ( SELECT itemFk, sum(visible) as visible - FROM vn.itemShelvingStock iss - JOIN vn.warehouse w ON w.id = iss.warehouseFk - WHERE w.aliasFk = vWarehouseAliasFk - GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk - SET pk.quantity = iss.visible; - - DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; - CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY - SELECT itemFk, `grouping` - FROM ( - SELECT itemFk, - CASE groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN packing - ELSE `grouping` - END AS `grouping` - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.warehouseInFk = vWarehouseFk - AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() - AND b.isIgnored = FALSE - ORDER BY tr.landed DESC - ) sub - GROUP BY sub.itemFk ; - - DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; - CREATE TEMPORARY TABLE tmp.grouping2 - ENGINE MEMORY - SELECT * FROM tmp.`grouping`; - - SELECT s.id as saleFk, s.itemFk, - p.code COLLATE utf8_general_ci as placement , - sh.code COLLATE utf8_general_ci as shelving, - ish.created, - ish.visible, - IFNULL(cpd.id,0) as `order`, - IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.coolerPathDetail cpd ON CAST(cpd.hallway AS DECIMAL(3,0)) = p.column - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - JOIN tmp.`grouping` g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND w.aliasFk = vWarehouseAliasFk - AND ish.visible > 0 - UNION ALL - SELECT s.id as saleFk, s.itemFk, - ip.code COLLATE utf8_general_ci as placement, - '' COLLATE utf8_general_ci as shelving, - modificationDate as created, - v.visible - p.quantity as visible, - IFNULL(cpd.id,0) as `order`, - g.`grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) - JOIN tmp.parked p ON p.itemFk = s.itemFk - JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk - LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND v.visible - p.quantity > 0 - AND IFNULL(cpd.id,0); - - DROP TEMPORARY TABLE - tmp.parked, - tmp.`grouping`, - tmp.grouping2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionPlacement_get__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionPlacement_get__`(vCollectionFk INT) -BEGIN - - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vWarehouseAliasFk INT; - - SELECT t.warehouseFk, w.aliasFk - INTO vWarehouseFk, vWarehouseAliasFk - FROM vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - LIMIT 1; - - CALL cache.visible_refresh(vCalcFk,FALSE,vWarehouseFk); - - DROP TEMPORARY TABLE IF EXISTS tmp.parked; - CREATE TEMPORARY TABLE tmp.parked - ENGINE MEMORY - SELECT s.itemFk, 0 as quantity - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk; - - UPDATE tmp.parked pk - JOIN ( SELECT itemFk, sum(visible) as visible - FROM vn.itemShelvingStock iss - JOIN vn.warehouse w ON w.id = iss.warehouseFk - WHERE w.aliasFk = vWarehouseAliasFk - GROUP BY iss.itemFk ) iss ON iss.itemFk = pk.itemFk - SET pk.quantity = iss.visible; - - DROP TEMPORARY TABLE IF EXISTS tmp.`grouping`; - CREATE TEMPORARY TABLE tmp.`grouping` - ENGINE MEMORY - SELECT itemFk, `grouping` - FROM ( - SELECT itemFk, - CASE groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN packing - ELSE `grouping` - END AS `grouping` - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - WHERE tr.warehouseInFk = vWarehouseFk - AND landed BETWEEN (SELECT FechaInventario FROM vn2008.tblContadores LIMIT 1) AND CURDATE() - AND b.isIgnored = FALSE - ORDER BY tr.landed DESC - ) sub - GROUP BY sub.itemFk ; - - DROP TEMPORARY TABLE IF EXISTS tmp.grouping2; - CREATE TEMPORARY TABLE tmp.grouping2 - ENGINE MEMORY - SELECT * FROM tmp.`grouping`; - - SELECT s.id as saleFk, s.itemFk, - p.code COLLATE utf8_general_ci as placement , - sh.code COLLATE utf8_general_ci as shelving, - ish.created, - ish.visible, - IFNULL(p.pickingOrder,0) as `order`, - IF(sc.isPreviousPreparedByPacking, ish.packing, g.`grouping`) as `grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk - JOIN vn.shelving sh ON sh.code = ish.shelvingFk - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - JOIN vn.warehouse w ON w.id = sc.warehouseFk - JOIN tmp.`grouping` g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND w.aliasFk = vWarehouseAliasFk - AND ish.visible > 0 - UNION ALL - SELECT s.id as saleFk, s.itemFk, - ip.code COLLATE utf8_general_ci as placement, - '' COLLATE utf8_general_ci as shelving, - modificationDate as created, - v.visible - p.quantity as visible, - IFNULL(cpd.hallway * 100,0) as `order`, - g.`grouping` - FROM vn.ticketCollection tc - JOIN vn.sale s ON s.ticketFk = tc.ticketFk - JOIN vn.itemPlacement ip ON ip.itemFk = s.itemFk AND ip.warehouseFk = vWarehouseFk - LEFT JOIN vn.coolerPathDetail cpd ON cpd.hallway = LEFT(ip.`code`,3) - JOIN tmp.parked p ON p.itemFk = s.itemFk - JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vCalcFk - LEFT JOIN tmp.grouping2 g ON g.itemFk = s.itemFk - WHERE tc.collectionFk = vCollectionFk - AND v.visible - p.quantity > 0 - AND IFNULL(cpd.id,0); - - DROP TEMPORARY TABLE - tmp.parked, - tmp.`grouping`, - tmp.grouping2; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `collectionSale_get` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -35608,37 +35618,6 @@ BEGIN LEFT JOIN vn.state st ON st.id = ts.stateFk WHERE tc.collectionFk = vCollectionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collectionStickers_print` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collectionStickers_print`(vCollectionFk INT) -BEGIN - - UPDATE vn.ticket t - JOIN vn.ticketCollection tc ON tc.ticketFk = t.id - SET t.notes = CONCAT('COL ',vCollectionFk,'-',tc.`level`) - WHERE tc.collectionFk = vCollectionFk; - - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) - SELECT w.labelReport, tc.ticketFk, getUser() - FROM vn.ticketCollection tc - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -35671,9 +35650,16 @@ BEGIN IF vLabelReport THEN - INSERT INTO vn.printServerQueue(reportFk, param1, workerFk) - SELECT vLabelReport, ticketFk, getUser() - FROM vn.ticketCollection + INSERT INTO vn.ticketTrolley(ticket, labelCount) + SELECT ticketFk, 1 + FROM vn.ticketCollection + WHERE collectionFk = vCollectionFk + ON DUPLICATE KEY UPDATE labelCount = labelCount + 1; + + INSERT INTO vn.printServerQueue(reportFk, param1, workerFk,param2) + SELECT vLabelReport, tc.ticketFk, getUser(), tt.labelCount + FROM vn.ticketCollection tc + LEFT JOIN vn.ticketTrolley tt ON tt.ticket = tc.ticketFk WHERE collectionFk = vCollectionFk; END IF; @@ -35700,11 +35686,14 @@ BEGIN SELECT tc.ticketFk, tc.level, am.name as agencyName, - t.warehouseFk + t.warehouseFk , + w.id as salesPersonFk FROM vn.ticketCollection tc JOIN vn.ticket t ON t.id = tc.ticketFk LEFT JOIN vn.zone z ON z.id = t.zoneFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk WHERE tc.collectionFk = vCollectionFk; END ;; @@ -35735,6 +35724,9 @@ proc:BEGIN DECLARE vWorkerCode VARCHAR(3); DECLARE vShelve INT; DECLARE vTicket INT; + DECLARE myUserIsSalesPersonRole BOOLEAN; + DECLARE vPrintedTickets INT; + DECLARE vMaxTicketPrinted INT DEFAULT 10; -- Establecemos el almacén y si es un sector de preparación previa, así como el estado para los tickets que se vayan preparando SELECT isPreviousPrepared, warehouseFk @@ -35755,6 +35747,13 @@ proc:BEGIN END IF; + -- Averiguamos si es comercial el usuario + SELECT (r.name = 'salesPerson') + INTO myUserIsSalesPersonRole + FROM account.user u + JOIN account.role r ON r.id = u.role + WHERE u.id = vn.getUser(); + -- Obtenemos el código del usuario SELECT w.code INTO vWorkerCode @@ -35769,16 +35768,58 @@ proc:BEGIN CALL vn2008.production_control_source(vWarehouseFk, 0); + SELECT COUNT(*) INTO vPrintedTickets + FROM tmp.production_buffer pb + JOIN vn.state s ON s.id = pb.state + WHERE pb.Fecha = CURDATE() + AND s.isPreparable; + + SET vMaxTicketPrinted = vMaxTicketPrinted - vPrintedTickets; + + -- AutoPRINT + + IF vMaxTicketPrinted > 0 THEN + + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT s2.id, pb.Id_Ticket, vn.getUser() + FROM tmp.production_buffer pb + JOIN vn.agency a ON a.id = pb.agency_id + JOIN vn.state s ON s.id = pb.state + JOIN vn.state s2 ON s2.code = 'PRINTED' + LEFT JOIN vn.route r ON r.id = pb.Id_Ruta + WHERE pb.Fecha = CURDATE() + AND NOT pb.problems + AND a.name != 'REC_SILLA' + AND (pb.ubicacion IS NOT NULL OR a.isOwn = FALSE) + AND s.isPrintable + AND (pb.m3 > 0.05 OR s.code = 'OK') + ORDER BY (Hora - 1) * 60 + minuto > hour(now()) * 60 + minute(now()) , + s.order DESC, + Hora, + minuto, + IFNULL(r.priority,99999), + pb.m3 DESC + LIMIT vMaxTicketPrinted; + + END IF; + + -- SELECT vMaxTicketPrinted; -- Se seleccionan los primeros tickets, asignando colección para dejarlos bloqueados a otros sacadores. - INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) + + INSERT IGNORE INTO vn.ticketCollection(ticketFk, collectionFk) SELECT pb.Id_Ticket, vCollectionFk FROM tmp.production_buffer pb JOIN vn.state s ON s.id = pb.state WHERE pb.collectionFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) + AND ( + (s.isPreparable AND NOT myUserIsSalesPersonRole AND pb.Agencia != 'REC_SILLA') + OR + (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) + ) ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto LIMIT vMaxTickets; + -- Creamos una tabla temporal con los datos que necesitamos para depurar la colección DROP TEMPORARY TABLE IF EXISTS tmp.ticket; @@ -35939,307 +35980,6 @@ proc:BEGIN SELECT vCollectionFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `collection_new__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `collection_new__`(vSectorFk INT) -proc:BEGIN - - DECLARE vIsPreviousPrepared BOOLEAN; - DECLARE vCollectionFk INT; - DECLARE vWarehouseFk INT; - - DECLARE vTicketLiters INT; - DECLARE vTicketLines INT; - DECLARE vTicketFk INT; - DECLARE vTicketHeight INT; - DECLARE vTicketHeightTop INT; - DECLARE vTicketHeightFloor INT; - DECLARE vIsTicketCollected BOOLEAN; - DECLARE vMaxTickets INT; - DECLARE vStateFk INT; - DECLARE vTopTicketFk INT; - DECLARE vFloorTicketFk INT; - - DECLARE vVolumetryLiters INT; - DECLARE vVolumetryLines INT; - DECLARE vVolumetryFk INT; - DECLARE vVolumetryLevel INT; - DECLARE vVolumetryHeight INT; - DECLARE vVolumetryLitersMax INT; - DECLARE vVolumetryLinesMax INT; - DECLARE vVolumetryHeightTop INT; - DECLARE vVolumetryHeightFloor INT; - - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vWorkerCode VARCHAR(3); - - DECLARE cVolumetry CURSOR FOR - SELECT level, liters, `lines`, height - FROM vn.collectionVolumetry - ORDER BY `level`; - - DECLARE cTicket CURSOR FOR - SELECT * - FROM tmp.ticket - ORDER BY height DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Reenvio a la version beta si el sector es el de pruebas - IF vSectorFk IN (17,18) THEN - - CALL vn.collection_new_beta(vSectorFk); - LEAVE proc; - - END IF; - - SELECT isPreviousPrepared, warehouseFk - INTO vIsPreviousPrepared, vWarehouseFk - FROM vn.sector - WHERE id = vSectorFk; - - SELECT w.code - INTO vWorkerCode - FROM vn.worker w - WHERE w.id = account.myUserGetId(); - - IF vIsPreviousPrepared THEN - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'PREVIOUS_PREPARATION'; - ELSE - - SELECT id INTO vStateFk - FROM vn.state - WHERE `code` = 'ON_PREPARATION'; - - END IF; - - SELECT COUNT(*), sum(liters), sum(`lines`) - INTO vMaxTickets, vVolumetryLitersMax, vVolumetryLinesMax - FROM vn.collectionVolumetry; - - CALL vn2008.production_control_source(vWarehouseFk, 0); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - - -- Recogida Silla requiere carros individuales - - IF (SELECT pb.Agencia - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1) = 'REC_SILLA' THEN - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia = 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT 1; - - ELSE - - CREATE TEMPORARY TABLE tmp.ticket - SELECT pb.Id_Ticket ticketFk, - pb.lines, - pb.m3 * 1000 liters, - 0 as height - FROM tmp.production_buffer pb - JOIN vn.state s ON s.id = pb.state - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = pb.Id_Ticket - WHERE pb.problems = 0 - AND pb.Agencia != 'REC_SILLA' - AND tc.ticketFk IS NULL - AND (s.isPreparable OR (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode)) - ORDER BY (s.code = 'PICKER_DESIGNED' AND pb.CodigoTrabajador = vWorkerCode) DESC, pb.Hora, pb.Minuto, m3 DESC, pb.lines DESC - LIMIT vMaxTickets; - - -- Establece altura máxima por pedido, porque las plantas no se pueden recostar. - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - CREATE TEMPORARY TABLE tmp.ticket2 - SELECT MAX(i.size) maxHeigth, t.ticketFk - FROM tmp.ticket t - JOIN vn.sale s ON s.ticketFk = t.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - JOIN vn.itemCategory ic ON ic.id = it.categoryFk - WHERE ic.isReclining = FALSE - GROUP BY t.ticketFk; - - UPDATE tmp.ticket t - JOIN tmp.ticket2 t2 ON t2.ticketFk = t.ticketFk - SET t.height = t2.maxHeigth; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - -- Si hay un ticket con una planta que supera la máxima altura para la bandeja superior, el pedido ha de ser único. Por tanto, eliminamos el resto. - -- Si hay dos tickets con plantas que superen la medida inferior, el carro llevará una bandeja. Hay que eliminar los otros dos. - - SELECT height, ticketFk - INTO vTicketHeightTop, vTopTicketFk - FROM tmp.ticket - ORDER BY height DESC - LIMIT 1; - - SELECT max(height) - INTO vVolumetryHeightTop - FROM vn.collectionVolumetry; - - SELECT height, ticketFk - INTO vTicketHeightFloor, vFloorTicketFk - FROM tmp.ticket - WHERE ticketFk != vTopTicketFk - ORDER BY height DESC - LIMIT 1; - - SELECT height - INTO vVolumetryHeightFloor - FROM vn.collectionVolumetry - WHERE level = 1; - /* - IF vTicketHeightTop > vVolumetryHeightTop - OR vTicketHeightFloor > vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk != vTopTicketFk; - - ELSEIF vTicketHeightFloor <= vVolumetryHeightFloor THEN - - DELETE FROM tmp.ticket WHERE ticketFk NOT IN (vTopTicketFk, vFloorTicketFk); - - END IF; - */ - - - END IF; - - - -- Empieza el bucle - OPEN cVolumetry; - OPEN cTicket; - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - IF NOT vDone THEN - - INSERT INTO vn.collection - SET workerFk = account.myUserGetId(); - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - - END IF; - - bucle:WHILE NOT vDone DO - - IF (vVolumetryLitersMax < vTicketLiters OR vVolumetryLinesMax < vTicketLines) AND vVolumetryLevel > 1 THEN - - LEAVE bucle; - - END IF; - - SELECT COUNT(*) INTO vIsTicketCollected - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - IF vIsTicketCollected THEN - - UPDATE vn.ticketCollection - SET level = CONCAT(level, vVolumetryLevel) - WHERE ticketFk = vTicketFk - AND collectionFk = vCollectionFk; - - ELSE - - INSERT INTO vn.ticketCollection - SET collectionFk = vCollectionFk, - ticketFk = vTicketFk, - level = vVolumetryLevel; - - INSERT INTO vncontrol.inter - SET state_id = vStateFk, - Id_Ticket = vTicketFk, - Id_Trabajador = account.myUserGetId(); - - END IF; - - SET vVolumetryLitersMax = GREATEST(0,vVolumetryLitersMax - vVolumetryLiters); - SET vVolumetryLinesMax = GREATEST(0,vVolumetryLinesMax - vVolumetryLines); - SET vTicketLiters = GREATEST(0,vTicketLiters - vVolumetryLiters); - SET vTicketLines = GREATEST(0,vTicketLines - vVolumetryLines); - - IF vVolumetryLitersMax = 0 OR vVolumetryLinesMax = 0 THEN - - LEAVE bucle; - - END IF; - - IF vTicketLiters > 0 OR vTicketLines > 0 THEN - - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - ELSE - - FETCH cTicket INTO vTicketFk, vTicketLines, vTicketLiters, vTicketHeight; - FETCH cVolumetry INTO vVolumetryLevel, vVolumetryLiters, vVolumetryLines, vVolumetryHeight; - - END IF; - - END WHILE; - - - UPDATE vn.collection c - JOIN vn.state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; - - INSERT IGNORE INTO vn.ticketDown(ticketFk) - SELECT DISTINCT tc.ticketFk - FROM vn.ticketCollection tc - JOIN vncontrol.inter vi ON vi.Id_Ticket = tc.ticketFk - JOIN vn.state st ON st.id = vi.state_id - JOIN vn.ticket t ON t.id = tc.ticketFk - JOIN vn.warehouse w ON w.id = t.warehouseFk - WHERE tc.collectionFk = vCollectionFk - AND w.name = 'Silla FV' - AND st.code = 'PREVIOUS_PREPARATION'; - - - SELECT vCollectionFk; - - CLOSE cVolumetry; - CLOSE cTicket; - -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - -- DROP TEMPORARY TABLE IF EXISTS tmp.ticket2; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -36279,6 +36019,74 @@ BEGIN WHERE id = vCollectionFk; END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `conveyorExpedition_Add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `conveyorExpedition_Add`(vDate DATE) +BEGIN + + DELETE FROM vn.conveyorExpedition + WHERE date(created) = vDate; + + INSERT INTO vn.conveyorExpedition( expeditionFk, + created, + conveyorBuildingClassFk, + length, + width, + height, + routeFk) + SELECT e.id, + e.created, + IF(e.itemFk = 94,1,4), + IF(e.itemFk = 94,1200,1000), + IF(e.itemFk = 94,500,300), + IF(e.itemFk = 94,250,300), + IFNULL(t.routeFk,am.agencyFk) routeFk + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + WHERE DATE(e.created) = vDate + AND t.warehouseFk = 1 + AND e.isBox = 71; + + INSERT INTO vn.conveyorExpedition( expeditionFk, + created, + conveyorBuildingClassFk, + length, + width, + height, + routeFk) + SELECT e.id, + e.created, + 5, + IF(e.itemFk = 94,600,400), + IF(e.itemFk = 94,320,250), + IF(e.itemFk = 94,900,600), + IFNULL(t.routeFk,am.agencyFk) routeFk + FROM vn.expedition e + JOIN vn.ticket t ON t.id = e.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + WHERE DATE(e.created) = vDate + AND t.warehouseFk = 44 + AND e.isBox = 71; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38675,13 +38483,24 @@ proc: BEGIN UPDATE config SET inventoried = vDate; SET @isModeInventory := FALSE; - DELETE e, t + DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete; + CREATE TEMPORARY TABLE tmp.entryToDelete + (INDEX(entryId) USING BTREE) ENGINE = MEMORY + SELECT e.id as entryId, + t.id as travelId + FROM vn.travel t + JOIN vn.entry e ON e.travelFk = t.id + WHERE e.supplierFk = 4 + AND t.shipped <= TIMESTAMPADD(DAY, -2, TIMESTAMPADD(DAY, -10, CURDATE())) + AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE())); + + DELETE e + FROM vn.entry e + JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id; + + DELETE IGNORE t FROM vn.travel t - JOIN vn.entry e ON e.travelFk = t.id - WHERE e.supplierFk = 4 - AND t.shipped <= vDeleteDate - AND (DAY(t.shipped) <> 1 OR shipped < TIMESTAMPADD(MONTH, -12, CURDATE())); - + JOIN tmp.entryToDelete tmp ON tmp.travelId = t.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41611,9 +41430,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -41648,7 +41467,7 @@ BEGIN LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk LEFT JOIN edi.ekt ek ON b.ektFk = ek.id - WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND CURDATE() + WHERE b.itemFk = vItem And tr.shipped BETWEEN vDays AND DATE_ADD(CURDATE(), INTERVAl + 10 DAY) ORDER BY tr.landed DESC , b.id DESC; END ;; DELIMITER ; @@ -43593,13 +43412,208 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `item_ValuateInventory`(IN vDated DATE, IN vIsDetailed BOOLEAN) +BEGIN + + DECLARE vInventoried DATE; + DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; + DECLARE vInventoried2 DATE; + DECLARE vDateDayEnd DATETIME; + + SET vDateDayEnd = util.dayEnd(vDated); + SELECT landed INTO vInventoried + FROM travel tr + JOIN entry E ON E.travelFk = tr.id + WHERE landed <= vDateDayEnd + AND E.supplierFk = 4 + ORDER BY landed DESC + LIMIT 1; + + SET vHasNotInventory = IF (vInventoried is null, TRUE, FALSE); + + IF vHasNotInventory THEN + + SELECT landed INTO vInventoried2 + FROM travel tr + JOIN entry E ON E.travelFk = tr.id + WHERE landed >= vDated + AND E.supplierFk = 4 + ORDER BY landed ASC + LIMIT 1; + + SET vInventoried = TIMESTAMPADD(DAY,1,vDated); + SET vDateDayEnd = vInventoried2; + + END IF; + + DROP TEMPORARY TABLE IF EXISTS inv; + + CREATE TEMPORARY TABLE inv + (warehouseFk SMALLINT, + Id_Article BIGINT, + cantidad INT, + coste DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + Almacen VARCHAR(20), + PRIMARY KEY (Almacen, Id_Article) USING HASH) + ENGINE = MEMORY; + + IF vHasNotInventory = TRUE THEN + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, SUM(b.quantity), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = warehouseInFk + WHERE landed = vDateDayEnd + AND e.supplierFk = 4 + AND w.valuatedInventory + AND t.isInventory + GROUP BY tr.warehouseInFk, b.itemFk; + + END IF; + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, b.quantity * IF(vHasNotInventory,-1,1), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd + AND IF(tr.landed = CURDATE(), tr.isReceived, trUE) + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,-1,1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseOutFk, b.itemFk, b.quantity * IF(vHasNotInventory,1,-1), w.`name` + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity * IF(vHasNotInventory,1,-1)); + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,1,-1), w.`name` + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd + AND w.valuatedInventory + AND it.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,1,-1); + + IF vDated = CURDATE() THEN -- volver a poner lo que esta aun en las estanterias + + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT w.id, s.itemFk, s.quantity * IF(vHasNotInventory,0,1), w.`name` + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDated AND vDateDayEnd + AND (s.isPicked <> 0 or t.isLabeled <> 0 ) + AND w.valuatedInventory + AND it.isInventory + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + s.quantity * IF(vHasNotInventory,0,1); + + END IF; + + -- Mercancia en transito + INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + SELECT tr.warehouseInFk, b.itemFk, b.quantity, CONCAT(wOut.`name`,' - ', wIn.`name`) + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN warehouse wIn ON wIn.id = tr.warehouseInFk + JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk + WHERE vDated >= tr.shipped AND vDated < tr.landed + AND NOT isRaid + -- AND wIn.valuatedInventory + AND t.isInventory + -- AND e.isConfirmed + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (b.quantity); + + CALL vn.buyUltimate(NULL,vDateDayEnd); + + UPDATE inv i + JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.Id_Article = bu.itemFk + JOIN buy b ON b.id = bu.buyFk + SET total = i.cantidad * (ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0)), + coste = ifnull(b.buyingValue,0) + IFNULL(b.packageValue,0) + IFNULL(b.freightValue,0) + IFNULL(b.comissionValue,0) + WHERE i.cantidad <> 0; + + DELETE FROM inv WHERE Cantidad IS NULL or Cantidad = 0; + + IF vIsDetailed THEN + + SELECT inv.warehouseFk, i.id, i.name, i.size, inv.Cantidad, tp.code, + tp.categoryFk, inv.coste, cast(inv.total as decimal(10,2)) total,Almacen + FROM inv + JOIN warehouse w on w.id = warehouseFk + JOIN item i ON i.id = inv.Id_Article + JOIN itemType tp ON tp.id = i.typeFk + WHERE w.valuatedInventory + and inv.total > 0 + order by inv.total desc; + + ELSE + + SELECT i.Almacen, ic.name as Reino, cast(i.total as decimal(10,2)) as Euros, w.code as Comprador,it.id + FROM inv i + JOIN warehouse wh on wh.id = warehouseFk + JOIN item it ON it.id = i.Id_Article + JOIN itemType itp ON itp.id = it.typeFk + LEFT JOIN worker w ON w.id = itp.workerFk + JOIN itemCategory ic ON ic.id = itp.categoryFk + WHERE wh.valuatedInventory + AND i.total > 0; + + END IF; + DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE inv; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_ValuateInventory__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `item_ValuateInventory__`(IN vDated DATE, IN vIsDetailed BOOLEAN) BEGIN DECLARE vInventoried DATE; @@ -45103,10 +45117,9 @@ BEGIN JOIN vn.item i ON i.id = isa.itemFk JOIN vn.sector s ON s.id = isa.sectorFk AND s.warehouseFk = isa.warehouseFk WHERE IF(s.isPreviousPreparedByPacking, (MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 ), TRUE) - AND isa.isPreviousPreparable = TRUE + -- AND isa.isPreviousPreparable = TRUE AND isa.sectorFk = vSectorFk AND isa.quantity > 0 - AND isa.sectorFk = vSectorFk GROUP BY saleFk HAVING isa.quantity <= totalAvailable ) sub2 @@ -45394,7 +45407,7 @@ BEGIN UPDATE vn.routeGate rg LEFT JOIN vn.routesControl rc ON rg.routeFk = rc.routeFk LEFT JOIN vn.route r ON r.id = rg.routeFk - LEFT JOIN vn2008.Agencias a ON a.Id_Agencia = r.agencyModeFk + LEFT JOIN vn.agencyMode a ON a.id = r.agencyModeFk LEFT JOIN ( SELECT Id_Ruta, count(*) AS pedidosLibres @@ -45509,9 +45522,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -45628,8 +45641,8 @@ BEGIN -- Coste TEORICO de una caja "virtual" para cada ruta, teniendo en cuenta que hay carros, pallets, etc UPDATE bi.rutasBoard r JOIN ( - SELECT t.routeFk, - SUM(z.price/ ebv.ratio)/ count(*) AS BultoTeoricoMedio + SELECT t.routeFk, + SUM(t.zonePrice/ ebv.ratio)/ count(*) AS BultoTeoricoMedio FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk JOIN vn.time tm ON tm.dated = r.created @@ -45637,7 +45650,7 @@ BEGIN JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = e.isBox JOIN vn.address ad ON ad.id = t.addressFk JOIN vn.client c ON c.id = ad.clientFk - JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk WHERE tm.year = vYear AND tm.month = vMonth AND z.isVolumetric = FALSE @@ -45652,8 +45665,8 @@ BEGIN FROM vn.ticket t JOIN vn.route r ON r.id = t.routeFk JOIN vn.time tm ON tm.dated = r.created - JOIN vn.saleFreight sf ON sf.ticketFk = t.id - JOIN vn.client c ON c.id = sf.clientFk + JOIN vn.saleVolume sf ON sf.ticketFk = t.id + JOIN vn.client c ON c.id = t.clientFk JOIN vn.zone z ON z.id = t.zoneFk WHERE tm.year = vYear AND tm.month = vMonth @@ -48058,6 +48071,63 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse`(vDateTo DATE) BEGIN +/** + * Inserta los tickets de todos los almacenes en la tabla temporal + * para ser cerrados. + * + * @param vDate Fecha del cierre + */ + DECLARE vDateToEndDay DATETIME DEFAULT util.dayEnd(vDateTo); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketClosure; + + CREATE TEMPORARY TABLE tmp.ticketClosure ENGINE = MEMORY ( + SELECT + t.id AS ticketFk + FROM expedition e + INNER JOIN ticket t ON t.id = e.ticketFk + INNER JOIN warehouse w ON w.id = t.warehouseFk AND hasComission + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + WHERE + ts.alertLevel = 2 + AND DATE(t.shipped) BETWEEN DATE_ADD(vDateTo, INTERVAL -2 DAY) AND vDateTo + AND t.refFk IS NULL + GROUP BY e.ticketFk); + + CALL ticketClosure(); + + INSERT INTO mail (sender, replyTo, subject, body) + SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', + GROUP_CONCAT(ticketFk) tickets + FROM ticket t + JOIN ticketState ts ON t.id = ts.ticketFk + JOIN alertLevel al ON al.alertLevel = ts.alertLevel + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE shipped BETWEEN vDateTo AND vDateToEndDay + AND al.code NOT IN('DELIVERED','PACKED') + AND t.routeFk + HAVING tickets IS NOT NULL; + + DROP TEMPORARY TABLE tmp.ticketClosure; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketClosureMultiWarehouse__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketClosureMultiWarehouse__`(vDateTo DATE) +BEGIN /** * Inserta los tickets de todos los almacenes en la tabla temporal * para ser cerrados. @@ -48082,6 +48152,19 @@ BEGIN CALL ticketClosure(); + INSERT INTO mail (sender, replyTo, subject, body) + SELECT 'jgallego@verdnatura.es', 'jgallego@verdnatura.es', 'Tickets enrutados y NO preparados', + GROUP_CONCAT(ticketFk) tickets + FROM ticket t + JOIN ticketState ts ON t.id = ts.ticketFk + JOIN alertLevel al ON al.alertLevel = ts.alertLevel + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE shipped = TIMESTAMPADD(DAY, -1, CURDATE()) + AND al.code NOT IN('DELIVERED','PACKED') + AND t.routeFk + HAVING tickets IS NOT NULL; + DROP TEMPORARY TABLE tmp.ticketClosure; END ;; DELIMITER ; @@ -48244,491 +48327,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentCalculate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculate__`( - vAddressFk INT, - vAgencyModeFk INT) -proc: BEGIN --- OBSOLETO usar catalog_componentCalculate -/** - * Calcula los componentes de un ticket - * - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id del modo de agencia - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, - i.typeFk, - IF(i.hasKgPrice,b.weight / b.packing, NULL) weightGrouping - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, aho.warehouseFk - FROM priceFixed pf - JOIN tmp.zoneGetShipped aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0 - WHERE aho.shipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - cr.id, - GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN componentRate cr - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((z.price - z.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN agencyMode am ON am.id = vAgencyModeFk - JOIN `address` a ON a.id = vAddressFk - JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = tcc.warehouseFk - JOIN zone z ON z.id = zgs.id - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - HAVING cost <> 0; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN componentRate cr ON cr.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE cr.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate - FROM tmp.ticketComponent tc - JOIN componentRate cr ON cr.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, - CAST(SUM(tcs.sumCost) / weightGrouping AS DECIMAL(10,2)) priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price, - SUM(tcs.sumCost) / weightGrouping priceKg - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentMakeUpdate__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentMakeUpdate__`( - vTicketFk INT, - vClientFk INT, - vAgencyModeFk INT, - vAddressFk INT, - vWarehouseFk TINYINT, - vCompanyFk SMALLINT, - vShipped DATETIME, - vLanded DATE, - vIsDeleted BOOLEAN, - vHasToBeUnrouted BOOLEAN, - vOption INT) -BEGIN - - - CALL vn.ticketComponentPreview (vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); - CALL vn.ticketComponentUpdate ( - vTicketFk, - vClientFk, - vAgencyModeFk, - vAddressFk, - vWarehouseFk, - vCompanyFk, - vShipped, - vLanded, - vIsDeleted, - vHasToBeUnrouted, - vOption - ); - - DROP TEMPORARY TABLE - tmp.ticketComponent, - tmp.ticketComponentPrice; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentPreview__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPreview__`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT, - vWarehouseFk SMALLINT) -BEGIN --- OBSOLETO usar ticket_componentPreview - DECLARE vShipped DATE; - DECLARE vBuyOrderItem INT DEFAULT 100; - - DECLARE vHasDataChanged BOOL DEFAULT FALSE; - DECLARE vHasAddressChanged BOOL; - DECLARE vHasAgencyModeChanged BOOL DEFAULT FALSE; - DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE; - - DECLARE vAddressTypeRateFk INT DEFAULT NULL; - DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL; - - DECLARE vHasChangeAll BOOL DEFAULT FALSE; - - SELECT DATE(landed) <> vLanded, - addressFk <> vAddressFk, - agencyModeFk <> vAgencyModeFk, - warehouseFk <> vWarehouseFk - INTO - vHasDataChanged, - vHasAddressChanged, - vHasAgencyModeChanged, - vHasWarehouseChanged - FROM vn.ticket t - WHERE t.id = vTicketFk; - - IF vHasDataChanged OR vHasWarehouseChanged THEN - SET vHasChangeAll = TRUE; - END IF; - - IF vHasAddressChanged THEN - SET vAddressTypeRateFk = 5; - END IF; - - IF vHasAgencyModeChanged THEN - SET vAgencyModeTypeRateFk = 6; - END IF; - - CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); - - SELECT shipped INTO vShipped - FROM tmp.zoneGetShipped - WHERE warehouseFk = vWarehouseFk; - - CALL buyUltimate(vWarehouseFk, vShipped); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; - CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, - s.itemFk, - bu.buyFk - FROM sale s - LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - WHERE s.ticketFk = vTicketFk - AND s.itemFk != vBuyOrderItem - GROUP BY bu.warehouseFk, bu.itemFk); - - CALL ticketComponentCalculate(vAddressFk, vAgencyModeFk); - - REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value - FROM saleComponent sc - JOIN sale s ON s.id = sc.saleFk - JOIN ticket t ON t.id = s.ticketFk - JOIN componentRate cr ON cr.id = sc.componentFk - WHERE s.ticketFk = vTicketFk - AND (cr.isRenewable = FALSE - OR - (NOT vHasChangeAll - AND (NOT (cr.componentTypeRate <=> vAddressTypeRateFk - OR cr.componentTypeRate <=> vAgencyModeTypeRateFk)))); - - SET @shipped = vShipped; - - DROP TEMPORARY TABLE - tmp.zoneGetShipped, - tmp.buyUltimate, - tmp.ticketLot; - - IF IFNULL(vShipped, CURDATE() - 1) < CURDATE() THEN - CALL util.throw('NO_AGENCY_AVAILABLE'); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentPriceDifference__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentPriceDifference__`( - vTicketFk INT, - vLanded DATE, - vAddressFk INT, - vAgencyModeFk INT, - vWarehouseFk INT) -BEGIN -/** - * Devuelve las diferencias de precio - * de los movimientos de un ticket. - * - * @param vTicketFk Id del ticket - * @param vLanded Fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id del modo de agencia - * @param vWarehouseFk Id del almacén - */ - CALL vn.ticketComponentPreview(vTicketFk, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk); - - SELECT s.itemFk, - i.name, - i.size, - i.category, - IFNULL(s.quantity, 0) AS quantity, - IFNULL(s.price, 0) AS price, - ROUND(SUM(tc.cost), 2) AS newPrice, - s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference, - s.id AS saleFk - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk - AND tc.warehouseFk = t.warehouseFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = tc.componentFk - LEFT JOIN componentRate cr ON cr.id = tc.componentFk - WHERE - t.id = vTicketFk - AND IF(sc.componentFk IS NULL - AND cr.classRate IS NOT NULL, FALSE, TRUE) - GROUP BY s.id ORDER BY s.id; - - DROP TEMPORARY TABLE - tmp.ticketComponent, - tmp.ticketComponentPrice; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49117,6 +48715,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketCreateWithUser`( BEGIN DECLARE vZoneFk INT; + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); IF vClientId IS NULL THEN CALL util.throw ('CLIENT_NOT_ESPECIFIED'); @@ -49132,7 +48732,8 @@ BEGIN CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); - SELECT zoneFk INTO vZoneFk FROM tmp.zoneGetShipped + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; IF vZoneFk IS NULL OR vZoneFk = 0 THEN @@ -49149,7 +48750,9 @@ BEGIN routeFk, companyFk, landed, - zoneFk + zoneFk, + zonePrice, + zoneBonus ) SELECT vClientId, @@ -49161,7 +48764,9 @@ BEGIN IF(vRouteFk,vRouteFk,NULL), vCompanyFk, vlanded, - vZoneFk + vZoneFk, + vPrice, + vBonus FROM address a JOIN agencyMode am ON am.id = a.agencyModeFk WHERE a.id = vAddressFk; @@ -50662,7 +50267,8 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticket_componentUpdate`( vHasToBeUnrouted BOOLEAN, vOption INT) BEGIN - + DECLARE vPrice DECIMAL(10,2); + DECLARE vBonus DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; @@ -50680,12 +50286,20 @@ BEGIN END IF; + CALL vn.zone_getShippedWarehouse(vlanded, vAddressFk, vAgencyModeFk); + + SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus + FROM tmp.zoneGetShipped + WHERE shipped = vShipped AND warehouseFk = vWarehouseFk LIMIT 1; + UPDATE ticket t SET t.clientFk = vClientFk, t.agencyModeFk = vAgencyModeFk, t.addressFk = vAddressFk, t.zoneFk = vZoneFk, + t.zonePrice = vPrice, + t.zoneBonus = vBonus, t.warehouseFk = vWarehouseFk, t.companyFk = vCompanyFk, t.landed = vLanded, @@ -50850,13 +50464,13 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vCursor CURSOR FOR SELECT id, landed, addressFk, agencyModeFk, warehouseFk - FROM vn.ticket WHERE shipped BETWEEN '2019-01-01' and '2019-02-01' AND zoneFk is null; + FROM vn.ticket WHERE shipped BETWEEN '2019-10-20' and '2019-11-01' AND zoneFk is null; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET vDone = 1; OPEN vCursor; REPEAT FETCH vCursor INTO vFechedTicket, vLanded, vAddressFk, vAgencyModeFk, vWarehouseFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); UPDATE vn.ticket t JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = vWarehouseFk SET t.zoneFk = zgs.zoneFk @@ -50864,6 +50478,7 @@ BEGIN UNTIL vDone END REPEAT; DROP TEMPORARY TABLE tmp.zoneGetShipped; + CLOSE vCursor; END ;; DELIMITER ; @@ -50970,7 +50585,7 @@ proc: BEGIN FROM ticket WHERE id = vTicketFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra @@ -50996,7 +50611,7 @@ proc: BEGIN IF vLanded IS NULL THEN - CALL zoneGetLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); UPDATE vn2008.Tickets t SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) @@ -51054,7 +50669,7 @@ proc: BEGIN FROM ticket WHERE id = vTicketFk; - CALL zoneGetShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); + CALL zone_getShippedWarehouse(vLanded, vAddressFk , vAgencyModeFk); CALL vn.buyUltimate (vWarehouseFk, vShipped); -- rellena la tabla buyUltimate con la ultima compra @@ -51080,7 +50695,7 @@ proc: BEGIN IF vLanded IS NULL THEN - CALL zoneGetLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); + CALL zone_getLanded(vShipped, vAddressFk, vAgencyModeFk, vWarehouseFk); UPDATE vn2008.Tickets t SET t.landing = (SELECT landed FROM tmp.zoneGetLanded) @@ -51174,9 +50789,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -51190,8 +50805,7 @@ BEGIN * @table tmp.user(userFk) * @return tmp.timeBusinessCalculate */ - DECLARE vHoursFullTime INT DEFAULT 40; - + DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate; DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime; @@ -51211,17 +50825,19 @@ BEGIN SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal, timeWorkSeconds / 3600 timeBusinessDecimal, type, - permissionrate, - hoursWeek + permissionRate, + hoursWeek, + discountRate FROM(SELECT rd.dated, b.business_id businessFk, w.userFk, bl.department_id departmentFk, - IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , - IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, - IF(cl.hours_week = vHoursFullTime, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart , + IF(j.start = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd, + IF(j.start = NULL, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds, cs.type, cs.permissionRate, + cs.discountRate, cl.hours_week hoursWeek FROM tmp.rangeDate rd LEFT JOIN postgresql.business b ON rd.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo ) @@ -51243,19 +50859,20 @@ BEGIN UPDATE tmp.timeBusinessCalculate t - SET t.timeWorkSeconds = vHoursFullTime / 5 * 3600, - t.timeWorkSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), - t.timeWorkDecimal = vHoursFullTime / 5, - t.timeBusinessSeconds = vHoursFullTime / 5 * 3600, - t.timeBusinessSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600), - t.timeBusinessDecimal = vHoursFullTime / 5 - WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND hoursWeek = vHoursFullTime ; + LEFT JOIN postgresql.journey j ON j.business_id = t.businessFk + SET t.timeWorkSeconds = t.hoursWeek / 5 * 3600, + t.timeWorkSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + t.timeWorkDecimal = t.hoursWeek / 5, + t.timeBusinessSeconds = t.hoursWeek / 5 * 3600, + t.timeBusinessSexagesimal = SEC_TO_TIME( t.hoursWeek / 5 * 3600), + t.timeBusinessDecimal = t.hoursWeek / 5 + WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND j.journey_id IS NULL ; UPDATE tmp.timeBusinessCalculate t - SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate) , - t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate)), - t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionrate) - WHERE permissionrate <> 0; + SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate) , + t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionRate)), + t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionRate) + WHERE permissionRate <> 0; UPDATE tmp.timeBusinessCalculate t JOIN postgresql.calendar_labour cl ON cl.day = t.dated @@ -51263,7 +50880,7 @@ BEGIN SET t.timeWorkSeconds = 0, t.timeWorkSexagesimal = 0, t.timeWorkDecimal = 0, - t.permissionrate = 1, + t.permissionRate = 1, t.type = 'Festivo' WHERE t.type IS NULL; @@ -53080,6 +52697,190 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) proc: BEGIN +/** + * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd + * + * @param vUserFk Identificador del trabajador + * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; + * En caso de tener algun problema retorna el primero que encuentra + */ + DECLARE vLastIn DATETIME ; + DECLARE vLastOut DATETIME ; + DECLARE vDayWorkMax INT; + DECLARE vDayBreak INT; + DECLARE vWeekBreak INT ; + DECLARE vWeekScope INT; + DECLARE vDayStayMax INT; + DECLARE vProblem VARCHAR(20) DEFAULT NULL; + DECLARE vTimedWorked INT; + DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; + DECLARE vTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; + DECLARE vBody VARCHAR(255) DEFAULT NULL; + + SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax + INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in'; + + SELECT MAX(timed) INTO vLastOut + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'out'; + + SELECT email INTO vTo + FROM vn.worker w + WHERE w.id = (SELECT bossFk FROM vn.worker WHERE id = vUserFk); + + SELECT CONCAT(firstName,' ',lastName) INTO vUserName + FROM vn.worker w + WHERE w.id = vUserFk; + + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA + + -- VERIFICAR DESCANSO DIARIO + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN + SELECT "Descansos 12 h" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ + IF (SELECT MOD(COUNT(*),2) -- <>0 + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND timed >= vLastIn + ) THEN + SELECT "Dias con fichadas impares" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + -- VERIFICAR VACACIONES + SELECT cs.type INTO vCalendarStateType + FROM postgresql.calendar_employee ce + JOIN postgresql.business b USING(business_id) + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN postgresql.calendar_state cs USING(calendar_state_id) + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE ce.date = CURDATE() + AND cs.isAllowedToWork = FALSE + AND w.userFk = vUserFk + LIMIT 1; + + IF(LENGTH(vCalendarStateType)) THEN + SELECT vCalendarStateType AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + + END IF; + + + -- VERIFICAR CONTRATO EN VIGOR + IF (SELECT COUNT(*) + FROM postgresql.business b + JOIN postgresql.profile pr ON pr.profile_id = b.client_id + JOIN postgresql.person p ON p.person_id = pr.person_id + JOIN vn.worker w ON w.id = p.id_trabajador + WHERE w.userFk = vUserFk + AND b.date_start <= vDated + AND IFNULL(b.date_end,vDated) >= vDated + ) = 0 THEN + SELECT "No hay un contrato en vigor" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + + END IF; + + -- VERIFICAR DESCANSO SEMANAL + SET @vHasBreakWeek:= FALSE; + SET @vLastTimed:= UNIX_TIMESTAMP((NOW() - INTERVAL vWeekScope SECOND)); + + DROP TEMPORARY TABLE IF EXISTS tmp.trash; + CREATE TEMPORARY TABLE tmp.trash + SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, + @vLastTimed:= UNIX_TIMESTAMP(timed) + FROM workerTimeControl + WHERE timed>= (NOW() - INTERVAL vWeekScope SECOND) + AND userFk= vUserFk + AND direction IN ('in','out') + ORDER BY timed ASC; + + IF UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA + SELECT "Descansos 36 h" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + DROP TEMPORARY TABLE tmp.trash; + + ELSE -- DIA ACTUAL + + -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO + SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(NOW()), 0) INTO vTimedWorked + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND timed >= vLastIn + ORDER BY timed; + + IF vTimedWorked > vDayWorkMax THEN + SELECT "Jornadas" AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + + END IF; + + -- VERIFICAR DEPARTAMENTO + IF vTabletFk IS NOT NULL THEN + IF ( SELECT COUNT(*) + FROM vn.tabletDepartment td + JOIN vn.workerTimeControlUserInfo wtcu ON wtcu.departmentFk = td.departmentFk + WHERE td.tabletFk = vTabletFk AND wtcu.userFk = vUserFk + ) = 0 THEN + SELECT "No perteneces a este departamento." AS problem; + -- ENVIAMOS CORREO AL BOSSFK + SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; + CALL vn.mail_insert(vTo,vTo,'error al fichar',vBody); + LEAVE proc; + END IF; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check_` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_check_`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) +proc: BEGIN /** * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a vn.workerTimeControlAdd * @@ -54009,15 +53810,14 @@ proc: BEGIN TRUNCATE TABLE zoneClosure; - REPEAT + WHILE vCounter <= vScope DO CALL zone_getOptionsForShipment(vShipped, TRUE); INSERT INTO zoneClosure(zoneFk, dated, `hour`) SELECT zoneFk, vShipped, `hour` FROM tmp.zoneOption; SET vCounter = vCounter + 1; SET vShipped = TIMESTAMPADD(DAY, 1, vShipped); - UNTIL vCounter > vScope - END REPEAT; + END WHILE; DROP TEMPORARY TABLE tmp.zone; DO RELEASE_LOCK('vn.zoneClosure_recalc'); @@ -54292,7 +54092,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetAgency` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetAgency__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54302,7 +54102,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency`(vAddress INT, vLanded DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency__`(vAddress INT, vLanded DATE) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha @@ -54320,7 +54120,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetLanded` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetLanded__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54330,7 +54130,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetLanded__`(vShipped DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) BEGIN /** * JGF procedimiento TEMPORAL @@ -54369,7 +54169,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShipped` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShippedWarehouse__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54379,7 +54179,34 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShipped__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShipped__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) BEGIN /** * OBSOLETO usar zone_getShippedWarehouse @@ -54400,7 +54227,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetShippedWarehouse` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54410,34 +54237,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) -BEGIN -/** - * Devuelve la mínima fecha de envío para cada warehouse - * - * @param vLanded La fecha de recepcion - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id de la agencia - * @return tmp.zoneGetShipped - */ - CALL zone_getShippedWarehouse(vLanded, vAddressFk, vAgencyModeFk); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) +CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse__`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN /** * Devuelve el listado de agencias disponibles para la fecha, @@ -54491,7 +54291,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `zoneGetWarehouse__` */; +/*!50003 DROP PROCEDURE IF EXISTS `zone_doCalcInitialize` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -54501,53 +54301,55 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetWarehouse__`(vAddress INT, vLanded DATE, vWarehouse INT) -BEGIN +CREATE DEFINER=`root`@`%` PROCEDURE `zone_doCalcInitialize`() +proc: BEGIN /** -* Devuelve el listado de agencias disponibles para la fecha, - * dirección y warehouse pasadas - * - * @param vAddress - * @param vWarehouse warehouse - * @param vLanded Fecha de recogida - * @select Listado de agencias disponibles + * Initialize ticket + * si en 01-07-20 aun esta este proc, kkear */ - - DECLARE vGeoFk INT; - - SELECT p.geoFk INTO vGeoFk - FROM address a - JOIN town t ON t.provinceFk = a.provinceFk - JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode - WHERE a.id = vAddress - ORDER BY (a.city SOUNDS LIKE t.`name`) DESC - LIMIT 1; + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + DECLARE vLanded DATE; + DECLARE vZoneFk INT; - SELECT * FROM ( - SELECT * FROM ( - SELECT am.id agencyModeFk, - am.name agencyMode, - am.description, - am.deliveryMethodFk, - TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, - z.warehouseFk, - zi.isIncluded, - z.id zoneFk - FROM zoneGeo zgSon - JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt - JOIN zoneIncluded zi ON zi.geoFk = zgFather.id - JOIN zone z ON z.id = zi.zoneFk - JOIN zoneCalendar zc ON zc.zoneFk = z.id - JOIN agencyMode am ON am.id = z.agencyModeFk - WHERE zgSon.`id` = vGeoFk - AND delivered = vLanded - AND z.warehouseFk = vWarehouse - AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) - ORDER BY z.id, zgFather.depth DESC) t - GROUP BY zoneFk - HAVING isIncluded > 0) t - GROUP BY agencyModeFk; + DECLARE cCur CURSOR FOR + SELECT t.id, t.landed, t.zoneFk + FROM ticket t + WHERE shipped >= '2020-01-01' AND shipped <= '2020-01-31' + AND zoneFk in (34, 43,51,55,66) + GROUP BY landed, zoneFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk, vLanded, vZoneFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + DROP TEMPORARY TABLE IF EXISTS tmp.zone; + CREATE TEMPORARY TABLE tmp.zone + (INDEX (id)) + ENGINE = MEMORY + SELECT vZoneFk id; + + CALL zone_getOptionsForLanding(vLanded, TRUE); + + UPDATE ticket t + LEFT JOIN tmp.zoneOption zo ON TRUE + SET zonePrice = zo.price, zoneBonus = zo.bonus + WHERE t.zoneFk = vZoneFk AND landed = vLanded; + + + END LOOP; + + CLOSE cCur; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54576,7 +54378,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; CREATE TEMPORARY TABLE tmp.zoneGetAgency @@ -54615,11 +54417,8 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getAvailable`(vAddress INT, vLanded DATE) BEGIN - -/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ - CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); SELECT * FROM tmp.zoneOption; @@ -54909,13 +54708,13 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE) +CREATE DEFINER=`root`@`%` PROCEDURE `zone_getOptionsForLanding`(vLanded DATE, vShowExpiredZones BOOLEAN) BEGIN /** * Gets computed options for the passed zones and delivery date. @@ -54968,9 +54767,11 @@ BEGIN JOIN zoneExclusion e ON e.zoneFk = t.zoneFk AND e.`dated` = vLanded; - DELETE FROM tmp.zoneOption - WHERE shipped < CURDATE() - OR (shipped = CURDATE() AND CURTIME() > `hour`); + IF NOT vShowExpiredZones THEN + DELETE FROM tmp.zoneOption + WHERE shipped < CURDATE() + OR (shipped = CURDATE() AND CURTIME() > `hour`); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55240,7 +55041,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN /** - * Devuelve la mínima fecha de envío para cada warehouse + * Devuelve la mínima fecha de envío para cada warehouse * * @param vLanded La fecha de recepcion * @param vAddressFk Id del consignatario @@ -55249,7 +55050,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddressFk)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded,TRUE); DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; CREATE TEMPORARY TABLE tmp.zoneGetShipped @@ -55257,8 +55058,11 @@ BEGIN SELECT * FROM ( SELECT zo.zoneFk, TIMESTAMPADD(DAY,-zo.travelingDays, vLanded) shipped, + zo.`hour`, zw.warehouseFk, - z.agencyModeFk + z.agencyModeFk, + zo.price, + zo.bonus FROM tmp.zoneOption zo JOIN zoneWarehouse zw ON zw.zoneFk = zo.zoneFk JOIN zone z ON z.id = zo.zoneFk @@ -55287,9 +55091,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zone_getWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT) BEGIN - -/* JGF esta trabajando en este archivo, si se modifica avisadme 2020-02-12*/ - /** * Devuelve el listado de agencias disponibles para la fecha, * dirección y almacén pasados. @@ -55301,7 +55102,7 @@ BEGIN */ CALL zone_getFromGeo(address_getGeo(vAddress)); - CALL zone_getOptionsForLanding(vLanded); + CALL zone_getOptionsForLanding(vLanded, FALSE); SELECT am.id agencyModeFk, am.name agencyMode, @@ -56801,28 +56602,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayDetail` +-- Final view structure for view `holidayDetail__` -- -/*!50001 DROP VIEW IF EXISTS `holidayDetail`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayDetail` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `holidayLegend` --- - -/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; +/*!50001 DROP VIEW IF EXISTS `holidayDetail__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -56831,25 +56614,43 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayLegend` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 VIEW `holidayDetail__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayType` +-- Final view structure for view `holidayLegend__` -- -/*!50001 DROP VIEW IF EXISTS `holidayType`*/; +/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayType` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free` `cf` */; +/*!50001 VIEW `holidayLegend__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `holidayType__` +-- + +/*!50001 DROP VIEW IF EXISTS `holidayType__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `holidayType__` AS select `cf`.`calendar_free_id` AS `id`,`cf`.`type` AS `name`,`cf`.`rgb` AS `rgb` from `postgresql`.`calendar_free` `cf` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57029,7 +56830,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`sectorProdPriority`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,0 AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`stock`.`visible` AS `available`,`stock`.`sectorFk` AS `sectorFk`,`stock`.`shelvingFk` AS `matricula`,`stock`.`parkingFk` AS `parking`,`stock`.`itemShelvingFk` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`stock`.`grouping` AS `grouping`,`stock`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable`,`sv`.`physicalVolume` AS `physicalVolume`,`t`.`warehouseFk` AS `warehouseFk` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelvingStock` `stock` on((`stock`.`itemFk` = `i`.`id`))) left join `vn`.`saleTracking` `stk` on((`stk`.`saleFk` = `s`.`id`))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) left join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `s`.`id`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and isnull(`stk`.`id`) and (`stock`.`visible` > 0) and isnull(`stk`.`saleFk`) and `st`.`isPreviousPreparable`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57214,6 +57015,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `lastHourProduction` +-- + +/*!50001 DROP VIEW IF EXISTS `lastHourProduction`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `lastHourProduction` AS select `t`.`warehouseFk` AS `warehouseFk`,greatest(10,cast(sum(`sv`.`volume`) as decimal(5,1))) AS `m3` from (((((((`vn`.`saleTracking` `st` join `vn`.`saleVolume` `sv` on((`sv`.`saleFk` = `st`.`saleFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `sv`.`ticketFk`))) join `vn`.`state` `s` on((`s`.`id` = `st`.`stateFk`))) join `account`.`user` `u` on((`u`.`id` = `st`.`workerFk`))) join `account`.`role` `r` on((`r`.`id` = `u`.`role`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) where ((`st`.`created` > (now() + interval -(1) hour)) and (`s`.`code` = 'CHECKED') and (`r`.`name` <> 'salesPerson') and (`wa`.`name` = 'Silla')) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `lastTopClaims` -- @@ -57305,19 +57124,19 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `saleFreight` +-- Final view structure for view `saleFreight__` -- -/*!50001 DROP VIEW IF EXISTS `saleFreight`*/; +/*!50001 DROP VIEW IF EXISTS `saleFreight__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleFreight` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`clientFk` AS `clientFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`zoneFk` AS `zoneFk`,`t`.`companyFk` AS `companyFk`,`t`.`shipped` AS `shipped`,`zc`.`price` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `zc`.`price`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` from (((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) join `vn`.`zoneCalendar` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`delivered` = `t`.`landed`)))) */; +/*!50001 VIEW `saleFreight__` AS select `s`.`ticketFk` AS `ticketFk`,`t`.`clientFk` AS `clientFk`,`t`.`routeFk` AS `routeFk`,`s`.`id` AS `saleFk`,`t`.`zoneFk` AS `zoneFk`,`t`.`companyFk` AS `companyFk`,`t`.`shipped` AS `shipped`,`t`.`zonePrice` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57353,7 +57172,43 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume` from (((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `saleVolume__` +-- + +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `saleVolume__` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `ic`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `ic`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume`,((((`s`.`quantity` * `ic`.`cm3`) * `t`.`zonePrice`) * `i`.`compression`) / `cb`.`volume`) AS `freight` from ((((`sale` `s` join `item` `i` on((`i`.`id` = `s`.`itemFk`))) join `ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `packaging` `cb` on((`cb`.`id` = '94'))) join `itemCost` `ic` on(((`ic`.`itemFk` = `s`.`itemFk`) and (`ic`.`warehouseFk` = `t`.`warehouseFk`)))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `sale_freightComponent` +-- + +/*!50001 DROP VIEW IF EXISTS `sale_freightComponent`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,(`sc`.`value` * `s`.`quantity`) AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on((`t`.`id` = `s`.`ticketFk`))) join `saleComponent` `sc` on((`sc`.`saleFk` = `s`.`id`))) join `component` `c` on((`c`.`id` = `sc`.`componentFk`))) join `componentType` `ct` on(((`ct`.`id` = `c`.`typeFk`) and (`ct`.`type` = 'agencia')))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -57700,6 +57555,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `zone_ETD` +-- + +/*!50001 DROP VIEW IF EXISTS `zone_ETD`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `zone_ETD` AS select `t`.`zoneFk` AS `zoneFk`,cast((curdate() + interval ((hour(`zc`.`hour`) * 60) + minute(`zc`.`hour`)) minute) as time) AS `HoraTeórica`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volumenTotal`,cast(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0)) as decimal(5,1)) AS `volumenPendiente`,`lhp`.`m3` AS `velocidad`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`) minute) as time) AS `HoraPráctica`,floor(((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`)) AS `minutesLess`,cast((`zc`.`hour` + interval ((-(sum(if((`s`.`alertLevel` < 2),`sv`.`volume`,0))) * 60) / `lhp`.`m3`) minute) as time) AS `etc` from (((((((`vn`.`ticket` `t` join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `s` on((`s`.`id` = `tst`.`state`))) join `vn`.`saleVolume` `sv` on((`sv`.`ticketFk` = `t`.`id`))) join `vn`.`lastHourProduction` `lhp` on((`lhp`.`warehouseFk` = `t`.`warehouseFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `t`.`warehouseFk`))) join `vn`.`warehouseAlias` `wa` on((`wa`.`id` = `w`.`aliasFk`))) join `vn`.`zoneClosure` `zc` on(((`zc`.`zoneFk` = `t`.`zoneFk`) and (`zc`.`dated` = curdate())))) where ((`wa`.`name` = 'Silla') and (cast(`t`.`shipped` as date) = curdate())) group by `t`.`zoneFk` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Current Database: `vncontrol` -- @@ -57715,4 +57588,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-13 9:07:01 +-- Dump completed on 2020-02-27 13:42:11 diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js new file mode 100644 index 000000000..81ddc9be2 --- /dev/null +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -0,0 +1,398 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +fdescribe('worker workerTimeControl_check()', () => { + it('should throw an error if the worker does not belong to this department', async() => { + let stmts = []; + let stmt; + const workerId = 110; + const tabletId = 2; + let err; + stmts.push('START TRANSACTION'); + try { + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + await app.models.Worker.rawStmt(sql); + } catch (e) { + err = e; + } + + expect(err.sqlMessage).toEqual('No perteneces a este departamento.'); + }); + + it('should EL TRABAJDOR ESTA EN EL DEPARTAMENTO Y TABLET CORRECTO', async() => { + let stmts = []; + let stmt; + const workerId = 110; + const tabletId = 1; + let err; + stmts.push('START TRANSACTION'); + try { + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + await app.models.Worker.rawStmt(sql); + } catch (e) { + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 9h', async() => { + const workerIdBreak9Hours = 110; + const tabletId = 1; + let stmts = []; + let stmt; + let sql; + let error; + + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-32399,NOW()),0,"out")`, [ + workerIdBreak9Hours, + workerIdBreak9Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak9Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + error = e; + } + + expect(error.sqlMessage).toEqual('Descansos 9 h'); + }); + + it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 9h', async() => { + const workerIdBreak9Hours = 110; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-17,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-32401,NOW()),0,"out")`, [ + workerIdBreak9Hours, + workerIdBreak9Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak9Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if the worker NO HA CUMPLIDO EL DESCANSO DE 12h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let sql; + let error; + + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-43199,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + error = e; + } + + expect(error.sqlMessage).toEqual('Descansos 12 h'); + }); + + it('should throw an error if the worker HA CUMPLIDO EL DESCANSO de 12h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"in"), + (?,TIMESTAMPADD(SECOND,-43201,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err).not.toBeDefined(); + }); + + it('should throw an error if FICHADAS IMPARES', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + stmts.push('START TRANSACTION'); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in")`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('Dias con fichadas impares'); + }); + + it('should throw an error if ESTA DE VACACIONES', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO postgresql.calendar_employee(business_id,calendar_state_id,date) + VALUES + (?,1,CURDATE())`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('Holidays'); + }); + + it('should throw an error if EL CONTRATO NO ESTA EN VIGOR', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); + + it('should throw an error if NO TIENE DESCANSO SEMANAL', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); + + it('should DESCANSO 32h', async() => { + const workerIdBreak12Hours = 109; + const tabletId = 1; + let stmts = []; + let stmt; + let err; + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`UPDATE postgresql.business SET date_end=DATE_ADD(CURDATE(), INTERVAL -1 DAY) WHERE business_id=?`, [ + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-20,NOW()),0,"out")`, [ + workerIdBreak12Hours, + workerIdBreak12Hours + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerIdBreak12Hours, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + + try { + await app.models.Worker.rawStmt(sql); + } catch (e) { + await app.models.Worker.rawSql('ROLLBACK'); + err = e; + } + + expect(err.sqlMessage).toEqual('No hay un contrato en vigor'); + }); +});