diff --git a/back/methods/dms/updateFile.js b/back/methods/dms/updateFile.js index dff45f640b..7585dd1b08 100644 --- a/back/methods/dms/updateFile.js +++ b/back/methods/dms/updateFile.js @@ -10,8 +10,7 @@ module.exports = Self => { type: 'Number', description: 'The document id', http: {source: 'path'} - }, - { + }, { arg: 'warehouseId', type: 'Number', description: 'The warehouse id' @@ -44,9 +43,9 @@ module.exports = Self => { } }); - Self.updateFile = async(ctx, id, warehouseId, companyId, - dmsTypeId, reference, description, hasFileAttached, options) => { + Self.updateFile = async(ctx, id, options) => { const models = Self.app.models; + const args = ctx.args; let tx; let myOptions = {}; @@ -60,20 +59,20 @@ module.exports = Self => { } try { - const hasWriteRole = await models.DmsType.hasWriteRole(ctx, dmsTypeId); + const hasWriteRole = await models.DmsType.hasWriteRole(ctx, args.dmsTypeId); if (!hasWriteRole) throw new UserError(`You don't have enough privileges`); const dms = await Self.findById(id, null, myOptions); await dms.updateAttributes({ - dmsTypeFk: dmsTypeId, - companyFk: companyId, - warehouseFk: warehouseId, - reference: reference, - description: description + dmsTypeFk: args.dmsTypeId, + companyFk: args.companyId, + warehouseFk: args.warehouseId, + reference: args.reference, + description: args.description }, myOptions); - if (hasFileAttached) + if (args.hasFileAttached) await uploadNewFile(ctx, dms, myOptions); if (tx) await tx.commit(); diff --git a/back/models/province.json b/back/models/province.json index 49a971b650..2e2ace5eda 100644 --- a/back/models/province.json +++ b/back/models/province.json @@ -1,46 +1,53 @@ { - "name": "Province", - "description": "Provinces of every country", - "base": "VnModel", - "options": { - "mysql": { - "table": "province" - } - }, - "properties": { - "id": { - "type": "Number", - "id": true, - "description": "Identifier" + "name": "Province", + "description": "Provinces of every country", + "base": "VnModel", + "options": { + "mysql": { + "table": "province" + } }, - "name": { - "type": "string", - "required": true - } - }, - "relations": { - "country": { - "type": "belongsTo", - "model": "Country", - "foreignKey": "countryFk" + "properties": { + "id": { + "type": "Number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } }, - "warehouse": { - "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + }, + "warehouse": { + "type": "belongsTo", + "model": "Warehouse", + "foreignKey": "warehouseFk" + }, + "zone": { + "type": "belongsTo", + "model": "Zone", + "foreignKey": "zoneFk" + } }, - "zone": { - "type": "belongsTo", - "model": "Zone", - "foreignKey": "zoneFk" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + "scopes": { + "location": { + "include": { + "relation": "country" + } + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } \ No newline at end of file diff --git a/db/changes/10161-postValentineDay/00-ACL.sql b/db/changes/10161-postValentineDay/00-ACL.sql new file mode 100644 index 0000000000..a7ac794864 --- /dev/null +++ b/db/changes/10161-postValentineDay/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES ('EntryLog', '*', 'READ', 'ALLOW', 'ROLE', 'buyer'); diff --git a/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql b/db/changes/10161-postValentineDay/00-workerTimeControlCheck.sql new file mode 100644 index 0000000000..31bc4922bc --- /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 ha 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 1554afbec1..0000000000 --- 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 74290b4514..acdd3ea14b 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 2f3a9378d9..7b2fd1cae5 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 @@ -197,14 +197,16 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (1, 'Valencia', 1), (2, 'Silla', 1), (3, 'Algemesi', 1), - (4, 'Alzira', 1); + (4, 'Alzira', 1), + (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), - ('46600', 4, 7); + ('46600', 4, 7), + ('EC170150', 5, 8); INSERT INTO `vn`.`clientType`(`id`, `code`, `type`) VALUES @@ -554,30 +556,30 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) VALUES - (1, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (2, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (3, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (4, 16, 5 , DATE_ADD(CURDATE(), INTERVAL -3 MONTH)), - (5, 16, 18, DATE_ADD(CURDATE(), INTERVAL -4 MONTH)), - (6, 16, 18, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), - (7, 10, 18, CURDATE()), - (8, 5, 19, CURDATE()), - (9, 5, 19, CURDATE()), - (10, 5, 19, CURDATE()), - (11, 3, 19, CURDATE()), - (12, 3, 19, CURDATE()), - (13, 3, 19, CURDATE()), - (14, 3, 19, CURDATE()), - (15, 3, 19, CURDATE()), - (16, 3, 19, CURDATE()), - (17, 3, 19, CURDATE()), - (18, 3, 19, CURDATE()), - (19, 17, 19, CURDATE()), - (20, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (21, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (22, 1, 19, DATE_ADD(CURDATE(), INTERVAL +1 MONTH)), - (23, 16, 21, CURDATE()), - (24, 16, 21, CURDATE()); + (1, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (2, 16, 5 , DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (3, 16, 5 , DATE_ADD(NOW(), INTERVAL -2 MONTH)), + (4, 16, 5 , DATE_ADD(NOW(), INTERVAL -3 MONTH)), + (5, 16, 18, DATE_ADD(NOW(), INTERVAL -4 MONTH)), + (6, 16, 18, DATE_ADD(NOW(), INTERVAL -1 MONTH)), + (7, 10, 18, NOW()), + (8, 5, 19, NOW()), + (9, 5, 19, NOW()), + (10, 5, 19, NOW()), + (11, 3, 19, NOW()), + (12, 3, 19, NOW()), + (13, 3, 19, NOW()), + (14, 3, 19, NOW()), + (15, 3, 19, NOW()), + (16, 3, 19, NOW()), + (17, 3, 19, NOW()), + (18, 3, 19, NOW()), + (19, 17, 19, NOW()), + (20, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (21, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (22, 1, 19, DATE_ADD(NOW(), INTERVAL +1 MONTH)), + (23, 16, 21, NOW()), + (24, 16, 21, NOW()); INSERT INTO `vn`.`stowaway`(`id`, `shipFk`, `created`) VALUES @@ -1580,6 +1582,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), @@ -1677,12 +1686,12 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) VALUES - (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), (1, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=6, 6, 13) - DAYOFWEEK(CURDATE())) DAY)), - (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9 ) - DAYOFWEEK(CURDATE())) DAY)), + (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=2, 2, 9) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=3, 3, 10) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=4, 4, 11) - DAYOFWEEK(CURDATE())) DAY)), (2, 'day', DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=5, 5, 12) - DAYOFWEEK(CURDATE())) DAY)), @@ -1901,11 +1910,11 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `path`, `readRoleFk`, `writeRoleFk`, `c VALUES (1, 'Facturas Recibidas', 'recibidas', NULL, NULL, 'invoiceIn'), (2, 'Doc oficial', 'oficial', NULL, NULL, 'officialDoc'), - (3, 'Laboral', 'laboral', NULL, NULL, 'hhrrData'), + (3, 'Laboral', 'laboral', 37, 37, 'hhrrData'), (4, 'Albaranes recibidos', 'entradas', NULL, NULL, 'deliveryNote'), (5, 'Otros', 'otros', 1, 1, 'miscellaneous'), (6, 'Pruebas', 'pruebas', NULL, NULL, 'tests'), - (7, 'IAE Clientes', 'IAE_Clientes', NULL, NULL, 'economicActivitiesTax'), + (7, 'IAE Clientes', 'IAE_Clientes', 1, 1, 'economicActivitiesTax'), (8, 'Fiscal', 'fiscal', NULL, NULL, 'fiscal'), (9, 'Vehiculos', 'vehiculos', NULL, NULL, 'vehicles'), (10, 'Plantillas', 'plantillas', NULL, NULL, 'templates'), @@ -1951,9 +1960,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 +1982,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 35cb82fd4a..c008cb055f 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/ticketCreateWithUser.spec.js b/db/tests/vn/ticketCreateWithUser.spec.js index 51ebfe0007..6728eb2da3 100644 --- a/db/tests/vn/ticketCreateWithUser.spec.js +++ b/db/tests/vn/ticketCreateWithUser.spec.js @@ -43,7 +43,6 @@ describe('ticket ticketCreateWithUser()', () => { let ticketResult = result[ticketResultIndex][0]; - expect(ticketResult.id).toBeGreaterThan(21); expect(ticketResult.clientFk).toEqual(params.clientFk); expect(ticketResult.warehouseFk).toEqual(params.warehouseFk); diff --git a/db/tests/vn/timeBusiness_calculateByUser.spec.js b/db/tests/vn/timeBusiness_calculateByUser.spec.js new file mode 100644 index 0000000000..0b09447ef5 --- /dev/null +++ b/db/tests/vn/timeBusiness_calculateByUser.spec.js @@ -0,0 +1,40 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('timeBusiness_calculateByUser()', () => { + it('should return the expected hours for today', async() => { + let start = new Date(); + start.setHours(0, 0, 0, 0); + let end = new Date(); + end.setHours(0, 0, 0, 0); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + let params = { + workerID: 106, + start: start, + end: end + }; + + stmt = new ParameterizedSQL('CALL vn.timeBusiness_calculateByUser(?, ?, ?)', [ + params.workerID, + params.start, + params.end + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeBusinessCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeBusinessCalculateTable] = result[tableIndex]; + + expect(timeBusinessCalculateTable.timeBusinessSeconds).toEqual(28800); + }); +}); diff --git a/db/tests/vn/timeControl_calculateByUser.spec.js b/db/tests/vn/timeControl_calculateByUser.spec.js new file mode 100644 index 0000000000..ac442ab7b3 --- /dev/null +++ b/db/tests/vn/timeControl_calculateByUser.spec.js @@ -0,0 +1,107 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('timeControl_calculateByUser()', () => { + it(`should return today's worked hours`, async() => { + let start = new Date(); + start.setHours(0, 0, 0, 0); + start.setDate(start.getDate() - 1); + + let end = new Date(); + end.setHours(0, 0, 0, 0); + end.setDate(end.getDate() + 1); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + stmts.push(` + DROP TEMPORARY TABLE IF EXISTS + tmp.timeControlCalculate, + tmp.timeBusinessCalculate + `); + + let params = { + workerID: 106, + start: start, + end: end + }; + + stmt = new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [ + params.workerID, + params.start, + params.end + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeControlCalculateTable] = result[tableIndex]; + + expect(timeControlCalculateTable.timeWorkSeconds).toEqual(29400); + }); + + it(`should return the worked hours between last sunday and monday`, async() => { + let lastSunday = new Date(); + let daysSinceSunday = lastSunday.getDay(); + if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :) + daysSinceSunday = 7; + lastSunday.setHours(23, 0, 0, 0); + lastSunday.setDate(lastSunday.getDate() - daysSinceSunday); + + let monday = new Date(); + let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday) + monday.setHours(7, 0, 0, 0); + monday.setDate(monday.getDate() - daysSinceMonday); + + let stmts = []; + let stmt; + + stmts.push('START TRANSACTION'); + + stmts.push(` + DROP TEMPORARY TABLE IF EXISTS + tmp.timeControlCalculate, + tmp.timeBusinessCalculate + `); + + const workerID = 107; + + stmt = new ParameterizedSQL(` + INSERT INTO vn.workerTimeControl(userFk, timed, manual, direction) + VALUES + (?, ?, 1, 'in'), + (?, ?, 1, 'out') + `, [ + workerID, + lastSunday, + workerID, + monday + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.timeControl_calculateByUser(?, ?, ?)', [ + workerID, + lastSunday, + monday + ]); + stmts.push(stmt); + + let tableIndex = stmts.push('SELECT * FROM tmp.timeControlCalculate') - 1; + + stmts.push('ROLLBACK'); + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Ticket.rawStmt(sql); + + let [timeControlCalculateTable] = result[tableIndex]; + + expect(timeControlCalculateTable.timeWorkSeconds).toEqual(30000); + }); +}); diff --git a/db/tests/vn/workerTimeControlCheck.spec.js b/db/tests/vn/workerTimeControlCheck.spec.js new file mode 100644 index 0000000000..620377291e --- /dev/null +++ b/db/tests/vn/workerTimeControlCheck.spec.js @@ -0,0 +1,587 @@ +const app = require('vn-loopback/server/server'); +const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; + +describe('worker workerTimeControl_check()', () => { + it(`should throw an error if the worker can't sign on that tablet`, 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 check that the worker can sign on that tablet', 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 with a special category has not finished the 9h break', async() => { + // dayBreak to 9h in postgresql.professional_category + const workerId = 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 check f the worker with a special category has finished the 9h break', async() => { + // dayBreak to 9h in postgresql.professional_category + const workerId = 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 has not finished the 12h break', async() => { + const workerId = 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 has finished the 12h break', async() => { + const workerId = 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 has odd entry records', async() => { + const workerId = 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")`, [ + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 the worker try to sign on a holiday day', async() => { + const workerId = 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())`, [ + workerId + ]); + 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 the worker try to sign with your contract ended', async() => { + const workerId = 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=?`, [ + workerId + ]); + 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")`, [ + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + 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 the worker has not finished the 36h weekly break', async() => { + const workerId = 109; + const tabletId = 1; + let stmts = []; + let stmt; + + stmts.push('SET @warn := NULL'); + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out")`, [ + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + + let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1; + stmts.push('ROLLBACK'); + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Worker.rawStmt(sql); + + expect(result[warningMessageIndex][0].warning).toEqual('Descansos 36 h'); + }); + + it('should check if the worker has finished the 36h weekly break', async() => { + const workerId = 109; + const tabletId = 1; + let stmts = []; + let stmt; + + stmts.push('SET @warn := NULL'); + + stmts.push('START TRANSACTION'); + + stmt = new ParameterizedSQL(`INSERT INTO vn.workerTimeControl(userFk,timed,manual,direction) + VALUES + (?,TIMESTAMPADD(HOUR,-24,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out")`, [ + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + let warningMessageIndex = stmts.push('SELECT @warn AS warning') - 1; + + let sql = ParameterizedSQL.join(stmts, ';'); + let result = await app.models.Worker.rawStmt(sql); + + expect(result[warningMessageIndex][0].warning).toBe(null); + }); + + it('should throw an error if the worker has not finished the 72h biweekly break', async() => { + const workerId = 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"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-289,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + stmts.push('SELECT @warn AS warning') - 1; + + 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('Descansos 72 h'); + }); + + it('should check if the worker has finished the 72h biweekly break', async() => { + const workerId = 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"), + (?,TIMESTAMPADD(HOUR,-16,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-48,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-40,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-72,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-64,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-96,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-88,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-120,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-112,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-144,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-136,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-168,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-160,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-192,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-184,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-216,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-208,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-240,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-232,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-264,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-256,NOW()),0,"out"), + (?,TIMESTAMPADD(HOUR,-288,NOW()),0,"in"), + (?,TIMESTAMPADD(HOUR,-280,NOW()),0,"out")`, [ + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId, + workerId + ]); + stmts.push(stmt); + + stmt = new ParameterizedSQL('CALL vn.workerTimeControl_check(?, ?, NULL)', [ + workerId, + tabletId + ]); + stmts.push(stmt); + stmts.push('ROLLBACK'); + + stmts.push('SELECT @warn AS warning') - 1; + + 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(); + }); +}); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7e3e726e42..2f1c5d893c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -9,6 +9,7 @@ export default { invoiceOutButton: '.modules-menu > li[ui-sref="invoiceOut.index"]', claimsButton: '.modules-menu > li[ui-sref="claim.index"]', returnToModuleIndexButton: 'a[ui-sref="order.index"]', + homeButton: 'vn-topbar > div.side.start > a', userMenuButton: '#user', userLocalWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.localWarehouseFk"]', userLocalBank: '.user-popover vn-autocomplete[ng-model="$ctrl.localBankFk"]', @@ -43,8 +44,8 @@ export default { taxNumber: 'vn-client-create vn-textfield[ng-model="$ctrl.client.fi"]', socialName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.socialName"]', street: 'vn-client-create vn-textfield[ng-model="$ctrl.client.street"]', - postcode: 'vn-client-create vn-textfield[ng-model="$ctrl.client.postcode"]', - city: 'vn-client-create vn-textfield[ng-model="$ctrl.client.city"]', + postcode: 'vn-client-create vn-datalist[ng-model="$ctrl.client.postcode"]', + city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]', province: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]', userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]', @@ -75,8 +76,8 @@ export default { equalizationTaxCheckbox: 'vn-client-fiscal-data vn-check[ng-model="$ctrl.client.isEqualizated"]', acceptPropagationButton: '.vn-confirm.shown button[response=accept]', address: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.street"]', - postcode: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.postcode"]', - city: 'vn-client-fiscal-data vn-textfield[ng-model="$ctrl.client.city"]', + postcode: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.postcode"]', + city: 'vn-client-fiscal-data vn-datalist[ng-model="$ctrl.client.city"]', province: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.provinceFk"]', country: 'vn-client-fiscal-data vn-autocomplete[ng-model="$ctrl.client.countryFk"]', activeCheckbox: 'vn-client-fiscal-data vn-check[label="Active"]', @@ -113,8 +114,8 @@ export default { defaultCheckbox: 'vn-check[label="Default"]', consignee: 'vn-textfield[ng-model="$ctrl.address.nickname"]', streetAddress: 'vn-textfield[ng-model="$ctrl.address.street"]', - postcode: 'vn-textfield[ng-model="$ctrl.address.postalCode"]', - city: 'vn-textfield[ng-model="$ctrl.address.city"]', + postcode: 'vn-datalist[ng-model="$ctrl.address.postalCode"]', + city: 'vn-datalist[ng-model="$ctrl.address.city"]', province: 'vn-autocomplete[ng-model="$ctrl.address.provinceId"]', agency: 'vn-autocomplete[ng-model="$ctrl.address.agencyModeId"]', phone: 'vn-textfield[ng-model="$ctrl.address.phone"]', @@ -192,7 +193,7 @@ export default { }, dms: { deleteFileButton: 'vn-client-dms-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', - firstDocWorker: 'vn-client-dms-index vn-td:nth-child(8) > span', + firstDocWorker: 'vn-client-dms-index vn-td:nth-child(7) > span', firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor', acceptDeleteButton: '.vn-confirm.shown button[response="accept"]' }, @@ -365,7 +366,7 @@ export default { ticketsIndex: { openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', advancedSearchInvoiceOut: 'vn-ticket-search-panel vn-textfield[ng-model="filter.refFk"]', - newTicketButton: 'vn-ticket-index > a', + newTicketButton: 'vn-ticket-index a', searchResult: 'vn-ticket-index vn-card > vn-table > div > vn-tbody > a.vn-tr', searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', searchResultDate: 'vn-ticket-index vn-table vn-tbody > a:nth-child(1) > vn-td:nth-child(5)', @@ -524,6 +525,7 @@ export default { }, ticketLog: { + firstTD: 'vn-ticket-log vn-table vn-td:nth-child(1)', logButton: 'vn-left-menu a[ui-sref="ticket.card.log"]', changedBy: 'vn-ticket-log > vn-log vn-tr:nth-child(1) > vn-td:nth-child(2) > span', actionTaken: 'vn-ticket-log > vn-log vn-td:nth-child(1) > div > div:nth-child(3) > span.value', @@ -630,6 +632,16 @@ export default { createButton: 'button[type=submit]', cancelButton: 'vn-button[href="#!/client/index"]' }, + orderSummary: { + header: 'vn-order-summary h5', + id: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(1) span', + alias: 'vn-order-summary vn-one:nth-child(1) > vn-label-value:nth-child(2) span', + consignee: 'vn-order-summary vn-one:nth-child(2) > vn-label-value:nth-child(3) span', + subtotal: 'vn-order-summary vn-one.taxes > p:nth-child(1)', + vat: 'vn-order-summary vn-one.taxes > p:nth-child(2)', + total: 'vn-order-summary vn-one.taxes > p:nth-child(3)', + sale: 'vn-order-summary vn-tbody > vn-tr', + }, orderCatalog: { plantRealmButton: 'vn-order-catalog > vn-side-menu vn-icon[icon="icon-plant"]', type: 'vn-autocomplete[data="$ctrl.itemTypes"]', @@ -700,6 +712,17 @@ export default { firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]', confirmButton: '.vn-confirm.shown button[response="accept"]' }, + workerSummary: { + header: 'vn-worker-summary h5', + id: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(2) > section > span', + email: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(3) > section > span', + department: 'vn-worker-summary vn-one:nth-child(1) > vn-label-value:nth-child(4) > section > span', + userId: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(2) > section > span', + userName: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(3) > section > span', + role: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(4) > section > span', + extension: 'vn-worker-summary vn-one:nth-child(2) > vn-label-value:nth-child(5) > section > span', + + }, workerBasicData: { name: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.firstName"]', surname: 'vn-worker-basic-data vn-textfield[ng-model="$ctrl.worker.lastName"]', @@ -783,10 +806,25 @@ export default { ticketOne: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(1)', ticketTwo: 'vn-invoice-out-summary > vn-card > vn-horizontal > vn-auto > vn-table > div > vn-tbody > vn-tr:nth-child(2)' }, + travelBasicDada: { + reference: 'vn-travel-basic-data vn-textfield[ng-model="$ctrl.travel.ref"]', + agency: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.agencyModeFk"]', + shippingDate: 'vn-travel-basic-data vn-date-picker[ng-model="$ctrl.travel.shipped"]', + deliveryDate: 'vn-travel-basic-data vn-date-picker[ng-model="$ctrl.travel.landed"]', + outputWarehouse: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.warehouseOutFk"]', + inputWarehouse: 'vn-travel-basic-data vn-autocomplete[ng-model="$ctrl.travel.warehouseInFk"]', + delivered: 'vn-travel-basic-data vn-check[ng-model="$ctrl.travel.isDelivered"]', + received: 'vn-travel-basic-data vn-check[ng-model="$ctrl.travel.isReceived"]', + save: 'vn-travel-basic-data vn-submit[label="Save"]', + undoChanges: 'vn-travel-basic-data vn-button[label="Undo changes"]' + }, + travelLog: { + firstLogFirstTD: 'vn-travel-log vn-tbody > vn-tr > vn-td:nth-child(1) > div' + }, travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', - uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="cloud_upload"]', + uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="attach_file"]', createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, @@ -806,5 +844,10 @@ export default { header: 'vn-entry-summary > vn-card > h5', reference: 'vn-entry-summary vn-label-value[label="Reference"]', confirmed: 'vn-entry-summary vn-check[label="Confirmed"]', + }, + entryDescriptor: { + agency: 'vn-entry-descriptor div.body vn-label-value:nth-child(3) span', + travelsQuicklink: 'vn-entry-descriptor vn-quick-links > a:nth-child(1)', + entriesQuicklink: 'vn-entry-descriptor vn-quick-links > a:nth-child(2)' } }; diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 27ed5049ae..65db9e7c6a 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -87,7 +87,7 @@ describe('Client create path', async() => { .waitToGetProperty(selectors.createClientView.country, 'value'); expect(clientCity).toEqual('Valencia'); - expect(clientProvince).toEqual('Province one'); + expect(clientProvince).toContain('Province one'); expect(clientCountry).toEqual('España'); }); diff --git a/e2e/paths/02-client/03_edit_fiscal_data.spec.js b/e2e/paths/02-client/03_edit_fiscal_data.spec.js index f7d6cbe920..4cd54b87d0 100644 --- a/e2e/paths/02-client/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client/03_edit_fiscal_data.spec.js @@ -198,11 +198,10 @@ describe('Client Edit fiscalData path', () => { expect(result).toEqual('Valencia'); }); - it(`should confirm the province have been autocompleted`, async() => { const result = await page.waitToGetProperty(selectors.clientFiscalData.province, 'value'); - expect(result).toEqual('Province one'); + expect(result).toContain('Province one'); }); it('should confirm the country have been autocompleted', async() => { diff --git a/e2e/paths/02-client/05_add_address.spec.js b/e2e/paths/02-client/05_add_address.spec.js index 737d6b05bb..c9228e1cff 100644 --- a/e2e/paths/02-client/05_add_address.spec.js +++ b/e2e/paths/02-client/05_add_address.spec.js @@ -25,9 +25,7 @@ describe('Client Add address path', () => { it('should receive an error after clicking save button as consignee, street and town fields are empty', async() => { await page.waitToClick(selectors.clientAddresses.defaultCheckbox); - await page.autocompleteSearch(selectors.clientAddresses.province, 'Province five'); - await page.write(selectors.clientAddresses.city, 'Valencia'); - await page.write(selectors.clientAddresses.postcode, '46000'); + await page.write(selectors.clientAddresses.postcode, 'EC170150'); await page.autocompleteSearch(selectors.clientAddresses.agency, 'Entanglement'); await page.write(selectors.clientAddresses.phone, '999887744'); await page.write(selectors.clientAddresses.mobileInput, '999887744'); @@ -37,6 +35,16 @@ describe('Client Add address path', () => { expect(result).toEqual('Some fields are invalid'); }); + it('should confirm that the city and province are propertly filled', async() => { + const city = await page + .waitToGetProperty(selectors.clientAddresses.city, 'value'); + + const province = await page + .waitToGetProperty(selectors.clientAddresses.province, 'value'); + + expect(city).toEqual('Quito'); + expect(province).toContain('Province five'); + }); it(`should receive an error after clicking save button as consignee, incoterms and customsAgent are empty`, async() => { await page.write(selectors.clientAddresses.consignee, 'Bruce Bunner'); diff --git a/e2e/paths/02-client/08_add_notes.spec.js b/e2e/paths/02-client/08_add_notes.spec.js index 8f1a9244d9..b759cbd078 100644 --- a/e2e/paths/02-client/08_add_notes.spec.js +++ b/e2e/paths/02-client/08_add_notes.spec.js @@ -16,6 +16,12 @@ describe('Client Add notes path', () => { await browser.close(); }); + it(`should reach the notes index`, async() => { + let url = await page.expectURL('/note'); + + expect(url).toBe(true); + }); + it(`should click on the add note button`, async() => { await page.waitToClick(selectors.clientNotes.addNoteFloatButton); let url = await page.expectURL('/note/create'); diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index f45937debf..0d020831eb 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -35,7 +35,7 @@ describe('Client balance path', () => { await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete); let result = await page.waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); + expect(result).toContain('Data saved!'); }); it('should click the new payment button', async() => { @@ -63,7 +63,6 @@ describe('Client balance path', () => { let firstBalanceLine = await page .waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText'); - expect(company).toEqual('VNL'); expect(firstBalanceLine).toContain('0.00'); }); diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js new file mode 100644 index 0000000000..86a95eee38 --- /dev/null +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -0,0 +1,71 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Worker summary path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'worker'); + await page.accessToSearchResult('agencyNick'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the employee summary section', async() => { + const url = await page.expectURL('#!/worker/3/summary'); + + expect(url).toBe(true); + }); + + it('should check the summary contains the name and userName on the header', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.header, 'innerText'); + + expect(result).toEqual('agency agency'); + }); + + it('should check the summary contains the basic data id', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.id, 'innerText'); + + expect(result).toEqual('3'); + }); + + it('should check the summary contains the basic data email', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.email, 'innerText'); + + expect(result).toEqual('agency@verdnatura.es'); + }); + + it('should check the summary contains the basic data department', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.department, 'innerText'); + + expect(result).toEqual('CAMARA'); + }); + + it('should check the summary contains the user data id', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.userId, 'innerText'); + + expect(result).toEqual('3'); + }); + + it('should check the summary contains the user data name', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.userName, 'innerText'); + + expect(result).toEqual('agency'); + }); + + it('should check the summary contains the user data role', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.role, 'innerText'); + + expect(result).toEqual('agency'); + }); + + it('should check the summary contains the user data extension', async() => { + const result = await page.waitToGetProperty(selectors.workerSummary.extension, 'innerText'); + + expect(result).toEqual('1101'); + }); +}); diff --git a/e2e/paths/03-worker/01_basicData.spec.js b/e2e/paths/03-worker/02_basicData.spec.js similarity index 100% rename from e2e/paths/03-worker/01_basicData.spec.js rename to e2e/paths/03-worker/02_basicData.spec.js diff --git a/e2e/paths/03-worker/02_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js similarity index 100% rename from e2e/paths/03-worker/02_time_control.spec.js rename to e2e/paths/03-worker/04_time_control.spec.js diff --git a/e2e/paths/05-ticket/17_log.spec.js b/e2e/paths/05-ticket/17_log.spec.js new file mode 100644 index 0000000000..2008d022e3 --- /dev/null +++ b/e2e/paths/05-ticket/17_log.spec.js @@ -0,0 +1,65 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Ticket log path', () => { + let browser; + let page; + const ticketId = '5'; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should navigate to the target ticket notes section', async() => { + await page.loginAndModule('employee', 'ticket'); + await page.accessToSearchResult(ticketId); + await page.accessToSection('ticket.card.observation'); + let url = await page.expectURL('/observation'); + + expect(url).toBe(true); + }); + + it('should create a new note for the test', async() => { + await page.waitToClick(selectors.ticketNotes.addNoteButton); + await page.autocompleteSearch(selectors.ticketNotes.firstNoteType, 'observation one'); + await page.write(selectors.ticketNotes.firstDescription, 'description'); + await page.waitToClick(selectors.ticketNotes.submitNotesButton); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should navigate to the log section', async() => { + await page.accessToSection('ticket.card.log'); + let url = await page.expectURL('/log'); + + expect(url).toBe(true); + }); + + it('should set the viewport width to 1920 to see the table full width', async() => { + await page.setViewport({ + width: 1920, + height: 0, + }); + + const result = await page.waitToGetProperty(selectors.ticketLog.firstTD, 'innerText'); + + expect(result.length).not.toBeGreaterThan('20'); + }); + + it('should set the viewport width to 800 to see the table shrink and move data to the 1st column', async() => { + await page.setViewport({ + width: 800, + height: 0, + }); + + const result = await page.waitToGetProperty(selectors.ticketLog.firstTD, 'innerText'); + + expect(result.length).toBeGreaterThan('20'); + }); +}); diff --git a/e2e/paths/07-order/01_summary.spec.js b/e2e/paths/07-order/01_summary.spec.js new file mode 100644 index 0000000000..cba56bf709 --- /dev/null +++ b/e2e/paths/07-order/01_summary.spec.js @@ -0,0 +1,65 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Order summary path', () => { + let browser; + let page; + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'order'); + await page.accessToSearchResult('16'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the order summary section', async() => { + const url = await page.expectURL('#!/order/16/summary'); + + expect(url).toBe(true); + }); + + it('should check the summary contains the order id', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.id, 'innerText'); + + expect(result).toEqual('16'); + }); + + it('should check the summary contains the order alias', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.alias, 'innerText'); + + expect(result).toEqual('address 26'); + }); + + it('should check the summary contains the order consignee', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.consignee, 'innerText'); + + expect(result).toEqual('Many places - Silla (Province one)'); + }); + + it('should check the summary contains the order subtotal', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.subtotal, 'innerText'); + + expect(result.length).toBeGreaterThan(1); + }); + + it('should check the summary contains the order vat', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.vat, 'innerText'); + + expect(result.length).toBeGreaterThan(1); + }); + + it('should check the summary contains the order total', async() => { + const result = await page.waitToGetProperty(selectors.orderSummary.total, 'innerText'); + + expect(result.length).toBeGreaterThan(1); + }); + + it('should check the summary contains the order sales', async() => { + const result = await page.countElement(selectors.orderSummary.sale); + + expect(result).toBeGreaterThan(0); + }); +}); diff --git a/e2e/paths/07-order/01_edit_basic_data.spec.js b/e2e/paths/07-order/02_basic_data.spec.js similarity index 100% rename from e2e/paths/07-order/01_edit_basic_data.spec.js rename to e2e/paths/07-order/02_basic_data.spec.js diff --git a/e2e/paths/07-order/02_catalog.spec.js b/e2e/paths/07-order/04_catalog.spec.js similarity index 100% rename from e2e/paths/07-order/02_catalog.spec.js rename to e2e/paths/07-order/04_catalog.spec.js diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js new file mode 100644 index 0000000000..a835df2a2b --- /dev/null +++ b/e2e/paths/10-travel/02_basic_data_and_log.spec.js @@ -0,0 +1,102 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Travel basic data path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'travel'); + await page.accessToSearchResult('3'); + await page.accessToSection('travel.card.basicData'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the thermograph section', async() => { + const result = await page.expectURL('/basic-data'); + + expect(result).toBe(true); + }); + + it('should set a wrong delivery date then receive an error on submit', async() => { + await page.datePicker(selectors.travelBasicDada.deliveryDate, -1, null); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Landing cannot be lesser than shipment'); + }); + + it('should undo the changes', async() => { + await page.waitToClick(selectors.travelBasicDada.undoChanges); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('No changes to save'); + }); + + it('should now edit the whole form then save', async() => { + await page.clearInput(selectors.travelBasicDada.reference); + await page.write(selectors.travelBasicDada.reference, 'new reference!'); + await page.waitFor(2000); + await page.autocompleteSearch(selectors.travelBasicDada.agency, 'Entanglement'); + await page.autocompleteSearch(selectors.travelBasicDada.outputWarehouse, 'Warehouse Three'); + await page.autocompleteSearch(selectors.travelBasicDada.inputWarehouse, 'Warehouse Four'); + await page.waitToClick(selectors.travelBasicDada.delivered); + await page.waitToClick(selectors.travelBasicDada.received); + await page.waitToClick(selectors.travelBasicDada.save); + const result = await page.waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should reload the section and check the reference was saved', async() => { + await page.reloadSection('travel.card.basicData'); + const result = await page.waitToGetProperty(selectors.travelBasicDada.reference, 'value'); + + expect(result).toEqual('new reference!'); + }); + + it('should check the agency was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.agency, 'value'); + + expect(result).toEqual('Entanglement'); + }); + + it('should check the output warehouse date was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.outputWarehouse, 'value'); + + expect(result).toEqual('Warehouse Three'); + }); + + it('should check the input warehouse date was saved', async() => { + const result = await page.waitToGetProperty(selectors.travelBasicDada.inputWarehouse, 'value'); + + expect(result).toEqual('Warehouse Four'); + }); + + it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => { + await page.waitForClassPresent(selectors.travelBasicDada.delivered, 'checked'); + }); + + it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => { + await page.waitForClassPresent(selectors.travelBasicDada.received, 'checked'); + }); + + it('should navigate to the travel logs', async() => { + await page.accessToSection('travel.card.log'); + const result = await page.expectURL('/log'); + + expect(result).toBe(true); + }); + + it('should check the 1st log contains details from the changes made', async() => { + const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText'); + + expect(result).toContain('new reference!'); + }); +}); diff --git a/e2e/paths/12-entry/02_descriptor.spec.js b/e2e/paths/12-entry/02_descriptor.spec.js new file mode 100644 index 0000000000..8fa0d2a4fe --- /dev/null +++ b/e2e/paths/12-entry/02_descriptor.spec.js @@ -0,0 +1,61 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Entry descriptor path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('buyer', 'entry'); + await page.accessToSearchResult('2'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should reach the second entry summary section', async() => { + let url = await page.expectURL('#!/entry/2/summary'); + + expect(url).toBe(true); + }); + + it('should show some entry information', async() => { + const result = await page.waitToGetProperty(selectors.entryDescriptor.agency, 'innerText'); + + expect(result).toContain('inhouse pickup'); + }); + + it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => { + await page.waitToClick(selectors.entryDescriptor.travelsQuicklink); + const url = await page.expectURL('/travel/index'); + const filter = await page.expectURL('agencyFk'); + + expect(url).toBe(true); + expect(filter).toBe(true); + }); + + it('should go back to the entry summary', async() => { + await page.waitToClick(selectors.globalItems.homeButton); + await page.selectModule('entry'); + await page.accessToSearchResult('2'); + let url = await page.expectURL('#!/entry/2/summary'); + + expect(url).toBe(true); + }); + + it('should click the entries button to be redirected to the entries index filtered by the current supplier', async() => { + await page.waitToClick(selectors.entryDescriptor.entriesQuicklink); + const url = await page.expectURL('/entry/index'); + const supplierFilter = await page.expectURL('supplierFk'); + const toFilter = await page.expectURL('to'); + const fromFilter = await page.expectURL('from'); + + expect(url).toBe(true); + expect(supplierFilter).toBe(true); + expect(toFilter).toBe(true); + expect(fromFilter).toBe(true); + }); +}); diff --git a/front/core/components/button/style.scss b/front/core/components/button/style.scss index 032c88cbb8..f799a21ae9 100644 --- a/front/core/components/button/style.scss +++ b/front/core/components/button/style.scss @@ -50,6 +50,17 @@ } } } + &.message { + color: white; + background-color: $color-bg-dark; + + &:not(.disabled) { + &:hover, + &:focus { + background-color: lighten($color-bg-dark, 10%); + } + } + } &.flat { color: $color-button; background-color: transparent; @@ -75,6 +86,22 @@ & > button > span { display: none; } + + &.xs { + font-size: 0.5em; + } + + &.sm { + font-size: 0.7em; + } + + &.md { + font-size: 0.9em; + } + + &.lg { + font-size: 1.2em; + } } &.disabled { opacity: .7; diff --git a/front/core/components/datalist/index.js b/front/core/components/datalist/index.js index bf3cab9a18..d52e6ca230 100644 --- a/front/core/components/datalist/index.js +++ b/front/core/components/datalist/index.js @@ -27,7 +27,7 @@ export default class Datalist extends Textfield { value = value == '' || value == null ? null : value; oldValue = oldValue == '' || oldValue == null ? null : oldValue; - this.refreshSelection(); + if (oldValue === undefined) this.refreshSelection(); if (!value || value === oldValue && this.modelData != null) return; @@ -52,7 +52,14 @@ export default class Datalist extends Textfield { validSelection(selection) { return this.modelData && this.modelData.find(item => { - return item[this.valueField] == selection; + let dataValue = item[this.valueField]; + if (typeof(dataValue) === 'string') + dataValue = dataValue.toLowerCase(); + + if (typeof(selection) === 'string') + selection = selection.toLowerCase(); + + return dataValue == selection; }); } diff --git a/front/core/components/input-file/index.html b/front/core/components/input-file/index.html index 11478430a4..be4c15248a 100644 --- a/front/core/components/input-file/index.html +++ b/front/core/components/input-file/index.html @@ -30,7 +30,7 @@ ng-click="$ctrl.onClear($event)"> diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js new file mode 100644 index 0000000000..70a79bcffc --- /dev/null +++ b/front/core/directives/specs/http-click.spec.js @@ -0,0 +1,66 @@ +describe('Directive http-click', () => { + let $scope; + let element; + let compile; + + beforeEach(ngModule('vnCore')); + + compile = (_element, _childElement) => { + inject(($compile, $rootScope) => { + $scope = $rootScope.$new(); + element = angular.element(_element); + $compile(element)($scope); + $scope.$digest(); + }); + }; + + it('should call click function on the element, disable it and then enable it again', () => { + let html = ``; + compile(html); + + const myPromise = new Promise(resolve => resolve()); + $scope.myEvent = () => { + return myPromise; + }; + + element[0].$ctrl = {disabled: false}; + element[0].click(); + + expect(element[0].$ctrl.disabled).toEqual(true); + + let finalValue; + myPromise.then(() => { + finalValue = 'called!'; + + expect(element[0].$ctrl.disabled).toEqual(false); + }).finally(() => { + expect(finalValue).toEqual('called!'); + }); + }); + + it('should call click function on the element and not disable it', () => { + let html = ``; + compile(html); + + const myPromise = new Promise(resolve => resolve()); + $scope.myEvent = () => { + return myPromise; + }; + + element[0].$ctrl = {disabled: true}; + element[0].click(); + + expect(element[0].$ctrl.disabled).toEqual(true); + + let finalValue; + myPromise.then(() => { + finalValue = 'called!'; + + expect(element[0].$ctrl.disabled).toEqual(true); + }).finally(() => { + expect(finalValue).toEqual('called!'); + }).catch(err => { + console.log(err); + }); + }); +}); diff --git a/front/core/lib/component.js b/front/core/lib/component.js index b9f04dba60..4552dfbe73 100644 --- a/front/core/lib/component.js +++ b/front/core/lib/component.js @@ -108,7 +108,10 @@ function runFn( $filter, $interpolate, $window, - vnApp) { + vnApp, + vnToken, + vnConfig, + aclService) { Object.assign(Component.prototype, { $translate, $q, @@ -121,7 +124,10 @@ function runFn( $filter, $interpolate, $window, - vnApp + vnApp, + vnToken, + vnConfig, + aclService }); } runFn.$inject = [ @@ -136,7 +142,10 @@ runFn.$inject = [ '$filter', '$interpolate', '$window', - 'vnApp' + 'vnApp', + 'vnToken', + 'vnConfig', + 'aclService' ]; ngModule.run(runFn); diff --git a/front/salix/components/descriptor/index.html b/front/salix/components/descriptor/index.html index 3804be627f..4a50be4307 100644 --- a/front/salix/components/descriptor/index.html +++ b/front/salix/components/descriptor/index.html @@ -1,24 +1,8 @@ - + ui-sref="{{::button.state}}"> - - - - - - - - + icon="{{::button.icon}}"> \ No newline at end of file diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 49cd0f1719..b8c31020bc 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -64,5 +64,6 @@ "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} (#{{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", - "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}" + "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 7577c5349a..fe95bc0650 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -127,5 +127,6 @@ "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000" + "Distance must be lesser than 1000": "La distancia debe ser inferior a 1000", + "This ticket is deleted": "Este ticket está eliminado" } \ No newline at end of file diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js index 7a04f95d5e..dc22cb4be6 100644 --- a/modules/claim/front/action/index.js +++ b/modules/claim/front/action/index.js @@ -155,7 +155,6 @@ class Controller { }); } - onUpdateGreugeResponse(response) { if (response == 'accept') { const promises = []; diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 7bc9c831ae..fd00368b8c 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -1,14 +1,11 @@ import ngModule from '../module'; +import Component from 'core/lib/component'; -class Controller { - constructor($scope, $state, $http, $translate, vnApp, aclService, $httpParamSerializer) { - this.$scope = $scope; - this.$state = $state; - this.$http = $http; - this.$translate = $translate; - this.vnApp = vnApp; - this.aclService = aclService; +class Controller extends Component { + constructor($element, $scope, $httpParamSerializer) { + super($element, $scope); this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ {callback: this.showPickupOrder, name: 'Show Pickup order'}, {callback: this.confirmPickupOrder, name: 'Send Pickup order'}, @@ -22,7 +19,7 @@ class Controller { return !hasAclProperty || (hasAclProperty && this.aclService.hasAny([option.acl])); }); - this.$scope.moreButton.data = options; + this.$.moreButton.data = options; } onMoreChange(callback) { @@ -63,7 +60,8 @@ class Controller { showPickupOrder() { const params = { clientId: this.claim.clientFk, - claimId: this.claim.id + claimId: this.claim.id, + authorization: this.vnToken.token }; const serializedParams = this.$httpParamSerializer(params); let url = `api/report/claim-pickup-order?${serializedParams}`; @@ -71,7 +69,7 @@ class Controller { } confirmPickupOrder() { - this.$scope.confirmPickupOrder.show(); + this.$.confirmPickupOrder.show(); } sendPickupOrder(response) { @@ -81,16 +79,14 @@ class Controller { clientId: this.claim.clientFk, claimId: this.claim.id }; - const serializedParams = this.$httpParamSerializer(params); - const url = `email/claim-pickup-order?${serializedParams}`; - this.$http.get(url).then( + this.$http.get(`email/claim-pickup-order`, {params}).then( () => this.vnApp.showMessage(this.$translate.instant('Notification sent!')) ); } } confirmDeleteClaim() { - this.$scope.confirmDeleteClaim.show(); + this.$.confirmDeleteClaim.show(); } deleteClaim(response) { @@ -103,7 +99,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnClaimDescriptor', { template: require('./index.html'), diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index a64d5ecc1b..4a78bda5a0 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -3,14 +3,19 @@ import './index.js'; describe('Item Component vnClaimDescriptor', () => { let $httpParamSerializer; let $httpBackend; + let $element; + let $scope; let controller; beforeEach(ngModule('claim')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; - controller = $componentController('vnClaimDescriptor'); + $scope = $rootScope.$new(); + + $element = angular.element(''); + controller = $componentController('vnClaimDescriptor', {$element, $scope}); controller.claim = {id: 2, clientFk: 101, client: {email: 'client@email'}}; })); @@ -31,13 +36,13 @@ describe('Item Component vnClaimDescriptor', () => { describe('confirmPickupOrder()', () => { it('should call confirmPickupOrder.show()', () => { - controller.$scope.confirmPickupOrder = { + controller.$.confirmPickupOrder = { show: jasmine.createSpy('show') }; controller.claim = {id: 2}; controller.confirmPickupOrder(); - expect(controller.$scope.confirmPickupOrder.show).toHaveBeenCalledWith(); + expect(controller.$.confirmPickupOrder.show).toHaveBeenCalledWith(); }); }); @@ -63,13 +68,13 @@ describe('Item Component vnClaimDescriptor', () => { describe('confirmDeleteClaim()', () => { it('should call confirmDeleteClaim.show()', () => { - controller.$scope.confirmDeleteClaim = { + controller.$.confirmDeleteClaim = { show: jasmine.createSpy('show') }; controller.claim = {id: 2}; controller.confirmDeleteClaim(); - expect(controller.$scope.confirmDeleteClaim.show).toHaveBeenCalledWith(); + expect(controller.$.confirmDeleteClaim.show).toHaveBeenCalledWith(); }); }); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 93d3db4559..f50af1e5ad 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -10,24 +10,17 @@ + + - - - - - - { let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson'); - expect(result.length).toEqual(14); + expect(result.length).toEqual(15); expect(isSalesPerson).toBeTruthy(); }); @@ -17,7 +17,7 @@ describe('Client activeWorkersWithRole', () => { let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer'); - expect(result.length).toEqual(11); + expect(result.length).toEqual(13); expect(isBuyer).toBeTruthy(); }); }); diff --git a/modules/client/back/methods/client/specs/isValidClient.spec.js b/modules/client/back/methods/client/specs/isValidClient.spec.js index 446392374b..71d7473f1b 100644 --- a/modules/client/back/methods/client/specs/isValidClient.spec.js +++ b/modules/client/back/methods/client/specs/isValidClient.spec.js @@ -16,7 +16,7 @@ describe('Client isValidClient', () => { }); it('should call the isValidClient() method with an unexistant id and receive false', async() => { - let id = 999999; + let id = 999; let result = await app.models.Client.isValidClient(id); expect(result).toBeFalsy(); diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index af956650d5..153036e058 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -47,7 +47,6 @@ module.exports = Self => { let xmlParsed; let status; - try { if (process.env.NODE_ENV !== 'production') { status = { diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 367e0f0ebd..417370e9ea 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -191,7 +191,6 @@ module.exports = Self => { if (socialNameChanged && !isAlpha(changes.socialName)) throw new UserError('The socialName has an invalid format'); - if (changes.salesPerson === null) { changes.credit = 0; changes.discount = 0; @@ -238,7 +237,9 @@ module.exports = Self => { const httpCtx = {req: loopBackContext.active}; const httpRequest = httpCtx.req.http.req; const $t = httpRequest.__; - const origin = httpRequest.headers.origin; + const headers = httpRequest.headers; + const origin = headers.origin; + const authorization = headers.authorization; const salesPersonId = instance.salesPersonFk; @@ -254,12 +255,14 @@ module.exports = Self => { // Send email to client if (!instance.email) return; - const serializedParams = httpParamSerializer({ + const params = { + authorization: authorization, clientId: instance.id, recipient: instance.email + }; + await request.get(`${origin}/api/email/payment-update`, { + qs: params }); - const query = `${origin}/api/email/payment-update?${serializedParams}`; - await request.get(query); } }); diff --git a/modules/client/front/address/create/index.html b/modules/client/front/address/create/index.html index 1c70a1cbd7..519638d48d 100644 --- a/modules/client/front/address/create/index.html +++ b/modules/client/front/address/create/index.html @@ -39,61 +39,53 @@ - - - - - - - - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + {{name}} ({{country.country}}) + { if (this.address.isDefaultAddress) @@ -51,6 +31,46 @@ export default class Controller extends Component { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id); } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + this._town = selection; + + if (!selection) return; + + const province = selection.province; + const postcodes = selection.postcodes; + + this.address.provinceId = province.id; + + if (postcodes.length === 1) + this.address.postalCode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + this._postcode = selection; + + if (!selection) return; + + const town = selection.town; + const province = town.province; + + this.address.city = town.name; + this.address.provinceId = province.id; + } + + onResponse(response) { + this.address.postalCode = response.code; + } } Controller.$inject = ['$element', '$scope']; diff --git a/modules/client/front/address/create/index.spec.js b/modules/client/front/address/create/index.spec.js index 289e0572d5..fb6567dcef 100644 --- a/modules/client/front/address/create/index.spec.js +++ b/modules/client/front/address/create/index.spec.js @@ -53,9 +53,48 @@ describe('Client', () => { }); }); - describe('postcodeSelection() setter', () => { - it(`should set the town, province and contry properties`, () => { - controller.postcodeSelection = { + describe('town() setter', () => { + it(`should set provinceId property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.address.provinceId).toEqual(1); + }); + + it(`should set provinceId property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.address.provinceId).toEqual(1); + expect(controller.address.postalCode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town and province properties`, () => { + controller.postcode = { townFk: 1, code: 46001, town: { @@ -73,7 +112,7 @@ describe('Client', () => { }; expect(controller.address.city).toEqual('New York'); - expect(controller.address.provinceFk).toEqual(1); + expect(controller.address.provinceId).toEqual(1); }); }); diff --git a/modules/client/front/address/edit/index.html b/modules/client/front/address/edit/index.html index 0356081209..70b3523c5c 100644 --- a/modules/client/front/address/edit/index.html +++ b/modules/client/front/address/edit/index.html @@ -56,58 +56,53 @@ - - - - - - - - - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + {{name}} ({{country.country}}) + this.$.model.save(true)) @@ -39,6 +35,48 @@ export default class Controller extends Component { return this.$http.post(`CustomsAgents`, this.newCustomsAgent) .then(res => this.address.customsAgentFk = res.data.id); } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + const oldValue = this._town; + this._town = selection; + + if (!oldValue) return; + + const province = selection.province; + const postcodes = selection.postcodes; + + this.address.provinceFk = province.id; + + if (postcodes.length === 1) + this.address.postalCode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + const oldValue = this._postcode; + this._postcode = selection; + + if (!oldValue) return; + + const town = selection.town; + const province = town.province; + + this.address.city = town.name; + this.address.provinceFk = province.id; + } + + onResponse(response) { + this.address.postalCode = response.code; + } } ngModule.component('vnClientAddressEdit', { diff --git a/modules/client/front/create/index.html b/modules/client/front/create/index.html index ce4b7d4ed0..b2ef42beb2 100644 --- a/modules/client/front/create/index.html +++ b/modules/client/front/create/index.html @@ -49,76 +49,63 @@ - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + + + {{name}} ({{country.country}}) + + - - - - - - - - - - this.$state.go('client.card.basicData', {id: json.data.id}) + ); } - set postcodeSelection(selection) { - this._postcodeSelection = selection; + get province() { + return this._province; + } + + // Province auto complete + set province(selection) { + this._province = selection; + + if (!selection) return; + + const country = selection.country; + + this.client.countryFk = country.id; + } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + this._town = selection; + + if (!selection) return; + + const province = selection.province; + const country = province.country; + const postcodes = selection.postcodes; + + this.client.provinceFk = province.id; + this.client.countryFk = country.id; + + if (postcodes.length === 1) + this.client.postcode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + this._postcode = selection; if (!selection) return; @@ -33,13 +76,8 @@ export default class Controller { onResponse(response) { this.client.postcode = response.code; } - - onSubmit() { - return this.$.watcher.submit().then( - json => this.$state.go('client.card.basicData', {id: json.data.id}) - ); - } } + Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; ngModule.component('vnClientCreate', { diff --git a/modules/client/front/create/index.spec.js b/modules/client/front/create/index.spec.js index 656392e3d0..c297b0545d 100644 --- a/modules/client/front/create/index.spec.js +++ b/modules/client/front/create/index.spec.js @@ -40,9 +40,63 @@ describe('Client', () => { }); }); - describe('postcodeSelection() setter', () => { - it(`should set the town, province and contry properties`, () => { - controller.postcodeSelection = { + describe('province() setter', () => { + it(`should set countryFk property`, () => { + controller.province = { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }; + + expect(controller.client.countryFk).toEqual(2); + }); + }); + + describe('town() setter', () => { + it(`should set provinceFk property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.client.provinceFk).toEqual(1); + }); + + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.postcode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town, provinceFk and contryFk properties`, () => { + controller.postcode = { townFk: 1, code: 46001, town: { diff --git a/modules/client/front/descriptor/index.js b/modules/client/front/descriptor/index.js index 95754b4df9..4cf35d1e93 100644 --- a/modules/client/front/descriptor/index.js +++ b/modules/client/front/descriptor/index.js @@ -5,6 +5,7 @@ class Controller extends Component { constructor($element, $, $httpParamSerializer) { super($element, $); this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ {name: 'Simple ticket', callback: this.newTicket}, {name: 'Send SMS', callback: this.showSMSDialog}, @@ -72,8 +73,13 @@ class Controller extends Component { sendConsumerReport(response) { if (response === 'accept') { - const data = {from: this.from, to: this.to, clientId: this.client.id}; - const serializedParams = this.$httpParamSerializer(data); + const params = { + authorization: this.vnToken.token, + clientId: this.client.id, + from: this.from, + to: this.to, + }; + const serializedParams = this.$httpParamSerializer(params); const url = `api/report/campaign-metrics?${serializedParams}`; window.open(url); } diff --git a/modules/client/front/dms/edit/index.html b/modules/client/front/dms/edit/index.html index dbc2e0ed1f..87d69fdcde 100644 --- a/modules/client/front/dms/edit/index.html +++ b/modules/client/front/dms/edit/index.html @@ -56,7 +56,16 @@ label="File" ng-model="$ctrl.dms.files" on-change="$ctrl.onFileChange($files)" - accept=".pdf, .png, .jpg, .jpeg, application/zip, application/rar, application/x-7z-compressed"> + accept="{{$ctrl.allowedContentTypes}}" + required="true" + multiple="true"> + + + + diff --git a/modules/client/front/dms/index/index.html b/modules/client/front/dms/index/index.html index 9ecafe887e..78bc45b574 100644 --- a/modules/client/front/dms/index/index.html +++ b/modules/client/front/dms/index/index.html @@ -53,11 +53,6 @@ {{::document.dms.description}} - - - - - + + {{code}} - {{town.name}} ({{town.province.name}}, + {{town.province.country.country}}) + + + + + + + + + {{name}}, {{province.name}} + ({{province.country.country}}) + + + + + + {{name}} ({{country.country}}) + + - - - - - - - - - + + + \ No newline at end of file diff --git a/modules/client/front/fiscal-data/index.js b/modules/client/front/fiscal-data/index.js index b2602f7a4c..f302606dd0 100644 --- a/modules/client/front/fiscal-data/index.js +++ b/modules/client/front/fiscal-data/index.js @@ -5,16 +5,29 @@ export default class Controller extends Component { onSubmit() { const orgData = this.$.watcher.orgData; delete this.client.despiteOfClient; - if (!orgData.isTaxDataChecked && this.client.isTaxDataChecked) + + const hasContactData = this.client.email || this.client.phone || this.client.mobile; + const hasChangedTaxData = !orgData.isTaxDataChecked && this.client.isTaxDataChecked; + if (hasChangedTaxData && hasContactData) this.checkExistingClient(); else this.save(); } checkExistingClient() { + const findParams = []; + if (this.client.email) + findParams.push({email: this.client.email}); + + if (this.client.phone) + findParams.push({phone: this.client.phone}); + + if (this.client.mobile) + findParams.push({mobile: this.client.mobile}); + const filterObj = { where: { and: [ - {or: [{email: this.client.email}, {phone: this.client.phone}]}, + {or: findParams}, {id: {neq: this.client.id}} ] } @@ -32,7 +45,8 @@ export default class Controller extends Component { this.$.confirmDuplicatedClient.show(); }).catch(error => { if (error.status == 404) - this.save(); + return this.save(); + throw error; }); } @@ -77,6 +91,68 @@ export default class Controller extends Component { this.$.$apply(); } + + get province() { + return this._province; + } + + // Province auto complete + set province(selection) { + const oldValue = this._province; + this._province = selection; + + if (!selection || !oldValue) return; + + const country = selection.country; + + this.client.countryFk = country.id; + } + + get town() { + return this._town; + } + + // Town auto complete + set town(selection) { + const oldValue = this._town; + this._town = selection; + + if (!selection || !oldValue) return; + + const province = selection.province; + const country = province.country; + const postcodes = selection.postcodes; + + this.client.provinceFk = province.id; + this.client.countryFk = country.id; + + if (postcodes.length === 1) + this.client.postcode = postcodes[0].code; + } + + get postcode() { + return this._postcode; + } + + // Postcode auto complete + set postcode(selection) { + const oldValue = this._postcode; + this._postcode = selection; + + if (!selection || !oldValue) return; + + const town = selection.town; + const province = town.province; + const country = province.country; + + this.client.city = town.name; + this.client.provinceFk = province.id; + this.client.countryFk = country.id; + } + + onResponse(response) { + this.client.postcode = response.code; + } } ngModule.component('vnClientFiscalData', { diff --git a/modules/client/front/fiscal-data/index.spec.js b/modules/client/front/fiscal-data/index.spec.js index 52c2ee29ef..a884f3e97a 100644 --- a/modules/client/front/fiscal-data/index.spec.js +++ b/modules/client/front/fiscal-data/index.spec.js @@ -25,6 +25,10 @@ describe('Client', () => { isEqualizated: false, isTaxDataChecked: false }; + + controller.province = {}; + controller.town = {}; + controller.postcode = {}; })); describe('onSubmit()', () => { @@ -49,9 +53,30 @@ describe('Client', () => { }); describe('checkExistingClient()', () => { - it('should show a save confirmation when a duplicated client is found and then set the despiteOfClient property', () => { + it(`should make a HTTP GET query filtering by email, phone and mobile`, () => { + controller.client.mobile = 222222222; + const filterObj = { + where: { + and: [ + {or: [ + {email: controller.client.email}, + {phone: controller.client.phone}, + {mobile: controller.client.mobile} + ]}, + {id: {neq: controller.client.id}} + ] + } + }; + const filter = encodeURIComponent(JSON.stringify(filterObj)); + $httpBackend.expect('GET', `Clients/findOne?filter=${filter}`).respond(404); + controller.checkExistingClient(); + $httpBackend.flush(); + }); + + it(`should show a save confirmation and then set the despiteOfClient property`, () => { controller.$.confirmDuplicatedClient = {show: () => {}}; jest.spyOn(controller.$.confirmDuplicatedClient, 'show'); + const filterObj = { where: { and: [ @@ -107,5 +132,84 @@ describe('Client', () => { $httpBackend.flush(); }); }); + + describe('province() setter', () => { + it(`should set countryFk property`, () => { + controller.province = { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }; + + expect(controller.client.countryFk).toEqual(2); + }); + }); + + describe('town() setter', () => { + it(`should set provinceFk property`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [] + }; + + expect(controller.client.provinceFk).toEqual(1); + }); + + it(`should set provinceFk property and fill the postalCode if there's just one`, () => { + controller.town = { + provinceFk: 1, + code: 46001, + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + }, + postcodes: [{code: '46001'}] + }; + + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.postcode).toEqual('46001'); + }); + }); + + describe('postcode() setter', () => { + it(`should set the town, provinceFk and contryFk properties`, () => { + controller.postcode = { + townFk: 1, + code: 46001, + town: { + id: 1, + name: 'New York', + province: { + id: 1, + name: 'New york', + country: { + id: 2, + name: 'USA' + } + } + } + }; + + expect(controller.client.city).toEqual('New York'); + expect(controller.client.provinceFk).toEqual(1); + expect(controller.client.countryFk).toEqual(2); + }); + }); }); }); diff --git a/modules/client/front/postcode/index.html b/modules/client/front/postcode/index.html index 55990281c3..fd81534eda 100644 --- a/modules/client/front/postcode/index.html +++ b/modules/client/front/postcode/index.html @@ -1,7 +1,7 @@ + on-accept="$ctrl.onAccept()">
New postcode

Please, ensure you put the correct data!

diff --git a/modules/client/front/postcode/index.js b/modules/client/front/postcode/index.js index bbf0b1953c..836ea9a81e 100644 --- a/modules/client/front/postcode/index.js +++ b/modules/client/front/postcode/index.js @@ -35,25 +35,20 @@ class Controller extends Component { this.$.postcode.focus(); } - onResponse(response) { - if (response == 'accept') { - try { - if (!this.data.code) - throw new Error(`The postcode can't be empty`); - if (!this.data.townFk) - throw new Error(`The town can't be empty`); + onAccept() { + try { + if (!this.data.code) + throw new Error(`The postcode can't be empty`); + if (!this.data.townFk) + throw new Error(`The town can't be empty`); - this.$http.patch(`postcodes`, this.data).then(response => { - if (response.data) { - this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); - - this.emit('response', {response: response.data}); - } - }); - } catch (e) { - this.vnApp.showError(this.$translate.instant(e.message)); - return false; - } + this.$http.patch(`postcodes`, this.data).then(res => { + this.vnApp.showMessage(this.$translate.instant('The postcode has been saved')); + this.emit('response', {$response: res.data}); + }); + } catch (e) { + this.vnApp.showError(this.$translate.instant(e.message)); + return false; } return true; } diff --git a/modules/client/front/postcode/index.spec.js b/modules/client/front/postcode/index.spec.js index 04f1a8924d..a5e5db9d56 100644 --- a/modules/client/front/postcode/index.spec.js +++ b/modules/client/front/postcode/index.spec.js @@ -15,7 +15,7 @@ describe('Client', () => { controller.client = {id: 101}; })); - describe('onResponse()', () => { + describe('onAccept()', () => { it('should perform a POST query and show a success snackbar', () => { let params = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; @@ -24,7 +24,7 @@ describe('Client', () => { $httpBackend.when('PATCH', `postcodes`, params).respond(200, params); $httpBackend.expect('PATCH', `postcodes`, params).respond(params); - controller.onResponse('accept'); + controller.onAccept(); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('The postcode has been saved'); diff --git a/modules/client/front/search-panel/index.html b/modules/client/front/search-panel/index.html index 579f044c14..7577676716 100644 --- a/modules/client/front/search-panel/index.html +++ b/modules/client/front/search-panel/index.html @@ -9,18 +9,6 @@ vn-focus>
- - - - - - + + \ No newline at end of file diff --git a/modules/entry/front/log/index.js b/modules/entry/front/log/index.js new file mode 100644 index 0000000000..a5fb6c6682 --- /dev/null +++ b/modules/entry/front/log/index.js @@ -0,0 +1,15 @@ +import ngModule from '../module'; + +class Controller { + constructor($scope, $stateParams) { + this.$scope = $scope; + this.$stateParams = $stateParams; + } +} + +Controller.$inject = ['$scope', '$stateParams']; + +ngModule.component('vnEntryLog', { + template: require('./index.html'), + controller: Controller, +}); diff --git a/modules/entry/front/log/locale/es.yml b/modules/entry/front/log/locale/es.yml new file mode 100644 index 0000000000..094615b472 --- /dev/null +++ b/modules/entry/front/log/locale/es.yml @@ -0,0 +1 @@ +Date: Fecha \ No newline at end of file diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 612edc157a..084ff7bb22 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -9,6 +9,8 @@ {"state": "entry.index", "icon": "icon-entry"} ], "card": [ + {"state": "entry.card.buy", "icon": "icon-lines"}, + {"state": "entry.card.log", "icon": "history"} ] }, "routes": [ @@ -36,6 +38,19 @@ "params": { "entry": "$ctrl.entry" } + }, { + "url" : "/log", + "state": "entry.card.log", + "component": "vn-entry-log", + "description": "Log" + }, { + "url" : "/buy", + "state": "entry.card.buy", + "component": "vn-entry-buy", + "description": "Buy", + "params": { + "entry": "$ctrl.entry" + } } ] } \ No newline at end of file diff --git a/modules/order/front/search-panel/index.html b/modules/order/front/search-panel/index.html index cb65e83c00..383df455f7 100644 --- a/modules/order/front/search-panel/index.html +++ b/modules/order/front/search-panel/index.html @@ -10,11 +10,6 @@ - - { + this.$http.get(`email/driver-route`, {params}).then(() => { this.vnApp.showSuccess(this.$translate.instant('Report sent')); }); } @@ -76,7 +73,7 @@ class Controller { } } -Controller.$inject = ['$scope', '$http', 'vnApp', '$translate', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnRouteDescriptor', { template: require('./index.html'), diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index 4a0e581126..c4e4f8d7e4 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -1,6 +1,6 @@ @@ -23,7 +23,7 @@ - + @@ -86,7 +86,7 @@
diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js index e516a5fa6e..f363302359 100644 --- a/modules/route/front/tickets/index.js +++ b/modules/route/front/tickets/index.js @@ -1,26 +1,24 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; import './style.scss'; -class Controller { - constructor($stateParams, $scope, $translate, $http, vnApp, $filter) { - this.$translate = $translate; - this.$stateParams = $stateParams; - this.$ = $scope; - this.$http = $http; - this.vnApp = vnApp; +class Controller extends Section { + constructor($element, $scope, $filter) { + super($element, $scope); + this.$filter = $filter; } + get route() { + return this._route; + } + set route(value) { this._route = value; if (value) this.buildPossibleTicketsFilter(); } - get route() { - return this._route; - } - get isChecked() { if (this.tickets) { for (let instance of this.tickets) @@ -104,7 +102,6 @@ class Controller { }); } - showDeleteConfirm(id) { this.selectedTicket = id; this.$.confirm.show(); @@ -122,7 +119,7 @@ class Controller { } updateVolume() { - let url = `Routes/${this.$stateParams.id}/updateVolume`; + let url = `Routes/${this.$params.id}/updateVolume`; this.$http.post(url).then(() => { this.card.reload(); this.$.model.refresh(); @@ -130,7 +127,7 @@ class Controller { } guessPriority() { - let query = `Routes/${this.$stateParams.id}/guessPriority/`; + let query = `Routes/${this.$params.id}/guessPriority/`; this.$http.get(query).then(() => { this.vnApp.showSuccess(this.$translate.instant('Order changed')); this.$.model.refresh(); @@ -171,9 +168,39 @@ class Controller { } return Promise.resolve(); } + + onDrop($event) { + const ticketId = $event.dataTransfer.getData('Text'); + + if (isNaN(ticketId)) { + const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); + const matches = ticketId.match(regexp); + + if (matches && matches.length) + this.insert(matches[1]); + else + this.vnApp.showError(this.$translate.instant('Ticket not found')); + } + + if (!isNaN(ticketId)) + this.insert(ticketId); + } + + insert(id) { + const params = {routeFk: this.route.id}; + this.$http.patch(`Tickets/${id}`, params).then(() => { + this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.$.model.refresh(); + this.card.reload(); + }).catch(error => { + if (error.status == 404) + return this.vnApp.showError(this.$translate.instant('Ticket not found')); + throw error; + }); + } } -Controller.$inject = ['$stateParams', '$scope', '$translate', '$http', 'vnApp', '$filter']; +Controller.$inject = ['$element', '$scope', '$filter']; ngModule.component('vnRouteTickets', { template: require('./index.html'), diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js index d1313dd659..f3c02cf511 100644 --- a/modules/route/front/tickets/index.spec.js +++ b/modules/route/front/tickets/index.spec.js @@ -1,14 +1,20 @@ -import './index.js'; +import './index'; describe('Route', () => { let controller; let $httpBackend; + let $scope; beforeEach(ngModule('route')); - beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnRouteTickets'); + $scope = $rootScope.$new(); + const $element = angular.element(''); + controller = $componentController('vnRouteTickets', {$element, $scope}); + controller.route = {id: 1}; + controller.$.model = {refresh: () => {}}; + controller.card = {reload: () => {}}; })); describe('route setter/getter', () => { @@ -86,7 +92,6 @@ describe('Route', () => { describe('setPriority()', () => { it('should set a ticket priority', () => { - controller.$.model = {refresh: () => {}}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.vnApp, 'showSuccess'); const ticketId = 1; @@ -175,16 +180,14 @@ describe('Route', () => { describe('updateVolume()', () => { it('should perform a POST query then call both reload and refresh methods', () => { - controller.$.model = {refresh: () => {}}; - controller.card = {reload: () => {}}; - controller.$stateParamds = {id: 999}; + controller.$params = {id: 999}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.card, 'reload'); let ticketId = 1; controller.selectedTicket = ticketId; - const url = `Routes/${controller.$stateParams.id}/updateVolume`; + const url = `Routes/${controller.$params.id}/updateVolume`; $httpBackend.expectPOST(url).respond('ok'); controller.updateVolume(); $httpBackend.flush(); @@ -196,12 +199,11 @@ describe('Route', () => { describe('guessPriority()', () => { it('should perform a GET query then call both refresh and showSuccess methods', () => { - controller.$.model = {refresh: () => {}}; jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$stateParams = {id: 99}; + controller.$params = {id: 99}; - const url = `Routes/${controller.$stateParams.id}/guessPriority/`; + const url = `Routes/${controller.$params.id}/guessPriority/`; $httpBackend.expectGET(url).respond('ok'); controller.guessPriority(); $httpBackend.flush(); @@ -288,4 +290,66 @@ describe('Route', () => { expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise)); }); }); + + describe('onDrop()', () => { + it('should call the insert method when dragging a ticket number', () => { + jest.spyOn(controller, 'insert'); + + const expectedTicketId = '11'; + const draggedElement = '11'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); + }); + + it('should call the insert method when dragging a ticket link', () => { + jest.spyOn(controller, 'insert'); + + const expectedTicketId = '11'; + const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); + }); + + it('should throw an error when dragging an invalid ticket link', () => { + jest.spyOn(controller.vnApp, 'showError'); + + const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; + const $event = { + dataTransfer: { + getData: () => draggedElement + } + }; + controller.onDrop($event); + + expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); + }); + }); + + describe('insert()', () => { + it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => { + jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); + jest.spyOn(controller.vnApp, 'showSuccess'); + + const ticketId = 11; + + $httpBackend.expect('PATCH', `Tickets/11`).respond({id: 11}); + controller.insert(ticketId); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + expect(controller.$.model.refresh).toHaveBeenCalledWith(); + }); + }); }); diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml index 02f9eed08c..b9892a2997 100644 --- a/modules/route/front/tickets/locale/es.yml +++ b/modules/route/front/tickets/locale/es.yml @@ -5,4 +5,5 @@ Order changed: Orden cambiado Delete ticket from route?: ¿Quitar el ticket de la ruta? Sort routes: Ordenar rutas Add ticket: Añadir ticket -Tickets to add: Tickets a añadir \ No newline at end of file +Tickets to add: Tickets a añadir +Ticket not found: No se ha encontrado el ticket \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index 6cce70b9c5..134ccca404 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -34,7 +34,7 @@ describe('ticket-request confirm()', () => { expect(error.message).toEqual(`That item doesn't exists`); }); - it(`should throw an error if the item is not available`, async() => { + it('should throw an error if the item is not available', async() => { const requestId = 5; const itemId = 4; const quantity = 99999; diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index fa3067c176..aff26c63ee 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -67,6 +67,10 @@ module.exports = Self => { arg: 'problems', type: 'Boolean', description: `Whether to show only tickets with problems` + }, { + arg: 'pending', + type: 'Boolean', + description: `Whether to show only tickets with state 'Pending'` }, { arg: 'mine', type: 'Boolean', @@ -130,7 +134,7 @@ module.exports = Self => { dateTo.setHours(23, 59, 0, 0); } - let where = buildFilter(ctx.args, (param, value) => { + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -155,6 +159,17 @@ module.exports = Self => { return {'c.salesPersonFk': {inq: teamIds}}; case 'alertLevel': return {'ts.alertLevel': value}; + case 'pending': + if (value) { + return {and: [ + {'st.alertLevel': 0}, + {'st.code': {neq: 'OK'}} + ]}; + } else { + return {and: [ + {'st.alertLevel': {gt: 0}} + ]}; + } case 'id': case 'clientFk': case 'agencyModeFk': @@ -244,7 +259,6 @@ module.exports = Self => { LEFT JOIN tmp.ticketProblems tp ON tp.ticketFk = f.id LEFT JOIN tmp.ticketTotal tt ON tt.ticketFk = f.id`); - let condition; let hasProblem; let range; diff --git a/modules/ticket/back/methods/ticket/isEditable.js b/modules/ticket/back/methods/ticket/isEditable.js index 3ebf15bf02..317cfac966 100644 --- a/modules/ticket/back/methods/ticket/isEditable.js +++ b/modules/ticket/back/methods/ticket/isEditable.js @@ -32,7 +32,7 @@ module.exports = Self => { let alertLevel = state ? state.alertLevel : null; let ticket = await Self.app.models.Ticket.findById(id, { - fields: ['isDeleted', 'clientFk', 'refFk'], + fields: ['clientFk'], include: [{ relation: 'client', scope: { @@ -42,13 +42,13 @@ module.exports = Self => { } }] }); + const isLocked = await Self.app.models.Ticket.isLocked(id); - const isDeleted = ticket && ticket.isDeleted; - const isOnDelivery = (alertLevel && alertLevel > 0); + const alertLevelGreaterThanZero = (alertLevel && alertLevel > 0); const isNormalClient = ticket && ticket.client().type().code == 'normal'; - const isInvoiced = ticket && ticket.refFk; + const validAlertAndRoleNormalClient = (alertLevelGreaterThanZero && isNormalClient && !isValidRole); - if (!ticket || isInvoiced || isDeleted || (isOnDelivery && isNormalClient && !isValidRole)) + if (!ticket || validAlertAndRoleNormalClient || isLocked) return false; return true; diff --git a/modules/ticket/back/methods/ticket/isLocked.js b/modules/ticket/back/methods/ticket/isLocked.js new file mode 100644 index 0000000000..7cf7b807ed --- /dev/null +++ b/modules/ticket/back/methods/ticket/isLocked.js @@ -0,0 +1,35 @@ +module.exports = Self => { + Self.remoteMethod('isLocked', { + description: 'Check if a ticket is invoiced or deleted', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'number', + required: true, + description: 'the ticket id', + http: {source: 'path'} + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/:id/isLocked`, + verb: 'get' + } + }); + + Self.isLocked = async id => { + const ticket = await Self.app.models.Ticket.findById(id, { + fields: ['isDeleted', 'refFk'] + }); + + const isDeleted = ticket && ticket.isDeleted; + const isInvoiced = ticket && ticket.refFk; + + if (!ticket || isInvoiced || isDeleted) + return true; + + return false; + }; +}; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 656f99d65d..faaeb82c07 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -41,6 +41,34 @@ describe('ticket filter()', () => { const firstRow = result[0]; expect(result.length).toEqual(1); - expect(firstRow.ticketFk).toEqual(11); + expect(firstRow.id).toEqual(11); + }); + + it('should return the tickets with grouped state "Pending" and not "Ok"', async() => { + const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); + const firstRow = result[0]; + const secondRow = result[1]; + const thirdRow = result[2]; + + expect(result.length).toEqual(3); + expect(firstRow.state).toEqual('Arreglar'); + expect(secondRow.state).toEqual('Arreglar'); + expect(thirdRow.state).toEqual('Arreglar'); + }); + + it('should return the tickets that are not pending', async() => { + const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}}; + const filter = {}; + const result = await app.models.Ticket.filter(ctx, filter); + const firstRow = result[0]; + const secondRow = result[1]; + const thirdRow = result[2]; + + expect(result.length).toEqual(13); + expect(firstRow.state).toEqual('Entregado'); + expect(secondRow.state).toEqual('Entregado'); + expect(thirdRow.state).toEqual('Entregado'); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js index a401289546..276aeacf16 100644 --- a/modules/ticket/back/methods/ticket/specs/isEditable.spec.js +++ b/modules/ticket/back/methods/ticket/specs/isEditable.spec.js @@ -1,13 +1,6 @@ const app = require('vn-loopback/server/server'); describe('ticket isEditable()', () => { - it('should return false if the given ticket is not editable', async() => { - let ctx = {req: {accessToken: {userId: 9}}}; - let result = await app.models.Ticket.isEditable(ctx, 2); - - expect(result).toEqual(false); - }); - it('should return false if the given ticket does not exist', async() => { let ctx = {req: {accessToken: {userId: 9}}}; let result = await app.models.Ticket.isEditable(ctx, 99999); @@ -15,37 +8,46 @@ describe('ticket isEditable()', () => { expect(result).toEqual(false); }); - it('should return false if the given ticket isDeleted', async() => { + it(`should return false if the given ticket isn't invoiced but isDeleted`, async() => { let ctx = {req: {accessToken: {userId: 9}}}; - let result = await app.models.Ticket.isEditable(ctx, 19); + let deletedTicket = await app.models.Ticket.findOne({ + where: { + invoiceOut: null, + isDeleted: true + }, + fields: ['id'] + }); + + let result = await app.models.Ticket.isEditable(ctx, deletedTicket.id); expect(result).toEqual(false); }); it('should return true if the given ticket is editable', async() => { let ctx = {req: {accessToken: {userId: 9}}}; + let result = await app.models.Ticket.isEditable(ctx, 16); expect(result).toEqual(true); }); - it('should be able to edit a deleted or invoiced ticket if the role is salesAssistant', async() => { + it('should not be able to edit a deleted or invoiced ticket even for salesAssistant', async() => { let ctx = {req: {accessToken: {userId: 21}}}; - let result = await app.models.Ticket.isEditable(ctx, 8); + let result = await app.models.Ticket.isEditable(ctx, 19); - expect(result).toEqual(true); + expect(result).toEqual(false); }); - it('should be able to edit a deleted or invoiced ticket if the role is productionBoss', async() => { + it('should not be able to edit a deleted or invoiced ticket even for productionBoss', async() => { let ctx = {req: {accessToken: {userId: 50}}}; - let result = await app.models.Ticket.isEditable(ctx, 8); + let result = await app.models.Ticket.isEditable(ctx, 19); - expect(result).toEqual(true); + expect(result).toEqual(false); }); - it('should not be able to edit a deleted or invoiced ticket if the role is salesPerson', async() => { + it('should not be able to edit a deleted or invoiced ticket even for salesPerson', async() => { let ctx = {req: {accessToken: {userId: 18}}}; - let result = await app.models.Ticket.isEditable(ctx, 8); + let result = await app.models.Ticket.isEditable(ctx, 19); expect(result).toEqual(false); }); diff --git a/modules/ticket/back/methods/ticket/specs/isLocked.spec.js b/modules/ticket/back/methods/ticket/specs/isLocked.spec.js new file mode 100644 index 0000000000..192c80f100 --- /dev/null +++ b/modules/ticket/back/methods/ticket/specs/isLocked.spec.js @@ -0,0 +1,34 @@ +const app = require('vn-loopback/server/server'); + +describe('ticket isLocked()', () => { + it('should return true if the given ticket does not exist', async() => { + let result = await app.models.Ticket.isLocked(99999); + + expect(result).toEqual(true); + }); + + it('should return true if the given ticket is invoiced', async() => { + let invoicedTicket = await app.models.Ticket.findOne({ + where: {invoiceOut: {neq: null}}, + fields: ['id'] + }); + + let result = await app.models.Ticket.isLocked(invoicedTicket.id); + + expect(result).toEqual(true); + }); + + it(`should return true if the given ticket isn't invoiced but deleted`, async() => { + let deletedTicket = await app.models.Ticket.findOne({ + where: { + invoiceOut: null, + isDeleted: true + }, + fields: ['id'] + }); + + let result = await app.models.Ticket.isLocked(deletedTicket.id); + + expect(result).toEqual(true); + }); +}); diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 247e7e6213..b91751d5df 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -3,13 +3,22 @@ const app = require('vn-loopback/server/server'); describe('ticket makeInvoice()', () => { let invoice; let ticketId = 11; + const okState = 3; afterAll(async done => { let ticket = await app.models.Ticket.findById(11); await ticket.updateAttributes({refFk: null}); - let ticketTracking = await app.models.TicketTracking.findOne({order: 'id DESC', limit: 1}); - await ticketTracking.destroy(); + let ticketTrackings = await app.models.TicketTracking.find({ + where: { + ticketFk: ticketId, + stateFk: {neq: okState} + }, + order: 'id DESC' + }); + + for (let state of ticketTrackings) + await state.destroy(); let invoiceOut = await app.models.InvoiceOut.findById(invoice.invoiceFk); await invoiceOut.destroy(); diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 8777a60fca..5ec887836b 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -35,6 +35,7 @@ module.exports = Self => { }); Self.updateDiscount = async(ctx, id, salesIds, newDiscount) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const tx = await Self.beginTransaction({}); @@ -68,8 +69,14 @@ module.exports = Self => { if (!allFromSameTicket) throw new UserError('All sales must belong to the same ticket'); - const isEditable = await models.Ticket.isEditable(ctx, id); - if (!isEditable) + const isLocked = await models.Ticket.isLocked(id); + const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson'); + const state = await Self.app.models.TicketState.findOne({ + where: {ticketFk: id} + }); + const alertLevel = state ? state.alertLevel : null; + + if (isLocked || (!isSalesPerson && alertLevel > 0 )) throw new UserError(`The sales of this ticket can't be modified`); const ticket = await models.Ticket.findById(id, { diff --git a/modules/ticket/back/models/ticket.js b/modules/ticket/back/models/ticket.js index 45284d60d2..a2891430a1 100644 --- a/modules/ticket/back/models/ticket.js +++ b/modules/ticket/back/models/ticket.js @@ -29,6 +29,7 @@ module.exports = Self => { require('../methods/ticket/recalculateComponents')(Self); require('../methods/ticket/deleteStowaway')(Self); require('../methods/ticket/sendSms')(Self); + require('../methods/ticket/isLocked')(Self); Self.observe('before save', async function(ctx) { if (ctx.isNewInstance) return; diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index 820d3d2c6b..b8fffd2c1c 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -22,7 +22,7 @@ class Controller { if (!value || !value.id) return; - this.onChangeClient(value.clientFk); + this.clientAddressesList(value.clientFk); } get clientId() { @@ -33,7 +33,10 @@ class Controller { this.ticket.clientFk = value; this.ticket.addressFk = null; - this.onChangeClient(value); + if (!value) return; + + this.getClientDefaultAddress(value); + this.clientAddressesList(value); } get addressId() { @@ -68,7 +71,6 @@ class Controller { } } - get shipped() { return this.ticket && this.ticket.shipped; } @@ -127,7 +129,7 @@ class Controller { /* * Autocompletes address on client change */ - onChangeClient(value) { + clientAddressesList(value) { let filter = { include: [ { @@ -153,6 +155,14 @@ class Controller { }); } + getClientDefaultAddress(value) { + let query = `Clients/${value}`; + this.$http.get(query).then(res => { + if (res.data) + this.ticket.addressFk = res.data.defaultAddressFk; + }); + } + /* * Gets an agency from an specified zone */ diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index 86977a738a..b1931d0bb0 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -22,18 +22,18 @@ describe('Ticket', () => { })); describe('ticket() setter', () => { - it('should set ticket property and call onChangeClient() method', () => { - jest.spyOn(controller, 'onChangeClient'); + it('should set ticket property and call clientAddressesList() method', () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {id: 1, clientFk: 101}; - expect(controller.onChangeClient).toHaveBeenCalledWith(101); + expect(controller.clientAddressesList).toHaveBeenCalledWith(101); }); - it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => { - jest.spyOn(controller, 'onChangeClient'); + it(`should not call clientAddressesList() method as the ticket doesn't have an ID`, () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {}; - expect(controller.onChangeClient).not.toHaveBeenCalledWith(); + expect(controller.clientAddressesList).not.toHaveBeenCalledWith(); }); }); @@ -46,12 +46,12 @@ describe('Ticket', () => { }); describe('clientId() setter', () => { - it('should set clientId property and call onChangeClient() method ', () => { - jest.spyOn(controller, 'onChangeClient'); + it('should set clientId property and call clientAddressesList() method ', () => { + jest.spyOn(controller, 'clientAddressesList'); controller.ticket = {id: 1, clientId: 101}; controller.clientId = 102; - expect(controller.onChangeClient).toHaveBeenCalledWith(102); + expect(controller.clientAddressesList).toHaveBeenCalledWith(102); }); }); @@ -155,7 +155,6 @@ describe('Ticket', () => { }; controller.landed = landed; - expect(controller.getShipped).toHaveBeenCalledWith(expectedResult); }); }); @@ -230,7 +229,7 @@ describe('Ticket', () => { }); }); - describe('onChangeClient()', () => { + describe('clientAddressesList()', () => { it('should return a list of addresses from choosed client', async() => { const clientId = 102; let filter = { @@ -253,7 +252,18 @@ describe('Ticket', () => { $httpBackend.when('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200); $httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`); - controller.onChangeClient(clientId); + controller.clientAddressesList(clientId); + $httpBackend.flush(); + }); + }); + + describe('getClientDefaultAddress()', () => { + it('should return the default address from choosed client', async() => { + const clientId = 102; + + $httpBackend.when('GET', `Clients/${clientId}`).respond(200); + $httpBackend.expect('GET', `Clients/${clientId}`); + controller.getClientDefaultAddress(clientId); $httpBackend.flush(); }); }); diff --git a/modules/ticket/front/basic-data/step-two/locale/es.yml b/modules/ticket/front/basic-data/step-two/locale/es.yml index 47fc87b0c0..49dd7fd808 100644 --- a/modules/ticket/front/basic-data/step-two/locale/es.yml +++ b/modules/ticket/front/basic-data/step-two/locale/es.yml @@ -1,4 +1,5 @@ Price (PPU): Precio (Ud.) New (PPU): Nuevo (Ud.) Difference: Diferencia -Charge difference to: Cargar diferencia a \ No newline at end of file +Charge difference to: Cargar diferencia a +The ticket has been unrouted: El ticket ha sido desenrutado \ No newline at end of file diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index d804a2eb23..c633dd3c1e 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -2,10 +2,10 @@ import ngModule from '../module'; import Component from 'core/lib/component'; class Controller extends Component { - constructor($element, $, aclService, $httpParamSerializer) { + constructor($element, $, $httpParamSerializer) { super($element, $); - this.aclService = aclService; this.$httpParamSerializer = $httpParamSerializer; + this.moreOptions = [ { name: 'Add turn', @@ -220,7 +220,8 @@ class Controller extends Component { showDeliveryNote() { const params = { clientId: this.ticket.client.id, - ticketId: this.ticket.id + ticketId: this.ticket.id, + authorization: this.vnToken.token }; const serializedParams = this.$httpParamSerializer(params); let url = `api/report/delivery-note?${serializedParams}`; @@ -332,7 +333,7 @@ class Controller extends Component { } } -Controller.$inject = ['$element', '$scope', 'aclService', '$httpParamSerializer']; +Controller.$inject = ['$element', '$scope', '$httpParamSerializer']; ngModule.component('vnTicketDescriptor', { template: require('./index.html'), diff --git a/modules/ticket/front/dms/index/index.html b/modules/ticket/front/dms/index/index.html index ae2844c738..4e4834510e 100644 --- a/modules/ticket/front/dms/index/index.html +++ b/modules/ticket/front/dms/index/index.html @@ -51,11 +51,6 @@ {{::document.dms.description}} - - - - - - - - - - - + +
+ + + + + + + + + +
+ diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 05dc23c085..563265ab31 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -1,4 +1,5 @@ import ngModule from '../module'; +import UserError from 'core/lib/user-error'; import './style.scss'; export default class Controller { @@ -9,33 +10,45 @@ export default class Controller { this.$stateParams = $stateParams; this.$state = $state; this.selectedTicket = null; - this.moreOptions = [ - { - name: 'Payment on account...', - always: true, - callback: () => { - this.setBalanceCreateDialog(); - this.$.balanceCreateDialog.show(); - } - } - ]; } - setBalanceCreateDialog() { - let data = this.$.tickets; - let description = []; + openBalanceDialog() { + const checkedTickets = this.checked; + const description = []; this.$.balanceCreateDialog.amountPaid = 0; - if (data) { - for (let i = 0; i < data.length; i++) { - if (data[i].checked) { - this.$.balanceCreateDialog.amountPaid += data[i].total; - this.$.balanceCreateDialog.clientFk = data[i].clientFk; - description.push(`${data[i].id}`); - } - } + + const firstTicketClientId = checkedTickets[0].clientFk; + const isSameClient = checkedTickets.every(ticket => { + return ticket.clientFk == firstTicketClientId; + }); + + if (!isSameClient) + throw new UserError('You cannot make a payment on account from multiple clients'); + + for (let ticket of checkedTickets) { + this.$.balanceCreateDialog.amountPaid += ticket.total; + this.$.balanceCreateDialog.clientFk = ticket.clientFk; + description.push(`${ticket.id}`); } + this.$.balanceCreateDialog.description = 'Albaran: '; this.$.balanceCreateDialog.description += description.join(', '); + this.$.balanceCreateDialog.show(); + } + + get checked() { + const tickets = this.$.tickets || []; + const checkedLines = []; + for (let ticket of tickets) { + if (ticket.checked) + checkedLines.push(ticket); + } + + return checkedLines; + } + + get totalChecked() { + return this.checked.length; } getScopeDates(days) { @@ -51,7 +64,7 @@ export default class Controller { onSearch(params) { if (params) { - if (typeof(params.scopeDays) === 'number') + if (typeof (params.scopeDays) === 'number') Object.assign(params, this.getScopeDates(params.scopeDays)); // Set default params to 1 scope days else if (Object.entries(params).length == 0) diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 987accd026..6b0b42ffde 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -82,12 +82,14 @@ describe('Component vnTicketIndex', () => { }); }); - describe('setBalanceCreateDialog()', () => { + describe('openBalanceDialog()', () => { it('should fill the object for the component balanceCreateDialog', () => { + controller.$.balanceCreateDialog = {show: () => {}}; + jest.spyOn(controller.$.balanceCreateDialog, 'show').mockReturnThis(); + controller.$.tickets = tickets; - controller.$.balanceCreateDialog = {}; controller.$.balanceCreateDialog.amountPaid = 0; - controller.setBalanceCreateDialog(); + controller.openBalanceDialog(); let description = controller.$.balanceCreateDialog.description; let amountPaid = controller.$.balanceCreateDialog.amountPaid; @@ -96,4 +98,26 @@ describe('Component vnTicketIndex', () => { expect(amountPaid).toEqual(50.5); }); }); + + describe('checked()', () => { + it('should return an array of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + const firstRow = result[0]; + const secondRow = result[1]; + + expect(result.length).toEqual(2); + expect(firstRow.id).toEqual(2); + expect(secondRow.id).toEqual(3); + }); + }); + + describe('totalChecked()', () => { + it('should return the total number of checked tickets', () => { + controller.$.tickets = tickets; + const result = controller.checked; + + expect(result.length).toEqual(2); + }); + }); }); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 224392debc..41ef74c38d 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -165,8 +165,8 @@ - {{(sale.discount / 100) | percentage}} diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 5159f7e82d..e7bf61cfe0 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -46,6 +46,7 @@ class Controller { set ticket(value) { this._ticket = value; this.isTicketEditable(); + this.isTicketLocked(); } get sales() { @@ -354,7 +355,7 @@ class Controller { } showEditDiscountPopover(event, sale) { - if (!this.isEditable) return; + if (this.isLocked) return; this.sale = sale; this.edit = [{ @@ -540,6 +541,12 @@ class Controller { }); } + isTicketLocked() { + this.$http.get(`Tickets/${this.$state.params.id}/isLocked`).then(res => { + this.isLocked = res.data; + }); + } + hasOneSaleSelected() { if (this.totalCheckedLines() === 1) return true; diff --git a/modules/ticket/front/sale/specs/index.spec.js b/modules/ticket/front/sale/specs/index.spec.js index 57ca1d2959..2e7979faa0 100644 --- a/modules/ticket/front/sale/specs/index.spec.js +++ b/modules/ticket/front/sale/specs/index.spec.js @@ -69,6 +69,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); $httpBackend.when('POST', `Claims/createFromSales`, {claim: claim, sales: sales}).respond(claim); $httpBackend.expect('POST', `Claims/createFromSales`).respond(claim); controller.createClaim(); @@ -98,6 +99,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); let result = controller.checkedLines(); $httpBackend.flush(); @@ -116,6 +118,7 @@ describe('Ticket', () => { $httpBackend.expectGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.expectGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.onStateOkClick(); $httpBackend.flush(); @@ -129,6 +132,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.onStateChange(3); $httpBackend.flush(); }); @@ -142,6 +146,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.onRemoveLinesClick('accept'); $httpBackend.flush(); @@ -183,6 +188,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.unmarkAsReserved(false); $httpBackend.flush(); }); @@ -213,6 +219,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.updateQuantity(sale); $httpBackend.flush(); @@ -232,6 +239,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.updateConcept(sale); $httpBackend.flush(); @@ -262,6 +270,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.addSale(newSale); $httpBackend.flush(); @@ -287,6 +296,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.transferSales(13); $httpBackend.flush(); @@ -305,6 +315,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.setTransferParams(); $httpBackend.flush(); @@ -330,6 +341,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.newOrderFromTicket(); $httpBackend.flush(); @@ -353,6 +365,7 @@ describe('Ticket', () => { $httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5); $httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5); $httpBackend.whenGET(`Tickets/1/isEditable`).respond(); + $httpBackend.whenGET(`Tickets/1/isLocked`).respond(); controller.calculateSalePrice(); $httpBackend.flush(); diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index ae5e152c69..50bc42d46d 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -15,11 +15,6 @@ label="Client id" ng-model="filter.clientFk"> - - + + diff --git a/modules/ticket/front/search-panel/locale/es.yml b/modules/ticket/front/search-panel/locale/es.yml index 0fcfdaa589..d8cde5b2a2 100644 --- a/modules/ticket/front/search-panel/locale/es.yml +++ b/modules/ticket/front/search-panel/locale/es.yml @@ -8,6 +8,8 @@ Warehouse: Almacén Sales person: Comercial Province: Provincia My team: Mi equipo -Order id: Id pedido +Order id: Id cesta Grouped States: Estado agrupado -Days onward: Días adelante \ No newline at end of file +Days onward: Días adelante +With problems: Con problemas +Pending: Pendientes \ No newline at end of file diff --git a/modules/travel/back/methods/travel/createThermograph.js b/modules/travel/back/methods/travel/createThermograph.js index cbf0678d1b..974b679238 100644 --- a/modules/travel/back/methods/travel/createThermograph.js +++ b/modules/travel/back/methods/travel/createThermograph.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('createThermograph', { - description: 'Upload and attach a document', + description: 'Creates a new travel thermograph', accessType: 'WRITE', accepts: [{ arg: 'id', @@ -14,6 +14,10 @@ module.exports = Self => { type: 'String', description: 'The thermograph id', required: true + }, { + arg: 'state', + type: 'String', + required: true }, { arg: 'warehouseId', type: 'Number', @@ -48,13 +52,12 @@ module.exports = Self => { } }); - Self.createThermograph = async(ctx, id, thermographId) => { + Self.createThermograph = async(ctx, id, thermographId, state) => { const models = Self.app.models; const tx = await Self.beginTransaction({}); try { const options = {transaction: tx}; - const travelThermograph = await models.TravelThermograph.findOne({ where: { thermographFk: thermographId, @@ -70,7 +73,8 @@ module.exports = Self => { await travelThermograph.updateAttributes({ dmsFk: firstDms.id, - travelFk: id + travelFk: id, + result: state }, options); await tx.commit(); diff --git a/modules/travel/back/methods/travel/updateThermograph.js b/modules/travel/back/methods/travel/updateThermograph.js new file mode 100644 index 0000000000..d89725920c --- /dev/null +++ b/modules/travel/back/methods/travel/updateThermograph.js @@ -0,0 +1,83 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethodCtx('updateThermograph', { + description: 'Updates a travel thermograph', + accessType: 'WRITE', + accepts: [{ + arg: 'id', + type: 'Number', + description: 'The travel id', + http: {source: 'path'} + }, { + arg: 'thermographId', + type: 'String', + description: 'The thermograph id', + required: true + }, { + arg: 'state', + type: 'String', + required: true + }, { + arg: 'warehouseId', + type: 'Number', + description: 'The warehouse id' + }, { + arg: 'companyId', + type: 'Number', + description: 'The company id' + }, { + arg: 'dmsTypeId', + type: 'Number', + description: 'The dms type id' + }, { + arg: 'reference', + type: 'String' + }, { + arg: 'description', + type: 'String' + }, { + arg: 'hasFileAttached', + type: 'Boolean', + description: 'True if has an attached file' + }], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/:id/updateThermograph`, + verb: 'POST' + } + }); + + Self.updateThermograph = async(ctx, id, thermographId, state) => { + const models = Self.app.models; + const tx = await Self.beginTransaction({}); + + try { + const options = {transaction: tx}; + const travelThermograph = await models.TravelThermograph.findOne({ + where: { + thermographFk: thermographId, + travelFk: id + } + }, options); + + if (!travelThermograph) + throw new UserError('No valid travel thermograph found'); + + const dmsFk = travelThermograph.dmsFk; + await models.Dms.updateFile(ctx, dmsFk, options); + await travelThermograph.updateAttributes({ + result: state + }, options); + + await tx.commit(); + return travelThermograph; + } catch (e) { + await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index 03307bd459..b06d00f06f 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -1,13 +1,17 @@ { "Travel": { "dataSource": "vn" - },"TravelLog": { + }, + "TravelLog": { "dataSource": "vn" - },"Currency": { + }, + "Currency": { "dataSource": "vn" - },"Thermograph": { + }, + "Thermograph": { "dataSource": "vn" - },"TravelThermograph": { + }, + "TravelThermograph": { "dataSource": "vn" } } diff --git a/modules/travel/back/models/travel.js b/modules/travel/back/models/travel.js index 895de7af19..4643f79fd5 100644 --- a/modules/travel/back/models/travel.js +++ b/modules/travel/back/models/travel.js @@ -4,4 +4,5 @@ module.exports = Self => { require('../methods/travel/filter')(Self); require('../methods/travel/createThermograph')(Self); require('../methods/travel/deleteThermograph')(Self); + require('../methods/travel/updateThermograph')(Self); }; diff --git a/modules/travel/front/index.js b/modules/travel/front/index.js index b72f9fd51c..28ec276939 100644 --- a/modules/travel/front/index.js +++ b/modules/travel/front/index.js @@ -11,4 +11,5 @@ import './log'; import './create'; import './thermograph/index/'; import './thermograph/create/'; +import './thermograph/edit/'; import './descriptor-popover'; diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index fcbe5b92f4..50e2368891 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -81,6 +81,15 @@ "travel": "$ctrl.travel" }, "acl": ["buyer"] + }, { + "url" : "/:thermographId/edit", + "state": "travel.card.thermograph.edit", + "component": "vn-travel-thermograph-edit", + "description": "Edit thermograph", + "params": { + "travel": "$ctrl.travel" + }, + "acl": ["buyer"] } ] } \ No newline at end of file diff --git a/modules/travel/front/summary/index.spec.js b/modules/travel/front/summary/index.spec.js index 202c666377..9b041f22b9 100644 --- a/modules/travel/front/summary/index.spec.js +++ b/modules/travel/front/summary/index.spec.js @@ -26,7 +26,6 @@ describe('component vnTravelSummary', () => { jest.spyOn(controller, 'getThermographs'); controller.travel = {id: 99}; - expect(controller._travel.id).toEqual(99); expect(controller.getTravel).toHaveBeenCalledWith(); expect(controller.getEntries).toHaveBeenCalledWith(); diff --git a/modules/travel/front/thermograph/create/index.html b/modules/travel/front/thermograph/create/index.html index 02ef542640..4b1fc8cf4f 100644 --- a/modules/travel/front/thermograph/create/index.html +++ b/modules/travel/front/thermograph/create/index.html @@ -9,6 +9,35 @@ enctype="multipart/form-data">
+ + + + + + + + + + + + - - - - - - - - + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/modules/travel/front/thermograph/edit/index.js b/modules/travel/front/thermograph/edit/index.js new file mode 100644 index 0000000000..0180983127 --- /dev/null +++ b/modules/travel/front/thermograph/edit/index.js @@ -0,0 +1,98 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; +import './style.scss'; + +class Controller extends Component { + get travel() { + return this._travel; + } + + set travel(value) { + this._travel = value; + + if (value) { + this.setDefaultParams(); + this.getAllowedContentTypes(); + } + } + + getAllowedContentTypes() { + this.$http.get('TravelThermographs/allowedContentTypes').then(res => { + const contentTypes = res.data.join(', '); + this.allowedContentTypes = contentTypes; + }); + } + + get contentTypesInfo() { + return this.$translate.instant('ContentTypesInfo', { + allowedContentTypes: this.allowedContentTypes + }); + } + + setDefaultParams() { + const filterObj = {include: {relation: 'dms'}}; + const filter = encodeURIComponent(JSON.stringify(filterObj)); + const path = `TravelThermographs/${this.$params.thermographId}?filter=${filter}`; + this.$http.get(path).then(res => { + const thermograph = res.data && res.data; + this.thermograph = { + thermographId: thermograph.thermographFk, + state: thermograph.result, + reference: thermograph.dms.reference, + warehouseId: thermograph.dms.warehouseFk, + companyId: thermograph.dms.companyFk, + dmsTypeId: thermograph.dms.dmsTypeFk, + description: thermograph.dms.description, + hasFile: thermograph.dms.hasFile, + hasFileAttached: false, + files: [] + }; + }); + } + + onSubmit() { + const query = `travels/${this.$params.id}/updateThermograph`; + const options = { + method: 'POST', + url: query, + params: this.thermograph, + headers: { + 'Content-Type': undefined + }, + transformRequest: files => { + const formData = new FormData(); + + for (let i = 0; i < files.length; i++) + formData.append(files[i].name, files[i]); + + return formData; + }, + data: this.thermograph.files + }; + this.$http(options).then(res => { + if (res) { + this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + this.$.watcher.updateOriginalData(); + this.$state.go('travel.card.thermograph.index'); + } + }); + } + + onFileChange(files) { + let hasFileAttached = false; + if (files.length > 0) + hasFileAttached = true; + + this.$.$applyAsync(() => { + this.thermograph.hasFileAttached = hasFileAttached; + }); + } +} + +ngModule.component('vnTravelThermographEdit', { + template: require('./index.html'), + controller: Controller, + bindings: { + travel: '<' + } +}); diff --git a/modules/travel/front/thermograph/edit/index.spec.js b/modules/travel/front/thermograph/edit/index.spec.js new file mode 100644 index 0000000000..eac92ba0fa --- /dev/null +++ b/modules/travel/front/thermograph/edit/index.spec.js @@ -0,0 +1,122 @@ +import './index'; +import watcher from 'core/mocks/watcher.js'; + +describe('Worker', () => { + describe('Component vnTravelThermographEdit', () => { + let controller; + let $scope; + let $element; + let $httpBackend; + let $httpParamSerializer; + + beforeEach(ngModule('travel')); + + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { + $scope = $rootScope.$new(); + $httpBackend = _$httpBackend_; + $httpParamSerializer = _$httpParamSerializer_; + $element = angular.element(` { + it('should set the travel data and then call setDefaultParams() and getAllowedContentTypes()', () => { + jest.spyOn(controller, 'setDefaultParams'); + jest.spyOn(controller, 'getAllowedContentTypes'); + controller._travel = undefined; + controller.travel = { + id: 3 + }; + + expect(controller.setDefaultParams).toHaveBeenCalledWith(); + expect(controller.travel).toBeDefined(); + expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); + }); + }); + + describe('setDefaultParams()', () => { + it('should perform a GET query and define the dms property on controller', () => { + const thermographId = 6; + const expectedResponse = { + thermographFk: 6, + result: 'Ok', + dms: { + reference: '123456-01', + warehouseFk: 1, + companyFk: 442, + dmsTypeFk: 3, + description: 'Test' + } + }; + + const filterObj = {include: {relation: 'dms'}}; + const filter = encodeURIComponent(JSON.stringify(filterObj)); + const query = `TravelThermographs/${thermographId}?filter=${filter}`; + $httpBackend.expect('GET', query).respond(expectedResponse); + controller.setDefaultParams(); + $httpBackend.flush(); + + expect(controller.thermograph).toBeDefined(); + expect(controller.thermograph.reference).toEqual('123456-01'); + expect(controller.thermograph.dmsTypeId).toEqual(3); + expect(controller.thermograph.state).toEqual('Ok'); + }); + }); + + describe('onFileChange()', () => { + it('should set dms hasFileAttached property to true if has any files', () => { + const files = [{id: 1, name: 'MyFile'}]; + controller.thermograph = {hasFileAttached: false}; + controller.onFileChange(files); + $scope.$apply(); + + expect(controller.thermograph.hasFileAttached).toBeTruthy(); + }); + }); + + describe('getAllowedContentTypes()', () => { + it('should make an HTTP GET request to get the allowed content types', () => { + const expectedResponse = ['image/png', 'image/jpg']; + $httpBackend.when('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); + $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`); + controller.getAllowedContentTypes(); + $httpBackend.flush(); + + expect(controller.allowedContentTypes).toBeDefined(); + expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); + }); + }); + + describe('contentTypesInfo()', () => { + it('should return a description with a list of allowed content types', () => { + controller.allowedContentTypes = ['image/png', 'image/jpg']; + const expectedTypes = controller.allowedContentTypes.join(', '); + + const expectedResult = `Allowed content types: ${expectedTypes}`; + jest.spyOn(controller.$translate, 'instant').mockReturnValue(expectedResult); + + const result = controller.contentTypesInfo; + + expect(result).toEqual(expectedResult); + }); + }); + + describe('onSubmit()', () => { + it('should make an HTTP POST request to save the form data', () => { + jest.spyOn(controller.$.watcher, 'updateOriginalData'); + + const files = [{id: 1, name: 'MyFile'}]; + controller.thermograph = {files}; + const serializedParams = $httpParamSerializer(controller.thermograph); + const query = `travels/${controller.$params.id}/updateThermograph?${serializedParams}`; + + $httpBackend.expect('POST', query).respond({}); + controller.onSubmit(); + $httpBackend.flush(); + }); + }); + }); +}); diff --git a/modules/travel/front/thermograph/edit/style.scss b/modules/travel/front/thermograph/edit/style.scss new file mode 100644 index 0000000000..73f136fc15 --- /dev/null +++ b/modules/travel/front/thermograph/edit/style.scss @@ -0,0 +1,7 @@ +vn-ticket-request { + .vn-textfield { + margin: 0!important; + max-width: 100px; + } +} + diff --git a/modules/travel/front/thermograph/index/index.html b/modules/travel/front/thermograph/index/index.html index ca9ebcaea7..583b40eed0 100644 --- a/modules/travel/front/thermograph/index/index.html +++ b/modules/travel/front/thermograph/index/index.html @@ -23,11 +23,11 @@ - {{thermograph.thermographFk}} - {{thermograph.temperature}} - {{thermograph.result}} - {{thermograph.warehouse.name}} - {{thermograph.created | date: 'dd/MM/yyyy'}} + {{::thermograph.thermographFk}} + {{::thermograph.temperature}} + {{::thermograph.result}} + {{::thermograph.warehouse.name}} + {{::thermograph.created | date: 'dd/MM/yyyy'}} @@ -37,6 +37,12 @@ + + + + { accepts: { arg: 'id', type: 'Number', - description: 'The document id', + description: 'The worker document id', http: {source: 'path'} }, returns: { diff --git a/modules/worker/back/methods/worker/mySubordinates.js b/modules/worker/back/methods/worker/mySubordinates.js index bf1cd1be80..cf45d3a9d2 100644 --- a/modules/worker/back/methods/worker/mySubordinates.js +++ b/modules/worker/back/methods/worker/mySubordinates.js @@ -35,7 +35,6 @@ module.exports = Self => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await conn.executeStmt(sql); - return result[1]; }; }; diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js new file mode 100644 index 0000000000..148b8467e3 --- /dev/null +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -0,0 +1,17 @@ +const app = require('vn-loopback/server/server'); + +describe('Worker getWorkedHours()', () => { + it(`should return the expected hours and the worked hours of a given date`, async() => { + const workerID = 106; + let started = new Date(); + started.setHours(0, 0, 0, 0); + + let ended = new Date(); + ended.setHours(0, 0, 0, 0); + + const [result] = await app.models.Worker.getWorkedHours(workerID, started, ended); + + expect(result.expectedHours).toEqual(28800); // 8:00 hours seconds + expect(result.workedHours).toEqual(29400); // 8:10 hours in seconds + }); +}); diff --git a/modules/worker/back/methods/worker/timeControl.js b/modules/worker/back/methods/worker/timeControl.js index bc88197fe1..9479ff0a18 100644 --- a/modules/worker/back/methods/worker/timeControl.js +++ b/modules/worker/back/methods/worker/timeControl.js @@ -44,7 +44,6 @@ module.exports = Self => { let sql = ParameterizedSQL.join(stmts, ';'); let result = await conn.executeStmt(sql); - return result[0]; }; }; diff --git a/modules/worker/back/models/worker-dms.json b/modules/worker/back/models/worker-dms.json index f8ad824bc4..56cad65a64 100644 --- a/modules/worker/back/models/worker-dms.json +++ b/modules/worker/back/models/worker-dms.json @@ -13,10 +13,10 @@ }, "properties": { "id": { - "type": "Number" + "type": "Number", + "id": true }, "dmsFk": { - "id": true, "type": "Number", "required": true, "mysql": { diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html index 2deffecf69..697d3d5aa1 100644 --- a/modules/worker/front/dms/index/index.html +++ b/modules/worker/front/dms/index/index.html @@ -19,7 +19,6 @@ Reference Description Original - File Created @@ -39,17 +38,13 @@ {{::document.dms.description}} - - - - {{::document.dms.file}} + {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js index 907047f970..ab3be34080 100644 --- a/modules/worker/front/dms/index/index.js +++ b/modules/worker/front/dms/index/index.js @@ -58,8 +58,8 @@ class Controller extends Component { deleteDms(response) { if (response === 'accept') { - const dmsFk = this.workerDms[this.dmsIndex].dmsFk; - const query = `WorkerDms/${dmsFk}/removeFile`; + const workerDmsId = this.workerDms[this.dmsIndex].id; + const query = `WorkerDms/${workerDmsId}/removeFile`; this.$http.post(query).then(() => { this.$.model.remove(this.dmsIndex); this.vnApp.showSuccess(this.$translate.instant('Data saved!')); diff --git a/modules/worker/front/dms/index/index.spec.js b/modules/worker/front/dms/index/index.spec.js index a354b74e97..7378ef3010 100644 --- a/modules/worker/front/dms/index/index.spec.js +++ b/modules/worker/front/dms/index/index.spec.js @@ -22,15 +22,15 @@ describe('Worker', () => { describe('deleteDms()', () => { it('should make an HTTP Post query', () => { - const dmsId = 4; + const workerDmsId = 1; const dmsIndex = 0; jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.$.model, 'remove'); - controller.workerDms = [{dmsFk: 4}]; + controller.workerDms = [{id: 1, dmsFk: 4}]; controller.dmsIndex = dmsIndex; - $httpBackend.when('POST', `WorkerDms/${dmsId}/removeFile`).respond({}); - $httpBackend.expect('POST', `WorkerDms/${dmsId}/removeFile`); + $httpBackend.when('POST', `WorkerDms/${workerDmsId}/removeFile`).respond({}); + $httpBackend.expect('POST', `WorkerDms/${workerDmsId}/removeFile`); controller.deleteDms('accept'); $httpBackend.flush(); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 7987c6a50a..5194468641 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -1,6 +1,5 @@ import './index.js'; - describe('Component vnWorkerTimeControl', () => { let $httpBackend; let $scope; @@ -9,7 +8,7 @@ describe('Component vnWorkerTimeControl', () => { beforeEach(ngModule('worker')); - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, $stateParams, _$httpBackend_) => { + beforeEach(angular.mock.inject(($componentController, $rootScope, $stateParams, _$httpBackend_) => { $stateParams.id = 1; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); diff --git a/print/boot.js b/print/boot.js index ae604db2c5..02bb278173 100644 --- a/print/boot.js +++ b/print/boot.js @@ -52,5 +52,3 @@ module.exports = app => { }); }); }; - - diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 6be065a143..b85589a816 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -157,6 +157,22 @@ table { border-spacing: 0; } +/** + * Prevent page break fix + */ +tbody { + page-break-inside: avoid; + break-inside: avoid; + display: block; + width: 100% +} + +thead, tbody tr { + table-layout: fixed; + display: table; + width: 100%; +} + .row-oriented, .column-oriented { text-align: left; width: 100% @@ -181,6 +197,10 @@ table { background-color: #e5e5e5 } +.column-oriented tbody { + border-bottom: 1px solid #DDD; +} + .column-oriented tfoot { border-top: 2px solid #808080; } @@ -190,7 +210,6 @@ table { } .column-oriented .description { - border-bottom: 1px solid #DDD; font-size: 0.8em } diff --git a/print/common/css/misc.css b/print/common/css/misc.css index 093d5a974e..09d7706b32 100644 --- a/print/common/css/misc.css +++ b/print/common/css/misc.css @@ -42,6 +42,7 @@ font-weight: bold } -.non-page-break { +.no-page-break { page-break-inside: avoid; + break-inside: avoid } \ No newline at end of file diff --git a/print/core/email.js b/print/core/email.js index 25d44df653..faf744e772 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -19,7 +19,6 @@ class Email extends Component { return `../templates/email/${this.name}`; } - async getSubject() { if (!this.lang) await this.getLang(); const locale = this.locale.messages; diff --git a/print/core/filters/index.js b/print/core/filters/index.js index 1d2eb182c5..bfd99c5048 100644 --- a/print/core/filters/index.js +++ b/print/core/filters/index.js @@ -3,3 +3,5 @@ require('./date'); require('./uppercase'); require('./currency'); require('./percentage'); +require('./number'); + diff --git a/print/core/filters/number.js b/print/core/filters/number.js new file mode 100644 index 0000000000..c785706fe4 --- /dev/null +++ b/print/core/filters/number.js @@ -0,0 +1,10 @@ +const Vue = require('vue'); +const config = require('../config'); +const defaultLocale = config.i18n.locale; + +Vue.filter('number', function(value, locale = defaultLocale) { + if (!locale) locale = defaultLocale; + return new Intl.NumberFormat(locale, { + style: 'decimal' + }).format(parseFloat(value)); +}); diff --git a/print/core/router.js b/print/core/router.js index f015ac03b5..3be6cdd35b 100644 --- a/print/core/router.js +++ b/print/core/router.js @@ -1,6 +1,62 @@ +const path = require('path'); +const fs = require('fs'); +const db = require('./database'); + module.exports = app => { - // Import methods - require('../methods/closure')(app); - require('../methods/report')(app); - require('../methods/email')(app); + const methodsPath = path.resolve(__dirname, '../methods'); + const methodsDir = fs.readdirSync(methodsPath); + const methods = []; + + // Get all methods + methodsDir.forEach(method => { + methods.push(method.replace('.js', '')); + }); + + // Auth middleware + const paths = []; + for (let method of methods) + paths.push(`/api/${method}/*`); + + app.use(paths, async function(request, response, next) { + const authorization = getToken(request); + const query = `SELECT userId, ttl, created + FROM salix.AccessToken WHERE id = ?`; + + try { + const authToken = await db.findOne(query, [authorization]); + + if (!authToken || isTokenExpired(authToken.created, authToken.ttl)) + throw new Error('Invalid authorization token'); + + next(); + } catch (error) { + next(error); + } + }); + + function getToken(request) { + const headers = request.headers; + const params = request.query; + + if (headers.authorization) + params.authorization = headers.authorization; + + return headers.authorization || params.authorization; + } + + function isTokenExpired(created, ttl) { + const date = new Date(created); + const currentDate = new Date(); + + date.setSeconds(date.getSeconds() + ttl); + + if (currentDate > date) + return true; + + return false; + } + + // Mount methods + for (let method of methods) + require(`../methods/${method}`)(app); }; diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js index 7d7cc84ef9..b2809ac284 100755 --- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js @@ -37,6 +37,9 @@ module.exports = { 'attachment': attachment.build() }, props: { + authorization: { + required: true + }, clientId: { required: true }, diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js index c34a9320a3..61f3c01adb 100755 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.js +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -37,11 +37,14 @@ module.exports = { 'attachment': attachment.build() }, props: { + authorization: { + required: true + }, clientId: { required: true }, companyId: { required: true - } + }, } }; diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.html b/print/templates/reports/campaign-metrics/campaign-metrics.html index 7a0f30948f..ee1908164c 100644 --- a/print/templates/reports/campaign-metrics/campaign-metrics.html +++ b/print/templates/reports/campaign-metrics/campaign-metrics.html @@ -59,37 +59,35 @@ {{$t('Code')}} {{$t('Quantity')}} - {{$t('Concept')}} + {{$t('Concept')}} - - + + + {{sale.itemFk}} + {{Math.trunc(sale.subtotal)}} + {{sale.concept}} + + + +
+ {{sale.tag5}} + {{sale.value5}} +
+ + +
+ {{sale.tag6}} + {{sale.value6}} +
+ + +
+ {{sale.tag7}} + {{sale.value7}} +
+ +
diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 9c6b0fa4e1..f23ee34014 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -61,15 +61,15 @@ {{$t('reference')}} {{$t('quantity')}} {{$t('claims')}} - {{$t('concept')}} + {{$t('concept')}} - - + + {{sale.id}} {{sale.quantity}} {{sale.claimQuantity}} - {{sale.concept}} + {{sale.concept}} diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index 77f214c07b..719397c085 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -76,53 +76,48 @@ {{$t('reference')}} {{$t('quantity')}} - {{$t('concept')}} + {{$t('concept')}} {{$t('price')}} {{$t('discount')}} {{$t('vat')}} {{$t('amount')}} - - - - + + + {{sale.itemFk}} + {{sale.quantity}} + {{sale.concept}} + {{sale.price | currency('EUR', locale)}} + {{(sale.discount / 100) | percentage}} + {{sale.vatType}} + {{sale.price * sale.quantity * (1 - sale.discount / 100) | currency('EUR', locale)}} + + + +
+ {{sale.tag5}} + {{sale.value5}} +
+ + +
+ {{sale.tag6}} + {{sale.value6}} +
+ + +
+ {{sale.tag7}} + {{sale.value7}} +
+ + + + + {{sale.ediBotanic}} {{sale.denomination}} {{sale.countryCode}}-{{sale.passportNumber}} + ZP + @@ -138,7 +133,7 @@
-
+

{{$t('services')}}

@@ -168,29 +163,35 @@ -
+

{{$t('taxBreakdown')}}

- - + + - - + + - - + + @@ -204,7 +205,7 @@ -
+

{{$t('packagings')}}

{{$t('type')}}{{$t('taxBase')}}{{$t('type')}} + {{$t('taxBase')}} + {{$t('tax')}} {{$t('fee')}}
{{tax.name}}{{tax.Base | currency('EUR', locale)}}{{tax.name}} + {{tax.Base | currency('EUR', locale)}} + {{tax.vatPercent | percentage}} {{tax.tax | currency('EUR', locale)}}
{{$t('subtotal')}}{{getTotalBase() | currency('EUR', locale)}}{{$t('subtotal')}} + {{getTotalBase() | currency('EUR', locale)}} + {{getTotalTax()| currency('EUR', locale)}}
@@ -226,7 +227,7 @@ -
+
{{$t('digitalSignature')}}
diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 6d3b840dfb..ba9a339da0 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -84,14 +84,14 @@
-
+
- + @@ -100,7 +100,7 @@ - + - +
{{$t('order')}} {{$t('ticket')}}{{$t('client')}}{{$t('client')}} {{$t('address')}} {{$t('packages')}}
{{ticket.priority}} {{ticket.id}}{{ticket.clientFk}} {{ticket.addressName}}{{ticket.clientFk}} {{ticket.addressName}} {{ticket.addressFk.toString().substr(0, ticket.addressFk.toString().length - 3)}} @@ -141,7 +141,7 @@
{{$t('import')}}{{ticket.import}}{{ticket.import | currency('EUR', locale)}}
diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index 498666cc63..8785527bc5 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -32,7 +32,6 @@ module.exports = { LEFT JOIN agencyMode am ON am.id = r.agencyModeFk WHERE r.id = :routeId`, {routeId: id}); }, - // Redmine #1855 Replace function Averiguar_ComercialCliente_Id() fetchTickets(routeId) { return db.rawSql( `SELECT diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index cbb0de0d5c..5ee45787c9 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -65,43 +65,41 @@ {{$t('boxes')}} {{$t('packing')}} - {{$t('concept')}} - {{$t('quantity')}} - {{$t('price')}} - {{$t('amount')}} + {{$t('concept')}} + {{$t('quantity')}} + {{$t('price')}} + {{$t('amount')}} - - + + + {{buy.box}} + {{buy.packing}} + {{buy.itemName}} + {{buy.quantity | number}} + {{buy.buyingValue | currency('EUR', locale)}} + {{buy.buyingValue * buy.quantity | currency('EUR', locale)}} + + + +
+ {{buy.tag5}} + {{buy.value5}} +
+ + +
+ {{buy.tag6}} + {{buy.value6}} +
+ + +
+ {{buy.tag7}} + {{buy.value7}} +
+ + @@ -115,7 +113,7 @@
-
+

{{$t('notes')}}

diff --git a/print/templates/reports/letter-debtor/letter-debtor.html b/print/templates/reports/letter-debtor/letter-debtor.html index 93e59bba12..534798f5e4 100644 --- a/print/templates/reports/letter-debtor/letter-debtor.html +++ b/print/templates/reports/letter-debtor/letter-debtor.html @@ -25,7 +25,7 @@ {{client.id}} - {{$t('dated')}} + {{$t('date')}} {{dated}} @@ -61,8 +61,8 @@ {{$t('balance')}} - - + + {{sale.issued | date('%d-%m-%Y')}} {{sale.ref}} {{sale.debtOut}} diff --git a/print/templates/reports/letter-debtor/locale/es.yml b/print/templates/reports/letter-debtor/locale/es.yml index 09a31ee5bc..a9bd8c7968 100644 --- a/print/templates/reports/letter-debtor/locale/es.yml +++ b/print/templates/reports/letter-debtor/locale/es.yml @@ -2,7 +2,7 @@ title: Extracto claimId: Reclamación clientId: Cliente clientData: Datos del cliente -dated: Fecha +date: Fecha concept: Concepto invoiced: Facturado payed: Pagado