diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index f49e3f0f9..3be9dd4f5 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -3,7 +3,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11031','12f36dc825b6660062e2c86fde9c6b451cb58f0d','2024-05-14 08:25:58','11048'); +INSERT INTO `version` VALUES ('vn-database','11071','60ac8cf6fc77b99b199b27866011b1efe8c961e8','2024-05-28 07:32:50','11074'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -759,6 +759,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10953','06-srt.sql','jenkins@db- INSERT INTO `versionLog` VALUES ('vn-database','10953','07-util.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:56',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10953','08-vn2.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10955','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL); @@ -788,22 +789,46 @@ INSERT INTO `versionLog` VALUES ('vn-database','10996','00-dropOrderRecalc.sql', INSERT INTO `versionLog` VALUES ('vn-database','10996','01-dropTicketRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10996','02-dropTravelRecalc.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10997','00-groupingMode.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11000','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11001','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11002','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11003','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11006','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11007','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11008','00-alter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11010','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11012','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11013','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11014','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11016','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-27 13:16:09',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11018','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:34:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11019','00-locker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11019','01-aclLocker.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11021','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-30 09:07:56',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11022','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','00-entryAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','01-entryUpdate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11026','02-entryInternal.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11030','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11031','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:27',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11033','00-rollbackAcls.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-07 12:45:45',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11051','00-sipConfig_callLimit.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-14 14:31:10',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11054','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11055','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','00-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','01-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','02-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11057','03-part.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11058','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11061','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11071','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:48',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1090,7 +1115,6 @@ INSERT INTO `roleInherit` VALUES (249,109,18,NULL); INSERT INTO `roleInherit` VALUES (250,109,13,NULL); INSERT INTO `roleInherit` VALUES (251,51,21,NULL); INSERT INTO `roleInherit` VALUES (253,48,49,NULL); -INSERT INTO `roleInherit` VALUES (254,110,1,NULL); INSERT INTO `roleInherit` VALUES (255,110,76,NULL); INSERT INTO `roleInherit` VALUES (256,48,69,NULL); INSERT INTO `roleInherit` VALUES (257,47,111,NULL); @@ -1165,6 +1189,7 @@ INSERT INTO `roleInherit` VALUES (360,101,129,NULL); INSERT INTO `roleInherit` VALUES (361,50,112,NULL); INSERT INTO `roleInherit` VALUES (362,122,15,NULL); INSERT INTO `roleInherit` VALUES (364,35,18,NULL); +INSERT INTO `roleInherit` VALUES (365,123,119,NULL); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -1887,6 +1912,14 @@ INSERT INTO `ACL` VALUES (834,'AgencyMode','*','READ','ALLOW','ROLE','employee') INSERT INTO `ACL` VALUES (835,'Agency','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (836,'Agency','*','WRITE','ALLOW','ROLE','deliveryAssistant'); INSERT INTO `ACL` VALUES (837,'AgencyWorkCenter','*','WRITE','ALLOW','ROLE','deliveryAssistant'); +INSERT INTO `ACL` VALUES (838,'Worker','getAvailablePda','READ','ALLOW','ROLE','hr'); +INSERT INTO `ACL` VALUES (839,'Locker','__get__codes','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (840,'Locker','*','*','ALLOW','ROLE','hr'); +INSERT INTO `ACL` VALUES (841,'Locker','*','*','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (842,'Worker','__get__locker','READ','ALLOW','ROLE','hr'); +INSERT INTO `ACL` VALUES (843,'Worker','__get__locker','READ','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (844,'RoadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (845,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2206,8 +2239,8 @@ INSERT INTO `continent` VALUES (3,'África','AF'); INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (5,'Oceanía','OC'); -INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,25,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); @@ -2217,28 +2250,28 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1 INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',38,71,NULL,0,0,0,1,16,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',78,79,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); -INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (58,'CMP','CAMPOS',86,89,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (61,NULL,'VNH',92,95,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (80,'vallesTeam','EQUIPO ESPAÑA 5',43,44,4250,72,0,0,2,0,43,'/1/43/','jvp_equipo',1,'equipojvalles@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',98,99,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',43,44,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); +INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (89,NULL,'COORDINACION',102,103,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (90,NULL,'TRAILER',93,94,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',0,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); @@ -2246,20 +2279,20 @@ INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065, INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (125,'miriamMarTeam','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','mir_equipo',0,'equipomirgir@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',57,58,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',0,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); -INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); +INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',87,88,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); +INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (139,'soriaTeam','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','jss_equipo',1,'equipojsoria@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); -INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 5b1b600b1..39b7d4a8c 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1300,7 +1300,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimState','juan@d INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','company','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -1400,6 +1400,12 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-prox INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceInConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','chat','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','roadmapStop','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyWorkCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; @@ -1595,10 +1601,7 @@ INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','editorFk', INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','recycledPlastic','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','nonRecycledPlastic','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','item','minQuantity','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','size','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','originFk','0000-00-00 00:00:00','Select,Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','longName','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','buyer','item','name','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','id','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','warehouseFk','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','ticket','shipped','0000-00-00 00:00:00','Update'); @@ -1873,7 +1876,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaParcialMak INSERT IGNORE INTO `procs_priv` VALUES ('','vn','palletizerBoss','packingsite_startcollection','PROCEDURE','alexm@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','sale_calculatecomponent','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','manaspellersrequery','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','adminBoss','packageinvoicing','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','packinglistswitch','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','previoussticker_get','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','productioncontrol','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -1976,7 +1978,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_ad INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_list','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expeditionscan_put','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','cmrpallet_add','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemtrash','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getbalance','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_checkroute','FUNCTION','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','addnotefromdelivery','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2029,7 +2030,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_add' INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_list','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionscan_put','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','cmrpallet_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemtrash','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','item_getbalance','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_checkroute','FUNCTION','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','addnotefromdelivery','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 1cb5c2964..b61cbcc5c 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -6458,7 +6458,8 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_add`( IN vStarted DATE, - IN vEnded DATE) + IN vEnded DATE +) BEGIN /** * Añade las ventas que se realizaron entre 2 fechas a la tabla bs.sale @@ -6467,64 +6468,55 @@ BEGIN * @param vEnded Fecha de fin * */ - DECLARE vLoopDate DATE; - DECLARE vLoopDateTime DATETIME; - IF vStarted < (util.VN_CURDATE() - INTERVAL 5 YEAR) OR vStarted > vEnded THEN CALL util.throw('Wrong date'); END IF; - SET vLoopDate = vStarted; - DELETE FROM sale WHERE dated BETWEEN vStarted AND vEnded; - WHILE vLoopDate <= vEnded DO - SET vLoopDateTime = util.dayEnd(vLoopDate); - - REPLACE sale( - saleFk, - amount, - surcharge, - dated, - typeFk, - clientFk, - companyFk, - margin - )WITH calculatedSales AS( - SELECT s.id saleFk, - SUM(IF(ct.isBase, s.quantity * sc.value, 0)) amount, - SUM(IF(ct.isBase, 0, s.quantity * sc.value)) surcharge, - s.total pvp, - DATE(t.shipped) dated, - i.typeFk, - t.clientFk, - t.companyFk, - SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) marginComponents - FROM vn.ticket t - STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id - 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 - JOIN vn.saleComponent sc ON sc.saleFk = s.id - JOIN vn.component c ON c.id = sc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE t.shipped BETWEEN vLoopDate AND vLoopDateTime - AND s.quantity <> 0 - AND ic.merchandise - GROUP BY s.id - )SELECT saleFk, - amount, - surcharge, - dated, - typeFk, - clientFk, - companyFk, - marginComponents + amount + surcharge - pvp - FROM calculatedSales; - - SET vLoopDate = vLoopDate + INTERVAL 1 DAY; - END WHILE; + REPLACE sale( + saleFk, + amount, + surcharge, + dated, + typeFk, + clientFk, + companyFk, + margin + )WITH calculatedSales AS( + SELECT s.id saleFk, + CAST(SUM(IF(ct.isBase, s.quantity * sc.value, 0)) AS DECIMAL(10, 3)) amount, + CAST(SUM(IF(ct.isBase, 0, s.quantity * sc.value)) AS DECIMAL(10, 3)) surcharge, + s.total, + DATE(t.shipped) dated, + i.typeFk, + t.clientFk, + t.companyFk, + CAST(SUM(IF(ct.isMargin, s.quantity * sc.value, 0 )) AS DECIMAL(10, 3)) marginComponents + FROM vn.ticket t + STRAIGHT_JOIN vn.sale s ON s.ticketFk = t.id + 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 + JOIN vn.saleComponent sc ON sc.saleFk = s.id + JOIN vn.component c ON c.id = sc.componentFk + JOIN vn.componentType ct ON ct.id = c.typeFk + WHERE t.shipped BETWEEN vStarted AND vEnded + AND s.quantity <> 0 + AND ic.merchandise + GROUP BY s.id + )SELECT saleFk, + amount, + surcharge, + dated, + typeFk, + clientFk, + companyFk, + IF (marginComponents IS NULL, + 0, + CAST(marginComponents + amount + surcharge - total AS DECIMAL(10, 3))) + FROM calculatedSales; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8276,7 +8268,7 @@ BEGIN vPrinterFk, IFNULL(right(`t`.`routeFk`, 3),0), if (@vVolume := vn.ticketTotalVolume(t.id) > 1.5, @vVolume, IFNULL( rm.beachFk, 0)), - LEFT(IFNULL(et.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName, + LEFT(IFNULL(rs.description ,replace(`z`.`name`, 'ZONA ', 'Z')),14) truckName, t.clientFk , ifnull(c.mobile, ifnull(a.mobile, ifnull(c.phone, a.phone))), LEFT(p.name, 20), @@ -8288,7 +8280,7 @@ BEGIN JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p ON p.id = a.provinceFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id @@ -11167,6 +11159,7 @@ CREATE TABLE `order` ( `isPaid` tinyint(1) NOT NULL DEFAULT 0, `payed` datetime DEFAULT NULL, `created` timestamp NULL DEFAULT current_timestamp(), + `observations` text DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `catalogueFk` (`catalogueFk`), CONSTRAINT `order_ibfk_1` FOREIGN KEY (`catalogueFk`) REFERENCES `catalogue` (`id`) ON UPDATE CASCADE @@ -15107,7 +15100,7 @@ BEGIN -- Código redundante - DO vn.till_new( + CALL vn.till_new( vCustomer ,vBank ,vAmount / 100 @@ -16028,7 +16021,7 @@ SET character_set_client = utf8; 1 AS `permit`, 1 AS `type`, 1 AS `context`, - 1 AS `incominglimit`, + 1 AS `call-limit`, 1 AS `pickupgroup`, 1 AS `directmedia`, 1 AS `insecure`, @@ -16060,7 +16053,7 @@ CREATE TABLE `sipConfig` ( `permit` varchar(95) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `type` enum('user','peer','friend') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `context` varchar(80) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `incomingLimit` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `call-limit` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `pickupGroup` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `directMedia` enum('yes','no') DEFAULT NULL, `insecure` varchar(45) NOT NULL, @@ -17926,7 +17919,7 @@ BEGIN IFNULL(c.street, ''), c.accountingAccount, @fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)), - IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)), + IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)), IFNULL(c.postcode, ''), IFNULL(c.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -17964,7 +17957,7 @@ BEGIN IFNULL(s.street, ''), s.account, @nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)), - IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)), + IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)), IFNULL(s.postCode,''), IFNULL(s.city, ''), IFNULL(pr.CodigoProvincia, ''), @@ -20277,14 +20270,14 @@ BEGIN DECLARE vDayMinute INT; - SELECT HOUR(IFNULL(et.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(et.ETD, z.`hour`)) INTO vDayMinute + SELECT HOUR(IFNULL(rs.ETD, z.`hour`)) * 60 + MINUTE(IFNULL(rs.ETD, z.`hour`)) INTO vDayMinute FROM vn.expedition e JOIN vn.ticket t ON e.ticketFk = t.id JOIN vn.`zone` z ON z.id = t.zoneFk LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk - LEFT JOIN vn.expeditionTruck et ON rm.expeditionTruckFk = et.id + LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id WHERE e.id = vExpeditionFk; RETURN vDayMinute; @@ -21803,8 +21796,8 @@ BEGIN SET @dm := (24 * 60) - 10; - UPDATE vn.expeditionTruck et - SET et.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE()) + UPDATE vn.roadmapStop rs + SET rs.eta = timestampadd(MINUTE ,@dm := 1 + @dm,util.VN_CURDATE()) WHERE description LIKE 'PRU%' ; DELETE FROM srt.movingLog ; @@ -26143,6 +26136,7 @@ CREATE TABLE `absenceType` ( `holidayEntitlementRate` decimal(3,2) DEFAULT 1.00, `isNaturalDay` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', `isCalculate` tinyint(1) DEFAULT 0 COMMENT 'Para el cálculo de los salarios de los repartidores', + `isFestiveEligible` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Para marcar un tipo de absence', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -27514,7 +27508,7 @@ CREATE TABLE `buy` ( `packing` int(11) NOT NULL DEFAULT 1 CHECK (`packing` > 0), `grouping` smallint(5) unsigned NOT NULL DEFAULT 1, `groupingMode` enum('grouping','packing') DEFAULT NULL, - `containerFk` smallint(5) unsigned DEFAULT NULL, + `containerFk__` smallint(5) unsigned DEFAULT NULL, `comissionValue` decimal(10,3) NOT NULL DEFAULT 0.000, `packageValue` decimal(10,3) NOT NULL DEFAULT 0.000, `location` varchar(5) DEFAULT NULL, @@ -27539,7 +27533,7 @@ CREATE TABLE `buy` ( KEY `CompresId_Trabajador` (`workerFk`), KEY `Id_Cubo` (`packagingFk`), KEY `Id_Entrada` (`entryFk`), - KEY `container_id` (`containerFk`), + KEY `container_id` (`containerFk__`), KEY `buy_edi_id` (`ektFk`), KEY `itemFk_entryFk` (`itemFk`,`entryFk`), KEY `buy_fk_4_idx` (`deliveryFk`), @@ -27547,7 +27541,6 @@ CREATE TABLE `buy` ( KEY `buy_itemFk_IDX` (`itemFk`) USING BTREE, KEY `buy_fk_editor` (`editorFk`), CONSTRAINT `buy_FK` FOREIGN KEY (`itemOriginalFk`) REFERENCES `item` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `buy_FK_1` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container__` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_ektFk` FOREIGN KEY (`ektFk`) REFERENCES `edi`.`ekt` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `buy_fk_4` FOREIGN KEY (`deliveryFk`) REFERENCES `edi`.`deliveryInformation` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL, CONSTRAINT `buy_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), @@ -28290,6 +28283,7 @@ CREATE TABLE `clientConfig` ( `defaultIsTaxDataChecked` tinyint(1) DEFAULT NULL, `defaultHasCoreVnl` tinyint(1) DEFAULT NULL, `defaultMandateTypeFk` smallint(5) DEFAULT NULL, + `monthsToDisableUser` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `clientNewConfigPayMethod_FK` (`defaultPayMethodFk`), KEY `clientNewConfigMandateType_FK` (`defaultMandateTypeFk`), @@ -29358,19 +29352,18 @@ CREATE TABLE `conveyorType` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `coolerPathDetail` +-- Table structure for table `coolerPathDetail__` -- -DROP TABLE IF EXISTS `coolerPathDetail`; +DROP TABLE IF EXISTS `coolerPathDetail__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `coolerPathDetail` ( +CREATE TABLE `coolerPathDetail__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `coolerPathFk` int(11) NOT NULL DEFAULT 1, `hallway` varchar(3) NOT NULL, PRIMARY KEY (`coolerPathFk`,`hallway`), - UNIQUE KEY `cooler_path_detail_id_UNIQUE` (`id`), - CONSTRAINT `coolerPathDetail_FK` FOREIGN KEY (`coolerPathFk`) REFERENCES `vn2008`.`cooler_path__` (`cooler_path_id`) ON UPDATE CASCADE + UNIQUE KEY `cooler_path_detail_id_UNIQUE` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29398,9 +29391,10 @@ DROP TABLE IF EXISTS `country`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `country` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `country` varchar(25) NOT NULL, + `name` varchar(25) NOT NULL, `CEE` tinyint(1) NOT NULL DEFAULT 1, `code` varchar(2) NOT NULL, + `viesCode` varchar(2) DEFAULT NULL, `currencyFk` tinyint(3) unsigned NOT NULL DEFAULT 1, `politicalCountryFk__` mediumint(8) unsigned DEFAULT NULL COMMENT 'Pais Real(apaño por culpa del España Exento)', `geoFk` int(11) DEFAULT NULL, @@ -29410,11 +29404,12 @@ CREATE TABLE `country` ( `continentFk` tinyint(4) DEFAULT NULL, `a3Code` int(11) DEFAULT NULL COMMENT 'Código país para a3', `isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1, + `country` varchar(25) GENERATED ALWAYS AS (`name`) VIRTUAL, PRIMARY KEY (`id`), UNIQUE KEY `country_unique` (`code`), KEY `Id_Paisreal` (`politicalCountryFk__`), KEY `currency_id_fk_idx` (`currencyFk`), - KEY `country_Ix4` (`country`), + KEY `country_Ix4` (`name`), KEY `continent_id_fk_idx` (`continentFk`), KEY `country_FK_1` (`geoFk`), CONSTRAINT `continent_id_fk` FOREIGN KEY (`continentFk`) REFERENCES `continent` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, @@ -29664,7 +29659,7 @@ CREATE TABLE `deliveryNote` ( `supervisorFk` int(10) unsigned NOT NULL, `departmentFk` int(11) NOT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, - `farmingFk` int(10) unsigned DEFAULT NULL, + `farmingFk__` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `fk_albaran_Proveedores_idx` (`supplierFk`), KEY `fk_albaran_empresa1_idx` (`companyFk`), @@ -29674,9 +29669,9 @@ CREATE TABLE `deliveryNote` ( KEY `fk_albaran_Trabajadores2_idx` (`supervisorFk`), KEY `fk_albaran_department1_idx` (`departmentFk`), KEY `fk_albaran_recibida_idx` (`invoiceInFk`), - KEY `albaran_FK` (`farmingFk`), + KEY `albaran_FK` (`farmingFk__`), CONSTRAINT `albaranCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, - CONSTRAINT `albaran_FK` FOREIGN KEY (`farmingFk`) REFERENCES `farming` (`id`), + CONSTRAINT `albaran_FK` FOREIGN KEY (`farmingFk__`) REFERENCES `farming` (`id`), CONSTRAINT `albaran_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_Trabajadores2` FOREIGN KEY (`supervisorFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, @@ -29923,6 +29918,7 @@ CREATE TABLE `deviceProductionConfig` ( `id` int(10) unsigned NOT NULL, `isAllUsersallowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Permite que cualquier usuario pueda loguearse', `isTractorHuntingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Habilita el modo cazador para usuarios que no se han logeado un tractor para sacar', + `maxDevicesPerUser` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), CONSTRAINT `deviceProductionConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -29996,16 +29992,18 @@ DROP TABLE IF EXISTS `deviceProductionUser`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `deviceProductionUser` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `deviceProductionFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, `created` timestamp NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`deviceProductionFk`), - UNIQUE KEY `deviceProductionUser_UN` (`userFk`), + `simSerialNumber` text DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `deviceProductionUser_unique` (`deviceProductionFk`), KEY `userFgn_idx` (`userFk`), KEY `deviceProductionUser_fk_editor` (`editorFk`), - CONSTRAINT `deviceProductionUser_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `deviceProductionUser_PK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `deviceProductionUser_deviceProduction_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`), CONSTRAINT `deviceProductionUser_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -30804,43 +30802,6 @@ SET character_set_client = utf8; 1 AS `rate` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `exchangeReportSource` --- - -DROP TABLE IF EXISTS `exchangeReportSource`; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSource`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `exchangeReportSource` AS SELECT - 1 AS `dated`, - 1 AS `amountIn`, - 1 AS `rateIn`, - 1 AS `amountOut`, - 1 AS `rateOut`, - 1 AS `amountEntry`, - 1 AS `rateEntry`, - 1 AS `rateECB` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `exchangeReportSourcePrevious` --- - -DROP TABLE IF EXISTS `exchangeReportSourcePrevious`; -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `exchangeReportSourcePrevious` AS SELECT - 1 AS `dated`, - 1 AS `amountIn`, - 1 AS `rateIn`, - 1 AS `amountOut`, - 1 AS `rateOut`, - 1 AS `amountEntry`, - 1 AS `rateEntry` */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `excuse` -- @@ -30995,7 +30956,7 @@ CREATE TABLE `expeditionPallet` ( `isPrint` tinyint(4) NOT NULL DEFAULT 2, PRIMARY KEY (`id`), KEY `expeditionPallet_fk1_idx` (`truckFk`), - CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `expeditionTruck` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `expeditionPallet_fk1` FOREIGN KEY (`truckFk`) REFERENCES `roadmapStop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -31190,33 +31151,23 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `expeditionTruck` +-- Temporary table structure for view `expeditionTruck` -- DROP TABLE IF EXISTS `expeditionTruck`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditionTruck` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `roadmapFk` int(10) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned DEFAULT NULL, - `eta` datetime DEFAULT NULL COMMENT 'Estimated time of arrival', - `description` varchar(45) NOT NULL, - `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', - `created` timestamp NULL DEFAULT current_timestamp(), - `userFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `expeditionTruck_idx1` (`eta`), - KEY `expeditionTruck_FK` (`bufferFk`), - KEY `expeditionTruck_FK_1` (`warehouseFk`), - KEY `expeditionTruck_FK_2` (`roadmapFk`), - KEY `expeditionTruck_FK_3` (`userFk`), - CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_2` FOREIGN KEY (`roadmapFk`) REFERENCES `roadmap` (`id`) ON UPDATE CASCADE, - CONSTRAINT `expeditionTruck_FK_3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintas paradas que hacen los trocales'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `expeditionTruck`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `expeditionTruck` AS SELECT + 1 AS `id`, + 1 AS `roadmapFk`, + 1 AS `warehouseFk`, + 1 AS `eta`, + 1 AS `description`, + 1 AS `bufferFk`, + 1 AS `created`, + 1 AS `userFk` */; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `expeditionTruck_Control` @@ -32128,12 +32079,12 @@ CREATE TABLE `invoiceInConfig` ( `id` int(10) unsigned NOT NULL, `retentionRate` int(3) NOT NULL, `retentionName` varchar(25) NOT NULL, - `sageWithholdingFk` smallint(6) NOT NULL, + `sageFarmerWithholdingFk` smallint(6) NOT NULL, `daysAgo` int(10) unsigned DEFAULT 45 COMMENT 'Días en el pasado para mostrar facturas en invoiceIn series en salix', `taxRowLimit` int(11) DEFAULT 4 COMMENT 'Número máximo de líneas de IVA que puede tener una factura', PRIMARY KEY (`id`), - KEY `invoiceInConfig_sageWithholdingFk` (`sageWithholdingFk`), - CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE, + KEY `invoiceInConfig_sageWithholdingFk` (`sageFarmerWithholdingFk`), + CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageFarmerWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -32574,8 +32525,8 @@ CREATE TABLE `item` ( `lastUsed` datetime DEFAULT current_timestamp(), `weightByPiece` int(10) unsigned DEFAULT NULL COMMENT 'peso por defecto para un articulo por tallo/unidad', `editorFk` int(10) unsigned DEFAULT NULL, - `recycledPlastic` int(11) DEFAULT NULL, - `nonRecycledPlastic` int(11) DEFAULT NULL, + `recycledPlastic` decimal(10,2) DEFAULT NULL, + `nonRecycledPlastic` decimal(10,2) DEFAULT NULL, `minQuantity` int(10) unsigned DEFAULT NULL COMMENT 'Cantidad mínima para una línea de venta', `isBoxPickingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'FALSE: using item.packingOut TRUE: boxPicking using itemShelving.packing', PRIMARY KEY (`id`), @@ -33674,6 +33625,22 @@ SET character_set_client = utf8; 1 AS `totalAmount` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `ledgerCompany` +-- + +DROP TABLE IF EXISTS `ledgerCompany`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ledgerCompany` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable', + `bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable', + PRIMARY KEY (`id`), + UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Contador para asientos contables'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `ledgerConfig` -- @@ -33682,9 +33649,28 @@ DROP TABLE IF EXISTS `ledgerConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ledgerConfig` ( - `lastBookEntry` int(11) NOT NULL, + `lastBookEntry__` int(11) NOT NULL COMMENT '@deprecated 2024-05-28 refs #7400 Modificar contador asientos contables', `maxTolerance` decimal(10,2) NOT NULL, - PRIMARY KEY (`lastBookEntry`) + PRIMARY KEY (`lastBookEntry__`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `locker` +-- + +DROP TABLE IF EXISTS `locker`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `locker` ( + `id` int(100) NOT NULL AUTO_INCREMENT, + `code` varchar(10) DEFAULT NULL, + `gender` enum('M','F') DEFAULT NULL, + `workerFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `code` (`code`), + UNIQUE KEY `workerFk` (`workerFk`), + CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34550,9 +34536,9 @@ DROP TABLE IF EXISTS `packaging`; CREATE TABLE `packaging` ( `id` varchar(10) NOT NULL, `volume` decimal(10,2) DEFAULT NULL CHECK (`volume` >= coalesce(`width`,1) * coalesce(`depth`,1) * coalesce(`height`,1)), - `width` decimal(10,2) DEFAULT 0.00, - `depth` decimal(10,2) DEFAULT 0.00, - `height` decimal(10,2) DEFAULT 0.00, + `width` decimal(10,2) DEFAULT NULL, + `depth` decimal(10,2) DEFAULT NULL, + `height` decimal(10,2) DEFAULT NULL, `value` decimal(10,2) DEFAULT 0.00, `isPackageReturnable` tinyint(1) NOT NULL DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), @@ -35936,7 +35922,7 @@ CREATE TABLE `province` ( `name` varchar(30) NOT NULL, `countryFk` mediumint(8) unsigned NOT NULL, `warehouseFk` smallint(6) unsigned DEFAULT NULL COMMENT 'warehouse responsable de las rutas', - `zoneFk` tinyint(4) DEFAULT NULL, + `zoneFk` int(11) DEFAULT NULL, `geoFk` int(11) DEFAULT NULL, `autonomyFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), @@ -35947,7 +35933,7 @@ CREATE TABLE `province` ( KEY `province_FK` (`autonomyFk`), CONSTRAINT `province_FK` FOREIGN KEY (`autonomyFk`) REFERENCES `autonomy` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, - CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones__` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `province_zone_FK` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36314,6 +36300,35 @@ CREATE TABLE `roadmap` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Troncales diarios que se contratan'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `roadmapStop` +-- + +DROP TABLE IF EXISTS `roadmapStop`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roadmapStop` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `roadmapFk` int(10) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `eta` datetime DEFAULT NULL COMMENT 'Estimated time of arrival', + `description` varchar(45) NOT NULL, + `bufferFk` int(11) DEFAULT NULL COMMENT 'buffer destino de las cajas', + `created` timestamp NULL DEFAULT current_timestamp(), + `userFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `expeditionTruck_idx1` (`eta`), + KEY `expeditionTruck_FK` (`bufferFk`), + KEY `expeditionTruck_FK_1` (`warehouseFk`), + KEY `expeditionTruck_FK_2` (`roadmapFk`), + KEY `expeditionTruck_FK_3` (`userFk`), + CONSTRAINT `expeditionTruck_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `expeditionTruck_FK_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expeditionTruck_FK_2` FOREIGN KEY (`roadmapFk`) REFERENCES `roadmap` (`id`) ON UPDATE CASCADE, + CONSTRAINT `expeditionTruck_FK_3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Distintas paradas que hacen los trocales'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `role` -- @@ -36356,7 +36371,7 @@ DROP TABLE IF EXISTS `route`; CREATE TABLE `route` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned DEFAULT NULL, - `firstEditorFk` int(10) unsigned NOT NULL COMMENT 'Usuario creador de la ruta', + `firstEditorFk` int(10) unsigned DEFAULT NULL, `created` date NOT NULL, `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, @@ -36386,13 +36401,17 @@ CREATE TABLE `route` ( KEY `route_idxIsOk` (`isOk`), KEY `route_WorkCenterFk_idx` (`commissionWorkCenterFk`), KEY `route_fk_editor` (`editorFk`), + KEY `route_vehicleFk` (`vehicleFk`), + KEY `route_firstEditorFk` (`firstEditorFk`), CONSTRAINT `fk_route_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_WorkCenterFk` FOREIGN KEY (`commissionWorkCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE, + CONSTRAINT `route_firstEditorFk` FOREIGN KEY (`firstEditorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `route_fk5` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT `route_invoiceInFk` FOREIGN KEY (`invoiceInFk`) REFERENCES `invoiceIn` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `route_vehicleFk` FOREIGN KEY (`vehicleFk`) REFERENCES `vehicle` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36694,7 +36713,7 @@ CREATE TABLE `routesMonitor` ( CONSTRAINT `routesMonitor_FK` FOREIGN KEY (`bufferFk`) REFERENCES `srt`.`buffer` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_1` FOREIGN KEY (`dockFk`) REFERENCES `dock` (`code`) ON UPDATE CASCADE, CONSTRAINT `routesMonitor_FK_2` FOREIGN KEY (`beachFk`) REFERENCES `beach` (`code`) ON UPDATE CASCADE, - CONSTRAINT `routesMonitor_FK_3` FOREIGN KEY (`expeditionTruckFk`) REFERENCES `expeditionTruck` (`id`) ON UPDATE CASCADE, + CONSTRAINT `routesMonitor_FK_3` FOREIGN KEY (`expeditionTruckFk`) REFERENCES `roadmapStop` (`id`) ON UPDATE CASCADE, CONSTRAINT `routesMonitor_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36723,6 +36742,7 @@ CREATE TABLE `sale` ( `isAdded` tinyint(1) NOT NULL DEFAULT 0, `total` decimal(10,2) GENERATED ALWAYS AS (`price` * `quantity` * (100 - `discount`) / 100) VIRTUAL, `editorFk` int(10) unsigned DEFAULT NULL, + `problem` set('hasItemShortage','hasComponentLack','hasItemDelay','hasRounding','hasItemLost') NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `Id_Ticket` (`ticketFk`), KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), @@ -38047,7 +38067,7 @@ CREATE TABLE `supplier` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, `nif` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `isOfficial` tinyint(1) NOT NULL DEFAULT 1, - `isFarmer` tinyint(1) NOT NULL DEFAULT 0, + `isFarmer__` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk', `retAccount` varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `phone` varchar(16) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL, `commission` float NOT NULL DEFAULT 0, @@ -38627,6 +38647,8 @@ CREATE TABLE `ticket` ( `clonedFrom` int(11) DEFAULT NULL, `cmrFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, + `problem` set('hasTicketRequest','isFreezed','hasRisk','hasHighRisk','isTaxDataChecked','isTooLittle') NOT NULL DEFAULT '', + `risk` decimal(10,2) DEFAULT NULL COMMENT 'cache calculada con el riesgo del cliente', PRIMARY KEY (`id`), KEY `Id_Cliente` (`clientFk`), KEY `Id_Consigna` (`addressFk`), @@ -39663,15 +39685,22 @@ CREATE TABLE `travelConfig` ( `warehouseOutFk` smallint(6) unsigned NOT NULL DEFAULT 60 COMMENT 'Warehouse destino', `agencyFk` int(11) NOT NULL DEFAULT 1378 COMMENT 'Agencia por defecto', `companyFk` int(10) unsigned NOT NULL DEFAULT 442 COMMENT 'Compañía por defecto', + `devalueWarehouseOutFk` smallint(6) unsigned DEFAULT NULL COMMENT 'Datos del travel para las entradas generadas al devaluar artículos de A1 a A2', + `devalueAgencyModeFk` int(11) DEFAULT NULL, + `devalueRef` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `travelConfig_FK` (`warehouseInFk`), KEY `travelConfig_FK_1` (`warehouseOutFk`), KEY `travelConfig_FK_2` (`agencyFk`), KEY `travelConfig_FK_3` (`companyFk`), + KEY `travelConfig_agencyMode_FK` (`devalueAgencyModeFk`), + KEY `travelConfig_warehouse_FK` (`devalueWarehouseOutFk`), CONSTRAINT `travelConfig_FK` FOREIGN KEY (`warehouseInFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_1` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_2` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travelConfig_FK_3` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `travelConfig_agencyMode_FK` FOREIGN KEY (`devalueAgencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `travelConfig_warehouse_FK` FOREIGN KEY (`devalueWarehouseOutFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `travelConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40375,12 +40404,10 @@ CREATE TABLE `worker` ( `sex` enum('M','F') NOT NULL DEFAULT 'F' COMMENT 'M Masculino F Femenino', `businessFk` int(11) DEFAULT NULL, `balance` decimal(10,2) DEFAULT NULL, - `locker` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `CodigoTrabajador_UNIQUE` (`code`), UNIQUE KEY `worker_business` (`businessFk`), - UNIQUE KEY `locker` (`locker`), KEY `sub` (`sub`), KEY `boss_idx` (`bossFk`), KEY `worker_FK` (`labelerFk__`), @@ -40777,7 +40804,7 @@ CREATE TABLE `workerLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text DEFAULT NULL, - `changedModel` enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl') NOT NULL DEFAULT 'Worker', + `changedModel` enum('Worker','Calendar','WorkerTimeControlMail','Business','WorkerDms','WorkerTimeControl','Locker') NOT NULL DEFAULT 'Worker', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, @@ -41593,42 +41620,7 @@ CREATE TABLE `zoneWarehouse` ( -- Dumping events for database 'vn' -- /*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `clientsDisable` */; -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 @saved_sql_mode = @@sql_mode */ ;; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; -/*!50003 SET @saved_time_zone = @@time_zone */ ;; -/*!50003 SET time_zone = 'SYSTEM' */ ;; -/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `clientsDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN - UPDATE account.user u - JOIN client c ON c.id = u.id - LEFT JOIN account.account a ON a.id = u.id - SET u.active = FALSE - WHERE c.typeFk = 'normal' - AND a.id IS NULL - AND u.active - AND c.created < util.VN_CURDATE() - INTERVAL 12 MONTH - AND u.id NOT IN ( - SELECT DISTINCT c.id - FROM client c - LEFT JOIN ticket t ON t.clientFk = c.id - WHERE c.salesPersonFk IS NOT NULL - OR t.created > util.VN_CURDATE() - INTERVAL 12 MONTH - OR shipped > util.VN_CURDATE() - INTERVAL 12 MONTH - ); -END */ ;; -/*!50003 SET time_zone = @saved_time_zone */ ;; -/*!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 */ ;; -/*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */;; +/*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; @@ -41646,6 +41638,24 @@ DELIMITER ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `client_userDisable` */;; +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 @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `client_userDisable` ON SCHEDULE EVERY 1 MONTH STARTS '2023-06-01 00:00:00' ON COMPLETION PRESERVE ENABLE DO CALL client_userDisable() */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!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 */ ;; /*!50106 DROP EVENT IF EXISTS `collection_make` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; @@ -44973,6 +44983,46 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `sale_hasComponentLack` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `sale_hasComponentLack`(vSelf INT +) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Check if a sales line has all the required components. + * + * @param vSelf Id de sale + * @return BOOL + */ + DECLARE vHasComponentLack TINYINT(1); + + WITH componentRequired AS( + SELECT COUNT(*) total + FROM vn.component + WHERE isRequired + )SELECT SUM(IF(c.isRequired, TRUE, FALSE)) <> cr.total INTO vHasComponentLack + FROM vn.sale s + JOIN componentRequired cr + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk + WHERE s.id = vSelf; + + RETURN vHasComponentLack; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `specie_IsForbidden` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45747,6 +45797,42 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `ticket_isTooLittle` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_isTooLittle`(vSelf INT +) RETURNS tinyint(1) + READS SQL DATA +BEGIN +/** + * Check if the ticket is small based on the volume and amount parameters. + * + * @param vSelf Id ticket + * @return BOOL + */ + DECLARE vIsTooLittle TINYINT(1); + + SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume + OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle + FROM ticket t + LEFT JOIN saleVolume sv ON sv.ticketFk = t.id + JOIN volumeConfig vc + WHERE t.id = vSelf; + + RETURN vIsTooLittle; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `till_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46359,61 +46445,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `xdiario_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 = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` FUNCTION `xdiario_new`(vAsiento INT, - vDated DATE, - vSubaccount VARCHAR(12), - vAccount VARCHAR(12), - vConcept VARCHAR(25), - vDebit DOUBLE, - vCredit DOUBLE, - vEuro DOUBLE, - vSerie CHAR(1), - vInvoice VARCHAR(8), - vVat DOUBLE, - vRe DOUBLE, - vAux TINYINT, - vCompany INT -) RETURNS int(11) - NO SQL -BEGIN - IF vAsiento IS NULL THEN - CALL vn.ledger_next(vAsiento); - END IF; - - INSERT INTO XDiario - SET ASIEN = vAsiento, - FECHA = vDated, - SUBCTA = vSubaccount, - CONTRA = vAccount, - CONCEPTO = vConcept, - EURODEBE = vDebit, - EUROHABER = vCredit, - BASEEURO = vEuro, - SERIE = vSerie, - FACTURA = vInvoice, - IVA = vVat, - RECEQUIV = vRe, - AUXILIAR = IF(vAux = FALSE, NULL, '*'), - MONEDAUSO = 2, - empresa_id = vCompany; - - RETURN vAsiento; -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_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `zoneGeo_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46958,7 +46989,7 @@ BEGIN DECLARE vEnded DATETIME DEFAULT util.dayEnd(util.VN_CURDATE()); SELECT ag.id agency_id, - CONCAT(RPAD(c.country, 16,' _') ,' ',ag.name) Agencia, + CONCAT(RPAD(c.name, 16,' _') ,' ',ag.name) Agencia, COUNT(*) expediciones, SUM(t.packages) Bultos, SUM(tpe.boxes) Faltan @@ -48133,6 +48164,76 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_clone` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_clone`(vEntryFk INT) +BEGIN +/** + * Clone buys to an entry + * + * @param vEntryFk The entry id + * @table tmp.buy(id) + */ + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vEntryFk, + b.itemFk, + b.quantity, + b.buyingValue, + b.freightValue, + b.isIgnored, + b.stickers, + b.packagingFk, + b.packing, + b.`grouping`, + b.groupingMode, + b.comissionValue, + b.packageValue, + b.price1, + b.price2, + b.price3, + b.minPrice, + b.isChecked, + b.location, + b.weight, + b.itemOriginalFk + FROM tmp.buy tb + JOIN vn.buy b ON b.id = tb.id; + +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getSplit` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -48492,7 +48593,7 @@ BEGIN */ DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc; - CREATE TEMPORARY TABLE tmp.buyRecalc + CREATE TEMPORARY TABLE tmp.buyRecalc SELECT vBuyFk id; CALL buy_recalcPrices(); @@ -49382,7 +49483,7 @@ BEGIN WHERE cs.description = 'Anulado' AND c.created < v2Months; - DELETE FROM expeditionTruck WHERE eta < v3Months; + DELETE FROM roadmapStop WHERE eta < v3Months; DELETE FROM XDiario WHERE FECHA < v3Months OR FECHA IS NULL; -- Borrar travels sin entradas @@ -50553,7 +50654,7 @@ BEGIN c.credit, CAST(r.risk AS DECIMAL (10,2)) risk, CAST(c.credit - r.risk AS DECIMAL (10,2)) difference, - co.country + co.name country FROM client c JOIN tmp.risk r ON r.clientFk = c.id JOIN country co ON co.id = c.countryFk @@ -50706,6 +50807,52 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `client_userDisable` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `client_userDisable`() +BEGIN +/** +* Desactiva los clientes inactivos en los últimos X meses. +*/ + DECLARE vMonths INT; + + SELECT monthsToDisableUser INTO vMonths + FROM clientConfig; + + IF vMonths IS NULL THEN + CALL util.throw('Config parameter not set'); + END IF; + + UPDATE account.user u + JOIN client c ON c.id = u.id + LEFT JOIN account.account a ON a.id = u.id + SET u.active = FALSE + WHERE c.typeFk = 'normal' + AND a.id IS NULL + AND u.active + AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND u.id NOT IN ( + SELECT DISTINCT c.id + FROM client c + LEFT JOIN ticket t ON t.clientFk = c.id + WHERE c.salesPersonFk IS NOT NULL + OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH + ); +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `cmrPallet_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -51024,6 +51171,7 @@ BEGIN BEGIN IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); + CALL util.debugAdd('releaseLock', vLockName); -- Tmp END IF; RESIGNAL; @@ -51515,6 +51663,7 @@ BEGIN BEGIN IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); + CALL util.debugAdd('releaseLock', vLockName); -- Tmp END IF; RESIGNAL; @@ -52182,11 +52331,12 @@ BEGIN FROM tPendingDuedates vp LEFT JOIN supplier s ON s.id = vp.supplierFk LEFT JOIN client c ON c.fi = s.nif - LEFT JOIN clientRisk cr ON cr.clientFk = c.id + LEFT JOIN clientRisk cr ON cr.clientFk = c.id AND cr.companyFk = vp.companyFk LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk - LEFT JOIN country co ON co.id = be.countryFk; + LEFT JOIN country co ON co.id = be.countryFk + GROUP BY vp.id; DROP TEMPORARY TABLE tOpeningBalances; DROP TEMPORARY TABLE tPendingDuedates; @@ -52420,7 +52570,7 @@ BEGIN 10 * p.height as height, IFNULL(t.routeFk,am.agencyFk) routeFk, hour(e.created) * 60 + minute(e.created), - IFNULL(et.description , a.name), + IFNULL(rs.description , a.name), IFNULL(t.routeFk,am.agencyFk) criterion, IFNULL(p.conveyorBuildingClassFk , pc.defaultConveyorBuildingClass) FROM vn.expedition e @@ -52430,7 +52580,7 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded @@ -52557,7 +52707,7 @@ BEGIN cac.invoiced billedAnnually, c.dueDay, cgd.grade, - c2.country + c2.name country FROM tmp.clientGetDebt cgd LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk JOIN client c ON c.id = cgd.clientFk @@ -53406,127 +53556,121 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `duaTaxBooking`(vDuaFk INT) BEGIN DECLARE vBookNumber INT; - DECLARE vBookDated DATE; - DECLARE vDiff DECIMAL(10,2); - DECLARE vApunte BIGINT; - - SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated - FROM dua + DECLARE vBookDated DATE; + DECLARE vDiff DECIMAL(10,2); + DECLARE vApunte BIGINT; + + SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) + INTO vBookNumber, vBookDated + FROM dua WHERE id = vDuaFk; - + IF vBookNumber IS NULL OR NOT vBookNumber THEN - CALL ledger_next(vBookNumber); + CALL ledger_next(YEAR(vBookDated), vBookNumber); END IF; -- Apunte de la aduana - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONCEPTO, - EUROHABER, - SERIE, - empresa_id, - CLAVE, - FACTURA) + ASIEN, + FECHA, + SUBCTA, + CONCEPTO, + EUROHABER, + SERIE, + empresa_id, + CLAVE, + FACTURA) + SELECT vBookNumber, + d.bookEntried, + '4700000999', + CONCAT('DUA ',d.`code`), + sum(dt.base * dt.rate / 100) EUROHABER, + 'R', + d.companyFk, + vDuaFk, + vDuaFk + FROM duaTax dt + JOIN dua d ON d.id = dt.duaFk + WHERE dt.duaFk = vDuaFk; - SELECT - vBookNumber, - d.bookEntried, - '4700000999', - CONCAT('DUA ',d.`code`), - sum(dt.base * dt.rate / 100) EUROHABER, - 'R', - d.companyFk, - vDuaFk, - vDuaFk - FROM duaTax dt - JOIN dua d ON d.id = dt.duaFk - WHERE dt.duaFk = vDuaFk; - - -- Apuntes por tipo de IVA y proveedor - - INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - FECHA_EX, - FECHA_OP, - FACTURAEX, - NFACTICK, - L340, - LDIFADUAN, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id, - FECREGCON - ) - - SELECT - vBookNumber ASIEN, - vBookDated FECHA, - tr.account SUBCTA, - '4330002067' CONTRA, - sum(dt.tax) EURODEBE, - sum(dt.base) BASEEURO, - CONCAT('DUA nº',d.code) CONCEPTO, - d.id FACTURA, - dt.rate IVA, - '*' AUXILIAR, - 'D' SERIE, - d.issued FECHA_EX, - d.operated FECHA_OP, - d.code FACTURAEX, - 1 NFACTICK, - 1 L340, - TRUE LDIFADUAN, - 1 TIPOCLAVE, - 1 TIPOEXENCI, - 1 TIPONOSUJE, - 5 TIPOFACT, - 1 TIPORECTIF, - IF(c.code = 'ES', 1, 4) TERIDNIF, - s.nif TERNIF, - s.name TERNOM, - d.companyFk, - d.booked FECREGCON - FROM duaTax dt - JOIN dua d ON dt.duaFk = d.id - JOIN (SELECT account, rate - FROM - (SELECT rate, account - FROM invoiceInTaxBookingAccount ta - WHERE ta.effectived <= vBookDated - AND taxAreaFk = 'WORLD' - ORDER BY ta.effectived DESC - LIMIT 10000000000000000000 - ) tba - GROUP BY rate + -- Apuntes por tipo de IVA y proveedor + INSERT INTO XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + FECHA_EX, + FECHA_OP, + FACTURAEX, + NFACTICK, + L340, + LDIFADUAN, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id, + FECREGCON) + SELECT vBookNumber ASIEN, + vBookDated FECHA, + tr.account SUBCTA, + '4330002067' CONTRA, + SUM(dt.tax) EURODEBE, + SUM(dt.base) BASEEURO, + CONCAT('DUA nº',d.code) CONCEPTO, + d.id FACTURA, + dt.rate IVA, + '*' AUXILIAR, + 'D' SERIE, + d.issued FECHA_EX, + d.operated FECHA_OP, + d.code FACTURAEX, + 1 NFACTICK, + 1 L340, + TRUE LDIFADUAN, + 1 TIPOCLAVE, + 1 TIPOEXENCI, + 1 TIPONOSUJE, + 5 TIPOFACT, + 1 TIPORECTIF, + IF(c.code = 'ES', 1, 4) TERIDNIF, + s.nif TERNIF, + s.name TERNOM, + d.companyFk, + d.booked FECREGCON + FROM duaTax dt + JOIN dua d ON dt.duaFk = d.id + JOIN (SELECT account, rate + FROM + (SELECT rate, account + FROM invoiceInTaxBookingAccount ta + WHERE ta.effectived <= vBookDated + AND taxAreaFk = 'WORLD' + ORDER BY ta.effectived DESC + LIMIT 10000000000000000000 + ) tba + GROUP BY rate ) tr ON tr.rate = dt.rate - JOIN supplier s ON s.id = d.companyFk - JOIN country c ON c.id = s.countryFk - WHERE d.id = vDuaFk - GROUP BY dt.rate; + JOIN supplier s ON s.id = d.companyFk + JOIN country c ON c.id = s.countryFk + WHERE d.id = vDuaFk + GROUP BY dt.rate; SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte FROM XDiario WHERE ASIEN = vBookNumber; - + UPDATE XDiario SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA, EURODEBE = EURODEBE - vDiff @@ -53535,7 +53679,6 @@ BEGIN UPDATE dua SET ASIEN = vBookNumber WHERE id = vDuaFk; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54025,8 +54168,8 @@ BEGIN * Clones an entry header. * * @param vSelf The entry id + * @param OUT vNewEntryFk The new entry id * @param vTravelFk Travel for the new entry or %NULL to use the source entry travel - * @param vNewEntryFk The new entry id */ INSERT INTO entry( travelFk, @@ -54104,62 +54247,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_copyBuys`(vSelf INT, vCopyTo INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `entry_copyBuys`(vSelf INT, vDestinationEntryFk INT) BEGIN /** - * Copies an entry buys to another buy. + * Copies all buys from an entry to an entry. * * @param vSelf The entry id - * @param vCopyTo The destination entry id + * @param vDestinationEntryFk The destination entry id */ - INSERT INTO buy( - entryFk, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk - ) - SELECT vCopyTo, - itemFk, - quantity, - buyingValue, - freightValue, - isIgnored, - stickers, - packing, - `grouping`, - groupingMode, - containerFk, - comissionValue, - packageValue, - packagingFk, - price1, - price2, - price3, - minPrice, - isChecked, - location, - weight, - itemOriginalFk + CREATE OR REPLACE TEMPORARY TABLE tmp.buy + SELECT id FROM buy WHERE entryFk = vSelf; + + CALL buy_clone(vDestinationEntryFk); + DROP TEMPORARY TABLE tmp.buy; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54203,7 +54305,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54223,7 +54324,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54590,7 +54690,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -54611,7 +54710,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, packagingFk, @@ -54648,7 +54746,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54667,7 +54764,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54892,7 +54988,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -54919,7 +55014,6 @@ BEGIN packing, `grouping`, groupingMode, - containerFk, comissionValue, packageValue, location, @@ -55680,7 +55774,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) BEGIN - INSERT INTO vn.expeditionTruck(eta,description) + INSERT INTO vn.roadmapStop(eta,description) VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); END ;; @@ -55704,10 +55798,10 @@ BEGIN SELECT id truckFk, eta, - description Destino - FROM expeditionTruck - WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - ORDER BY eta; + description Destino + FROM roadmapStop + WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) + ORDER BY eta; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55814,8 +55908,8 @@ BEGIN am.name zonaRuta, t.routeFk ruta, rm.beachFk ubicacion, - et.eta , - et.description camion, + rs.eta , + rs.description camion, vTicketsPendientes AS ticketsPendientes, vEtiquetasTotales AS etiquetasTotales, vEtiquetasEscaneadas AS etiquetasEscaneadas @@ -55827,7 +55921,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk WHERE e.id = vExpeditionFk; END ;; @@ -55900,8 +55994,8 @@ BEGIN am.name zonaRuta, t.routeFk ruta, rm.beachFk ubicacion, - et.eta , - et.description camion, + rs.eta , + rs.description camion, vTicketsPendientes AS ticketsPendientes, vEtiquetasTotales AS etiquetasTotales, vEtiquetasEscaneadas AS etiquetasEscaneadas, @@ -55914,7 +56008,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk WHERE e.id = vExpeditionFk; END ;; @@ -55944,120 +56038,6 @@ BEGIN WHERE r.workerFk = workerFk ORDER BY r.id DESC LIMIT 1; -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_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `fv_pca` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `fv_pca`() -BEGIN - -DECLARE done INT DEFAULT FALSE; - -DECLARE vTicketFk INT; -DECLARE vSaleFk INT; -DECLARE vClonTicket INT DEFAULT 0; - -DECLARE cur1 CURSOR FOR -SELECT s.ticketFk, s.id - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.itemType it ON it.id = i.typeFk - WHERE t.shipped BETWEEN '2020-10-18' AND '2020-10-31' - AND it.code IN ('ANT','ANS','ORQ','TRO') - and t.warehouseFk = 1; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN cur1; - -FETCH cur1 INTO vTicketFk, vSaleFk; - - WHILE done = 0 DO - - SELECT t.id INTO vClonTicket - FROM vn.ticket t - JOIN (SELECT addressFk, shipped FROM vn.ticket WHERE id = vTicketFk) sub USING(addressFk, shipped) - WHERE t.warehouseFk = 44 - LIMIT 1; - - SELECT vTicketFk, vClonTicket; - - IF vClonTicket = 0 THEN - - INSERT INTO ticket ( - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - warehouseFk, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - ) - SELECT - clientFk, - shipped, - addressFk, - agencyModeFk, - nickname, - 44, - companyFk, - landed, - zoneFk, - zonePrice, - zoneBonus, - routeFk - - FROM ticket - WHERE id = vTicketFk; - - SET vClonTicket = LAST_INSERT_ID(); - - SELECT 'lstID', vClonTicket; - /* - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN ticket t ON t.addressFk = ao.addressFk - WHERE t.id = vClonTicket; -*/ - INSERT INTO ticketLog - SET originFk = vTicketFk, userFk = account.myUser_getId(), `action` = 'insert', - description = CONCAT('Ha creado el ticket:', ' ', vClonTicket, ' clonando el ', vTicketFk); - - END IF; - - UPDATE vn.sale - SET ticketFk = vClonTicket - WHERE id = vSaleFk; - - SET vClonTicket = 0; - - SET done = 0; - FETCH cur1 INTO vTicketFk, vSaleFk; - - END WHILE; - - CLOSE cur1; - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57197,26 +57177,26 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`(IN vInvoiceInFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInTax_getFromEntries`( + IN vInvoiceInFk INT +) BEGIN DECLARE vRate DOUBLE DEFAULT 1; - DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - SELECT MAX(rr.dated) INTO vDated - FROM referenceRate rr - JOIN invoiceIn ii ON ii.id = vInvoiceInFk - WHERE rr.dated <= ii.issued - AND rr.currencyFk = ii.currencyFk ; - - IF vDated THEN - SELECT `value` INTO vRate - FROM referenceRate - WHERE dated = vDated; - END IF; + WITH rate AS( + SELECT MAX(rr.dated) dated, ii.currencyFk + FROM vn.invoiceIn ii + JOIN vn.referenceRate rr ON rr.currencyFk = ii.currencyFk + WHERE ii.id = vInvoiceInFk + AND rr.dated <= ii.issued + ) SELECT `value` INTO vRate + FROM vn.referenceRate rr + JOIN rate r ON r.dated = rr.dated + AND r.currencyFk = rr.currencyFk; SELECT id INTO vExpenseFk - FROM vn.expense + FROM expense WHERE `name` = 'Adquisición mercancia Extracomunitaria' GROUP BY id LIMIT 1; @@ -57224,19 +57204,25 @@ BEGIN DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk; - INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk) - SELECT ii.id, - SUM(b.buyingValue * b.quantity) / IFNULL(vRate,1) taxableBase, - vExpenseFk, - IF(ii.currencyFk = 1,NULL,SUM(b.buyingValue * b.quantity )) divisa, - taxTypeSageFk, + INSERT INTO invoiceInTax( + invoiceInFk, + taxableBase, + expenseFk, + foreignValue, + taxTypeSageFk, transactionTypeSageFk + )SELECT ii.id, + SUM(b.buyingValue * b.quantity) / vRate taxableBase, + vExpenseFk, + IF(ii.currencyFk = 1, + NULL, + SUM(b.buyingValue * b.quantity )), + taxTypeSageFk, + transactionTypeSageFk FROM invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN supplier s ON s.id = e.supplierFk JOIN buy b ON b.entryFk = e.id - LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk - AND rr.dated = ii.issued WHERE ii.id = vInvoiceInFk HAVING taxableBase IS NOT NULL; END ;; @@ -57328,6 +57314,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceIn_booking`(vSelf INT) BEGIN DECLARE vBookNumber INT; + DECLARE vFiscalYear INT; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn ENGINE = MEMORY @@ -57382,7 +57369,8 @@ BEGIN LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva WHERE ii.id = vSelf; - CALL vn.ledger_next(vBookNumber); + SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; + CALL ledger_next(vFiscalYear, vBookNumber); -- Apunte del proveedor INSERT INTO XDiario( @@ -57728,22 +57716,24 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceOutBooking`(IN vInvoice INT) BEGIN -/* Asienta la factura emitida -* -* param vInvoice factura_id -*/ +/** + * Asienta una factura emitida + * + * @param vInvoice Id invoiceOut + */ DECLARE vBookNumber INT; - DECLARE vExpenseConcept VARCHAR(50); - DECLARE vSpainCountryFk INT; - DECLARE vOldBookNumber INT; + DECLARE vExpenseConcept VARCHAR(50); + DECLARE vSpainCountryFk INT; + DECLARE vOldBookNumber INT; + DECLARE vFiscalYear INT; - SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES'; + SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES'; - SELECT ASIEN + SELECT ASIEN INTO vOldBookNumber FROM XDiario x JOIN invoiceOut io ON io.id = vInvoice - WHERE x.SERIE = io.serial + WHERE x.SERIE = io.serial AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1) LIMIT 1; @@ -57753,140 +57743,133 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS rs; CREATE TEMPORARY TABLE rs - SELECT - c.accountingAccount AS clientBookingAccount, - io.amount as totalAmount, - CONCAT('n/fra ', io.ref) as simpleConcept, - CONCAT('n/fra ', io.ref, ' ', c.name) as Concept, - io.serial AS SERIE, - io.issued AS FECHA_EX, - io.issued AS FECHA_OP, - io.issued AS FECHA, - 1 AS NFACTICK, - IF(ic.correctingFk,'D','') AS TIPOOPE, - io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - io.cplusTaxBreakFk AS TIPOEXENCI, - io.cplusSubjectOpFk AS TIPONOSUJE, - io.siiTypeInvoiceOutFk AS TIPOFACT, - ic.cplusRectificationTypeFk AS TIPORECTIF, + SELECT c.accountingAccount clientBookingAccount, + io.amount totalAmount, + CONCAT('n/fra ', io.ref) simpleConcept, + CONCAT('n/fra ', io.ref, ' ', c.name) Concept, + io.serial SERIE, + io.issued FECHA_EX, + io.issued FECHA_OP, + io.issued FECHA, + 1 NFACTICK, + IF(ic.correctingFk,'D','') TIPOOPE, + io.siiTrascendencyInvoiceOutFk TIPOCLAVE, + io.cplusTaxBreakFk TIPOEXENCI, + io.cplusSubjectOpFk TIPONOSUJE, + io.siiTypeInvoiceOutFk TIPOFACT, + ic.cplusRectificationTypeFk TIPORECTIF, io.companyFk, - RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum, - IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF, - CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF, - c.socialName AS TERNOM, - ior.serial AS SERIE_RT, - RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT, - ior.issued AS FECHA_RT, - IF(ior.id,TRUE,FALSE) AS RECTIFICA + RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum, + IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF, + CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF, + c.socialName TERNOM, + ior.serial SERIE_RT, + RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT, + ior.issued FECHA_RT, + IF(ior.id,TRUE,FALSE) RECTIFICA FROM invoiceOut io JOIN invoiceOutSerial ios ON ios.code = io.serial JOIN client c ON c.id = io.clientFk JOIN country ct ON ct.id = c.countryFk LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id - LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk + LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk WHERE io.id = vInvoice; - CALL vn.ledger_next(vBookNumber); - + SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; + CALL ledger_next(vFiscalYear, vBookNumber); -- Linea del cliente INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - EURODEBE, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + EURODEBE, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, rs.FECHA, - rs.clientBookingAccount AS SUBCTA, - rs.totalAmount AS EURODEBE, - rs.simpleConcept AS CONCEPTO, + rs.clientBookingAccount, + rs.totalAmount, + rs.simpleConcept, rs.FECHA_EX, rs.FECHA_OP, - rs.companyFk AS empresa_id + rs.companyFk FROM rs; -- Lineas de gasto INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - CONCEPTO, - FECHA_EX, - FECHA_OP, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, - rs.FECHA, - ioe.expenseFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - ioe.amount AS EUROHABER, - rs.Concept AS CONCEPTO, - rs.FECHA_EX, - rs.FECHA_OP, - rs.companyFk AS empresa_id - FROM rs - JOIN invoiceOutExpense ioe - WHERE ioe.invoiceOutFk = vInvoice; + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + CONCEPTO, + FECHA_EX, + FECHA_OP, + empresa_id) + SELECT vBookNumber, + rs.FECHA, + ioe.expenseFk, + rs.clientBookingAccount, + ioe.amount, + rs.Concept, + rs.FECHA_EX, + rs.FECHA_OP, + rs.companyFk + FROM rs + JOIN invoiceOutExpense ioe + WHERE ioe.invoiceOutFk = vInvoice; - SELECT GROUP_CONCAT(`name` SEPARATOR ',') - INTO vExpenseConcept - FROM expense e - JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id - WHERE ioe.invoiceOutFk = vInvoice; + SELECT GROUP_CONCAT(`name` SEPARATOR ',') + INTO vExpenseConcept + FROM expense e + JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id + WHERE ioe.invoiceOutFk = vInvoice; - -- Lineas de IVA + -- Lineas de IVA INSERT INTO XDiario( - ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - RECEQUIV, - AUXILIAR, - SERIE, - SERIE_RT, - FACTU_RT, - RECTIFICA, - FECHA_RT, - FECHA_OP, - FECHA_EX, - TIPOOPE, - NFACTICK, - TERIDNIF, - TERNIF, - TERNOM, - L340, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - empresa_id - ) - SELECT - vBookNumber AS ASIEN, + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + RECEQUIV, + AUXILIAR, + SERIE, + SERIE_RT, + FACTU_RT, + RECTIFICA, + FECHA_RT, + FECHA_OP, + FECHA_EX, + TIPOOPE, + NFACTICK, + TERIDNIF, + TERNIF, + TERNOM, + L340, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + empresa_id) + SELECT vBookNumber ASIEN, rs.FECHA, - iot.pgcFk AS SUBCTA, - rs.clientBookingAccount AS CONTRA, - iot.vat AS EUROHABER, - iot.taxableBase AS BASEEURO, - CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO, - rs.invoiceNum AS FACTURA, - IF(pe2.equFk,0,pgc.rate) AS IVA, - IF(pe2.equFk,0,pgce.rate) AS RECEQUIV, - IF(pgc.mod347,'','*') AS AUXILIAR, + iot.pgcFk SUBCTA, + rs.clientBookingAccount CONTRA, + iot.vat EUROHABER, + iot.taxableBase BASEEURO, + CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO, + rs.invoiceNum FACTURA, + IF(pe2.equFk,0,pgc.rate) IVA, + IF(pe2.equFk,0,pgce.rate) RECEQUIV, + IF(pgc.mod347,'','*') AUXILIAR, rs.SERIE, rs.SERIE_RT, rs.FACTU_RT, @@ -57895,28 +57878,28 @@ BEGIN rs.FECHA_OP, rs.FECHA_EX, rs.TIPOOPE, - rs.NFACTICK, + rs.NFACTICK, rs.TERIDNIF, rs.TERNIF, rs.TERNOM, - pgc.mod340 AS L340, - pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE, - pgc.cplusTaxBreakFk as TIPOEXENCI, + pgc.mod340 L340, + pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE, + pgc.cplusTaxBreakFk TIPOEXENCI, rs.TIPONOSUJE, rs.TIPOFACT, rs.TIPORECTIF, - rs.companyFk AS empresa_id + rs.companyFk FROM rs JOIN invoiceOutTax iot JOIN pgc ON pgc.code = iot.pgcFk LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado LEFT JOIN pgc pgce ON pgce.code = pe.equFk - LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. + LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv. WHERE iot.invoiceOutFk = vInvoice; - - UPDATE invoiceOut - SET booked = util.VN_CURDATE() - WHERE id = vInvoice; + + UPDATE invoiceOut + SET booked = util.VN_CURDATE() + WHERE id = vInvoice; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -58918,11 +58901,12 @@ BEGIN 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 - WHERE sc.id = vSectorFk - AND ish.visible > 0 + WHERE ish.visible > 0 AND ish.itemFk = vItemFk GROUP BY ish.id - ORDER BY sh.priority DESC, + ORDER BY + (sc.id = vSectorFk) DESC, + sh.priority DESC, ish.created, p.pickingOrder; END ;; @@ -59362,7 +59346,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingRadar`( vSectorFk INT ) -proc:BEGIN +BEGIN /** * Calcula la información detallada respecto un sector. * @@ -59375,37 +59359,24 @@ proc:BEGIN DECLARE vWarehouseFk INT DEFAULT 0; DECLARE vSonSectorFk INT; DECLARE vWorkerFk INT; - - SELECT s.workerFk - INTO vWorkerFk - FROM vn.sector s + + SELECT s.workerFk INTO vWorkerFk + FROM sector s WHERE s.id = vSectorFk; - SELECT w.id, s.warehouseFk INTO vBuyerFk, vWarehouseFk - FROM vn.worker w - JOIN vn.sector s ON s.code = w.code - WHERE s.id = vSectorFk; - - SELECT s.id INTO vSectorFk - FROM vn.sector s - WHERE s.warehouseFk = vWarehouseFk - AND s.isMain; - SELECT COUNT(*) INTO hasFatherSector - FROM vn.sector + FROM sector WHERE sonFk = vSectorFk; - + SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk - FROM vn.sector + FROM sector WHERE id = vSectorFk; - + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - + IF hasFatherSector THEN - CREATE TEMPORARY TABLE tmp.itemShelvingRadar + CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT * @@ -59414,57 +59385,77 @@ proc:BEGIN i.longName, i.size, i.subName producer, - IFNULL(a.available,0) available, - SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible,0), 0)) upstairs, - SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible,0), 0)) downstairs, - IF(it.isPackaging, NULL, IFNULL(v.visible,0)) as visible, - vSectorFk sectorFk - FROM vn.itemShelvingStock iss - JOIN vn.sector s ON s.id = iss.sectorFk - JOIN vn.item i on i.id = iss.itemFk - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk + IFNULL(a.available, 0) available, + SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible, 0), 0)) upstairs, + SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible, 0), 0)) downstairs, + IF(it.isPackaging, NULL, IFNULL(v.visible, 0)) visible, + vSectorFk sectorFk, + ish.isChecked, + sub.isAllChecked + FROM itemShelvingStock iss + JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk + LEFT JOIN ( + SELECT itemFk, + IF( + COUNT(*) = SUM(IF(isChecked >= 0, 1, 0)), + TRUE, + FALSE + ) isAllChecked + FROM itemShelving is2 + GROUP BY itemFk + ) sub ON sub.itemFk = ish.itemFk + JOIN sector s ON s.id = iss.sectorFk + JOIN item i ON i.id = iss.itemFk + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN cache.available a ON a.item_id = iss.itemFk + AND a.calc_id = vCalcAvailableFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk + AND v.calc_id = vCalcVisibleFk WHERE vSectorFk IN (iss.sectorFk, s.sonFk) GROUP BY iss.itemFk - UNION ALL - - SELECT v.item_id, + SELECT v.item_id, i.longName, i.size, - i.subName producer, - IFNULL(a.available,0) as available, - 0 upstairs, - 0 downstairs, - IF(it.isPackaging, NULL, v.visible) visible, - vSectorFk as sectorFk + i.subName, + IFNULL(a.available, 0), + 0, + 0, + IF(it.isPackaging, NULL, v.visible), + vSectorFk, + NULL, + NULL FROM cache.visible v - JOIN vn.item i on i.id = v.item_id - JOIN vn.itemType it ON it.id = i.typeFk AND vBuyerFk IN (0,it.workerFk) - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouseFk - LEFT JOIN cache.available a ON a.item_id = v.item_id AND a.calc_id = vCalcAvailableFk + JOIN item i ON i.id = v.item_id + JOIN itemType it ON it.id = i.typeFk + LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id + AND iss.warehouseFk = vWarehouseFk + LEFT JOIN cache.available a ON a.item_id = v.item_id + AND a.calc_id = vCalcAvailableFk WHERE v.calc_id = vCalcVisibleFk AND iss.itemFk IS NULL AND it.isInventory - ) sub GROUP BY itemFk; + ) sub + GROUP BY itemFk; SELECT ishr.*, - CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) AS nicho, - CAST(downstairs - IFNULL(notPickedYed,0) AS DECIMAL(10,0)) as pendiente - FROM tmp.itemShelvingRadar ishr - JOIN vn.item i ON i.id = ishr.itemFk - LEFT JOIN (SELECT s.itemFk, sum(s.quantity) as notPickedYed - FROM vn.ticket t - JOIN vn.ticketStateToday tst ON tst.ticketFk = t.id - JOIN vn.sale s ON s.ticketFk = t.id - WHERE t.warehouseFk = vWarehouseFk - AND tst.alertLevel = 0 - GROUP BY s.itemFk - ) sub ON sub.itemFk = ishr.itemFk - ORDER BY i.typeFk, i.longName; + CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho, + CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente + FROM tItemShelvingRadar ishr + JOIN item i ON i.id = ishr.itemFk + LEFT JOIN ( + SELECT s.itemFk, SUM(s.quantity) notPickedYed + FROM ticket t + JOIN ticketStateToday tst ON tst.ticketFk = t.id + JOIN alertLevel al ON al.id = tst.alertLevel + JOIN sale s ON s.ticketFk = t.id + WHERE t.warehouseFk = vWarehouseFk + AND al.code = 'FREE' + GROUP BY s.itemFk + ) sub ON sub.itemFk = ishr.itemFk + ORDER BY i.typeFk, i.longName; ELSE - CREATE TEMPORARY TABLE tmp.itemShelvingRadar + CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT iss.itemFk, @@ -59475,80 +59466,86 @@ proc:BEGIN i.size, i.subName producer, i.upToDown, - IFNULL(a.available,0) available, - IFNULL(v.visible - iss.visible,0) dayEndVisible, - IFNULL(v.visible - iss.visible,0) firstNegative, - IFNULL(v.visible - iss.visible,0) itemPlacementVisible, - IFNULL(i.minimum * b.packing,0) itemPlacementSize, + IFNULL(a.available, 0) available, + IFNULL(v.visible - iss.visible, 0) dayEndVisible, + IFNULL(v.visible - iss.visible, 0) firstNegative, + IFNULL(v.visible - iss.visible, 0) itemPlacementVisible, + IFNULL(i.minimum * b.packing, 0) itemPlacementSize, ips.onTheWay, iss.visible itemShelvingStock, - IFNULL(v.visible,0) visible, + IFNULL(v.visible, 0) visible, b.isPickedOff, iss.sectorFk - FROM vn.itemShelvingStock iss - JOIN vn.item i on i.id = iss.itemFk - LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN cache.available a ON a.item_id = iss.itemFk AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk AND v.calc_id = vCalcVisibleFk - LEFT JOIN (SELECT itemFk, sum(saldo) as onTheWay - FROM vn.itemPlacementSupplyList - WHERE saldo > 0 - GROUP BY itemFk - ) ips ON ips.itemFk = i.id - WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) - OR iss.sectorFk = vSectorFk; + FROM itemShelvingStock iss + JOIN item i ON i.id = iss.itemFk + LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk + AND lb.warehouse_id = vWarehouseFk + LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN cache.available a ON a.item_id = iss.itemFk + AND a.calc_id = vCalcAvailableFk + LEFT JOIN cache.visible v ON v.item_id = iss.itemFk + AND v.calc_id = vCalcVisibleFk + LEFT JOIN ( + SELECT itemFk, SUM(saldo) onTheWay + FROM itemPlacementSupplyList + WHERE saldo > 0 + GROUP BY itemFk + ) ips ON ips.itemFk = i.id + WHERE iss.sectorFk = vSectorFk + OR iss.sectorFk IS NULL; - DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; - CREATE TEMPORARY TABLE tmp.itemOutTime - SELECT *,SUM(amount) quantity - FROM - (SELECT io.itemFk, - io.quantity amount, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) as hours, - IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) as minutes - FROM itemTicketOut io - JOIN tmp.itemShelvingRadar isr ON isr.itemFk = io.itemFk - JOIN vn.ticket t on t.id= io.ticketFk - JOIN vn.ticketState ts on ts.ticketFk = io.ticketFk - JOIN vn.state s ON s.id = ts.stateFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM vn.saleTracking st - WHERE st.created > util.VN_CURDATE() - AND st.isChecked - ) stPrevious ON `stPrevious`.`saleFk` = io.saleFk - WHERE t.warehouseFk = vWarehouseFk - AND s.isPicked = 0 - AND NOT io.reserved - AND stPrevious.saleFk IS NULL - AND io.shipped >= util.VN_CURDATE() - AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY - ) sub - GROUP BY itemFk, hours, minutes; + CREATE OR REPLACE TEMPORARY TABLE tmp.itemOutTime + SELECT *, SUM(amount) quantity + FROM ( + SELECT io.itemFk, + io.quantity amount, + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`, + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes` + FROM itemTicketOut `io` + JOIN tItemShelvingRadar isr ON isr.itemFk = io.itemFk + JOIN ticket t ON t.id= io.ticketFk + JOIN ticketState ts ON ts.ticketFk = io.ticketFk + JOIN `state` s ON s.id = ts.stateFk + LEFT JOIN `zone` z ON z.id = t.zoneFk + LEFT JOIN ( + SELECT DISTINCT saleFk + FROM saleTracking st + WHERE st.created > util.VN_CURDATE() + AND st.isChecked + ) stPrevious ON stPrevious.saleFk = io.saleFk + WHERE t.warehouseFk = vWarehouseFk + AND NOT s.isPicked + AND NOT io.reserved + AND stPrevious.saleFk IS NULL + AND io.shipped >= util.VN_CURDATE() + AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY + ) sub + GROUP BY itemFk, `hours`, `minutes`; - INSERT INTO tmp.itemShelvingRadar (itemFk) + INSERT INTO tItemShelvingRadar (itemFk) SELECT itemFk FROM tmp.itemOutTime - ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, - firstNegative = if (firstNegative < 0, firstNegative, firstNegative + quantity), - `hour` = ifnull(if (firstNegative > 0 , `hour`, hours),0), - `minute` = ifnull(if (firstNegative > 0, `minute`, minutes),0); + ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, + firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity), + `hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0), + `minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0); - UPDATE tmp.itemShelvingRadar isr - JOIN (SELECT s.itemFk, sum(s.quantity) amount - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN ticketLastState tls ON tls.ticketFk = t.id - WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND tls.name = 'Prep Camara' - GROUP BY s.itemFk) sub ON sub.itemFk = isr.itemFk + UPDATE tItemShelvingRadar isr + JOIN ( + SELECT s.itemFk, SUM(s.quantity) amount + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketState ts ON ts.ticketFk = t.id + WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) + AND ts.code = 'COOLER_PREPARATION' + GROUP BY s.itemFk + ) sub ON sub.itemFk = isr.itemFk SET isr.dayEndVisible = dayEndVisible + sub.amount, firstNegative = firstNegative + sub.amount; - SELECT * FROM tmp.itemShelvingRadar; + SELECT * FROM tItemShelvingRadar; END IF; - DROP TEMPORARY TABLE tmp.itemShelvingRadar; + DROP TEMPORARY TABLE tItemShelvingRadar; END ;; DELIMITER ; @@ -60470,6 +60467,74 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getItemDetails` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_getItemDetails`( + vBarcodeItem INT, + vShelvingFK VARCHAR(10) +) +BEGIN +/** + * Obtiene el precio y visible de un item + * + * @param vBarcodeItem barcode de artículo + * @param vShelvingFK Ubicación actual del artículo + */ + DECLARE vIsItem BOOL; + DECLARE vBuyFk INT; + DECLARE vWarehouseFk INT; + + SELECT COUNT(*) > 0 INTO vIsItem + FROM item + WHERE id = vBarcodeItem; + + IF vIsItem THEN + SELECT warehouseFk INTO vWarehouseFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + + SELECT buyFk INTO vBuyFk + FROM tmp.buyUltimate + WHERE itemFk = vBarcodeItem + AND warehouseFk = vWarehouseFk; + + DELETE FROM tmp.buyUltimate; + ELSE + SELECT vBarcodeItem INTO vBuyFk; + END IF; + + WITH visible AS( + SELECT itemFk, + IFNULL(buyingValue, 0) + + IFNULL(freightValue, 0) + + IFNULL(comissionValue, 0) + + IFNULL(packageValue, 0) itemCost + FROM vn.buy b + WHERE b.id = vBuyFk + ) SELECT v.itemFk, + vShelvingFK, + v.itemCost, + SUM(ish.visible) visible + FROM vn.itemShelving ish + JOIN visible v + WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci + AND ish.itemFk = v.itemFk; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelving_getSaleDate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61131,75 +61196,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemTrash` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, - vIsTrash BOOLEAN) -BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; - DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - - SELECT t.id INTO vTicketFk - FROM ticket t - JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk - AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; - - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - util.VN_CURDATE(), - account.myUser_getId(), - FALSE, - vTicketFk); - END IF; - - INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, - vItemFk, - CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), - vQuantity - FROM item - WHERE id = vItemFk; - - UPDATE cache.visible - SET visible = visible - vQuantity - WHERE calc_id = vCalc - AND item_id = vItemFk; -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_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemUpdateTag` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61821,6 +61817,427 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_devalueA2` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_devalueA2`( + vSelf INT, + vShelvingFK VARCHAR(10), + vBuyingValue DECIMAL(10,4), + vQuantity INT +) +BEGIN +/** + * Devalua un item modificando su calidad de A1 a A2. + * Si no existe el item A2 lo crea y genera los movimientos de las entradas + * de almacén y shelvings correspondientes + * + * @param vSelf Id de artículo a devaluar + * @param vShelvingFK Ubicación actual del artículo + * @param vBuyingValue Nuevo precio de coste + * @param vQuantity Cantidad del ítem a pasar a A2 + */ + DECLARE vItemA2Fk INT; + DECLARE vLastBuyFk BIGINT; + DECLARE vA1BuyFk INT; + DECLARE vA2BuyFk INT; + DECLARE vTargetEntryFk INT; + DECLARE vTargetEntryDate DATE; + DECLARE vTargetItemShelvingFk BIGINT; + DECLARE vWarehouseFk INT; + DECLARE vCacheFk INT; + DECLARE vLastEntryFk INT; + DECLARE vCurrentVisible INT; + DECLARE vDevalueTravelFk INT; + DECLARE vCurdate DATE; + DECLARE vBuyingValueOriginal DECIMAL(10,4); + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT TRUE FROM item WHERE id = vSelf AND (category <> 'A1' OR category IS NULL)) THEN + CALL util.throw('Item has not category A1'); + END IF; + + SELECT warehouseFk INTO vWarehouseFk + FROM userConfig + WHERE userFk = account.myUser_getId(); + + IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN + CALL util.throw ('Operator has not a valid warehouse'); + END IF; + + IF vQuantity <= 0 OR vQuantity IS NULL THEN + CALL util.throw ('The quantity is incorrect'); + END IF; + + SELECT util.VN_CURDATE() INTO vCurdate; + + SELECT t.id INTO vDevalueTravelFk + FROM travel t + JOIN travelConfig tc + WHERE t.shipped = vCurdate + AND t.landed = vCurdate + AND t.warehouseInFk = vWarehouseFk + AND t.warehouseOutFk = tc.devalueWarehouseOutFk + AND t.agencyModeFk = tc.devalueAgencyModeFk + LIMIT 1; + + IF NOT vDevalueTravelFk OR vDevalueTravelFk IS NULL THEN + INSERT INTO travel ( + shipped, + landed, + warehouseInFk, + warehouseOutFk, + `ref`, + isReceived, + agencyModeFk) + SELECT vCurdate, + vCurdate, + vWarehouseFk, + tc.devalueWarehouseOutFk, + tc.devalueRef, + TRUE, + tc.devalueAgencyModeFk + FROM travelConfig tc; + SET vDevalueTravelFk = LAST_INSERT_ID(); + END IF; + + SELECT id, DATE(dated) INTO vTargetEntryFk, vTargetEntryDate + FROM `entry` e + WHERE DATE(dated) = vCurdate + AND typeFk = 'devaluation' + AND travelFk = vDevalueTravelFk + ORDER BY created DESC + LIMIT 1; + + CALL buyUltimate(vWarehouseFk, vCurdate); + + SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal + FROM tmp.buyUltimate bu + JOIN vn.buy b ON b.id = bu.buyFk + WHERE bu.itemFk = vSelf + AND bu.warehouseFk = vWarehouseFk; + + IF vBuyingValue > vBuyingValueOriginal THEN + CALL util.throw ('Price not valid'); + END IF; + + IF vLastEntryFk IS NULL OR vLastBuyFk IS NULL THEN + CALL util.throw ('The item has not a buy'); + END IF; + + SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible + FROM itemShelving + WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + AND itemFk = vSelf + LIMIT 1; + + IF vCurrentVisible IS NULL THEN + CALL util.throw ('The shelving has not a visible for this item'); + END IF; + + IF vQuantity > vCurrentVisible THEN + CALL util.throw('Quantity is greater than visible'); + END IF; + + START TRANSACTION; + + IF NOT vTargetEntryFk OR vTargetEntryFk IS NULL + OR NOT vTargetEntryDate <=> vCurdate THEN + INSERT INTO entry( + travelFk, + supplierFk, + dated, + commission, + currencyFk, + companyFk, + clonedFrom, + typeFk + ) + SELECT vDevalueTravelFk, + supplierFk, + vCurdate, + commission, + currencyFk, + companyFk, + vLastEntryFk, + 'devaluation' + FROM entry + WHERE id = vLastEntryFk; + + SET vTargetEntryFk = LAST_INSERT_ID(); + END IF; + + SELECT i.id INTO vItemA2Fk + FROM item i + JOIN ( + SELECT i.id, + i.name, + i.subname, + i.value5, + i.value6, + i.value7, + i.value8, + i.value9, + i.value10, + i.NumberOfItemsPerCask, + i.EmbalageCode, + i.quality + FROM item i + WHERE i.id = vSelf + )i2 ON i2.name <=> i.name + AND i2.subname <=> i.subname + AND i2.value5 <=> i.value5 + AND i2.value6 <=> i.value6 + AND i2.value8 <=> i.value8 + AND i2.value9 <=> i.value9 + AND i2.value10 <=> i.value10 + AND i2.NumberOfItemsPerCask <=> i.NumberOfItemsPerCask + AND i2.EmbalageCode <=> i.EmbalageCode + AND i2.quality <=> i.quality + WHERE i.id <> i2.id + AND i.category = 'A2' + LIMIT 1; + + IF vItemA2Fk IS NULL THEN + INSERT INTO item ( + equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + category, + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic) + SELECT equivalent, + name, + `size`, + stems, + minPrice, + isToPrint, + family, + box, + 'A2', + originFk, + doPhoto, + image, + inkFk, + intrastatFk, + hasMinPrice, + created, + comment, + typeFk, + generic, + producerFk, + description, + density, + relevancy, + expenseFk, + isActive, + longName, + subName, + minimum, + upToDown, + supplyResponseFk, + hasKgPrice, + isFloramondo, + isFragile, + numberOfItemsPerCask, + embalageCode, + quality, + stemMultiplier, + itemPackingTypeFk, + packingOut, + genericFk, + isLaid, + lastUsed, + weightByPiece, + editorFk, + recycledPlastic, + nonRecycledPlastic + FROM item + WHERE id = vSelf; + + SET vItemA2Fk = LAST_INSERT_ID(); + + INSERT INTO itemTag (itemFk, tagFk, `value`, intValue, priority, editorFk) + SELECT vItemA2Fk, tagFk, `value`, intValue, priority, editorFk + FROM itemTag + WHERE id = vSelf; + + UPDATE itemTaxCountry itc + JOIN itemTaxCountry itc2 ON itc2.itemFk = vSelf + AND itc2.countryFk = itc.countryFk + SET itc2.taxClassFk = itc.taxClassFk + WHERE itc.id = vItemA2Fk; + + INSERT INTO itemBotanical (itemFk, genusFk, specieFk) + SELECT vItemA2Fk, genusFk, specieFk + FROM itemBotanical + WHERE itemFk = vSelf; + END IF; + + IF vQuantity = vCurrentVisible THEN + DELETE FROM itemShelving + WHERE id = vTargetItemShelvingFk; + ELSE + UPDATE itemShelving + SET visible = vCurrentVisible - vQuantity + WHERE id = vTargetItemShelvingFk; + END IF; + + INSERT INTO buy( + entryFk, + itemFk, + quantity, + buyingValue, + freightValue, + isIgnored, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk) + SELECT vTargetEntryFk, + itemFk, + - LEAST(vQuantity, vCurrentVisible), + buyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk + UNION + SELECT vTargetEntryFk, + vItemA2Fk, + vQuantity, + vBuyingValue, + freightValue, + TRUE, + stickers, + packagingFk, + packing, + `grouping`, + groupingMode, + comissionValue, + packageValue, + price1, + price2, + price3, + minPrice, + isChecked, + location, + weight, + itemOriginalFk + FROM vn.buy + WHERE id = vLastBuyFk; + + INSERT IGNORE INTO itemShelving ( + itemFk, + shelvingFk, + visible, + `grouping`, + packing, + packagingFk, + userFk, + isChecked) + SELECT vItemA2Fk, + shelvingFk, + vQuantity , + `grouping`, + packing, + packagingFk, + account.myUser_getId(), + isChecked + FROM itemShelving + WHERE itemFK = vSelf + AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci + ON DUPLICATE KEY UPDATE + visible = vQuantity + VALUES(visible); + + COMMIT; + CALL cache.visible_refresh(vCacheFk, TRUE, vWarehouseFk); + CALL cache.available_refresh(vCacheFk, TRUE, vWarehouseFk, vCurdate); + CALL buy_recalcPricesByBuy(vA2BuyFk); +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_getAtp` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61900,7 +62317,7 @@ BEGIN * @vItemFk item a buscar * @vWarehouseFk almacen donde buscar * @vDate Si la fecha es null, muestra el histórico desde el inventario. - * Si la fecha no es null, muestra histórico desde la fecha pasada. + * Si la fecha no es null, muestra histórico desde la fecha de vDate. */ DECLARE vDateInventory DATETIME; @@ -61931,117 +62348,154 @@ BEGIN inventorySupplierFk INT(10) ); - INSERT INTO tItemDiary - SELECT tr.landed shipped, - b.quantity `in`, - NULL `out`, - st.alertLevel , - st.name stateName, - s.name `name`, - e.invoiceNumber reference, - e.id origin, - s.id clientFk, - IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, - FALSE isTicket, - b.id lineFk, - NULL `order`, - NULL clientType, - NULL claimFk, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() - OR (util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.landed >= vDateInventory - AND vWarehouseFk = tr.warehouseInFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT tr.shipped, - NULL, - b.quantity, - st.alertLevel, - st.name, - s.name, - e.invoiceNumber, - e.id, - s.id, - IF(st.`code` = 'DELIVERED' , TRUE, FALSE), - FALSE, - b.id, - NULL, - NULL, - NULL, - ec.inventorySupplierFk - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel tr ON tr.id = e.travelFk - JOIN warehouse w ON w.id = tr.warehouseOutFk - JOIN supplier s ON s.id = e.supplierFk - JOIN state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() + INSERT INTO tItemDiary + WITH entriesIn AS ( + SELECT tr.landed shipped, + b.quantity `in`, + NULL `out`, + st.alertLevel , + st.name stateName, + s.name `name`, + e.invoiceNumber reference, + e.id origin, + s.id clientFk, + IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, + FALSE isTicket, + b.id lineFk, + NULL `order`, + NULL clientType, + NULL claimFk, + ec.inventorySupplierFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() + OR (util.VN_CURDATE() AND tr.isReceived), + 'DELIVERED', + 'FREE') + JOIN vn.entryConfig ec + WHERE tr.landed >= vDateInventory + AND vWarehouseFk = tr.warehouseInFk + AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT e.isRaid + ), entriesOut AS ( + SELECT tr.shipped, + NULL, + b.quantity, + st.alertLevel, + st.name stateName, + s.name , + e.invoiceNumber, + e.id entryFk, + s.id supplierFk, + IF(st.`code` = 'DELIVERED' , TRUE, FALSE), + FALSE isTicket, + b.id, + NULL `order`, + NULL clientType, + NULL claimFk, + ec.inventorySupplierFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel tr ON tr.id = e.travelFk + JOIN vn.warehouse w ON w.id = tr.warehouseOutFk + JOIN vn.supplier s ON s.id = e.supplierFk + JOIN vn.state st ON st.`code` = IF(tr.shipped < util.VN_CURDATE() OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), - 'DELIVERED', - 'FREE') - JOIN entryConfig ec - WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) - AND b.itemFk = vItemFk - AND e.isExcludedFromAvailable = FALSE - AND w.isFeedStock = FALSE - AND e.isRaid = FALSE - UNION ALL - SELECT DATE(t.shipped), - NULL, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id, - t.clientFk, - stk.id, - TRUE, - s.id, - st.`order`, - c.typeFk, - cb.claimFk, - NULL - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.`code` = ts.`code` - JOIN client c ON c.id = t.clientFk - JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED' - LEFT JOIN saleTracking stk ON stk.saleFk = s.id - AND stk.stateFk = stPrep.id - LEFT JOIN claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk =t.warehouseFk - ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, - alertLevel DESC, - isTicket, - `order` DESC, - isPicked DESC, - `in` DESC, - `out` DESC; + 'DELIVERED', + 'FREE') + JOIN vn.entryConfig ec + WHERE tr.shipped >= vDateInventory + AND vWarehouseFk = tr.warehouseOutFk + AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND b.itemFk = vItemFk + AND NOT e.isExcludedFromAvailable + AND NOT w.isFeedStock + AND NOT e.isRaid + ), sales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.nickname, + t.refFk, + t.id ticketFk, + t.clientFk, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + LEFT JOIN vn.state st ON st.`code` = ts.`code` + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(ts.code, 'FREE'))) + LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND vWarehouseFk = t.warehouseFk + ),sale AS ( + SELECT s.shipped, + NULL `in`, + s.quantity, + s.alertLevel, + s.name, + s.nickname, + s.refFk, + s.ticketFk, + s.clientFk, + IF(stk.saleFk, TRUE, NULL), + TRUE, + s.saleFk, + s.`order`, + s.typeFk, + s.claimFk, + NULL + FROM sales s + LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' + LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk + AND stk.stateFk = stPrep.id + GROUP BY s.saleFk + ) SELECT shipped, + `in`, + `out`, + alertLevel, + stateName, + `name`, + reference, + origin, + clientFk, + isPicked, + isTicket, + lineFk, + `order`, + clientType, + claimFk, + inventorySupplierFk + FROM entriesIn + UNION ALL + SELECT * FROM entriesOut + UNION ALL + SELECT * FROM sale + ORDER BY shipped, + (inventorySupplierFk = clientFk) DESC, + alertLevel DESC, + isTicket, + `order` DESC, + isPicked DESC, + `in` DESC, + `out` DESC; IF vDate IS NULL THEN - + SET @a := 0; SET @currentLineFk := 0; SET @shipped := ''; @@ -62111,7 +62565,7 @@ BEGIN FROM tItemDiary WHERE shipped >= vDate; END IF; - + DROP TEMPORARY TABLE tItemDiary; END ;; DELIMITER ; @@ -62435,6 +62889,9 @@ BEGIN CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); + -- Añadido temporalmente para que no se cuelgue la db + SET vShowType = TRUE; + WITH itemTags AS ( SELECT i.id, typeFk, @@ -63390,7 +63847,15 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_doCompensation`( + vDated DATE, + vCompensationAccount VARCHAR(10), + vBankFk VARCHAR(10), + vConcept VARCHAR(255), + vAmount DECIMAL(10,2), + vCompanyFk INT, + vOriginalAccount VARCHAR(10) +) BEGIN /** * Compensa un pago o un recibo insertando en contabilidad @@ -63400,29 +63865,31 @@ BEGIN * @param vBankFk banco de la compensacion * @param vConcept descripcion * @param vAmount cantidad que se compensa - * @param vCompany empresa + * @param vCompanyFk empresa * @param vOriginalAccount cuenta contable desde la cual se compensa * - */ + */ DECLARE vNewBookEntry INT; - DECLARE vIsClientCompensation INT; + DECLARE vIsClientCompensation INT; DECLARE vClientFk INT; - DECLARE vSupplierFk INT; - DECLARE vIsOriginalAClient BOOL; - DECLARE vPayMethodCompensation INT; - - CALL ledger_next(vNewBookEntry); + DECLARE vSupplierFk INT; + DECLARE vIsOriginalAClient BOOL; + DECLARE vPayMethodCompensation INT; - SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; + CALL ledger_next(YEAR(vDated), vNewBookEntry); + + SELECT COUNT(id) INTO vIsOriginalAClient + FROM client + WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci; SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation FROM client WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci; - + SET @vAmount1:= 0.0; SET @vAmount2:= 0.0; - INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) + INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id) VALUES ( vNewBookEntry, vDated, vOriginalAccount, @@ -63440,31 +63907,52 @@ BEGIN ), vCompanyFk ), - ( vNewBookEntry, - vDated, - vCompensationAccount, - vOriginalAccount, - vConcept, - @vAmount2, + ( vNewBookEntry, + vDated, + vCompensationAccount, + vOriginalAccount, + vConcept, + @vAmount2, @vAmount1, - vCompanyFk); - - IF vIsClientCompensation THEN - IF vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate) - VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE); - ELSE - IF NOT vIsOriginalAClient THEN - SET vAmount = -vAmount; - END IF; - SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; - SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation'; - - INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated) - VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE); - END IF; + vCompanyFk); + + IF vIsClientCompensation THEN + IF vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + INSERT INTO receipt + SET invoiceFk = vConcept, + amountPaid = vAmount, + payed = vDated, + bankFk = vBankFk, + companyFk = vCompanyFk, + clientFk = vClientFk, + isConciliate = TRUE; + ELSE + IF NOT vIsOriginalAClient THEN + SET vAmount = -vAmount; + END IF; + + SELECT id INTO vSupplierFk + FROM supplier + WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci; + + SELECT id INTO vPayMethodCompensation + FROM payMethod + WHERE `code` = 'compensation'; + + INSERT INTO payment + SET received = vDated, + dueDated = vDated, + supplierFk = vSupplierFk, + amount = vAmount, + bankFk = vBankFk, + payMethodFk = vPayMethodCompensation, + concept = vConcept, + companyFk = vCompanyFk, + isConciliated = TRUE; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63481,12 +63969,58 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`(OUT vNewBookEntry INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ledger_next`( + IN vFiscalYear INT, + OUT vLastBookEntry INT +) BEGIN - - UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1); - SET vNewBookEntry = LAST_INSERT_ID(); - + DECLARE vHasStartTransaction BOOLEAN; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + + IF vHasStartTransaction THEN + ROLLBACK TO sp; + RESIGNAL; + ELSE + ROLLBACK; + CALL util.throw ('It has not been possible to generate a new ledger'); + END IF; + END; + + IF vFiscalYear IS NULL THEN + CALL util.throw('Fiscal year is required'); + END IF; + + SELECT @@in_transaction INTO vHasStartTransaction; + + IF NOT vHasStartTransaction THEN + START TRANSACTION; + ELSE + SAVEPOINT sp; + END IF; + + SELECT bookEntry + 1 INTO vLastBookEntry + FROM ledgerCompany + WHERE fiscalYear = vFiscalYear + FOR UPDATE; + + IF vLastBookEntry IS NULL THEN + INSERT INTO ledgerCompany + SET fiscalYear = vFiscalYear, + bookEntry = 1; + SET vLastBookEntry = 1; + END IF; + + UPDATE ledgerCompany + SET bookEntry = vLastBookEntry + WHERE fiscalYear = vFiscalYear; + + IF vHasStartTransaction THEN + RELEASE SAVEPOINT sp; + ELSE + COMMIT; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64447,140 +64981,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `packageInvoicing` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `packageInvoicing`( - IN vClient INT, - IN vDate DATE, - IN vCompany INT, - IN vIsAllInvoiceable BOOLEAN, - OUT vNewTicket INT(11) - ) -BEGIN - - DECLARE vGraceDays INT; - DECLARE vDateStart DATE DEFAULT '2017-11-21'; - DECLARE vIsInvoiceable BOOLEAN; - DECLARE vWarehouse INT DEFAULT 13; - DECLARE vComponentCost INT DEFAULT 28; - DECLARE vGraceDate DATE; - DECLARE vDateEnd DATE; - - SET vGraceDays = IF(vIsAllInvoiceable ,0, 30); - SET vGraceDate = TIMESTAMPADD(DAY, - vGraceDays, vDate); - - /* Clientes especiales: - 3240 MADEFLOR - 992 JAVIER FELIU - 4 TONI VENDRELL - */ - - IF vClient IN (992, 3240, 4) THEN - - SET vGraceDays = 365; - - END IF; - /* Fin clientes especiales */ - - SET vDateEnd = DATE_ADD(vDate, INTERVAL 1 DAY); - - DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoice; - - CREATE TEMPORARY TABLE tmp.packageToInvoice - SELECT p.itemFk, - tp.packagingFk, - IF(tp.quantity < 0 OR t.shipped < vGraceDate, tp.quantity, 0) quantity, - tp.ticketFk, - p.price - FROM ticketPackaging tp - JOIN packaging p ON p.id = tp.packagingFk - JOIN ticket t ON t.id = tp.ticketFk - WHERE t.shipped BETWEEN vDateStart AND vDateEnd - AND t.clientFk = vClient; - - DROP TEMPORARY TABLE IF EXISTS tmp.packageToInvoicePositives; - - CREATE TEMPORARY TABLE tmp.packageToInvoicePositives - SELECT itemFk, sum(quantity) as totalQuantity - FROM tmp.packageToInvoice - GROUP BY itemFk - HAVING totalQuantity > 0; - - SELECT COUNT(*) - INTO vIsInvoiceable - FROM tmp.packageToInvoicePositives; - - IF vIsInvoiceable THEN - - CALL ticket_add(vClient, - vDateEnd, - vWarehouse, - vCompany, - NULL, - NULL, - NULL, - vDateEnd, - account.myUser_getId(), - TRUE, - vNewTicket); - - INSERT INTO ticketPackaging( - ticketFk, - packagingFk, - quantity, - pvp) - SELECT vNewTicket, - pti.packagingFk, - - SUM(pti.quantity) AS totalQuantity, - pti.price - FROM tmp.packageToInvoice pti - LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL - OR vIsAllInvoiceable - GROUP BY packagingFk - HAVING totalQuantity; - - INSERT INTO sale( - ticketFk, - itemFk, - concept, - quantity, - price - ) - SELECT vNewTicket, - pti.itemFk, - i.name as concept, - sum(pti.quantity) as totalQuantity, - pti.price - FROM tmp.packageToInvoice pti - JOIN item i ON i.id = pti.itemFk - LEFT JOIN tmp.packageToInvoicePositives ptip ON pti.itemFk = ptip.itemFk - WHERE ptip.itemFK IS NOT NULL - OR vIsAllInvoiceable - GROUP BY pti.itemFk - HAVING totalQuantity; - - INSERT INTO saleComponent(saleFk, componentFk, value) - SELECT id, vComponentCost, price - FROM sale - WHERE ticketFk = vNewTicket; - - 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_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `packingListSwitch` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66156,7 +66556,7 @@ BEGIN CONCAT(tc.collectionFk, ' ', LEFT(cc.code, 4)) color, CONCAT(tc.collectionFk, ' ', SUBSTRING('ABCDEFGH',tc.wagon, 1), '-', tc.level) levelV, tc.ticketFk, - LEFT(COALESCE(et.description, zo.name, am.name),12) agencyDescription, + LEFT(COALESCE(rs.description, zo.name, am.name),12) agencyDescription, am.name, t.clientFk, CONCAT(CAST(SUM(sv.volume) AS DECIMAL(5, 2)), 'm³') m3 , @@ -66183,7 +66583,7 @@ BEGIN LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN expeditionTruck et ON et.id = rm.expeditionTruckFk + LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.code; @@ -66485,8 +66885,8 @@ BEGIN SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.expeditionTruck et ON et.id = rm.expeditionTruckFk - SET rm.etd = et.eta; + JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + SET rm.etd = rs.eta; DROP TEMPORARY TABLE tmp.routesMonitor; END ;; @@ -67971,7 +68371,7 @@ BEGIN ticketFk INT(11), saleFk INT(11), isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,2) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, hasHighRisk TINYINT(1) DEFAULT 0, hasTicketRequest INTEGER(1) DEFAULT 0, itemShortage VARCHAR(255), @@ -67981,6 +68381,7 @@ BEGIN hasComponentLack INTEGER(1), hasRounding VARCHAR(255), isTooLittle BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; @@ -68016,6 +68417,14 @@ BEGIN JOIN volumeConfig vc WHERE sub.litros < vc.minTicketVolume AND sub.totalWithoutVat < vc.minTicketValue; + + -- VIP + INSERT INTO tmp.sale_problems(ticketFk, isVip) + SELECT DISTINCT tl.ticketFk, TRUE + FROM tmp.ticket_list tl + JOIN client c ON c.id = tl.clientFk + WHERE c.businessTypeFk = 'VIP' + ON DUPLICATE KEY UPDATE isVip = TRUE; -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) @@ -68587,6 +68996,160 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblem` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setProblem`( + vProblemCode VARCHAR(25) +) +BEGIN +/** + * Update column sale.problem with a problem code + * @param vProblemCode Code to set or unset + * @table tmp.sale(saleFk, hasProblem) + */ + UPDATE sale s + JOIN tmp.sale ts ON ts.saleFk = s.id + SET s.problem = CONCAT( + IF(ts.hasProblem, + CONCAT(s.problem, ',', vProblemCode), + REPLACE(s.problem, vProblemCode , ''))); +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblemComponentLack` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setProblemComponentLack`( + vSelf INT +) +BEGIN +/** + * Update the problems for sales lines that have or no longer have problems with components, + * verify whether all mandatory components are present or not + * + * @param vSelf Id del sale + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk)) + ENGINE = MEMORY + SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem; + + CALL sale_setProblem('hasComponentLack'); + + DROP TEMPORARY TABLE tmp.sale; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblemComponentLackByComponent` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setProblemComponentLackByComponent`( + vComponentFk INT +) +BEGIN +/** + * Update the issues for sales lines that have or no longer have problems with components, verify + * whether all mandatory components are present or not resulting from changes in the table vn.component + * + * @param vComponentFk Id component + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk)) + ENGINE = MEMORY + SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem + FROM ( + SELECT s.id saleFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE t.shipped >= util.midnight() + AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) + GROUP BY s.id) sub; + + CALL sale_setProblem('hasComponentLack'); + + DROP TEMPORARY TABLE tmp.sale; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `sale_setProblemRounding` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setProblemRounding`( + vSelf INT +) +BEGIN +/** + * Update the rounding problem for a sales line + * @param vSelf Id sale + */ + DECLARE vItemFk INT; + DECLARE vWarehouseFk INT; + DECLARE vShipped DATE; + DECLARE vQuantity INT; + + SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity + INTO vItemFk, vWarehouseFk, vShipped, vQuantity + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + WHERE s.id = vSelf; + + CALL buyUltimate(vWarehouseFk, vShipped); + + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem + FROM tmp.buyUltimate bu + JOIN buy b ON b.id = bu.buyFk + WHERE bu.itemFk = vItemFk; + + CALL sale_setProblem('hasRounding'); + + DROP TEMPORARY TABLE tmp.sale; + DROP TEMPORARY TABLE tmp.buyUltimate; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sectorCollectionSaleGroup_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -69418,7 +69981,7 @@ BEGIN INSERT INTO stockBuyed(buyed, dated, description) SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000), vDated, - IF(c.code = 'ES', p.name, c.country) destiny + IF(c.code = 'ES', p.name, c.name) destiny FROM itemTicketOut ito JOIN ticket t ON t.id = ito.ticketFk JOIN `address` a ON a.id = t.addressFk @@ -69702,7 +70265,7 @@ BEGIN itemFk, longName, supplier, - entryFk, + CONCAT('E',entryFk) entryFk, landed, `in`, `out`, @@ -69716,16 +70279,98 @@ BEGIN itemFk, longName, supplier, - 'previous', + 'E previous', vFromDated, SUM(`in`), SUM(`out`), NULL, - buyingValue + AVG(buyingValue) FROM supplierPackaging WHERE supplierFk = vSupplierFk AND landed < vFromDated GROUP BY itemFk + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + CONCAT('T',s.ticketFk), + DATE(t.shipped), + -LEAST(s.quantity,0) `in`, + GREATEST(s.quantity,0) `out`, + t.warehouseFk, + s.price * (100 - s.discount) / 100 + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + s.itemFk, + i.longName, + c.name, + 'T previous', + vFromDated, + SUM(-LEAST(s.quantity,0)) `in`, + SUM(GREATEST(s.quantity,0)) `out`, + NULL, + AVG(s.price * (100 - s.discount) / 100) + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN packaging p ON p.itemFk = i.id + JOIN ticket t ON t.id = s.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped < vFromDated + AND p.isPackageReturnable + GROUP BY s.itemFk + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + CONCAT('TP',tp.ticketFk), + DATE(t.shipped), + -LEAST(tp.quantity,0) `in`, + GREATEST(tp.quantity,0) `out`, + t.warehouseFk, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + UNION ALL + SELECT vSupplierFk, + p.itemFk, + i.longName, + c.name, + 'TP previous', + vFromDated, + SUM(-LEAST(tp.quantity,0)) `in`, + SUM(GREATEST(tp.quantity,0)) `out`, + NULL, + 0 + FROM ticketPackaging tp + JOIN packaging p ON p.id = tp.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = tp.ticketFk + JOIN client c ON c.id = t.clientFk + JOIN supplier su ON su.nif = c.fi + WHERE su.id = vSupplierFk + AND t.shipped >= vFromDated + AND p.isPackageReturnable + GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub WHERE `out` OR `in`; @@ -69736,8 +70381,8 @@ BEGIN supplier, entryFk, landed, - `in`, - `out`, + CAST(`in` AS DECIMAL(10,0)) `in`, + CAST(`out` AS DECIMAL(10,0)) `out`, warehouse, buyingValue, balance @@ -71174,37 +71819,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketRefund_beforeUpsert` */; -/*!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 */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketRefund_beforeUpsert`(vRefundTicketFk INT, vOriginalTicketFk INT) -BEGIN - DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE; - - IF vRefundTicketFk = vOriginalTicketFk THEN - CALL util.throw('Original ticket and refund ticket has same id'); - END IF; - - SELECT COUNT(*) INTO vAlreadyExists - FROM ticketRefund - WHERE refundTicketFk = vOriginalTicketFk; - - IF vAlreadyExists > 0 THEN - CALL util.throw('This ticket is already a refund'); - 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_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketStateToday_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -72821,7 +73435,7 @@ BEGIN * * @param vSelf El id del ticket */ - DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT; + DECLARE vCmrFk INT; SELECT cmrFk INTO vCmrFk FROM ticket WHERE id = vSelf; @@ -72858,8 +73472,6 @@ BEGIN AND t.id = vSelf GROUP BY t.id; - START TRANSACTION; - IF vCmrFk THEN UPDATE cmr c JOIN tTicket t @@ -72871,9 +73483,7 @@ BEGIN c.supplierFk = t.supplierFk, c.ead = t.landed WHERE id = vCmrFk; - ELSE - SELECT MAX(id) INTO vPreviousCmrFk FROM cmr; - + ELSE INSERT INTO cmr ( senderInstruccions, truckPlate, @@ -72884,17 +73494,14 @@ BEGIN ead ) SELECT * FROM tTicket; - - SELECT MAX(id) INTO vCurrentCmrFk FROM cmr; - IF vPreviousCmrFk <> vCurrentCmrFk THEN + IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN UPDATE ticket - SET cmrFk = vCurrentCmrFk + SET cmrFk = LAST_INSERT_ID() WHERE id = vSelf; END IF; END IF; - COMMIT; DROP TEMPORARY TABLE tTicket; END ;; DELIMITER ; @@ -73146,6 +73753,7 @@ BEGIN MAX(itemDelay) itemDelay, MAX(hasRounding) hasRounding, MAX(itemLost) itemLost, + MAX(isVip) isVip, 0 totalProblems FROM tmp.sale_problems GROUP BY ticketFk; @@ -73161,7 +73769,8 @@ BEGIN (tp.isTooLittle) + (tp.itemLost) + (tp.hasRounding) + - (tp.itemShortage) + (tp.itemShortage) + + (tp.isVip) ); DROP TEMPORARY TABLE tmp.sale_problems; @@ -73998,6 +74607,425 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblem` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblem`( + vProblemCode VARCHAR(25) +) +BEGIN +/** + * Update column ticket.problem with a problem code + * + * @param vProblemCode Code to set or unset + * @table tmp.ticket(ticketFk, hasProblem) + */ + UPDATE ticket t + JOIN tmp.ticket tt ON tt.ticketFk = t.id + SET t.problem = CONCAT( + IF(tt.hasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))); +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemFreeze` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemFreeze`( + vClientFk INT +) +BEGIN +/** + * Update the problem of tickets whose client is frozen or unfrozen + * + * @param vClientFk Id Cliente, if NULL all clients + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, FALSE hasProblem + FROM ticket t + WHERE t.shipped >= util.midnight() + AND (vClientFk IS NULL OR t.clientFk = vClientFk); + + UPDATE tmp.ticket t + JOIN ticket ti ON ti.id = t.ticketFk + JOIN client c ON c.id = ti.clientFk + SET t.hasProblem = TRUE + WHERE c.isFreezed; + + CALL ticket_setProblem('isFreezed'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRequest` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemRequest`( + vSelf INT +) +BEGIN +/** + * Update the problems of tickets that have a pending ticketRequest or no longer have it + * + * @param vSelf Id ticket, if NULL ALL tickets + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, FALSE hasProblem + FROM ticket t + WHERE t.shipped >= util.midnight() + AND (vSelf IS NULL OR t.id = vSelf); + + UPDATE tmp.ticket t + JOIN ticketRequest tr ON tr.ticketFk = t.ticketFk + SET t.hasProblem = TRUE + WHERE tr.isOK IS NULL; + + CALL ticket_setProblem('hasTicketRequest'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRisk` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemRisk`( + vSelf INT +) +BEGIN +/** + * Update the risk problem for a specific ticket + * + * @param vSelf Id ticket + */ + DECLARE vHasRisk BOOL; + DECLARE vHasHighRisk BOOL; + + SELECT t.risk > (c.credit + 10), ((t.risk - cc.riskTolerance) > (c.credit + 10)) + INTO vHasRisk, vHasHighRisk + FROM client c + JOIN ticket t ON t.clientFk = c.id + JOIN clientConfig cc + WHERE t.id = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + SELECT vSelf ticketFk, vHasRisk hasProblem; + + CALL ticket_setProblem('hasRisk'); + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + SELECT vSelf ticketFk, vHasHighRisk hasProblem; + + CALL ticket_setProblem('hasHighRisk'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRounding` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemRounding`( + vSelf INT +) +BEGIN +/** + * Update the rounding problem for the sales lines of a ticket + * + * @param vSelf Id de ticket + */ + DECLARE vWarehouseFk INT; + DECLARE vDated DATE; + + SELECT warehouseFk, shipped + INTO vWarehouseFk, vDated + FROM ticket + WHERE id = vSelf; + + CALL buyUltimate(vWarehouseFk, vDated); + + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk + JOIN buy b ON b.id = bu.buyFk + WHERE t.id = vSelf; + + CALL sale_setProblem('hasRounding'); + + DROP TEMPORARY TABLE tmp.sale; + DROP TEMPORARY TABLE tmp.buyUltimate; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTaxDataChecked` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemTaxDataChecked`(vClientFk INT) +BEGIN +/** + * Update the problem of tickets, depending on whether + * the client taxDataCheched is verified or not + * + * @param vClientFk Id cliente, if NULL all clients + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.shipped >= util.midnight() + AND (c.id = vClientFk OR vClientFk IS NULL); + + CALL ticket_setProblem('isTaxDataChecked'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTooLittle` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemTooLittle`( + vSelf INT +) +BEGIN +/** + * Update the problems when the ticket is too small or is no longer so + * + * @param vSelf Id del ticket + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT vSelf ticketFk, ticket_isTooLittle(vSelf) hasProblem; + + CALL ticket_setProblem('isTooLittle'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemTooLittleItemCost` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemTooLittleItemCost`( + vItemFk INT +) +BEGIN +/** + * Update the problems when the ticket is too small or is no longer so, + * derived from changes in the itemCost table + * + * @param vItemFk Id del item, NULL ALL items + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + WITH tickets AS( + SELECT t.id ticketFk + FROM vn.ticket t + LEFT JOIN vn.sale s ON s.ticketFk = t.id + WHERE t.shipped >= util.midnight() + AND (s.itemFk = vItemFk OR vItemFk IS NULL) + GROUP BY t.id + )SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem + FROM tickets; + + CALL ticket_setProblem('isTooLittle'); + + DROP TEMPORARY TABLE tmp.ticket; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setRisk` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setRisk`( + vClientFk INT) +BEGIN +/** + * Update the risk for a client with pending tickets + * + * @param vClientFk Id cliente + */ + DECLARE vHasDebt BOOL; + + SELECT COUNT(*) INTO vHasDebt + FROM `client` + WHERE id = vClientFk + AND typeFk = 'normal'; + + IF vHasDebt THEN + + CREATE OR REPLACE TEMPORARY TABLE tTicketRisk + (KEY (ticketFk)) + ENGINE = MEMORY + WITH ticket AS( + SELECT id ticketFk, companyFk, DATE(shipped) dated + FROM vn.ticket t + WHERE clientFk = vClientFk + AND refFk IS NULL + AND NOT isDeleted + AND totalWithoutVat <> 0 + ), dated AS( + SELECT t.companyFk, MIN(DATE(t.dated) - INTERVAL cc.riskScope MONTH) started, + MAX(DATE(t.dated)) ended + FROM ticket t + JOIN vn.clientConfig cc + GROUP BY t.companyFk + ), balance AS( + SELECT SUM(amount)amount, companyFk + FROM ( + SELECT amount, companyFk + FROM vn.clientRisk + WHERE clientFk = vClientFk + UNION ALL + SELECT -(SUM(amount) / 100) amount, tm.companyFk + FROM hedera.tpvTransaction t + JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk + WHERE clientFk = vClientFk + AND receiptFk IS NULL + AND status = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), uninvoiced AS( + SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount + FROM vn.ticket t + JOIN dated d + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND t.shipped BETWEEN d.started AND d.ended + GROUP BY t.companyFk, DATE(t.shipped) + ), receipt AS( + SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount + FROM vn.receipt + WHERE clientFk = vClientFk + AND payed > util.VN_CURDATE() + GROUP BY companyFk, DATE(payed) + ), risk AS( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount + FROM ticket ti + JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; + + UPDATE ticket t + JOIN tTicketRisk tr ON tr.ticketFk = t.id + SET t.risk = tr.amount; + + DROP TEMPORARY TABLE tTicketRisk; + 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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74385,6 +75413,92 @@ BEGIN GROUP BY ib.ediBotanic, o.code; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `till_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 = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `till_new`( + vClient INT, + vBank INT, + vAmount DOUBLE, + vConcept VARCHAR(25), + vDated DATE, + vSerie CHAR(1), + vBatch TINYINT, + vNumber INT, + vCompany SMALLINT, + vWorker INT +) +BEGIN + DECLARE vAccount VARCHAR(12); + DECLARE vSubaccount VARCHAR(12); + DECLARE vAsiento INT DEFAULT NULL; + + -- Inserta el registro en cajas + INSERT INTO till + SET + workerFk = vWorker, + bankFk = vBank, + `in` = vAmount, + concept = vConcept, + dated = vDated, + serie = vSerie, + isAccountable = vBatch, + `number` = vNumber, + companyFk = vCompany; + + -- Inserta los asientos contables + SELECT account INTO vAccount + FROM accounting WHERE id = vBank; + + SELECT accountingAccount INTO vSubaccount + FROM `client` WHERE id = vClient; + + CALL xdiario_new( + vAsiento, + vDated, + vAccount, + vSubaccount, + vConcept, + vAmount, + 0, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); + + CALL xdiario_new( + vAsiento, + vDated, + vSubaccount, + vAccount, + vConcept, + 0, + vAmount, + 0, + NULL, -- Serie + NULL, -- Factura + NULL, -- IVA + NULL, -- Recargo + FALSE, -- Auxiliar + vCompany, + vAsiento); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76533,6 +77647,10 @@ mainLabel:BEGIN UPDATE `client` c SET c.salesPersonFk = null WHERE c.salesPersonFk = vUserId; + + UPDATE locker l + SET l.workerFk = NULL + WHERE l.workerFk = vUserId; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78369,6 +79487,43 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `worker_checkMultipleDevice` */; +/*!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 */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_checkMultipleDevice`( + vSelf INT +) +BEGIN +/** + * Verify if a worker has multiple assigned devices, + * except for freelancers. + * + * @param vUserFk worker id. + */ + DECLARE vHasPda BOOLEAN; + DECLARE vIsFreelance BOOLEAN; + DECLARE vMaxDevicesPerUser INT; + + SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf; + SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1; + + IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN + CALL util.throw('You can only have one PDA'); + 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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `worker_getFromHasMistake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78477,7 +79632,7 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBalance`(vSelfFk INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `worker_updateBalance`(vSelf INT(11), vCredit DECIMAL(10,2), vDebit DECIMAL(10,2)) BEGIN /** * Actualiza la columna balance de worker. @@ -78486,7 +79641,7 @@ BEGIN */ UPDATE worker SET balance = IFNULL(balance, 0) + IFNULL(vCredit, 0) - IFNULL(vDebit, 0) - WHERE id = vSelfFk; + WHERE id = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78797,6 +79952,62 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `xdiario_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 = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `xdiario_new`( + vBookNumber INT, + vDated DATE, + vSubaccount VARCHAR(12), + vAccount VARCHAR(12), + vConcept VARCHAR(25), + vDebit DOUBLE, + vCredit DOUBLE, + vEuro DOUBLE, + vSerie CHAR(1), + vInvoice VARCHAR(8), + vVat DOUBLE, + vRe DOUBLE, + vAux TINYINT, + vCompanyFk INT, + OUT vNewBookNumber INT +) +BEGIN + IF vBookNumber IS NULL THEN + CALL ledger_next(YEAR(vDated), vBookNumber); + END IF; + + INSERT INTO XDiario + SET ASIEN = vBookNumber, + FECHA = vDated, + SUBCTA = vSubaccount, + CONTRA = vAccount, + CONCEPTO = vConcept, + EURODEBE = vDebit, + EUROHABER = vCredit, + BASEEURO = vEuro, + SERIE = vSerie, + FACTURA = vInvoice, + IVA = vVat, + RECEQUIV = vRe, + AUXILIAR = IF(vAux = FALSE, NULL, '*'), + MONEDAUSO = 2, + empresa_id = vCompanyFk; + + SET vNewBookNumber = vBookNumber; +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_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `zoneClosure_recalc` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -80323,29 +81534,6 @@ SET character_set_client = utf8; 1 AS `isRiskFree` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Agencias_province__` --- - -DROP TABLE IF EXISTS `Agencias_province__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Agencias_province__` ( - `province_id` smallint(6) unsigned NOT NULL, - `agency_id` smallint(5) unsigned NOT NULL, - `zona` tinyint(4) NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - `route` tinyint(4) NOT NULL COMMENT 'Etiqueta zeleris', - `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`province_id`,`agency_id`,`warehouse_id`), - KEY `warehouse_id` (`warehouse_id`), - KEY `agency_id` (`agency_id`), - CONSTRAINT `Agencias_province___ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_province___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Agencias_province___ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Articles` -- @@ -80405,21 +81593,6 @@ SET character_set_client = utf8; 1 AS `packingOut` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Baldas__` --- - -DROP TABLE IF EXISTS `Baldas__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Baldas__` ( - `Id_Estanterias` int(11) NOT NULL, - `Id_Baldas` int(11) NOT NULL, - `h` int(11) NOT NULL, - PRIMARY KEY (`Id_Estanterias`,`Id_Baldas`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Bancos` -- @@ -80468,25 +81641,6 @@ SET character_set_client = utf8; 1 AS `insuranceExpired` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Brasa__` --- - -DROP TABLE IF EXISTS `Brasa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Brasa__` ( - `Id_Cliente` int(10) unsigned NOT NULL DEFAULT 0, - `Cliente` varchar(50) NOT NULL, - `Vista` int(10) unsigned NOT NULL DEFAULT 0, - `Reg` bigint(21) unsigned NOT NULL DEFAULT 0, - `Consumo` double NOT NULL, - `Grupo` int(10) unsigned NOT NULL, - PRIMARY KEY (`Id_Cliente`), - KEY `Index_1` (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Cajas` -- @@ -80518,20 +81672,6 @@ SET character_set_client = utf8; 1 AS `Proveedores_account_Id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Clases__` --- - -DROP TABLE IF EXISTS `Clases__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clases__` ( - `Id_Clase` int(11) NOT NULL DEFAULT 0, - `Clase` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Clase`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Clientes` -- @@ -80586,92 +81726,6 @@ SET character_set_client = utf8; 1 AS `typeFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Clientes_dits__` --- - -DROP TABLE IF EXISTS `Clientes_dits__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_dits__` ( - `idClientes_dits` int(11) NOT NULL AUTO_INCREMENT, - `idaccion_dits` int(11) NOT NULL, - `ODBC_DATE` timestamp NOT NULL DEFAULT current_timestamp(), - `Id_Ticket` int(11) NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `value_old` varchar(100) DEFAULT NULL, - `value_new` varchar(100) DEFAULT NULL, - PRIMARY KEY (`idClientes_dits`), - KEY `idaccion_dits` (`idaccion_dits`), - CONSTRAINT `Clientes_dits___ibfk_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits__` (`idaccion_dits`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_empresa__` --- - -DROP TABLE IF EXISTS `Clientes_empresa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_empresa__` ( - `Id_Clientes_empresa` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL, - `empresa_id` int(10) unsigned NOT NULL, - `fecha_ini` date NOT NULL, - `fecha_fin` date NOT NULL, - PRIMARY KEY (`Id_Clientes_empresa`), - KEY `empresa_id_idx` (`empresa_id`), - CONSTRAINT `Clientes_empresaCompany_Fk` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_event__` --- - -DROP TABLE IF EXISTS `Clientes_event__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_event__` ( - `Id_Cliente` int(11) NOT NULL, - `quantity` tinyint(3) unsigned NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`Id_Cliente`), - CONSTRAINT `Clientes_event___ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Clientes_potenciales__` --- - -DROP TABLE IF EXISTS `Clientes_potenciales__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Clientes_potenciales__` ( - `id` int(11) NOT NULL, - `PAIS` varchar(12) DEFAULT NULL, - `ACTIVIDAD` varchar(10) DEFAULT NULL, - `NOMBRE` varchar(45) NOT NULL DEFAULT '', - `PROVINCIA` varchar(25) DEFAULT NULL, - `POBLACION` varchar(45) NOT NULL DEFAULT '', - `CP` varchar(10) DEFAULT NULL, - `DIR_POSTAL` varchar(45) NOT NULL DEFAULT '', - `TELEFONO` varchar(12) NOT NULL DEFAULT '', - `TELEFONO2` varchar(12) NOT NULL DEFAULT '', - `FAX` varchar(12) NOT NULL DEFAULT '', - `E-MAIL` varchar(45) DEFAULT NULL, - `pagweb` varchar(45) DEFAULT NULL, - `SERVICIOS` varchar(45) DEFAULT NULL, - `state_id` smallint(6) DEFAULT 0 COMMENT '0 no se ha hecho nada\n1 ya existe el cliente\n2 cliente conseguido\n3 desestimado', - `Id_Trabajador` smallint(6) DEFAULT NULL, - `Notas` varchar(255) DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`NOMBRE`,`POBLACION`,`DIR_POSTAL`,`TELEFONO`,`TELEFONO2`,`FAX`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Comparativa` -- @@ -80725,7 +81779,6 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `weight`, 1 AS `dispatched`, - 1 AS `container_id`, 1 AS `itemOriginalFk` */; SET character_set_client = @saved_cs_client; @@ -80744,30 +81797,6 @@ SET character_set_client = utf8; 1 AS `odbc_date` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Compres_ok__` --- - -DROP TABLE IF EXISTS `Compres_ok__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Compres_ok__` ( - `Id_Compra` int(11) NOT NULL, - `valor` tinyint(3) unsigned NOT NULL DEFAULT 0, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `original_quantity` double DEFAULT NULL, - `Id_Trabajador` int(10) unsigned NOT NULL, - `Id_Accion` varchar(45) NOT NULL, - `Id_Compra_ok` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`Id_Compra_ok`), - KEY `Id_Movimiento` (`Id_Compra`), - KEY `Id_Accion` (`Id_Accion`), - KEY `Compres_ok_Id_Trabajador_idx` (`Id_Trabajador`), - CONSTRAINT `Compres_ok_Id_Trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`), - CONSTRAINT `Compres_ok___ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Consignatarios` -- @@ -80794,39 +81823,6 @@ SET character_set_client = utf8; 1 AS `active` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Consignatarios_devices__` --- - -DROP TABLE IF EXISTS `Consignatarios_devices__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Consignatarios_devices__` ( - `Id_Consigna` int(11) NOT NULL, - `serialNumber` varchar(45) NOT NULL, - `notas` varchar(45) DEFAULT NULL, - PRIMARY KEY (`Id_Consigna`,`serialNumber`), - CONSTRAINT `Condigna_devices` FOREIGN KEY (`Id_Consigna`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Conteo__` --- - -DROP TABLE IF EXISTS `Conteo__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Conteo__` ( - `Id_Conteo` int(11) NOT NULL AUTO_INCREMENT, - `Id_Article` int(11) NOT NULL, - `Fecha` timestamp NOT NULL DEFAULT current_timestamp(), - `dispositivo` varchar(15) DEFAULT NULL, - `warehouse_id` int(10) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`Id_Conteo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Cubos` -- @@ -80918,24 +81914,6 @@ SET character_set_client = utf8; 1 AS `Id_Entrada` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Entradas_kop__` --- - -DROP TABLE IF EXISTS `Entradas_kop__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Entradas_kop__` ( - `Id_Entradas_kop` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Entrada` int(11) NOT NULL, - `kop` int(11) DEFAULT NULL, - `sub` mediumint(8) unsigned DEFAULT NULL, - PRIMARY KEY (`Id_Entradas_kop`), - KEY `entradas_entradas_kop_idx` (`Id_Entrada`), - CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Entradas_orden` -- @@ -80949,85 +81927,6 @@ SET character_set_client = utf8; 1 AS `orden` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Espionajes__` --- - -DROP TABLE IF EXISTS `Espionajes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Espionajes__` ( - `idEspionaje` int(11) NOT NULL AUTO_INCREMENT, - `Id_Trabajador` varchar(45) DEFAULT NULL, - `Fecha` date DEFAULT NULL, - `HoraEntrada` time DEFAULT NULL, - `HoraSalida` time DEFAULT NULL, - `Id_Equipo` int(11) DEFAULT NULL, - PRIMARY KEY (`idEspionaje`), - KEY `index` (`Id_Trabajador`,`Fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Estados__` --- - -DROP TABLE IF EXISTS `Estados__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Estados__` ( - `Id_Estado` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `Estado` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Estado`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Familias__` --- - -DROP TABLE IF EXISTS `Familias__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Familias__` ( - `Familia` varchar(3) NOT NULL, - `Subcuenta` varchar(10) DEFAULT NULL, - `Descripcion` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Familia`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Forms__` --- - -DROP TABLE IF EXISTS `Forms__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Forms__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `titulo` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Grupos__` --- - -DROP TABLE IF EXISTS `Grupos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Grupos__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `Grupo` varchar(45) NOT NULL, - `observation_type_id` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `name` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Impresoras` -- @@ -81044,38 +81943,6 @@ SET character_set_client = utf8; 1 AS `isLabeler` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Informes__` --- - -DROP TABLE IF EXISTS `Informes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Informes__` ( - `Id_Informe` tinyint(3) unsigned NOT NULL, - `Informe` varchar(50) DEFAULT NULL, - PRIMARY KEY (`Id_Informe`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Jefes__` --- - -DROP TABLE IF EXISTS `Jefes__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Jefes__` ( - `Id_Trabajador` int(10) unsigned NOT NULL, - `Id_Jefe` int(10) unsigned NOT NULL, - `Departamento` varchar(45) NOT NULL, - PRIMARY KEY (`Id_Trabajador`,`Id_Jefe`), - KEY `trabajador_jefe_idx` (`Id_Jefe`), - CONSTRAINT `trabajador_jefe` FOREIGN KEY (`Id_Jefe`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `trabajador_trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Monedas` -- @@ -81091,33 +81958,6 @@ SET character_set_client = utf8; 1 AS `Cambio` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Monitoring__` --- - -DROP TABLE IF EXISTS `Monitoring__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Monitoring__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `equipo_id` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `user_id` int(10) unsigned NOT NULL, - `form_id` int(11) NOT NULL, - `cliente_id` int(11) NOT NULL, - `ticket_id` int(11) NOT NULL, - `ODBC_TIME` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - KEY `equipo_id` (`equipo_id`,`user_id`,`form_id`,`cliente_id`,`ticket_id`), - KEY `user_id` (`user_id`), - KEY `form_id` (`form_id`), - KEY `cliente_id` (`cliente_id`), - KEY `ticket_id` (`ticket_id`), - CONSTRAINT `Monitoring_FK` FOREIGN KEY (`equipo_id`) REFERENCES `vn`.`host` (`code`) ON UPDATE CASCADE, - CONSTRAINT `Monitoring___ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `vn`.`worker` (`id`), - CONSTRAINT `Monitoring___ibfk_3` FOREIGN KEY (`form_id`) REFERENCES `Forms__` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Movimientos` -- @@ -81143,23 +81983,6 @@ SET character_set_client = utf8; 1 AS `isAdded` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Movimientos_avisar__` --- - -DROP TABLE IF EXISTS `Movimientos_avisar__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_avisar__` ( - `Id_Movimiento` int(11) NOT NULL, - `Id_Remitente` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Movimiento`), - KEY `Movimiento` (`Id_Movimiento`), - KEY `Remitente` (`Id_Remitente`), - CONSTRAINT `Id_Movimientos_avisar_fk` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Movimientos_componentes` -- @@ -81194,40 +82017,6 @@ SET character_set_client = utf8; 1 AS `stateFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Movimientos_revisar__` --- - -DROP TABLE IF EXISTS `Movimientos_revisar__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Movimientos_revisar__` ( - `Id_Movimiento` int(11) NOT NULL, - `Comentario` varchar(255) DEFAULT NULL, - `Revisado` tinyint(1) NOT NULL DEFAULT 0, - `Id_Remitente` int(11) DEFAULT NULL, - `Id_Destinatario` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Movimiento`), - KEY `Remitente` (`Id_Remitente`), - KEY `Destinatario` (`Id_Destinatario`), - CONSTRAINT `Movimientos_revisar___ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn`.`sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Objetivos__` --- - -DROP TABLE IF EXISTS `Objetivos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Objetivos__` ( - `Periodo` int(11) NOT NULL, - `Objetivo` double NOT NULL, - PRIMARY KEY (`Periodo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Ordenes` -- @@ -81308,26 +82097,6 @@ SET character_set_client = utf8; 1 AS `hasDailyInvoice` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Permisos__` --- - -DROP TABLE IF EXISTS `Permisos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Permisos__` ( - `Id_Grupo` int(10) unsigned NOT NULL, - `Id_Trabajador` int(10) unsigned NOT NULL, - `empresa_id` int(10) unsigned NOT NULL DEFAULT 442, - PRIMARY KEY (`Id_Grupo`,`Id_Trabajador`), - KEY `empresa_id` (`empresa_id`), - KEY `Permisos_ibfk_3_idx` (`Id_Trabajador`), - CONSTRAINT `PermisosCompany_Fk` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Permisos___ibfk_2` FOREIGN KEY (`Id_Grupo`) REFERENCES `Grupos__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `Permisos___ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `PreciosEspeciales` -- @@ -81357,7 +82126,6 @@ SET character_set_client = utf8; 1 AS `cuenta`, 1 AS `pais_id`, 1 AS `NIF`, - 1 AS `Agricola`, 1 AS `Telefono`, 1 AS `cuentaret`, 1 AS `ComisionProveedor`, @@ -81397,41 +82165,6 @@ SET character_set_client = utf8; 1 AS `Id_Proveedor` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Proveedores_comunicados__` --- - -DROP TABLE IF EXISTS `Proveedores_comunicados__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_comunicados__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Proveedor` int(10) unsigned NOT NULL, - `escrito_id` int(11) NOT NULL, - `fecha` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`), - KEY `Proveedor` (`Id_Proveedor`), - KEY `Escrito` (`escrito_id`), - CONSTRAINT `Proveedores_comunicados___ibfk_4` FOREIGN KEY (`escrito_id`) REFERENCES `Proveedores_escritos__` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Proveedores_comunicados_supplierFk` FOREIGN KEY (`Id_Proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `Proveedores_escritos__` --- - -DROP TABLE IF EXISTS `Proveedores_escritos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Proveedores_escritos__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `escrito` varchar(45) NOT NULL, - `informe` varchar(45) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Proveedores_gestdoc` -- @@ -81466,21 +82199,6 @@ SET character_set_client = utf8; 1 AS `conciliado` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Recibos_recorded__` --- - -DROP TABLE IF EXISTS `Recibos_recorded__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Recibos_recorded__` ( - `Id_Recibos` int(11) NOT NULL, - `recorded` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marcado si se ha contabilizado', - PRIMARY KEY (`Id_Recibos`), - CONSTRAINT `Recibos_recorded___ibfk_1` FOREIGN KEY (`Id_Recibos`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Remesas` -- @@ -81496,34 +82214,6 @@ SET character_set_client = utf8; 1 AS `empresa_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Reservas__` --- - -DROP TABLE IF EXISTS `Reservas__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Reservas__` ( - `Id_Reserva` int(11) NOT NULL AUTO_INCREMENT, - `Id_Ticket` int(11) DEFAULT 0, - `Fecha` datetime DEFAULT NULL, - `Alias` varchar(50) DEFAULT NULL, - `article` varchar(50) DEFAULT NULL, - `medida` varchar(50) DEFAULT NULL, - `categoria` varchar(50) DEFAULT NULL, - `color` varchar(50) DEFAULT NULL, - `origen` varchar(50) DEFAULT NULL, - `cantidad` int(11) DEFAULT 0, - `Id_Article` double DEFAULT 0, - `buyFk` int(11) NOT NULL, - `grouping` int(11) DEFAULT NULL, - `packing` int(11) DEFAULT NULL, - PRIMARY KEY (`Id_Reserva`), - KEY `Id_1` (`Id_Ticket`), - KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Deprecated 27-02-2023'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Rutas` -- @@ -81567,21 +82257,6 @@ SET character_set_client = utf8; 1 AS `empresa_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Series__` --- - -DROP TABLE IF EXISTS `Series__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Series__` ( - `Id_Serie` varchar(2) NOT NULL, - `Serie` varchar(30) DEFAULT NULL, - `Cuenta` varchar(10) DEFAULT NULL, - PRIMARY KEY (`Id_Serie`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Split_lines` -- @@ -81653,22 +82328,6 @@ SET character_set_client = utf8; 1 AS `totalWithoutVat` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Tickets_stack__` --- - -DROP TABLE IF EXISTS `Tickets_stack__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tickets_stack__` ( - `Id_Ticket` int(11) NOT NULL, - `orden` smallint(5) unsigned NOT NULL, - `label_number` smallint(6) DEFAULT 0, - `preparado` tinyint(4) DEFAULT 0, - PRIMARY KEY (`Id_Ticket`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Tickets_state` -- @@ -81743,20 +82402,6 @@ SET character_set_client = utf8; 1 AS `profit` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `Tipos_f11__` --- - -DROP TABLE IF EXISTS `Tipos_f11__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tipos_f11__` ( - `f11_id` tinyint(4) NOT NULL AUTO_INCREMENT, - `description` varchar(15) NOT NULL, - PRIMARY KEY (`f11_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `Trabajadores` -- @@ -81846,21 +82491,6 @@ SET character_set_client = utf8; 1 AS `gasoline` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `accion_dits__` --- - -DROP TABLE IF EXISTS `accion_dits__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `accion_dits__` ( - `idaccion_dits` int(11) NOT NULL AUTO_INCREMENT, - `accion` varchar(255) DEFAULT NULL, - PRIMARY KEY (`idaccion_dits`), - UNIQUE KEY `accion_UNIQUE` (`accion`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `account_conciliacion` -- @@ -81909,24 +82539,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `agencia_descuadre__` --- - -DROP TABLE IF EXISTS `agencia_descuadre__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agencia_descuadre__` ( - `agencia_descuadre_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Ticket` int(11) NOT NULL, - `date` date NOT NULL, - `price` double(7,2) NOT NULL, - `Consignatario` varchar(50) NOT NULL, - `Tipo` varchar(30) NOT NULL, - PRIMARY KEY (`agencia_descuadre_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `agency` -- @@ -81943,50 +82555,6 @@ SET character_set_client = utf8; 1 AS `workCenterFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `agency_hour__` --- - -DROP TABLE IF EXISTS `agency_hour__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agency_hour__` ( - `agency_hour_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `week_day` tinyint(3) unsigned DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', - `agency_id` smallint(5) unsigned DEFAULT NULL, - `warehouse_id` smallint(5) unsigned DEFAULT NULL, - `province_id` smallint(5) unsigned DEFAULT NULL, - `subtract_day` tinyint(10) unsigned NOT NULL COMMENT 'dias a restar de la Fecha de entrega', - `max_hour` tinyint(3) unsigned NOT NULL COMMENT 'maxima hora hasta la cual se pueden hacer pedidos', - PRIMARY KEY (`agency_hour_id`), - UNIQUE KEY `week_day` (`week_day`,`agency_id`,`warehouse_id`,`province_id`,`max_hour`), - KEY `agency_id` (`agency_id`), - KEY `warehouse_id` (`warehouse_id`), - KEY `province_id` (`province_id`), - CONSTRAINT `agency_hour___ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_hour___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_hour___ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `agency_warehouse__` --- - -DROP TABLE IF EXISTS `agency_warehouse__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `agency_warehouse__` ( - `agency_id` smallint(5) unsigned NOT NULL, - `warehouse_id` smallint(5) unsigned NOT NULL DEFAULT 1, - `Vista` tinyint(3) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`agency_id`,`warehouse_id`), - KEY `warehouse_id` (`warehouse_id`), - CONSTRAINT `agency_warehouse___ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agency` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `agency_warehouse___ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `airline` -- @@ -82035,8 +82603,7 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `Id_Responsable`, 1 AS `department_id`, - 1 AS `recibida_id`, - 1 AS `farmingFk` */; + 1 AS `recibida_id` */; SET character_set_client = @saved_cs_client; -- @@ -82402,37 +82969,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `call_information__` --- - -DROP TABLE IF EXISTS `call_information__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `call_information__` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Descripcio` text NOT NULL, - `Conclusio` tinyint(3) unsigned NOT NULL, - `Id_Cliente` int(11) NOT NULL, - `fecha` date NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `call_option__` --- - -DROP TABLE IF EXISTS `call_option__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `call_option__` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `descripcion` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cdr` -- @@ -82522,20 +83058,6 @@ SET character_set_client = utf8; 1 AS `consecuencia` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `cl_dep__` --- - -DROP TABLE IF EXISTS `cl_dep__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_dep__` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `departamento` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cl_det` -- @@ -82585,34 +83107,6 @@ SET character_set_client = utf8; 1 AS `motivo` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `cl_pet__` --- - -DROP TABLE IF EXISTS `cl_pet__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_pet__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `peticion` varchar(15) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cl_que__` --- - -DROP TABLE IF EXISTS `cl_que__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_que__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `queja` varchar(25) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `cl_res` -- @@ -82641,39 +83135,6 @@ SET character_set_client = utf8; 1 AS `addressFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `commission__` --- - -DROP TABLE IF EXISTS `commission__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `commission__` ( - `commisision_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `percentage` tinyint(3) unsigned NOT NULL, - `value` float unsigned NOT NULL, - PRIMARY KEY (`commisision_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `config__` --- - -DROP TABLE IF EXISTS `config__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `config__` ( - `id` int(11) NOT NULL, - `generic_item` int(11) NOT NULL COMMENT 'Id del artículo genérico', - `edi_entry` int(11) NOT NULL COMMENT 'Entrada usada para los EKTs', - `lastMana` int(11) NOT NULL DEFAULT 0, - `lastNicho` varchar(10) DEFAULT NULL, - `lastReserve` varchar(10) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `config_host` -- @@ -82692,26 +83153,6 @@ SET character_set_client = utf8; 1 AS `route_days_after` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `config_host_forms__` --- - -DROP TABLE IF EXISTS `config_host_forms__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `config_host_forms__` ( - `config_host_id` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `formname` varchar(56) NOT NULL, - `x` int(8) NOT NULL, - `y` int(8) NOT NULL, - `h` int(8) NOT NULL, - `l` int(8) NOT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - PRIMARY KEY (`config_host_id`,`formname`), - CONSTRAINT `config_host_forms_FK` FOREIGN KEY (`config_host_id`) REFERENCES `vn`.`host` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `consignatarios_observation` -- @@ -82727,51 +83168,6 @@ SET character_set_client = utf8; 1 AS `text` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `container__` --- - -DROP TABLE IF EXISTS `container__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `container__` ( - `container_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `Continente` varchar(10) DEFAULT NULL, - PRIMARY KEY (`container_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cooler_path__` --- - -DROP TABLE IF EXISTS `cooler_path__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cooler_path__` ( - `cooler_path_id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(45) DEFAULT NULL, - PRIMARY KEY (`cooler_path_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cp__` --- - -DROP TABLE IF EXISTS `cp__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cp__` ( - `cp_id` int(11) NOT NULL AUTO_INCREMENT, - `cpd` int(11) NOT NULL, - `cph` int(11) NOT NULL, - `zone_id` smallint(6) DEFAULT NULL, - `town` varchar(45) NOT NULL, - PRIMARY KEY (`cp_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `credit` -- @@ -82788,62 +83184,6 @@ SET character_set_client = utf8; 1 AS `odbc_date` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `credit_card__` --- - -DROP TABLE IF EXISTS `credit_card__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `credit_card__` ( - `credit_card_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(10) NOT NULL, - `number` varchar(20) NOT NULL, - `expiration_month` tinyint(2) unsigned zerofill NOT NULL, - `expiration_year` tinyint(2) unsigned zerofill NOT NULL, - `priority` tinyint(3) unsigned NOT NULL DEFAULT 1, - `obs` varchar(45) DEFAULT NULL, - PRIMARY KEY (`credit_card_id`), - KEY `Id_Cliente` (`Id_Cliente`), - CONSTRAINT `credit_card___ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cyc__` --- - -DROP TABLE IF EXISTS `cyc__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cyc__` ( - `Id_Cliente` int(11) NOT NULL, - `Riesgo` double DEFAULT NULL, - `Fecha` timestamp NOT NULL DEFAULT current_timestamp(), - `cyc_id` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`cyc_id`), - KEY `Cliente` (`Id_Cliente`), - CONSTRAINT `Cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `cyc_declaration__` --- - -DROP TABLE IF EXISTS `cyc_declaration__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cyc_declaration__` ( - `factura_id` int(10) unsigned NOT NULL, - `Riesgo` double DEFAULT NULL, - `Fecha` date NOT NULL, - `Vencimiento` int(10) NOT NULL DEFAULT 0, - PRIMARY KEY (`factura_id`), - CONSTRAINT `Factura` FOREIGN KEY (`factura_id`) REFERENCES `vn`.`invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `definitivo` -- @@ -82860,37 +83200,6 @@ SET character_set_client = utf8; 1 AS `fecha` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `dock__` --- - -DROP TABLE IF EXISTS `dock__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `dock__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(5) NOT NULL, - `xPos` int(11) DEFAULT NULL, - `yPos` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-03-05'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `duaDismissed__` --- - -DROP TABLE IF EXISTS `duaDismissed__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `duaDismissed__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ticketFk` varchar(45) NOT NULL, - PRIMARY KEY (`id`,`ticketFk`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `edi_article` -- @@ -82976,36 +83285,6 @@ SET character_set_client = utf8; 1 AS `company_name` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `edi_testigos__` --- - -DROP TABLE IF EXISTS `edi_testigos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `edi_testigos__` ( - `id` smallint(6) NOT NULL AUTO_INCREMENT, - `table` varchar(25) NOT NULL, - `field` varchar(32) NOT NULL, - `testigo` varchar(5) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `emp_day_pay__` --- - -DROP TABLE IF EXISTS `emp_day_pay__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `emp_day_pay__` ( - `id` smallint(5) unsigned NOT NULL, - `emp_day_pay` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`id`,`emp_day_pay`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `empresa` -- @@ -83090,65 +83369,6 @@ SET character_set_client = utf8; 1 AS `observationWorkerCode` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `expeditions_deleted__` --- - -DROP TABLE IF EXISTS `expeditions_deleted__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditions_deleted__` ( - `expeditions_id` int(11) NOT NULL AUTO_INCREMENT, - `agency_id` int(11) NOT NULL, - `ticket_id` int(10) NOT NULL, - `EsBulto` int(11) DEFAULT 1, - `odbc_date` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `reembolso` bit(1) DEFAULT b'0', - `recogida` bit(1) DEFAULT b'0', - `Id_Article` int(11) DEFAULT NULL, - `counter` smallint(5) unsigned NOT NULL, - `checked` tinyint(4) NOT NULL DEFAULT 0, - `completed` tinyint(4) DEFAULT 0, - `expedicion` varchar(45) DEFAULT NULL, - `Id_Trabajador` int(11) DEFAULT NULL, - PRIMARY KEY (`expeditions_id`), - KEY `index1` (`agency_id`), - KEY `index2` (`EsBulto`), - KEY `index3` (`odbc_date`), - KEY `index4` (`ticket_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `expeditions_pictures__` --- - -DROP TABLE IF EXISTS `expeditions_pictures__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `expeditions_pictures__` ( - `Id_Article` int(11) NOT NULL, - `NoImprimirEtiqueta` bit(1) DEFAULT b'0', - PRIMARY KEY (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6371 deprecated 2024-01-11'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `filtros__` --- - -DROP TABLE IF EXISTS `filtros__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `filtros__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) NOT NULL, - `sql` varchar(255) NOT NULL, - `Estanteria` tinyint(1) DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `financialProductType` -- @@ -83181,23 +83401,6 @@ SET character_set_client = utf8; 1 AS `airport_in` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `form_query__` --- - -DROP TABLE IF EXISTS `form_query__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `form_query__` ( - `form_query_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `query` varchar(50) NOT NULL, - `response1` varchar(10) NOT NULL, - `response2` varchar(10) NOT NULL, - `type_id` enum('gest_doc') NOT NULL, - PRIMARY KEY (`form_query_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-21;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `gastos_resumen` -- @@ -83215,38 +83418,6 @@ SET character_set_client = utf8; 1 AS `empresa_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `guillen__` --- - -DROP TABLE IF EXISTS `guillen__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `guillen__` ( - `bulto` tinyint(3) unsigned NOT NULL, - `1` float unsigned NOT NULL, - `2` float unsigned NOT NULL, - `re_exp` float unsigned NOT NULL, - PRIMARY KEY (`bulto`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `guillen_carry__` --- - -DROP TABLE IF EXISTS `guillen_carry__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `guillen_carry__` ( - `carry` tinyint(3) unsigned NOT NULL, - `1` float unsigned NOT NULL, - `2` float unsigned NOT NULL, - `re_exp` float unsigned NOT NULL, - PRIMARY KEY (`carry`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `integra2` -- @@ -83261,23 +83432,6 @@ SET character_set_client = utf8; 1 AS `warehouse_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `integra2_escala__` --- - -DROP TABLE IF EXISTS `integra2_escala__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `integra2_escala__` ( - `province_id` smallint(6) unsigned NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`province_id`,`warehouse_id`), - KEY `warehouse_escala_idx` (`warehouse_id`), - CONSTRAINT `province_escala` FOREIGN KEY (`province_id`) REFERENCES `vn`.`province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_escala` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `integra2_province` -- @@ -83291,72 +83445,6 @@ SET character_set_client = utf8; 1 AS `franquicia` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `invoice_observation__` --- - -DROP TABLE IF EXISTS `invoice_observation__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `invoice_observation__` ( - `invoice_observation_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `desde` date NOT NULL, - `hasta` date NOT NULL, - `serie` varchar(1) NOT NULL DEFAULT '0', - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT 0, - `text` text NOT NULL, - PRIMARY KEY (`invoice_observation_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `jerarquia__` --- - -DROP TABLE IF EXISTS `jerarquia__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `jerarquia__` ( - `worker_id` int(10) unsigned NOT NULL, - `boss_id` int(10) unsigned NOT NULL, - `vinculado` tinyint(3) unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`worker_id`,`boss_id`), - KEY `worker_trabajador` (`worker_id`), - KEY `jerarquiaBossFk_idx` (`boss_id`), - CONSTRAINT `jerarquiaBossFk` FOREIGN KEY (`boss_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `jerarquiaWorkerFk` FOREIGN KEY (`worker_id`) REFERENCES `account`.`account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #7258 @deprecated 2023-12-13'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `language__` --- - -DROP TABLE IF EXISTS `language__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `language__` ( - `code` varchar(10) NOT NULL, - `name` varchar(20) NOT NULL, - `active` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `link__` --- - -DROP TABLE IF EXISTS `link__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `link__` ( - `Id_Cliente` int(11) NOT NULL, - `Id_Proveedor` int(11) NOT NULL, - PRIMARY KEY (`Id_Cliente`,`Id_Proveedor`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `mail` -- @@ -83411,19 +83499,6 @@ SET character_set_client = utf8; 1 AS `Nombre` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `nichos__` --- - -DROP TABLE IF EXISTS `nichos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `nichos__` ( - `id` varchar(5) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `pago` -- @@ -83515,45 +83590,6 @@ SET character_set_client = utf8; 1 AS `isNotified` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_basess__` --- - -DROP TABLE IF EXISTS `payroll_basess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_basess__` ( - `id_payroll_Basess` int(11) NOT NULL AUTO_INCREMENT, - `empresa_id` int(10) NOT NULL, - `id_tipobasess` int(11) NOT NULL, - `valor` double NOT NULL, - `fechadesde` date NOT NULL, - `fechahasta` date DEFAULT NULL, - `contratotemporal` tinyint(1) DEFAULT 0, - PRIMARY KEY (`id_payroll_Basess`), - KEY `payroll_basess_1_idx` (`id_tipobasess`), - KEY `payroll_basess_2_idx` (`empresa_id`), - CONSTRAINT `payroll_basess_1` FOREIGN KEY (`id_tipobasess`) REFERENCES `payroll_tipobasess__` (`id_payroll_tipobasess`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `payroll_basess_2` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`payrollWorkCenter` (`empresa_id__`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payroll_bonificaciones__` --- - -DROP TABLE IF EXISTS `payroll_bonificaciones__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_bonificaciones__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(11) NOT NULL, - `Fecha` date NOT NULL, - `bonificacionSS` double NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `payroll_categorias` -- @@ -83597,49 +83633,6 @@ SET character_set_client = utf8; 1 AS `isException` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_datos__` --- - -DROP TABLE IF EXISTS `payroll_datos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_datos__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(10) NOT NULL, - `Fecha` date NOT NULL, - `conceptoid` int(11) NOT NULL, - `orden` tinyint(4) DEFAULT NULL, - `dias` smallint(6) DEFAULT NULL, - `Importe` decimal(8,2) NOT NULL, - `DH` tinyint(4) DEFAULT NULL, - `T_Paga` tinyint(4) NOT NULL, - `TributaIRPF` tinyint(4) NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`conceptoid`,`Fecha`), - KEY `fgkey_payrolldatos_1_idx` (`conceptoid`), - CONSTRAINT `fgkey_payrolldatos_1` FOREIGN KEY (`conceptoid`) REFERENCES `vn`.`payrollComponent` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payroll_embargos__` --- - -DROP TABLE IF EXISTS `payroll_embargos__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_embargos__` ( - `codtrabajador` int(11) NOT NULL, - `codempresa` int(10) NOT NULL, - `conceptoid` int(11) NOT NULL, - `Fecha` date NOT NULL, - `pagado` double NOT NULL, - `pendiente` double DEFAULT NULL, - `total` double NOT NULL, - PRIMARY KEY (`codtrabajador`,`codempresa`,`Fecha`,`conceptoid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `payroll_employee` -- @@ -83654,41 +83647,6 @@ SET character_set_client = utf8; 1 AS `workerFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `payroll_tipobasess__` --- - -DROP TABLE IF EXISTS `payroll_tipobasess__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payroll_tipobasess__` ( - `id_payroll_tipobasess` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id_payroll_tipobasess`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `payrroll_apEmpresarial__` --- - -DROP TABLE IF EXISTS `payrroll_apEmpresarial__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `payrroll_apEmpresarial__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `codTrabajador` int(11) NOT NULL, - `Fecha` date NOT NULL, - `CosteEmpresaAT` decimal(8,2) NOT NULL, - `costeEmpresaCC` decimal(8,2) NOT NULL, - `costeEmpresaDesempleo` decimal(8,2) NOT NULL, - `costeEmpresaFP` decimal(8,2) NOT NULL, - `costeEmpresaFogasa` decimal(8,2) NOT NULL, - `costeEmpresaExtra` decimal(8,2) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `plantpassport` -- @@ -83718,22 +83676,6 @@ SET character_set_client = utf8; 1 AS `Paises_Id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `preparation_exception__` --- - -DROP TABLE IF EXISTS `preparation_exception__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `preparation_exception__` ( - `exception_day` date NOT NULL COMMENT 'preparation day', - `warehouse_id` smallint(6) unsigned DEFAULT NULL, - `percentage` tinyint(2) NOT NULL DEFAULT 0, - UNIQUE KEY `exception_day_UNIQUE` (`exception_day`), - UNIQUE KEY `warehouse_id_UNIQUE` (`warehouse_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `price_fixed` -- @@ -83805,22 +83747,6 @@ SET character_set_client = utf8; 1 AS `geoFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `rec_translator__` --- - -DROP TABLE IF EXISTS `rec_translator__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `rec_translator__` ( - `Id_Article` int(11) NOT NULL, - `denominacion` varchar(85) NOT NULL, - PRIMARY KEY (`Id_Article`,`denominacion`), - KEY `id_article_rec_idx` (`Id_Article`), - CONSTRAINT `id_article_rec` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `recibida` -- @@ -83854,21 +83780,6 @@ SET character_set_client = utf8; 1 AS `expenseFkDeductible` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `recibida_agricola__` --- - -DROP TABLE IF EXISTS `recibida_agricola__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `recibida_agricola__` ( - `recibida_id` mediumint(8) unsigned NOT NULL, - `num` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`recibida_id`), - CONSTRAINT `recibida_agricola___ibfk_1` FOREIGN KEY (`recibida_id`) REFERENCES `vn`.`invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `recibida_intrastat` -- @@ -83971,150 +83882,6 @@ SET character_set_client = utf8; 1 AS `efimero` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `rounding__` --- - -DROP TABLE IF EXISTS `rounding__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `rounding__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `amount` double NOT NULL DEFAULT 0, - `price` double DEFAULT 0, - `discount` double NOT NULL DEFAULT 0, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `route__` --- - -DROP TABLE IF EXISTS `route__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `route__` ( - `agency_id` smallint(5) unsigned NOT NULL, - `week_day` tinyint(3) unsigned NOT NULL COMMENT 'weekday de access el domingo = 1, sabado = 7. Intentar cambiar al de Mysql Lunes = 0', - PRIMARY KEY (`agency_id`,`week_day`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scanTree__` --- - -DROP TABLE IF EXISTS `scanTree__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scanTree__` ( - `id` int(11) NOT NULL DEFAULT 0, - `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `lft` int(11) NOT NULL, - `rgt` int(11) NOT NULL, - `depth` bigint(22) NOT NULL DEFAULT 0, - `sons` int(11) DEFAULT 0, - `lastScanned` datetime DEFAULT NULL, - `routeCount` int(11) DEFAULT NULL, - `minRoute` int(11) DEFAULT NULL, - `maxRoute` int(11) DEFAULT NULL, - `scanned` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `lft_rgt_depth` (`lft`,`rgt`,`depth`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scan__` --- - -DROP TABLE IF EXISTS `scan__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scan__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `lft` int(11) NOT NULL, - `rgt` int(11) NOT NULL, - `name` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `scan_line__` --- - -DROP TABLE IF EXISTS `scan_line__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `scan_line__` ( - `scan_line_id` int(11) NOT NULL AUTO_INCREMENT, - `scan_id` int(11) NOT NULL, - `code` varchar(45) NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - PRIMARY KEY (`scan_line_id`), - KEY `id_scan_id_idx` (`scan_id`), - CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `sort_merge_results_ernesto__` --- - -DROP TABLE IF EXISTS `sort_merge_results_ernesto__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `sort_merge_results_ernesto__` ( - `hora` datetime NOT NULL, - `uptime` int(11) DEFAULT NULL, - `log_output` varchar(5) DEFAULT NULL, - `uptime_since_flush` int(11) DEFAULT NULL, - `smp_old` int(11) DEFAULT NULL, - `smp_new` int(11) DEFAULT NULL, - `smp` int(11) DEFAULT NULL, - `smp_hour` int(11) DEFAULT NULL, - `connections` int(11) DEFAULT NULL, - `Threads_created` int(11) DEFAULT NULL, - `Threads_cached` int(11) DEFAULT NULL, - `Thread_cache_size` int(11) DEFAULT NULL, - `comment` varchar(255) DEFAULT NULL, - `TABLE_OPEN_CACHE_OVERFLOWS` int(11) DEFAULT NULL, - `TABLE_OPEN_CACHE_MISSES` int(11) DEFAULT NULL, - `TABLE_OPEN_CACHE_HITS` int(11) DEFAULT NULL, - `table_open_cache` int(11) DEFAULT NULL, - `table_open_cache_instances` int(11) DEFAULT NULL, - `open_tables` int(11) DEFAULT NULL, - `opened_tables` int(11) DEFAULT NULL, - `Innodb_os_log_written` double DEFAULT NULL, - `table_definition_cache` int(11) DEFAULT NULL, - `Open_table_definitions` int(11) DEFAULT NULL, - `sort_buffer_size` int(11) DEFAULT NULL, - `join_buffer_size` int(11) DEFAULT NULL, - `read_rnd_buffer_size` int(11) DEFAULT NULL, - `tmp_table_size` int(11) DEFAULT NULL, - `max_heap_table_size` int(11) DEFAULT NULL, - `created_tmp_disk_tables` int(11) DEFAULT NULL, - `created_tmp_tables` int(11) DEFAULT NULL, - `Created_tmp_files` int(11) DEFAULT NULL, - `OpenTablesxUptimeDivOpened` float DEFAULT NULL, - `innodb_open_files` int(11) DEFAULT NULL, - `Innodb_num_open_files` int(11) DEFAULT NULL, - `open_files_limit` int(11) DEFAULT NULL, - `query_cache_size` int(11) DEFAULT NULL, - `query_cache_type` varchar(3) DEFAULT NULL, - `trx_rseg_history_len` int(11) DEFAULT NULL, - `Qcache_hits` int(11) DEFAULT NULL, - `Qcache_inserts` int(11) DEFAULT NULL, - `Qcache_not_cached` int(11) DEFAULT NULL, - PRIMARY KEY (`hora`), - UNIQUE KEY `hora_UNIQUE` (`hora`), - KEY `uptime` (`uptime`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `state` -- @@ -84229,78 +83996,6 @@ SET character_set_client = utf8; 1 AS `ASIEN` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `tblIVA__` --- - -DROP TABLE IF EXISTS `tblIVA__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tblIVA__` ( - `tipoiva` varchar(50) NOT NULL, - `iva` smallint(6) NOT NULL DEFAULT 0, - `cuenta` double DEFAULT 0, - `cuentaRE` double DEFAULT 0, - `cuentaivaRE` double DEFAULT 0, - `REQ` double DEFAULT 0, - PRIMARY KEY (`tipoiva`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_component__` --- - -DROP TABLE IF EXISTS `template_bionic_component__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_component__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `component_id` int(10) unsigned NOT NULL, - `cost` decimal(10,4) NOT NULL, - UNIQUE KEY `item_warehouse_component` (`item_id`,`warehouse_id`,`component_id`) USING HASH, - KEY `item_warehouse` (`item_id`,`warehouse_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_lot__` --- - -DROP TABLE IF EXISTS `template_bionic_lot__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_lot__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `available` double DEFAULT NULL, - `buy_id` int(11) DEFAULT NULL, - `fix` tinyint(3) unsigned DEFAULT 0, - UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`), - KEY `item_id` (`item_id`) -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `template_bionic_price__` --- - -DROP TABLE IF EXISTS `template_bionic_price__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `template_bionic_price__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `item_id` int(11) NOT NULL, - `rate` tinyint(3) unsigned NOT NULL, - `items` int(11) DEFAULT NULL, - `grouping` int(11) DEFAULT NULL, - `price` decimal(10,2) DEFAULT NULL, - UNIQUE KEY `warehouse_id` (`warehouse_id`,`item_id`,`rate`), - KEY `item_id` (`item_id`) USING BTREE -) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `thermograph` -- @@ -84360,52 +84055,6 @@ SET character_set_client = utf8; 1 AS `yearMonth` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `tipsa__` --- - -DROP TABLE IF EXISTS `tipsa__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tipsa__` ( - `kilos` tinyint(3) unsigned NOT NULL, - `importe` double unsigned NOT NULL, - `zona` tinyint(3) unsigned NOT NULL, - PRIMARY KEY (`kilos`,`zona`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `tmpNEWTARIFAS__` --- - -DROP TABLE IF EXISTS `tmpNEWTARIFAS__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tmpNEWTARIFAS__` ( - `Id_Cliente` int(11) NOT NULL, - `Cliente` varchar(50) NOT NULL, - `Consumo_medio_mensual` double(17,0) DEFAULT NULL, - `Tarifa_Actual` int(11) DEFAULT 0, - `Nueva_Tarifa` int(11) DEFAULT NULL, - `Id_Trabajador` int(11) DEFAULT 20, - PRIMARY KEY (`Id_Cliente`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `transport__` --- - -DROP TABLE IF EXISTS `transport__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `transport__` ( - `wday` tinyint(4) NOT NULL, - PRIMARY KEY (`wday`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `travel` -- @@ -84434,196 +84083,6 @@ SET character_set_client = utf8; 1 AS `awbFk` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `travel_pattern__` --- - -DROP TABLE IF EXISTS `travel_pattern__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `travel_pattern__` ( - `travel_pattern_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `week_start` tinyint(3) unsigned NOT NULL, - `week_end` tinyint(3) unsigned NOT NULL, - `warehouse_out` smallint(5) unsigned NOT NULL, - `warehouse_in` smallint(5) unsigned NOT NULL, - `agency_id` int(11) NOT NULL, - `day_out` tinyint(3) unsigned NOT NULL, - `duration` tinyint(3) unsigned NOT NULL, - `ref` varchar(20) NOT NULL, - `cargoSupplierFk` int(10) unsigned DEFAULT NULL, - `kg` decimal(10,0) unsigned DEFAULT NULL, - `travelFk` int(10) unsigned DEFAULT NULL COMMENT 'travel origen para clonar ademas sus entradas', - PRIMARY KEY (`travel_pattern_id`), - KEY `warehouse_out` (`warehouse_out`), - KEY `warehouse_in` (`warehouse_in`), - KEY `agency_id` (`agency_id`), - KEY `travel_pattern_ibfk_6_idx` (`cargoSupplierFk`), - KEY `travel_pattern_FK` (`travelFk`), - CONSTRAINT `travel_pattern_FK` FOREIGN KEY (`travelFk`) REFERENCES `vn`.`travel` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern___ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `travel_pattern_supplierFk` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `travel_reserve__` --- - -DROP TABLE IF EXISTS `travel_reserve__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `travel_reserve__` ( - `travel_reserve_id` int(11) NOT NULL AUTO_INCREMENT, - `travel_id` int(11) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `reserved` decimal(4,1) DEFAULT NULL, - `buyed` decimal(4,1) DEFAULT NULL, - `askingfor` decimal(4,1) DEFAULT NULL, - `odbc_date` timestamp NULL DEFAULT current_timestamp(), - `labeled` decimal(4,1) unsigned NOT NULL DEFAULT 0.0, - PRIMARY KEY (`Id_Trabajador`,`travel_id`), - UNIQUE KEY `travel_reserve_id_UNIQUE` (`travel_reserve_id`), - KEY `travel_travel_reserve_idx` (`travel_id`), - KEY `traveL_buyer_id_idx` (`Id_Trabajador`), - CONSTRAINT `travel_reserve___ibfk_1` FOREIGN KEY (`travel_id`) REFERENCES `vn`.`travel` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `trolley__` --- - -DROP TABLE IF EXISTS `trolley__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `trolley__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `ref` varchar(4) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unaryScanFilter__` --- - -DROP TABLE IF EXISTS `unaryScanFilter__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unaryScanFilter__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL, - `filter` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary__` --- - -DROP TABLE IF EXISTS `unary__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `parent` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `idunary_UNIQUE` (`id`), - KEY `unary_parent_idx` (`parent`), - CONSTRAINT `unary_parent` FOREIGN KEY (`parent`) REFERENCES `unary__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #7258 @deprecated 2023-12-13'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan__` --- - -DROP TABLE IF EXISTS `unary_scan__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan__` ( - `unary_id` int(11) NOT NULL, - `name` varchar(45) DEFAULT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - `type` set('BUYS','EXPEDITIONS') NOT NULL, - PRIMARY KEY (`unary_id`), - KEY `scan_unary_idx` (`unary_id`), - CONSTRAINT `unary_scan` FOREIGN KEY (`unary_id`) REFERENCES `unary__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line__` --- - -DROP TABLE IF EXISTS `unary_scan_line__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(45) NOT NULL, - `odbc_date` timestamp NOT NULL DEFAULT current_timestamp(), - `unary_id` int(11) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `id_UNIQUE` (`id`), - KEY `unary_line_idx` (`unary_id`), - CONSTRAINT `unary_line` FOREIGN KEY (`unary_id`) REFERENCES `unary_scan__` (`unary_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line_buy__` --- - -DROP TABLE IF EXISTS `unary_scan_line_buy__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line_buy__` ( - `scan_line_id` int(11) NOT NULL, - `Id_Article` int(11) NOT NULL, - PRIMARY KEY (`scan_line_id`), - UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), - KEY `Id_Article_buy_idx` (`Id_Article`), - CONSTRAINT `Id_Article_buy` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `scan_line_id_patriarcal` FOREIGN KEY (`scan_line_id`) REFERENCES `unary_scan_line__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_scan_line_expedition__` --- - -DROP TABLE IF EXISTS `unary_scan_line_expedition__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_scan_line_expedition__` ( - `scan_line_id` int(11) NOT NULL, - `expedition_id` int(11) NOT NULL, - PRIMARY KEY (`scan_line_id`), - UNIQUE KEY `scan_line_id_UNIQUE` (`scan_line_id`), - KEY `expedition_id_scan_idx` (`expedition_id`), - CONSTRAINT `expedition_id_scan` FOREIGN KEY (`expedition_id`) REFERENCES `vn`.`expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `unary_source__` --- - -DROP TABLE IF EXISTS `unary_source__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `unary_source__` ( - `name` varchar(100) NOT NULL, - PRIMARY KEY (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `v_Articles_botanical` -- @@ -84743,90 +84202,6 @@ SET character_set_client = utf8; 1 AS `critical` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `viaxpress__` --- - -DROP TABLE IF EXISTS `viaxpress__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `viaxpress__` ( - `codigo_postal` varchar(5) NOT NULL, - `zona` tinyint(4) NOT NULL DEFAULT 2, - `m_t` tinyint(4) NOT NULL DEFAULT 0, - `POBLACION` varchar(25) NOT NULL, - `PROVINCIA` varchar(20) NOT NULL, - PRIMARY KEY (`codigo_postal`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_filtro__` --- - -DROP TABLE IF EXISTS `warehouse_filtro__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_filtro__` ( - `warehouse_id` smallint(6) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `ok` tinyint(3) unsigned DEFAULT 1, - PRIMARY KEY (`Id_Trabajador`,`warehouse_id`), - KEY `wh_worker_idx` (`Id_Trabajador`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_group__` --- - -DROP TABLE IF EXISTS `warehouse_group__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_group__` ( - `warehouse_alias_id` smallint(5) unsigned NOT NULL DEFAULT 22, - `warehouse_id` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`warehouse_alias_id`,`warehouse_id`), - KEY `warehosue_group_ware_idx` (`warehouse_id`), - CONSTRAINT `warehosue_group_ware` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `warehouse_group_alias` FOREIGN KEY (`warehouse_alias_id`) REFERENCES `vn`.`warehouseAlias__` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_joined__` --- - -DROP TABLE IF EXISTS `warehouse_joined__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_joined__` ( - `warehouse_id` smallint(5) unsigned NOT NULL, - `warehouse_alias_id` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`warehouse_id`,`warehouse_alias_id`), - CONSTRAINT `warehouse_joined___ibfk_3` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `warehouse_lc__` --- - -DROP TABLE IF EXISTS `warehouse_lc__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `warehouse_lc__` ( - `whin` smallint(6) unsigned NOT NULL, - `whout` smallint(6) unsigned NOT NULL, - `m3` double NOT NULL DEFAULT 15, - `days` int(11) NOT NULL DEFAULT 1, - PRIMARY KEY (`whin`,`whout`), - KEY `whout_wh_idx` (`whout`), - CONSTRAINT `whin_wh` FOREIGN KEY (`whin`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, - CONSTRAINT `whout_wh` FOREIGN KEY (`whout`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `warehouse_pickup` -- @@ -84840,71 +84215,6 @@ SET character_set_client = utf8; 1 AS `agency_id` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `wh_selection__` --- - -DROP TABLE IF EXISTS `wh_selection__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `wh_selection__` ( - `Id_Trabajador` int(10) unsigned NOT NULL, - `warehouse_id` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`Id_Trabajador`,`warehouse_id`), - KEY `Trabajadores` (`Id_Trabajador`), - KEY `Warehouse` (`warehouse_id`), - CONSTRAINT `Trabajadores` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-11-28;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `widget__` --- - -DROP TABLE IF EXISTS `widget__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `widget__` ( - `widget_id` int(11) NOT NULL, - `chr` int(11) NOT NULL, - PRIMARY KEY (`widget_id`), - UNIQUE KEY `chr_UNIQUE` (`chr`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `wks__` --- - -DROP TABLE IF EXISTS `wks__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `wks__` ( - `wk` int(10) unsigned NOT NULL, - `yr` int(10) unsigned NOT NULL, - `vwk` int(10) unsigned NOT NULL, - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `comments` text DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `zones__` --- - -DROP TABLE IF EXISTS `zones__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `zones__` ( - `zone_id` tinyint(4) NOT NULL, - `name` varchar(45) NOT NULL, - `printingOrder` int(11) NOT NULL DEFAULT 0, - PRIMARY KEY (`zone_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='refs #6372 @deprecated 2023-12-13;'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Dumping events for database 'vn2008' -- @@ -85779,7 +85089,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,`s`.`extension` AS `regexten`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`incomingLimit` AS `incominglimit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`directMedia` AS `directmedia`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`c`.`disallow` AS `disallow`,`c`.`allow` AS `allow`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; +/*!50001 VIEW `sipConf` AS select `s`.`user_id` AS `id`,`s`.`extension` AS `name`,`s`.`extension` AS `regexten`,NULL AS `callbackextension`,`s`.`md5Secret` AS `md5secret`,`u`.`nickname` AS `callerid`,`c`.`host` AS `host`,`c`.`deny` AS `deny`,`c`.`permit` AS `permit`,`c`.`type` AS `type`,`c`.`context` AS `context`,`c`.`call-limit` AS `call-limit`,`c`.`pickupGroup` AS `pickupgroup`,`c`.`directMedia` AS `directmedia`,`c`.`insecure` AS `insecure`,`c`.`transport` AS `transport`,`c`.`nat` AS `nat`,`c`.`disallow` AS `disallow`,`c`.`allow` AS `allow`,`r`.`ipAddr` AS `ipaddr`,`r`.`regSeconds` AS `regseconds`,`r`.`port` AS `port`,`r`.`defaultUser` AS `defaultuser`,`r`.`userAgent` AS `useragent`,`r`.`lastMs` AS `lastms`,`r`.`fullContact` AS `fullcontact`,`r`.`regServer` AS `regserver` from (((`pbx`.`sip` `s` join `account`.`user` `u` on(`u`.`id` = `s`.`user_id`)) left join `pbx`.`sipReg` `r` on(`s`.`user_id` = `r`.`userId`)) join `pbx`.`sipConfig` `c`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85965,7 +85275,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bufferDayMinute` AS select `b`.`id` AS `bufferFk`,`e`.`id` AS `expeditionFk`,`srt`.`dayMinute`(ifnull(`et`.`eta`,`z`.`hour`)) AS `dayMinute`,`e`.`position` AS `position`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) minute) AS `ETD`,`e2`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`es`.`description` AS `expeditionState` from ((((((((`srt`.`buffer` `b` left join `srt`.`expedition` `e` on(`b`.`id` = `e`.`bufferFk`)) left join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) left join `vn`.`expedition` `e2` on(`e2`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`e2`.`ticketFk` = `t`.`id`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) where `b`.`isActive` <> 0 */; +/*!50001 VIEW `bufferDayMinute` AS select `b`.`id` AS `bufferFk`,`e`.`id` AS `expeditionFk`,`srt`.`dayMinute`(ifnull(`rs`.`eta`,`z`.`hour`)) AS `dayMinute`,`e`.`position` AS `position`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) minute) AS `ETD`,`e2`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`es`.`description` AS `expeditionState` from ((((((((`srt`.`buffer` `b` left join `srt`.`expedition` `e` on(`b`.`id` = `e`.`bufferFk`)) left join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) left join `vn`.`expedition` `e2` on(`e2`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`e2`.`ticketFk` = `t`.`id`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`expeditionTruckFk` = `rs`.`id`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) where `b`.`isActive` <> 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86001,7 +85311,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `bufferStock` AS select `e`.`id` AS `expeditionFk`,`e`.`bufferFk` AS `bufferFk`,`e`.`position` AS `position`,`srt`.`dayMinute`(ifnull(`et`.`eta`,`z`.`hour`)) AS `dayMinute`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `eta`,`ve`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`et`.`description` AS `truck`,`es`.`description` AS `expeditionState`,`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,`b`.`isActive` AS `isActive`,if(`et`.`id` is null,`c`.`bufferDefault`,`et`.`bufferFk`) AS `bufferTruck`,`bt`.`typeName` AS `typeName`,`rm`.`bufferFk` AS `routeBuffer` from (((((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`buffer` `b` on(`b`.`id` = `e`.`bufferFk`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) join `srt`.`config` `c`) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) where `bt`.`typeName` <> 'DISABLED' */; +/*!50001 VIEW `bufferStock` AS select `e`.`id` AS `expeditionFk`,`e`.`bufferFk` AS `bufferFk`,`e`.`position` AS `position`,`srt`.`dayMinute`(ifnull(`rs`.`eta`,`z`.`hour`)) AS `dayMinute`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `eta`,`ve`.`ticketFk` AS `ticketFk`,ifnull(`t`.`routeFk`,`t`.`agencyModeFk`) AS `routeFk`,`z`.`name` AS `zonaTicket`,`rs`.`description` AS `truck`,`es`.`description` AS `expeditionState`,`b`.`hasWorkerWaiting` AS `hasWorkerWaiting`,`b`.`isActive` AS `isActive`,if(`rs`.`id` is null,`c`.`bufferDefault`,`rs`.`bufferFk`) AS `bufferTruck`,`bt`.`typeName` AS `typeName`,`rm`.`bufferFk` AS `routeBuffer` from (((((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) join `srt`.`expeditionState` `es` on(`es`.`id` = `e`.`stateFk`)) join `srt`.`buffer` `b` on(`b`.`id` = `e`.`bufferFk`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`expeditionTruckFk` = `rs`.`id`)) join `srt`.`config` `c`) join `srt`.`bufferType` `bt` on(`bt`.`id` = `b`.`typeFk`)) where `bt`.`typeName` <> 'DISABLED' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86091,7 +85401,7 @@ USE `srt`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `upperStickers` AS select `e`.`id` AS `expeditionFk`,`e`.`id` MOD 10000 AS `expedition`,ifnull(`et`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `ETD`,`ve`.`ticketFk` AS `ticketFk`,right(ifnull(`t`.`routeFk`,`t`.`agencyModeFk`),3) AS `routeFk`,`z`.`name` AS `zonaTicket`,`et`.`description` AS `truck`,`epo`.`workerCode` AS `worker`,`p`.`name` AS `labeler`,`ve`.`counter` AS `expeditionCounter`,`vn`.`ticketTotalVolume`(`t`.`id`) AS `m3`,`t`.`clientFk` AS `clientFk` from (((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`expeditionTruck` `et` on(`rm`.`expeditionTruckFk` = `et`.`id`)) join `dipole`.`expedition_PrintOut` `epo` on(`epo`.`expeditionFk` = `e`.`id`)) join `vn`.`printer` `p` on(`p`.`id` = `epo`.`printerFk`)) */; +/*!50001 VIEW `upperStickers` AS select `e`.`id` AS `expeditionFk`,`e`.`id` MOD 10000 AS `expedition`,ifnull(`rs`.`eta`,`util`.`VN_CURDATE`() + interval `srt`.`dayMinute`(`z`.`hour`) + 120 minute) AS `ETD`,`ve`.`ticketFk` AS `ticketFk`,right(ifnull(`t`.`routeFk`,`t`.`agencyModeFk`),3) AS `routeFk`,`z`.`name` AS `zonaTicket`,`rs`.`description` AS `truck`,`epo`.`workerCode` AS `worker`,`p`.`name` AS `labeler`,`ve`.`counter` AS `expeditionCounter`,`vn`.`ticketTotalVolume`(`t`.`id`) AS `m3`,`t`.`clientFk` AS `clientFk` from (((((((`srt`.`expedition` `e` left join `vn`.`expedition` `ve` on(`ve`.`id` = `e`.`id`)) left join `vn`.`ticket` `t` on(`t`.`id` = `ve`.`ticketFk`)) left join `vn`.`zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `vn`.`routesMonitor` `rm` on(`t`.`routeFk` = `rm`.`routeFk`)) left join `vn`.`roadmapStop` `rs` on(`rm`.`expeditionTruckFk` = `rs`.`id`)) join `dipole`.`expedition_PrintOut` `epo` on(`epo`.`expeditionFk` = `e`.`id`)) join `vn`.`printer` `p` on(`p`.`id` = `epo`.`printerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86498,42 +85808,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `exchangeReportSource` --- - -/*!50001 DROP VIEW IF EXISTS `exchangeReportSource`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(ifnull(`rr`.`value`,`rrc`.`simulatedValue`) as decimal(10,4)) AS `rateECB` from ((`exchangeReportSourcePrevious` `e` left join `referenceRate` `rr` on(`rr`.`dated` = `e`.`dated`)) join `referenceRateConfig` `rrc` on(1)) group by `e`.`dated` order by `e`.`dated` */; -/*!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 `exchangeReportSourcePrevious` --- - -/*!50001 DROP VIEW IF EXISTS `exchangeReportSourcePrevious`*/; -/*!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_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSourcePrevious` AS select `exchangeInsuranceIn`.`dated` AS `dated`,`exchangeInsuranceIn`.`amount` AS `amountIn`,`exchangeInsuranceIn`.`rate` AS `rateIn`,0.00 AS `amountOut`,0.00 AS `rateOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceIn` union all select `exchangeInsuranceOut`.`received` AS `received`,0.00 AS `amountIn`,0.00 AS `ratedIn`,`exchangeInsuranceOut`.`divisa` AS `amountOut`,`exchangeInsuranceOut`.`rate` AS `ratedOut`,0.00 AS `amountEntry`,0.00 AS `rateEntry` from `exchangeInsuranceOut` union all select `exchangeInsuranceEntry`.`dated` AS `dated`,0.00 AS `amountIn`,0.00 AS `ratedIn`,0.00 AS `amountOut`,0.00 AS `ratedOut`,`exchangeInsuranceEntry`.`Dolares` AS `amountEntry`,`exchangeInsuranceEntry`.`rate` AS `rateEntry` from `exchangeInsuranceEntry` */; -/*!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 `expeditionCommon` -- @@ -86547,7 +85821,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionCommon` AS select `et`.`id` AS `truckFk`,`et`.`eta` AS `eta`,ifnull(ucase(`et`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`expeditionTruck` `et` left join `routesMonitor` `r` on(`et`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `et`.`eta` >= `util`.`VN_CURDATE`() */; +/*!50001 VIEW `expeditionCommon` AS select `rs`.`id` AS `truckFk`,`rs`.`eta` AS `eta`,ifnull(ucase(`rs`.`description`),'SIN ESCANEAR') AS `description`,`es`.`palletFk` AS `palletFk`,`t`.`routeFk` AS `routeFk`,`es`.`id` AS `scanFk`,`e`.`id` AS `expeditionFk`,`r`.`expeditionTruckFk` AS `expeditionTruckFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`roadmapStop` `rs` left join `routesMonitor` `r` on(`rs`.`id` = `r`.`expeditionTruckFk`)) left join `ticket` `t` on(`r`.`routeFk` = `t`.`routeFk`)) left join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`e`.`id` = `es`.`expeditionFk`)) left join `expeditionPallet` `ep` on(`es`.`palletFk` = `ep`.`id`)) where `rs`.`eta` >= `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86565,7 +85839,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `et2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`expeditionTruck` `et` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `expeditionTruck` `et2` on(`et2`.`id` = `rm`.`expeditionTruckFk`)) group by `ep`.`id`,`t`.`routeFk` */; +/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`expeditionTruckFk`)) group by `ep`.`id`,`t`.`routeFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86583,7 +85857,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */; +/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`expeditionTruckFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86619,7 +85893,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionScan_Monitor` AS select `et`.`id` AS `truckFk`,`et`.`eta` AS `ETD`,`et`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`expeditionTruck` `et` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `et`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; +/*!50001 VIEW `expeditionScan_Monitor` AS select `rs`.`id` AS `truckFk`,`rs`.`eta` AS `ETD`,`rs`.`description` AS `description`,`ep`.`id` AS `palletFk`,`ep`.`position` AS `position`,`ep`.`built` AS `built`,`es`.`id` AS `scanFk`,`es`.`expeditionFk` AS `expeditionFk`,`es`.`scanned` AS `scanned` from ((`roadmapStop` `rs` left join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) left join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86637,7 +85911,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',right(`t`.`routeFk`,3),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`et`.`description`,replace(`am`.`name`,'ZONA ','Z')),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from (((((((((((`expedition` `e` join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) left join `beach` `b` on(`b`.`code` = `rm`.`beachFk`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `agencyMode` `am` on(`am`.`id` = `r`.`agencyModeFk`)) join `client` `c` on(`c`.`id` = `a`.`clientFk`)) join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) */; +/*!50001 VIEW `expeditionSticker` AS select `e`.`id` AS `expeditionFk`,`e`.`ticketFk` AS `ticketFk`,`t`.`addressFk` AS `addressFk`,`t`.`clientFk` AS `clientFk`,`a`.`street` AS `street`,`a`.`postalCode` AS `postalCode`,`a`.`city` AS `city`,`a`.`nickname` AS `nickname`,concat('R(',right(`t`.`routeFk`,3),')') AS `routeFk`,`rm`.`beachFk` AS `beachFk`,if(`t`.`routeFk`,ifnull(`rs`.`description`,replace(`am`.`name`,'ZONA ','Z')),`z`.`name`) AS `zona`,`p`.`name` AS `province`,ifnull(`c`.`mobile`,ifnull(`a`.`mobile`,ifnull(`c`.`phone`,`a`.`phone`))) AS `phone`,`w`.`code` AS `workerCode` from (((((((((((`expedition` `e` join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`expeditionTruckFk`)) left join `beach` `b` on(`b`.`code` = `rm`.`beachFk`)) left join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) left join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `agencyMode` `am` on(`am`.`id` = `r`.`agencyModeFk`)) join `client` `c` on(`c`.`id` = `a`.`clientFk`)) join `worker` `w` on(`w`.`id` = `e`.`workerFk`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86655,7 +85929,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`et`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `expeditionTruck` `et` on(`et`.`id` = `rm`.`expeditionTruckFk`)) where `e`.`id` is null and `et`.`eta` > `util`.`VN_CURDATE`() */; +/*!50001 VIEW `expeditionTicket_NoBoxes` AS select `t`.`id` AS `ticketFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`routeFk` AS `routeFk`,`rs`.`description` AS `description` from (((`ticket` `t` left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) join `routesMonitor` `rm` on(`rm`.`routeFk` = `t`.`routeFk`)) join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`expeditionTruckFk`)) where `e`.`id` is null and `rs`.`eta` > `util`.`VN_CURDATE`() */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86678,6 +85952,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `expeditionTruck` +-- + +/*!50001 DROP VIEW IF EXISTS `expeditionTruck`*/; +/*!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_unicode_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `expeditionTruck` AS select `rs`.`id` AS `id`,`rs`.`roadmapFk` AS `roadmapFk`,`rs`.`warehouseFk` AS `warehouseFk`,`rs`.`eta` AS `eta`,`rs`.`description` AS `description`,`rs`.`bufferFk` AS `bufferFk`,`rs`.`created` AS `created`,`rs`.`userFk` AS `userFk` from `roadmapStop` `rs` */; +/*!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 `expeditionTruck_Control` -- @@ -86727,7 +86019,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `eta`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`et`.`description` AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`expeditionCommon` `e` left join `expeditionTruck` `et` on(`et`.`id` = `e`.`expeditionTruckFk`)) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`palletFk` */; +/*!50001 VIEW `expeditionTruck_Control_Detail_Pallet` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `eta`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,`e`.`routeFk` AS `route`,count(distinct `e`.`scanFk`) AS `scans`,`rs`.`description` AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,`e`.`expeditionTruckFk` AS `expeditionTruckFk`,max(`e`.`lastPacked`) AS `lastPacked` from (`expeditionCommon` `e` left join `roadmapStop` `rs` on(`rs`.`id` = `e`.`expeditionTruckFk`)) group by `e`.`truckFk`,`e`.`palletFk`,`e`.`routeFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`palletFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87501,7 +86793,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `routesControl` AS select `t`.`routeFk` AS `routeFk`,count(`e`.`id`) AS `expeditions`,count(`es`.`id`) AS `scanned`,count(distinct `es`.`palletFk`) AS `pallets`,max(`es`.`scanned`) AS `lastScanned`,max(`et`.`description`) AS `description`,max(`et`.`eta`) AS `eta` from ((((`ticket` `t` join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `expeditionPallet` `ep` on(`ep`.`id` = `es`.`palletFk`)) left join `expeditionTruck` `et` on(`et`.`id` = `ep`.`truckFk`)) where `t`.`shipped` >= `util`.`VN_CURDATE`() and `t`.`routeFk` <> 0 group by `t`.`routeFk` order by max(`et`.`eta`) */; +/*!50001 VIEW `routesControl` AS select `t`.`routeFk` AS `routeFk`,count(`e`.`id`) AS `expeditions`,count(`es`.`id`) AS `scanned`,count(distinct `es`.`palletFk`) AS `pallets`,max(`es`.`scanned`) AS `lastScanned`,max(`rs`.`description`) AS `description`,max(`rs`.`eta`) AS `eta` from ((((`ticket` `t` join `expedition` `e` on(`t`.`id` = `e`.`ticketFk`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) left join `expeditionPallet` `ep` on(`ep`.`id` = `es`.`palletFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `ep`.`truckFk`)) where `t`.`shipped` >= `util`.`VN_CURDATE`() and `t`.`routeFk` <> 0 group by `t`.`routeFk` order by max(`rs`.`eta`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87609,7 +86901,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) * `z`.`inflation` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,round(`ic`.`cm3delivery` * `s`.`quantity` / 1000,0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,`t`.`landed` AS `landed`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `volume`,`s`.`quantity` * `ic`.`grams` / 1000 AS `physicalWeight`,`s`.`quantity` * `ic`.`cm3delivery` * greatest(`ic`.`grams` / `ic`.`cm3delivery`,`vc`.`aerealVolumetricDensity`) / 1000000 AS `weight`,`s`.`quantity` * `ic`.`cm3delivery` / 1000000 AS `physicalVolume`,`s`.`quantity` * `ic`.`cm3delivery` * ifnull(`t`.`zonePrice` - ifnull(`t`.`zoneBonus`,0),`z`.`price` - `z`.`bonus`) / (`vc`.`standardFlowerBox` * 1000) * `z`.`inflation` AS `freight`,`t`.`zoneFk` AS `zoneFk`,`t`.`clientFk` AS `clientFk`,`s`.`isPicked` AS `isPicked`,`s`.`quantity` * `s`.`price` * (100 - `s`.`discount`) / 100 AS `eurosValue`,`i`.`itemPackingTypeFk` AS `itemPackingTypeFk` from (((((`sale` `s` join `item` `i` on(`i`.`id` = `s`.`itemFk`)) join `ticket` `t` on(`t`.`id` = `s`.`ticketFk`)) join `zone` `z` on(`z`.`id` = `t`.`zoneFk`)) join `volumeConfig` `vc`) join `itemCost` `ic` FORCE INDEX (PRIMARY) on(`ic`.`itemFk` = `s`.`itemFk` and `ic`.`warehouseFk` = `t`.`warehouseFk`)) where `s`.`quantity` > 0 */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87627,7 +86919,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`country` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; +/*!50001 VIEW `saleVolume_Today_VNH` AS select `t`.`nickname` AS `Cliente`,`p`.`name` AS `Provincia`,`c`.`name` AS `Pais`,cast(sum(`sv`.`volume`) as decimal(5,1)) AS `volume` from (((((`saleVolume` `sv` join `ticket` `t` on(`t`.`id` = `sv`.`ticketFk`)) join `address` `a` on(`a`.`id` = `t`.`addressFk`)) join `province` `p` on(`p`.`id` = `a`.`provinceFk`)) join `country` `c` on(`c`.`id` = `p`.`countryFk`)) join `warehouse` `w` on(`w`.`id` = `t`.`warehouseFk`)) where `w`.`name` = 'VNH' and `t`.`shipped` between `util`.`VN_CURDATE`() and `util`.`dayend`(`util`.`VN_CURDATE`()) group by `t`.`nickname`,`p`.`name` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88276,12 +87568,12 @@ USE `vn2008`; /*!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 = utf8mb3 */; -/*!50001 SET character_set_results = utf8mb3 */; -/*!50001 SET collation_connection = utf8mb3_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Compres` AS select `c`.`id` AS `Id_Compra`,`c`.`entryFk` AS `Id_Entrada`,`c`.`itemFk` AS `Id_Article`,`c`.`buyingValue` AS `Costefijo`,`c`.`quantity` AS `Cantidad`,`c`.`packagingFk` AS `Id_Cubo`,`c`.`stickers` AS `Etiquetas`,`c`.`freightValue` AS `Portefijo`,`c`.`packageValue` AS `Embalajefijo`,`c`.`comissionValue` AS `Comisionfija`,`c`.`packing` AS `Packing`,`c`.`grouping` AS `grouping`,`c`.`groupingMode` AS `caja`,`c`.`location` AS `Nicho`,`c`.`price1` AS `Tarifa1`,`c`.`price2` AS `Tarifa2`,`c`.`price3` AS `Tarifa3`,`c`.`minPrice` AS `PVP`,`c`.`printedStickers` AS `Vida`,`c`.`isChecked` AS `punteo`,`c`.`ektFk` AS `buy_edi_id`,`c`.`created` AS `odbc_date`,`c`.`isIgnored` AS `Novincular`,`c`.`isPickedOff` AS `isPickedOff`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`weight` AS `weight`,`c`.`dispatched` AS `dispatched`,`c`.`containerFk` AS `container_id`,`c`.`itemOriginalFk` AS `itemOriginalFk` from `vn`.`buy` `c` */; +/*!50001 VIEW `Compres` AS select `c`.`id` AS `Id_Compra`,`c`.`entryFk` AS `Id_Entrada`,`c`.`itemFk` AS `Id_Article`,`c`.`buyingValue` AS `Costefijo`,`c`.`quantity` AS `Cantidad`,`c`.`packagingFk` AS `Id_Cubo`,`c`.`stickers` AS `Etiquetas`,`c`.`freightValue` AS `Portefijo`,`c`.`packageValue` AS `Embalajefijo`,`c`.`comissionValue` AS `Comisionfija`,`c`.`packing` AS `Packing`,`c`.`grouping` AS `grouping`,`c`.`groupingMode` AS `caja`,`c`.`location` AS `Nicho`,`c`.`price1` AS `Tarifa1`,`c`.`price2` AS `Tarifa2`,`c`.`price3` AS `Tarifa3`,`c`.`minPrice` AS `PVP`,`c`.`printedStickers` AS `Vida`,`c`.`isChecked` AS `punteo`,`c`.`ektFk` AS `buy_edi_id`,`c`.`created` AS `odbc_date`,`c`.`isIgnored` AS `Novincular`,`c`.`isPickedOff` AS `isPickedOff`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`weight` AS `weight`,`c`.`dispatched` AS `dispatched`,`c`.`itemOriginalFk` AS `itemOriginalFk` from `vn`.`buy` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88569,7 +87861,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Paises` AS select `c`.`id` AS `Id`,`c`.`country` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn`.`country` `c` */; +/*!50001 VIEW `Paises` AS select `c`.`id` AS `Id`,`c`.`name` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice` from `vn`.`country` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88605,7 +87897,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`isFarmer` AS `Agricola`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; +/*!50001 VIEW `Proveedores` AS select `s`.`id` AS `Id_Proveedor`,`s`.`name` AS `Proveedor`,`s`.`account` AS `cuenta`,`s`.`countryFk` AS `pais_id`,`s`.`nif` AS `NIF`,`s`.`phone` AS `Telefono`,`s`.`retAccount` AS `cuentaret`,`s`.`commission` AS `ComisionProveedor`,`s`.`created` AS `odbc_time`,`s`.`postcodeFk` AS `postcode_id`,`s`.`isActive` AS `active`,`s`.`street` AS `Domicilio`,`s`.`city` AS `Localidad`,`s`.`provinceFk` AS `province_id`,`s`.`postCode` AS `codpos`,`s`.`payMethodFk` AS `pay_met_id`,`s`.`payDemFk` AS `pay_dem_id`,`s`.`nickname` AS `Alias`,`s`.`isOfficial` AS `oficial`,`s`.`workerFk` AS `workerFk`,`s`.`payDay` AS `pay_day`,`s`.`isReal` AS `serious`,`s`.`note` AS `notas`,`s`.`taxTypeSageFk` AS `taxTypeSageFk`,`s`.`withholdingSageFk` AS `withholdingSageFk`,`s`.`isTrucker` AS `isTrucker`,`s`.`transactionTypeSageFk` AS `transactionTypeSageFk`,`s`.`supplierActivityFk` AS `supplierActivityFk`,`s`.`healthRegister` AS `healthRegister`,`s`.`isPayMethodChecked` AS `isPayMethodChecked` from `vn`.`supplier` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89037,7 +88329,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `albaran` AS select `dn`.`id` AS `albaran_id`,`dn`.`ref` AS `ref`,`dn`.`note` AS `note`,`dn`.`shipped` AS `fecha`,`dn`.`landed` AS `fecha_entrega`,`dn`.`amount` AS `valor`,`dn`.`supplierFk` AS `Id_Proveedor`,`dn`.`companyFk` AS `empresa_id`,`dn`.`warehouseFk` AS `warehouse_id`,`dn`.`stateFk` AS `albaran_state_id`,`dn`.`workerFk` AS `Id_Trabajador`,`dn`.`supervisorFk` AS `Id_Responsable`,`dn`.`departmentFk` AS `department_id`,`dn`.`invoiceInFk` AS `recibida_id`,`dn`.`farmingFk` AS `farmingFk` from `vn`.`deliveryNote` `dn` */; +/*!50001 VIEW `albaran` AS select `dn`.`id` AS `albaran_id`,`dn`.`ref` AS `ref`,`dn`.`note` AS `note`,`dn`.`shipped` AS `fecha`,`dn`.`landed` AS `fecha_entrega`,`dn`.`amount` AS `valor`,`dn`.`supplierFk` AS `Id_Proveedor`,`dn`.`companyFk` AS `empresa_id`,`dn`.`warehouseFk` AS `warehouse_id`,`dn`.`stateFk` AS `albaran_state_id`,`dn`.`workerFk` AS `Id_Trabajador`,`dn`.`supervisorFk` AS `Id_Responsable`,`dn`.`departmentFk` AS `department_id`,`dn`.`invoiceInFk` AS `recibida_id` from `vn`.`deliveryNote` `dn` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90563,4 +89855,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-05-14 6:26:25 +-- Dump completed on 2024-05-28 6:58:24 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 251e46260..fd1042138 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -3789,7 +3789,7 @@ DELIMITER ;; BEFORE INSERT ON `country` FOR EACH ROW BEGIN - SET NEW.geoFk = zoneGeo_new('country', NEW.country, NULL); + SET NEW.geoFk = zoneGeo_new('country', NEW.name, NULL); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3811,14 +3811,17 @@ DELIMITER ;; BEGIN UPDATE sage.Naciones SET countryFk = NEW.id - WHERE Nacion = NEW.country; + WHERE Nacion = NEW.name; IF ROW_COUNT() = 0 THEN CALL mail_insert( 'cau@verdnatura.es', NULL, 'Actualizar tabla sage.Naciones', - CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.country, ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) + CONCAT('Se ha insertado un nuevo país en la tabla vn.conuntry. + Para el correcto funcionamiento del sistema \n\t\t\t\tde contabilidad es necesario actualizar la columna + sage.Naciones.countryFk con el valor del nuevo país. \n\t\t\t Hay que buscar el nuevo país: ', NEW.name, + ' en la tabla sage.Naciones y actualizar el campo sage.Naciones.countryFk con el valor ', NEW.id) ); END IF; END */;; @@ -3862,8 +3865,8 @@ DELIMITER ;; AFTER UPDATE ON `country` FOR EACH ROW BEGIN - IF !(OLD.country <=> NEW.country) THEN - UPDATE zoneGeo SET `name` = NEW.country + IF !(OLD.name <=> NEW.name) THEN + UPDATE zoneGeo SET `name` = NEW.name WHERE id = NEW.geoFk; END IF; END */;; @@ -4325,10 +4328,32 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_afterInsert` + AFTER INSERT ON `deviceProductionUser` + FOR EACH ROW +BEGIN + CALL worker_checkMultipleDevice(NEW.userFk); +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_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`deviceProductionUser_beforeUpdate` BEFORE UPDATE ON `deviceProductionUser` FOR EACH ROW BEGIN + + CALL worker_checkMultipleDevice(NEW.userFk); SET NEW.editorFk = account.myUser_getId(); END */;; DELIMITER ; @@ -5060,50 +5085,6 @@ BEGIN SET e.stateTypeFk = NEW.typeFk WHERE e.id = NEW.expeditionFk; -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_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeInsert` - BEFORE INSERT ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - -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_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeUpdate` - BEFORE UPDATE ON `expeditionTruck` - FOR EACH ROW -BEGIN - - SET NEW.description = UCASE(NEW.description); - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6796,94 +6777,95 @@ DELIMITER ;; BEFORE INSERT ON `payment` FOR EACH ROW BEGIN - DECLARE cuenta_banco,cuenta_proveedor DOUBLE; - DECLARE vNewBookEntry INT; - DECLARE bolCASH BOOLEAN; - DECLARE isSupplierActive BOOLEAN; + DECLARE vBankAccount DOUBLE; + DECLARE vSupplierAccount DOUBLE; + DECLARE vNewBookEntry INT; + DECLARE vIsCash BOOLEAN; + DECLARE vIsSupplierActive BOOLEAN; - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH - SELECT (at2.code = 'cash') INTO bolCASH - FROM accounting a - JOIN accountingType at2 ON at2.id = a.accountingTypeFk - WHERE a.id = NEW.bankFk; + -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH + SELECT (at2.code = 'cash') INTO vIsCash + FROM accounting a + JOIN accountingType at2 ON at2.id = a.accountingTypeFk + WHERE a.id = NEW.bankFk; - IF bolCASH THEN - - SELECT account INTO cuenta_banco - FROM accounting - WHERE id = NEW.bankFk; - - SELECT account INTO cuenta_proveedor - FROM supplier - WHERE id = NEW.supplierFk; + IF vIsCash THEN + SELECT account INTO vBankAccount + FROM accounting + WHERE id = NEW.bankFk; - CALL ledger_next(vNewBookEntry); - - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - SUBCTA, - CONTRA, - NEW.concept, - EURODEBE, - EUROHABER, - NEW.companyFk - FROM ( SELECT cuenta_banco SUBCTA, - cuenta_proveedor CONTRA, - 0 EURODEBE, - NEW.amount + NEW.bankingFees EUROHABER - UNION ALL - SELECT cuenta_proveedor SUBCTA, - cuenta_banco CONTRA, - NEW.amount EURODEBE, - 0 EUROHABER) gf; - - IF NEW.bankingFees <> 0 THEN - INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - CONCEPTO, - EURODEBE, - EUROHABER, - empresa_id) - SELECT vNewBookEntry, - NEW.received, - IF(c.id = 1,6260000002, - IF(CEE = 1,6260000003,6260000004)), - cuenta_banco, - NEW.concept, - NEW.bankingFees, - 0, - NEW.companyFk - FROM supplier s - JOIN country c ON s.countryFk = c.id - WHERE s.id = NEW.supplierFk; - END IF; - END IF; - - SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); - - SELECT isActive INTO isSupplierActive + SELECT account INTO vSupplierAccount FROM supplier WHERE id = NEW.supplierFk; - - IF isSupplierActive = FALSE THEN - CALL util.throw('SUPPLIER_INACTIVE'); - END IF; - - IF ISNULL(NEW.workerFk) THEN - SET NEW.workerFk = account.myUser_getId(); - END IF; - - END */;; + + CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry); + + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + SUBCTA, + CONTRA, + NEW.concept, + EURODEBE, + EUROHABER, + NEW.companyFk + FROM (SELECT vBankAccount SUBCTA, + vSupplierAccount CONTRA, + 0 EURODEBE, + NEW.amount + NEW.bankingFees EUROHABER + UNION ALL + SELECT vSupplierAccount SUBCTA, + vBankAccount CONTRA, + NEW.amount EURODEBE, + 0 EUROHABER) gf; + + IF NEW.bankingFees <> 0 THEN + INSERT INTO XDiario ( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + CONCEPTO, + EURODEBE, + EUROHABER, + empresa_id) + SELECT vNewBookEntry, + NEW.received, + IF(c.id = 1,6260000002, + IF(CEE = 1,6260000003,6260000004)), + vBankAccount, + NEW.concept, + NEW.bankingFees, + 0, + NEW.companyFk + FROM supplier s + JOIN country c ON s.countryFk = c.id + WHERE s.id = NEW.supplierFk; + END IF; + END IF; + + SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); + + SELECT isActive INTO vIsSupplierActive + FROM supplier + WHERE id = NEW.supplierFk; + + IF vIsSupplierActive = FALSE THEN + CALL util.throw('SUPPLIER_INACTIVE'); + END IF; + + IF ISNULL(NEW.workerFk) THEN + SET NEW.workerFk = account.myUser_getId(); + END IF; +END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET character_set_client = @saved_cs_client */ ; @@ -7472,6 +7454,48 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeInsert` + BEFORE INSERT ON `roadmapStop` FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +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_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`expeditionTruck_beforeUpdate` + BEFORE UPDATE ON `roadmapStop` FOR EACH ROW +BEGIN + + SET NEW.description = UCASE(NEW.description); + +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_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`route_beforeInsert` BEFORE INSERT ON `route` FOR EACH ROW @@ -8961,6 +8985,8 @@ BEGIN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; + + CALL ticket_doCmr(NEW.id); END IF; END */;; DELIMITER ; @@ -9318,7 +9344,6 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9339,7 +9364,6 @@ DELIMITER ;; FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - CALL ticketRefund_beforeUpsert(NEW.refundTicketFk, NEW.originalTicketFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9655,11 +9679,6 @@ BEGIN `changedModel` = 'TicketTracking', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL util.debugAdd('deletedState', - CONCAT('interFk: ', OLD.id, - ' ticketFk: ', OLD.ticketFk, - ' stateFk: ', OLD.stateFk)); SELECT i.ticketFk, i.id, s.`name` INTO vTicketFk, vTicketTrackingFk, vStateName @@ -10805,4 +10824,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-05-14 6:26:46 +-- Dump completed on 2024-05-28 6:58:42 diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f82f84e59..55f79220e 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3788,14 +3788,22 @@ INSERT INTO vn.workerTeam(id, team, workerFk) VALUES (8, 1, 19); -INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) +INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; +INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES + ('1M', 'M', 1), + ('2M', 'M', 9), + ('3M', 'M', NULL), + ('4M', 'M', NULL), + ('1F', 'F', 1110), + ('2F', 'F', NULL), + ('3F', 'F', NULL), + ('4F', 'F', NULL); INSERT INTO `vn`.`ledgerCompany` SET fiscalYear = YEAR(util.VN_CURDATE()), bookEntry = 2; -INSERT INTO `vn`.`ledgerConfig` SET +INSERT INTO `vn`.`ledgerConfig` SET maxTolerance = 0.01; diff --git a/modules/worker/back/models/specs/locker.spec.js b/modules/worker/back/models/specs/locker.spec.js index 32abb830e..96fca2405 100644 --- a/modules/worker/back/models/specs/locker.spec.js +++ b/modules/worker/back/models/specs/locker.spec.js @@ -6,8 +6,9 @@ describe('locker model ', () => { const hrId = 37; const jessicaJonesId = 1110; const bruceBannerId = 1109; - const lockerMaleId = 1; - const lockerFemaleId = 147; + const lockerMaleId = 3; + const lockerFemaleId = 5; + const lockerNewFemaleId = 6; let ctx; let options; let tx; @@ -46,11 +47,13 @@ describe('locker model ', () => { }); it('should change a locker', async() => { - const locker = await models.Locker.findById(148, null, options); - await locker.updateAttributes({workerFk: jessicaJonesId}, options); const oldLocker = await models.Locker.findById(lockerFemaleId, null, options); + const locker = await models.Locker.findById(lockerNewFemaleId, null, options); + await locker.updateAttributes({workerFk: jessicaJonesId}, options); + const oldNowLocker = await models.Locker.findById(lockerFemaleId, null, options); + expect(oldLocker.workerFk).toEqual(jessicaJonesId); expect(locker.workerFk).toEqual(jessicaJonesId); - expect(oldLocker.workerFk).toEqual(null); + expect(oldNowLocker.workerFk).toEqual(null); }); });