diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 18e3fd4b5..c979ea1a2 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','11090','7adf4a373d19ce126adbc7b1077f69a74559c09a','2024-06-11 08:32:36','11094'); +INSERT INTO `version` VALUES ('vn-database','11114','cf0f80142fed798c3307565a69158d7dba9276c4','2024-06-25 09:25:54','11115'); 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); @@ -834,19 +834,34 @@ INSERT INTO `versionLog` VALUES ('vn-database','11058','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11059','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11060','00-createRoleReviewer.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',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','11063','00-roadmapAddress.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11063','01-roadmapStop.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11063','02-roadmapStopGrants.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11064','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11065','00-modifyInvoiceInPrivileges.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11065','01-modifyInvoiceInAcls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11068','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11069','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11070','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',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); INSERT INTO `versionLog` VALUES ('vn-database','11074','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11075','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-28 12:54:13',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11078','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11079','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 08:22:10',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11080','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-31 12:01:58',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11082','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11083','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-03 10:46:36',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11084','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11087','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11089','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11090','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11092','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-07 08:21:23',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11093','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11096','00-addBuyerAcl.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 12:48:51',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11105','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-20 15:36:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11106','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11109','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-18 19:09:56',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11114','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -930,7 +945,7 @@ INSERT INTO `role` VALUES (109,'salesTeamBoss','Jefe de equipo de comerciales',1 INSERT INTO `role` VALUES (110,'palletizer','Paletizadores',1,'2022-12-02 13:56:22','2022-12-02 13:56:30',NULL); INSERT INTO `role` VALUES (111,'entryEditor','Entry editor',1,'2023-01-13 12:21:55','2023-01-13 12:21:55',NULL); INSERT INTO `role` VALUES (112,'maintenance','Personal de mantenimiento',1,'2023-01-19 07:23:35','2023-01-19 07:23:35',NULL); -INSERT INTO `role` VALUES (114,'maintenanceBos','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2023-05-17 13:07:21',NULL); +INSERT INTO `role` VALUES (114,'maintenanceBoss','Jefe de mantenimiento',1,'2023-01-19 07:31:16','2024-06-14 08:56:41',19295); INSERT INTO `role` VALUES (115,'itManagement','TI management',1,'2023-03-29 09:27:55','2023-03-29 09:28:04',NULL); INSERT INTO `role` VALUES (119,'palletizerBoss','Jefe de paletizadores',1,'2023-06-07 13:51:54','2023-06-07 13:51:54',NULL); INSERT INTO `role` VALUES (120,'developerBoss','Jefe de proyecto de desarrollo',1,'2023-06-19 09:07:21','2023-06-19 09:07:21',21709); @@ -1212,6 +1227,7 @@ INSERT INTO `roleInherit` VALUES (367,30,73,NULL); INSERT INTO `roleInherit` VALUES (368,130,49,10578); INSERT INTO `roleInherit` VALUES (369,50,130,10578); INSERT INTO `roleInherit` VALUES (370,72,130,10578); +INSERT INTO `roleInherit` VALUES (371,36,35,NULL); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -1535,7 +1551,7 @@ INSERT INTO `ACL` VALUES (383,'Sector','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (384,'Sector','*','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (385,'Route','driverRoutePdf','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (386,'Route','driverRouteEmail','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','customer'); +INSERT INTO `ACL` VALUES (387,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','$owner'); INSERT INTO `ACL` VALUES (388,'Supplier','newSupplier','WRITE','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (389,'ClaimRma','*','READ','ALLOW','ROLE','claimManager'); INSERT INTO `ACL` VALUES (390,'ClaimRma','*','WRITE','ALLOW','ROLE','claimManager'); @@ -1791,10 +1807,6 @@ INSERT INTO `ACL` VALUES (686,'MailForward','*','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (687,'ClientSms','find','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); -INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); @@ -1863,7 +1875,7 @@ INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (765,'Route','getExternalCmrs','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee'); @@ -1939,8 +1951,6 @@ 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 `ACL` VALUES (846,'Ticket','refund','WRITE','ALLOW','ROLE','logistic'); INSERT INTO `ACL` VALUES (847,'RouteConfig','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (848,'InvoiceIn','updateInvoiceIn','WRITE','ALLOW','ROLE','administrative'); @@ -1960,6 +1970,19 @@ INSERT INTO `ACL` VALUES (861,'InvoiceIn','toBook','WRITE','ALLOW','ROLE','buyer INSERT INTO `ACL` VALUES (862,'InvoiceIn','deleteById','WRITE','ALLOW','ROLE','buyer'); INSERT INTO `ACL` VALUES (863,'InvoiceIn','create','WRITE','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (864,'InvoiceIn','create','WRITE','ALLOW','ROLE','buyer'); +INSERT INTO `ACL` VALUES (865,'Ticket','deliveryNotePdf','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (866,'InvoiceOut','download','READ','ALLOW','ROLE','$owner'); +INSERT INTO `ACL` VALUES (867,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBoss'); +INSERT INTO `ACL` VALUES (868,'InvoiceIn','*','READ','ALLOW','ROLE','maintenanceBos'); +INSERT INTO `ACL` VALUES (869,'Ticket','editZone','WRITE','ALLOW','ROLE','buyer'); +INSERT INTO `ACL` VALUES (870,'Entry','find','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (871,'RoadmapAddress','*','WRITE','ALLOW','ROLE','palletizerBoss'); +INSERT INTO `ACL` VALUES (872,'RoadmapAddress','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (873,'Roadmap','*','WRITE','ALLOW','ROLE','palletizerBoss'); +INSERT INTO `ACL` VALUES (874,'Roadmap','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (875,'RoadmapStop','*','WRITE','ALLOW','ROLE','palletizerBoss'); +INSERT INTO `ACL` VALUES (876,'RoadmapStop','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (877,'TravelKgPercentage','*','READ','ALLOW','ROLE','employee'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2280,7 +2303,7 @@ 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,25,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +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,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); @@ -2291,49 +2314,49 @@ 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,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 (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,0,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 (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',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 (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 (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',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 (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 (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',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 (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 (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',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 (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,'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 (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 (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); -INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',0,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); +INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); 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',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 (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,'spainTeam3','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'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',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 (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 (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,'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 (139,'spainTeam4','EQUIPO ESPAÑA 4',65,66,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',67,68,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 00ef1018b..b99a60395 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -647,7 +647,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','pgcMaster',' INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemBarcode','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','host','alexm@%','0000-00-00 00:00:00','Select,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticket','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete','Update'); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceIn','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select','Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','invoiceIn','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert','Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','inventoryFailure','alexm@%','0000-00-00 00:00:00','Select',''); @@ -982,7 +982,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','invoiceCorre INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ink','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zone','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','XDiario','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','XDiario','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTimeControlMail','alexm@%','0000-00-00 00:00:00','Select,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerTimeControl','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bi','financial','Greuge_Evolution','alexm@%','0000-00-00 00:00:00','Select',''); @@ -1048,7 +1048,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','userSession','j INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','receipt','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buy','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendarHolidays','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','parking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','role','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','errorLogApp','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','continent','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1300,7 +1300,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','g 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',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','ink','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','supplierDms','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); @@ -1350,7 +1350,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','warehouse INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','component','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','config','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','componentType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','priceFixed','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','itemShelvingSale','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','tagAbbreviation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketTracking','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); @@ -1361,7 +1361,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','sale_freight INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBos','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -1384,6 +1384,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategor INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','entry','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); @@ -1398,23 +1399,29 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visit','root@lo 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','financial','bankPolicyReview','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','roadmapStop','guillermo@10.5.1.3','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',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','antenna','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','bufferPool','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','enteringLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','expeditionLoading','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','failureLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','movingLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBos','sorterLog','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','solunionCAP','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientUnpaid','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','pay_dem','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','invoiceOut','guillermo@10.5.1.3','0000-00-00 00:00:00','Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','antenna','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','bufferPool','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','enteringLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','expeditionLoading','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','failureLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','movingLog','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','srt','maintenanceBoss','sorterLog','guillermo@db-proxy1.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 */; @@ -1474,28 +1481,6 @@ INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','user_id','0 INSERT IGNORE INTO `columns_priv` VALUES ('','pbx','grafana','sip','extension','0000-00-00 00:00:00','Select'); INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','name','0000-00-00 00:00:00','Select'); INSERT IGNORE INTO `columns_priv` VALUES ('','account','grafana','user','active','0000-00-00 00:00:00','Select'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','editorFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','expenseFkDeductible','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','withholdingSageFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','isVatDeductible','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','bookEntried','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','siiTrascendencyInvoiceInFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusTaxBreakFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusSubjectOpFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','cplusRectificationTypeFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','siiTypeInvoiceInFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','operated','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','booked','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','docFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','companyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','created','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','currencyFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','supplierRef','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','issued','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','supplierFk','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','serial','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','serialNumber','0000-00-00 00:00:00','Update'); -INSERT IGNORE INTO `columns_priv` VALUES ('','vn','administrative','invoiceIn','id','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','routeFk','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','name','0000-00-00 00:00:00','Update'); INSERT IGNORE INTO `columns_priv` VALUES ('','vn','employee','routesMonitor','beachFk','0000-00-00 00:00:00','Update'); @@ -1904,7 +1889,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceoutboo INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','productionAssi','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','dipole','employee','expedition_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticketstateupdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','itempacking','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','available_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -2151,6 +2135,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','artificialBoss','confection_co INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','remittance_calc','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','developer','connection_kill','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financial','client_getRisk','PROCEDURE','jenkins@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasRole','FUNCTION','root@localhost','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','financialBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hrBoss','balance_create','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPricesByEntry','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2215,7 +2200,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','logisticAssist','{\"access\":0,\"v INSERT IGNORE INTO `global_priv` VALUES ('','logisticBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','maintenance','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBos','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','maintenanceBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','manager','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','marketing','{\"access\": 0, \"is_role\": true,\"version_id\":101106}'); INSERT IGNORE INTO `global_priv` VALUES ('','marketingBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index dd068cdc7..cd5b6aa3b 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -3240,11 +3240,12 @@ BEGIN JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN vn.state st ON st.id = tt.stateFk + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE sc.componentFk = 17 AND sc.isGreuge = 0 AND t.shipped >= '2016-10-01' AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; + AND st.alertLevel >= al.id; DELETE g.* FROM vn.greuge g @@ -8280,7 +8281,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.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk 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 @@ -13105,7 +13106,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getVisible`( vType INT, vPrefix VARCHAR(255)) BEGIN - + /** * Gets visible items of the specified type at specified date. * @@ -13114,7 +13115,7 @@ BEGIN * @param vType The type id * @param vPrefix The article prefix to filter or %NULL for all * @return tmp.itemVisible Visible items - */ + */ DECLARE vPrefixLen SMALLINT; DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vDateInv DATE DEFAULT vn.getInventoryDate(); @@ -13123,13 +13124,13 @@ BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, + 'cau@verdnatura.es', + NULL, CONCAT('hedera.item_getVisible error: ', @message), CONCAT( - 'warehouse: ', IFNULL(vWarehouse, ''), - ', Fecha:', IFNULL(vDate, ''), - ', tipo: ', IFNULL(vType,''), + 'warehouse: ', IFNULL(vWarehouse, ''), + ', Fecha:', IFNULL(vDate, ''), + ', tipo: ', IFNULL(vType,''), ', prefijo: ', IFNULL(vPrefix,''))); RESIGNAL; END; @@ -13174,9 +13175,10 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse - AND s.alertLevel = 3 + AND s.alertLevel = al.id ) t GROUP BY itemFk HAVING quantity > 0; @@ -13208,7 +13210,7 @@ BEGIN IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, CEIL(s.quantity / t.packing) etiquetas FROM vn.item i - JOIN `filter` f ON f.itemFk = i.id + JOIN `filter` f ON f.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN vn.packaging p ON p.id = t.packagingFk @@ -14618,7 +14620,7 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, + SELECT o.date_send, o.address_id, o.note, a.clientFk, o.company_id, o.agency_id, c.isTaxDataChecked INTO vDelivery, vAddress, vNotes, vClientId, vCompanyId, vAgencyModeId, vIsTaxDataChecked @@ -14677,6 +14679,7 @@ BEGIN ) SELECT t.id INTO vTicket FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id JOIN hedera.`order` o @@ -14687,7 +14690,7 @@ BEGIN WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado @@ -17013,6 +17016,22 @@ SET character_set_client = utf8; 1 AS `companyFk` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `clientSupplier` +-- + +DROP TABLE IF EXISTS `clientSupplier`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientSupplier` ( + `companyFk` smallint(6) NOT NULL, + `type` enum('C','P') NOT NULL, + `idClientSupplier` int(11) NOT NULL, + `isSync` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`companyFk`,`idClientSupplier`,`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Clients and suppliers present in Sage and their synchronization status'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientesProveedores` -- @@ -17596,7 +17615,8 @@ BEGIN DECLARE vTransactionExportTaxFreeFk INT; DECLARE vSerialDua VARCHAR(1) DEFAULT 'D'; DECLARE vInvoiceTypeInformativeCode VARCHAR(1); - DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ; + DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); + DECLARE vCompanyCode INT; SELECT SiglaNacion INTO vCountryCanariasCode FROM Naciones @@ -17606,9 +17626,6 @@ BEGIN FROM Naciones WHERE Nacion ='CEUTA Y MELILLA'; - SELECT pendingServiceTransactionTypeFk INTO vDuaTransactionFk - FROM config; - SELECT id INTO vTaxImportFk FROM taxType WHERE code = 'import21'; @@ -17621,10 +17638,14 @@ BEGIN FROM taxType WHERE code = 'import4'; - SELECT definitiveExportTransactionTypeFk INTO vTransactionExportFk - FROM config; - - SELECT shipmentTransactionTypeFk INTO vTransactionExportTaxFreeFk + SELECT shipmentTransactionTypeFk, + definitiveExportTransactionTypeFk, + pendingServiceTransactionTypeFk, + company_getCode(vCompanyFk) + INTO vTransactionExportTaxFreeFk, + vTransactionExportFk, + vDuaTransactionFk, + vCompanyCode FROM config; SELECT codeSage INTO vInvoiceTypeInformativeCode @@ -17639,8 +17660,6 @@ BEGIN WHERE enlazadoSage = FALSE AND Asiento <> 1 ; - CALL clientSupplier_add(vCompanyFk); - CALL pgc_add(vCompanyFk); CALL invoiceOut_manager(vYear, vCompanyFk); CALL invoiceIn_manager(vYear, vCompanyFk); @@ -17733,7 +17752,7 @@ BEGIN ) SELECT 'EN' TipoEntrada, YEAR(x.FECHA) Ejercicio, - company_getCode(vCompanyFk) AS CodigoEmpresa, + vCompanyCode CodigoEmpresa, x.ASIEN Asiento, IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono, @@ -17866,20 +17885,6 @@ BEGIN WHERE m.CargoAbono = 'D' AND m.enlazadoSage = FALSE; --- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación - DELETE cp - FROM clientesProveedores cp - LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - --- Elimina cuentas contables que no se utilizarán en la importación - DELETE pc - FROM planCuentasPGC pc - LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta - AND mc.enlazadoSage = FALSE - WHERE mc.codigoCuenta IS NULL; - -- DUAS UPDATE movConta mci JOIN vn.XDiario x ON x.ASIEN = mci.Asiento @@ -17986,6 +17991,56 @@ BEGIN AND importeDivisa > 0 AND ImporteAsiento < 0; + CREATE OR REPLACE TEMPORARY TABLE tmp.clientSupplier + (INDEX(idClientSupplier, `type`)) + ENGINE = MEMORY + WITH client AS( + SELECT DISTINCT c.id + FROM sage.movConta mc + JOIN vn.client c ON c.accountingAccount = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),supplier AS( + SELECT DISTINCT s.id + FROM sage.movConta mc + JOIN vn.supplier s ON s.account = mc.CodigoCuenta + WHERE NOT enlazadoSage + ),clientSupplierSync AS( + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE isSync + ) + SELECT idClientSupplier, `type` + FROM sage.clientSupplier cs + WHERE NOT isSync + UNION + SELECT id, 'C' + FROM client c + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = c.id + AND cs.Type ='C' + WHERE cs.idClientSupplier IS NULL + UNION + SELECT id, 'P' + FROM supplier s + LEFT JOIN clientSupplierSync cs ON cs.idClientSupplier = s.id + AND cs.Type ='P' + WHERE cs.idClientSupplier IS NULL; + + CALL clientSupplier_add(vCompanyFk); + + INSERT IGNORE INTO sage.clientSupplier (companyFk, `type`, idClientSupplier, isSync) + SELECT vCompanyCode, `type`, idClientSupplier, FALSE + FROM tmp.clientSupplier; + + DROP TEMPORARY TABLE tmp.clientSupplier; + + CALL pgc_add(vCompanyFk); +-- Elimina cuentas contables que no se utilizarán en la importación + DELETE pc + FROM planCuentasPGC pc + LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta + AND mc.enlazadoSage = FALSE + WHERE mc.codigoCuenta IS NULL; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -18027,13 +18082,18 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`(vCompanyFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `clientSupplier_add`( + vCompanyFk INT +) BEGIN /** - * Prepara los datos de clientes y proveedores para exportarlos a Sage - * @vCompanyFk Empresa dela que se quiere trasladar datos + * Inserta en la tabla sage.clientesProveedores los datos de clientes y proveedores + * que se actualizaran o se daran de alta en Sage + * @vCompanyFk Id de empresa + * @table tmp.clientSupplier(idClientSupplier, `type`) */ DECLARE vCountryCeutaMelillaFk INT; + DECLARE vCompanyCode INT DEFAULT company_getCode(vCompanyFk); DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2); SELECT SiglaNacion INTO vCountryCanariasCode @@ -18073,7 +18133,7 @@ BEGIN Email1, iban) SELECT - company_getCode(vCompanyFk), + vCompanyCode, 'C', c.id, c.socialName, @@ -18081,7 +18141,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(IFNULL(cu.viesCode,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, ''), @@ -18103,15 +18163,14 @@ BEGIN IFNULL(SUBSTR(c.email, 1, LOCATE(',', CONCAT(c.email, ','))-1), ''), IFNULL(c.iban, '') FROM vn.`client` c - JOIN clientLastTwoMonths clm ON clm.clientFk = c.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = c.id LEFT JOIN vn.country cu ON cu.id = c.countryFk LEFT JOIN Naciones n ON n.countryFk = cu.id LEFT JOIN vn.province p ON p.id = c.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id - WHERE c.isRelevant - AND clm.companyFk = vCompanyFk + WHERE cs.type = 'C' UNION ALL - SELECT company_getCode(vCompanyFk), + SELECT vCompanyCode, 'P', s.id, s.name, @@ -18135,19 +18194,17 @@ BEGIN IFNULL(s.transactionTypeSageFk, 0), IFNULL(s.withholdingSageFk, '0'), IFNULL(SUBSTR(sc.email, 1, (COALESCE(NULLIF(LOCATE(',', sc.email), 0), 99) - 1)), ''), - IFNULL(iban, '') + IFNULL(sa.iban, '') FROM vn.supplier s - JOIN supplierLastThreeMonths pl ON pl.supplierFk = s.id + JOIN tmp.clientSupplier cs ON cs.idClientSupplier = s.id LEFT JOIN vn.country co ON co.id = s.countryFk LEFT JOIN Naciones n ON n.countryFk = co.id LEFT JOIN vn.province p ON p.id = s.provinceFk LEFT JOIN Provincias pr ON pr.provinceFk = p.id LEFT JOIN vn.supplierContact sc ON sc.supplierFk = s.id LEFT JOIN vn.supplierAccount sa ON sa.supplierFk = s.id - WHERE pl.companyFk = vCompanyFk AND - s.isActive AND - s.nif <> '' - GROUP BY pl.supplierFk, pl.companyFk; + WHERE cs.type = 'P' + GROUP BY s.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -20439,7 +20496,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 t.routeFk = rm.routeFk - LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id + LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id WHERE e.id = vExpeditionFk; RETURN vDayMinute; @@ -23592,12 +23649,13 @@ BEGIN m.created, TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, - m.isPicked OR s.alertLevel > 1 isPicked + m.isPicked OR s.alertLevel > al.id isPicked FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.item i ON i.id = m.itemFk JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION' WHERE ( vTableId IS NULL OR (vTableName = 'ticket' AND t.id = vTableId) @@ -25637,7 +25695,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`(vVariable VARCHAR(255), vValue VARCHAR(255)) +CREATE DEFINER=`root`@`localhost` PROCEDURE `debugAdd`( + vVariable VARCHAR(255), + vValue TEXT +) MODIFIES SQL DATA BEGIN /** @@ -28592,7 +28653,7 @@ CREATE TABLE `clientLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `changedModel` enum('Client','Address','ClientContact','ClientDms','ClientObservation','ClientSample','Greuge','Recovery','TpvTransaction','WorkerDms','Sms') NOT NULL DEFAULT 'Client', + `changedModel` enum('Client','Address','ClientContact','ClientDms','ClientObservation','ClientSample','ClientUnpaid','Greuge','Recovery','TpvTransaction','WorkerDms','Sms') NOT NULL DEFAULT 'Client', `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, @@ -28706,6 +28767,24 @@ CREATE TABLE `clientProtected` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Lista de clientes y comerciales que no se van a ver afectados por las desagsignaciones mensuales automaticas'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `clientRate` +-- + +DROP TABLE IF EXISTS `clientRate`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `clientRate` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `dated` date NOT NULL DEFAULT current_timestamp(), + `value` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `clientRate_unique` (`clientFk`,`dated`), + CONSTRAINT `clientRate_client_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `clientRisk` -- @@ -29567,7 +29646,6 @@ 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__`), @@ -31063,7 +31141,7 @@ SET character_set_client = utf8; 1 AS `routeFk`, 1 AS `scanFk`, 1 AS `expeditionFk`, - 1 AS `expeditionTruckFk`, + 1 AS `roadmapStopFk`, 1 AS `warehouseFk`, 1 AS `lastPacked`, 1 AS `ticketFk` */; @@ -31233,6 +31311,7 @@ CREATE TABLE `expeditionState` ( `expeditionFk` int(11) NOT NULL, `typeFk` int(11) NOT NULL, `userFk` int(11) DEFAULT NULL, + `isScanned` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `expeditionState_FK` (`expeditionFk`), KEY `expeditionState_FK_1` (`typeFk`), @@ -31324,7 +31403,6 @@ 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`, @@ -31332,68 +31410,6 @@ SET character_set_client = utf8; 1 AS `userFk` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `expeditionTruck_Control` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control` AS SELECT - 1 AS `id`, - 1 AS `ETD`, - 1 AS `description`, - 1 AS `ticketsSinBultos`, - 1 AS `pallets`, - 1 AS `routes`, - 1 AS `scans`, - 1 AS `expeditions`, - 1 AS `fallos`, - 1 AS `lastPacked` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `expeditionTruck_Control_Detail` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control_Detail`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control_Detail` AS SELECT - 1 AS `id`, - 1 AS `eta`, - 1 AS `destino`, - 1 AS `pallet`, - 1 AS `routes`, - 1 AS `scans`, - 1 AS `destinos`, - 1 AS `fallos`, - 1 AS `lastPacked` */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `expeditionTruck_Control_Detail_Pallet` --- - -DROP TABLE IF EXISTS `expeditionTruck_Control_Detail_Pallet`; -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `expeditionTruck_Control_Detail_Pallet` AS SELECT - 1 AS `id`, - 1 AS `eta`, - 1 AS `destino`, - 1 AS `pallet`, - 1 AS `route`, - 1 AS `scans`, - 1 AS `destinos`, - 1 AS `fallos`, - 1 AS `expeditionTruckFk`, - 1 AS `lastPacked` */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `expense` -- @@ -31628,13 +31644,13 @@ CREATE TABLE `floramondoConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `forecastedBalance` +-- Table structure for table `forecastedBalance__` -- -DROP TABLE IF EXISTS `forecastedBalance`; +DROP TABLE IF EXISTS `forecastedBalance__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `forecastedBalance` ( +CREATE TABLE `forecastedBalance__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `description` varchar(45) DEFAULT NULL, `amount` double NOT NULL DEFAULT 0, @@ -31647,7 +31663,7 @@ CREATE TABLE `forecastedBalance` ( KEY `empresa_prevision_idx` (`companyFk`), CONSTRAINT `Saldos_PrevisionCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `banco_prevision` FOREIGN KEY (`accountingFk`) REFERENCES `accounting` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-05-21'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -33197,11 +33213,11 @@ CREATE TABLE `itemShelving` ( `buyFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `itemShelving_UN` (`buyFk`,`shelvingFk`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), KEY `itemShelving_fk3_idx` (`packagingFk`), KEY `itemShelving_fk3_idx1` (`userFk`), + KEY `itemShelvingBuy_FK` (`buyFk`), CONSTRAINT `itemShelvingBuy_FK` FOREIGN KEY (`buyFk`) REFERENCES `buy` (`id`), CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -35804,13 +35820,20 @@ CREATE TABLE `productionConfig` ( `defaultSectorFk` int(10) unsigned NOT NULL DEFAULT 37 COMMENT 'Default sector', `scannableCodeType` enum('qr','barcode') NOT NULL DEFAULT 'barcode', `scannablePreviusCodeType` enum('qr','barcode') NOT NULL DEFAULT 'barcode', + `itemOlderReviewHours` int(11) NOT NULL DEFAULT 0 COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.', + `sectorFromCode` varchar(15) DEFAULT NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear', + `sectorToCode` varchar(15) DEFAULT NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear', PRIMARY KEY (`id`), KEY `productionConfig_FK` (`shortageAddressFk`), KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`), KEY `productionConfig_FK_2` (`addressSelfConsumptionFk`), + KEY `productionConfig_sector_FK` (`sectorFromCode`), + KEY `productionConfig_sector_FK_1` (`sectorToCode`), CONSTRAINT `productionConfig_FK` FOREIGN KEY (`shortageAddressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_1` FOREIGN KEY (`clientSelfConsumptionFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_2` FOREIGN KEY (`addressSelfConsumptionFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_sector_FK` FOREIGN KEY (`sectorFromCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_sector_FK_1` FOREIGN KEY (`sectorToCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -36473,6 +36496,21 @@ 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 `roadmapAddress` +-- + +DROP TABLE IF EXISTS `roadmapAddress`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roadmapAddress` ( + `addressFk` int(11) NOT NULL, + `isActive` tinyint(4) DEFAULT 1, + PRIMARY KEY (`addressFk`), + CONSTRAINT `roadmapAddress_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `roadmapStop` -- @@ -36483,7 +36521,7 @@ DROP TABLE IF EXISTS `roadmapStop`; CREATE TABLE `roadmapStop` ( `id` int(11) NOT NULL AUTO_INCREMENT, `roadmapFk` int(10) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `addressFk` int(11) 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', @@ -36492,13 +36530,13 @@ CREATE TABLE `roadmapStop` ( 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`), + KEY `roadmapStop_roadmapAddress_FK` (`addressFk`), 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 + CONSTRAINT `expeditionTruck_FK_3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE, + CONSTRAINT `roadmapStop_roadmapAddress_FK` FOREIGN KEY (`addressFk`) REFERENCES `roadmapAddress` (`addressFk`) 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 */; @@ -36872,21 +36910,22 @@ CREATE TABLE `routesMonitor` ( `m3` decimal(10,1) DEFAULT NULL, `priority` int(11) NOT NULL DEFAULT 0, `etd` time DEFAULT NULL, - `expeditionTruckFk` int(11) DEFAULT NULL, + `roadmapStopFk` int(11) DEFAULT NULL, `m3boxes` decimal(10,1) DEFAULT NULL, `bufferFk` int(11) DEFAULT NULL COMMENT 'Buffer del sorter por el que se quiere sacar esa ruta', `isPickingAllowed` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Los tickets de esta ruta se pueden preparar', `editorFk` int(10) unsigned DEFAULT NULL, + `expeditionTruckFk` int(11) GENERATED ALWAYS AS (`roadmapStopFk`) VIRTUAL, PRIMARY KEY (`routeFk`), KEY `routesMonitor_FK` (`bufferFk`), KEY `routesMonitor_FK_2` (`beachFk`), KEY `routesMonitor_FK_1` (`dockFk`), - KEY `routesMonitor_FK_3` (`expeditionTruckFk`), + KEY `routesMonitor_FK_3` (`roadmapStopFk`), KEY `routesMonitor_fk_editor` (`editorFk`), 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 `roadmapStop` (`id`) ON UPDATE CASCADE, + CONSTRAINT `routesMonitor_FK_3` FOREIGN KEY (`roadmapStopFk`) 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 */; @@ -39160,7 +39199,7 @@ CREATE TABLE `ticketPackagingStartingStock` ( KEY `ticketPackagingStartingStock_fk2_idx` (`packagingFk`), KEY `ticketPackagingStartingStock_fk3_idx` (`itemFk`), CONSTRAINT `ticketPackagingStartingStock_fk1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `ticketPackagingStartingStock_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackagingStartingStock_fk3` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39879,6 +39918,20 @@ CREATE TABLE `travelConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `travelKgPercentage` +-- + +DROP TABLE IF EXISTS `travelKgPercentage`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `travelKgPercentage` ( + `value` int(3) NOT NULL, + `className` varchar(50) DEFAULT NULL, + PRIMARY KEY (`value`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `travelLog` -- @@ -48182,7 +48235,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_afterUpsert`(vSelf INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_afterUpsert`( + vSelf INT +) BEGIN /** * Triggered actions when a buy is updated or inserted. @@ -48199,7 +48254,7 @@ BEGIN DECLARE vIsFeedStock BOOL; DECLARE vWeight DECIMAL(10,2); DECLARE vPacking INT; - + SELECT b.entryFk, b.itemFk, i.packingOut, @@ -48230,8 +48285,11 @@ BEGIN WHERE e.id = vEntryFk; IF vIsMerchandise THEN + IF vWarehouse IS NULL THEN + CALL util.throw('The entry does not have travel'); + END IF; - REPLACE itemCost SET + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf), @@ -48257,7 +48315,7 @@ BEGIN WHERE b.id = vSelf; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck + CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT vSelf id; CALL buy_checkItem(); END ;; @@ -51672,6 +51730,8 @@ BEGIN DECLARE vLockName VARCHAR(215); DECLARE vLockTime INT DEFAULT 30; DECLARE vFreeWagonFk INT; + DECLARE vErrorNumber INT; + DECLARE vErrorMsg TEXT; DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 @@ -51691,12 +51751,18 @@ BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + GET DIAGNOSTICS CONDITION 1 + vErrorNumber = MYSQL_ERRNO, + vErrorMsg = MESSAGE_TEXT; + IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); - CALL util.debugAdd(JSON_OBJECT( - 'type', 'releaseLock', - 'userFk', vUserFk - ), vLockName); -- Tmp + CALL util.debugAdd('collection_new', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'lockName', vLockName, + 'userFk', vUserFk + )); -- Tmp END IF; RESIGNAL; @@ -52613,7 +52679,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.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded @@ -55323,13 +55389,13 @@ BEGIN LIMIT 1; IF vPalletFk IS NULL THEN - SELECT expeditionTruckFk + SELECT roadmapStopFk INTO vTruckFk FROM ( - SELECT rm.expeditionTruckFk, count(*) n + SELECT rm.roadmapStopFk, count(*) n FROM vn.routesMonitor rm JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY expeditionTruckFk + GROUP BY roadmapStopFk ORDER BY n DESC LIMIT 1) sub; @@ -55795,53 +55861,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 `expeditionTruck_Add` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) -BEGIN - - INSERT INTO vn.roadmapStop(eta,description) - VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); - -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 `expeditionTruck_List` */; -/*!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 `expeditionTruck_List`() -BEGIN - - SELECT id truckFk, - 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 */ ; -/*!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 `expedition_getFromRoute` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55866,7 +55885,8 @@ BEGIN t.addressFk, a.nickname, sub2.itemPackingTypeConcat, - est.code + est.code, + es.isScanned FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -55884,6 +55904,10 @@ BEGIN GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk + LEFT JOIN expeditionState es ON es.id = ( + SELECT MAX(id) + FROM expeditionState es + WHERE expeditionFk = e.id) WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END ;; @@ -55953,7 +55977,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.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END ;; @@ -56040,7 +56064,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.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END ;; @@ -58276,8 +58300,8 @@ BEGIN OR t.isDeleted OR c.hasToInvoice = FALSE OR itc.id IS NULL - OR a.id IS NULL - OR (vTaxArea = 'WORLD' + OR a.id IS NULL + OR (vTaxArea = 'WORLD' AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 @@ -58349,7 +58373,9 @@ BEGIN FROM tmp.ticketToInvoice ti LEFT JOIN ticketState ts ON ti.id = ts.ticketFk JOIN state s - WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); + JOIN alertLevel al ON al.code = 'DELIVERED' + WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id) + AND s.`code` = getAlert3State(ti.id); INSERT INTO ticketTracking(stateFk, ticketFk, userFk) SELECT * FROM tmp.updateInter; @@ -59438,7 +59464,7 @@ BEGIN ish.isChecked, sub.isAllChecked FROM itemShelvingStock iss - JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN ( SELECT itemFk, IF( @@ -60138,9 +60164,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelving_add`( + vShelvingFk VARCHAR(8), + vBarcode VARCHAR(22), + vQuantity INT, + vPackagingFk VARCHAR(10), + vGrouping INT, + vPacking INT, + vWarehouseFk INT +) BEGIN - /** * Añade registro o lo actualiza si ya existe. * @@ -60162,12 +60195,7 @@ BEGIN SELECT barcodeToItem(vBarcode) INTO vItemFk; IF vBuyFk IS NULL THEN - CALL cache.last_buy_refresh(FALSE); - - SELECT buy_id INTO vBuyFk - FROM cache.last_buy - WHERE item_id = vItemFk - AND warehouse_id = vWarehouseFk; + CALL util.throw('The buy is required'); END IF; IF vPacking IS NULL @@ -62827,6 +62855,7 @@ BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + AND t.warehouseFk AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) @@ -62837,7 +62866,7 @@ BEGIN t.warehouseInFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND !e.isExcludedFromAvailable @@ -62850,7 +62879,7 @@ BEGIN t.warehouseOutFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable @@ -63601,6 +63630,239 @@ BEGIN */ UPDATE item SET itemPackingTypeFk = vItemPackingTypeFk WHERE id = vItem; +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 = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_valuateInventory` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb3 */ ; +/*!50003 SET character_set_results = utf8mb3 */ ; +/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_valuateInventory`( +vDated DATE +) +BEGIN +DECLARE vInventoried DATE; +DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; +DECLARE vInventoryClone DATE; +DECLARE vDateDayEnd DATETIME; +DECLARE vInventorySupplierFk INT; + +SELECT inventorySupplierFk INTO vInventorySupplierFk +FROM entryConfig; + +SET vDateDayEnd = util.dayEnd(vDated); + +SELECT tr.landed INTO vInventoried +FROM travel tr +JOIN `entry` e ON e.travelFk = tr.id +WHERE tr.landed <= vDateDayEnd +AND e.supplierFk = vInventorySupplierFk +ORDER BY tr.landed DESC +LIMIT 1; + +SET vHasNotInventory = (vInventoried IS NULL); + +IF vHasNotInventory THEN +SELECT landed INTO vInventoryClone +FROM travel tr +JOIN `entry` e ON e.travelFk = tr.id +WHERE tr.landed >= vDated +AND e.supplierFk = vInventorySupplierFk +ORDER BY landed ASC +LIMIT 1; + +SET vInventoried = vDated + INTERVAL 1 DAY; +SET vDateDayEnd = vInventoryClone; +END IF; + +CREATE OR REPLACE TEMPORARY TABLE tInventory( +warehouseFk SMALLINT, +itemFk BIGINT, +quantity INT, +volume DECIMAL(10,2), +cost DOUBLE DEFAULT 0, +total DOUBLE DEFAULT 0, +warehouseInventory VARCHAR(20), +PRIMARY KEY (warehouseInventory, itemFk) USING HASH +) +ENGINE = MEMORY; + + +IF vHasNotInventory THEN +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT tr.warehouseInFk, +b.itemFk, +SUM(b.quantity), +w.name +FROM buy b +JOIN item i ON i.id = b.itemFk +JOIN `entry` e ON e.id = b.entryFk +JOIN travel tr ON tr.id = e.travelFk +JOIN itemType t ON t.id = i.typeFk +JOIN warehouse w ON w.id = tr.warehouseInFk +WHERE tr.landed = vDateDayEnd +AND e.supplierFk = vInventorySupplierFk +AND w.valuatedInventory +AND t.isInventory +GROUP BY tr.warehouseInFk, b.itemFk; +ELSE +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT tr.warehouseInFk, +b.itemFk, +SUM(b.quantity), +w.name +FROM buy b +JOIN item i ON i.id = b.itemFk +JOIN `entry` e ON e.id = b.entryFk +JOIN travel tr ON tr.id = e.travelFk +JOIN itemType t ON t.id = i.typeFk +JOIN warehouse w ON w.id = tr.warehouseInFk +WHERE tr.landed = vInventoried +AND e.supplierFk = vInventorySupplierFk +AND w.valuatedInventory +AND t.isInventory +GROUP BY tr.warehouseInFk, b.itemFk; +END IF; + + +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT tr.warehouseInFk, +b.itemFk, +b.quantity * IF(vHasNotInventory, -1, 1), +w.name +FROM buy b +JOIN item i ON i.id = b.itemFk +JOIN `entry` e ON e.id = b.entryFk +JOIN travel tr ON tr.id = e.travelFk +JOIN itemType t ON t.id = i.typeFk +JOIN warehouse w ON w.id = tr.warehouseInFk +WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd +AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) +AND NOT e.isRaid +AND w.valuatedInventory +AND t.isInventory +AND e.supplierFk <> vInventorySupplierFk +ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); + + +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT tr.warehouseOutFk, +b.itemFk, +b.quantity * IF(vHasNotInventory, 1, -1), +w.name +FROM buy b +JOIN item i ON i.id = b.itemFk +JOIN `entry` e ON e.id = b.entryFk +JOIN travel tr ON tr.id = e.travelFk +JOIN itemType t ON t.id = i.typeFk +JOIN warehouse w ON w.id = tr.warehouseOutFk +WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd +AND NOT e.isRaid +AND w.valuatedInventory +AND t.isInventory +ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); + + +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT w.id, +s.itemFk, +s.quantity * IF(vHasNotInventory, 1, -1), +w.name +FROM sale s +JOIN ticket t ON t.id = s.ticketFk +JOIN `client` c ON c.id = t.clientFk +JOIN item i ON i.id = s.itemFk +JOIN itemType it ON it.id = i.typeFk +JOIN warehouse w ON w.id = t.warehouseFk +WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd +AND w.valuatedInventory +AND it.isInventory +ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); + + +IF vDated = util.VN_CURDATE() THEN +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT w.id, +s.itemFk, +s.quantity * IF(vHasNotInventory, 0, 1), +w.name +FROM sale s +JOIN ticket t ON t.id = s.ticketFk +JOIN `client` c ON c.id = t.clientFk +JOIN item i ON i.id = s.itemFk +JOIN itemType it ON it.id = i.typeFk +JOIN warehouse w ON w.id = t.warehouseFk +WHERE t.shipped BETWEEN vDated AND vDateDayEnd +AND NOT (s.isPicked OR t.isLabeled) +AND w.valuatedInventory +AND it.isInventory +ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); +END IF; + + +INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) +SELECT tr.warehouseInFk, +b.itemFk, +b.quantity, +CONCAT(wOut.`name`, ' - ', wIn.`name`) +FROM buy b +JOIN item i ON i.id = b.itemFk +JOIN `entry` e ON e.id = b.entryFk +JOIN travel tr ON tr.id = e.travelFk +JOIN itemType t ON t.id = i.typeFk +JOIN warehouse wIn ON wIn.id = tr.warehouseInFk +JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk +WHERE vDated >= tr.shipped AND vDated < tr.landed +AND NOT isRaid +AND wIn.valuatedInventory +AND t.isInventory +AND e.isConfirmed +ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); + +CALL buyUltimate(NULL, vDateDayEnd); + +DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; + +UPDATE tInventory i +JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk +JOIN buy b ON b.id = bu.buyFk +LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk +AND ic.warehouseFk = i.warehouseFk +SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), +i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), +i.volume = i.quantity * ic.cm3delivery / 1000000; + +SELECT ti.warehouseFk, +i.id, +i.longName, +i.size, +ti.quantity, +ti.volume, +tp.name itemTypeName, +ic.name itemCategoryName, +ti.cost, +ti.total, +ti.warehouseInventory +FROM tInventory ti +JOIN warehouse w ON w.id = warehouseFk +JOIN item i ON i.id = ti.itemFk +JOIN itemType tp ON tp.id = i.typeFk +JOIN itemCategory ic ON ic.id = tp.categoryFk +WHERE w.valuatedInventory +AND ti.total > 0; + +DROP TEMPORARY TABLE +tmp.buyUltimate, +tInventory; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65248,14 +65510,16 @@ BEGIN (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk - FROM vn.ticket t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk + FROM ticket t + JOIN alertLevel al ON al.code = 'DELIVERED' + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( - ts.alertLevel < 3 + ts.alertLevel < al.id AND t.shipped >= vStartingDate AND t.shipped < util.VN_CURDATE() ) @@ -65383,7 +65647,7 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `productionControl`( - vWarehouseFk INT, + vWarehouseFk INT, vScopeDays INT ) proc: BEGIN @@ -65450,7 +65714,7 @@ proc: BEGIN wk.code salesPersonCode, p.id provinceFk, tls.productionOrder, - IFNULL(tls.alertLevel, 0) alertLevel, + IFNULL(tls.alertLevel, al.id) alertLevel, t.isBoxed palletized, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, tlu.lastUpdated, @@ -65464,6 +65728,7 @@ proc: BEGIN rm.bufferFk FROM tmp.productionTicket tt JOIN ticket t ON tt.ticketFk = t.id + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN client c ON c.id = t.clientFk @@ -65484,7 +65749,7 @@ proc: BEGIN LEFT JOIN parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); - + UPDATE tmp.productionBuffer pb JOIN ( SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking @@ -65492,12 +65757,12 @@ proc: BEGIN JOIN sale s ON s.ticketFk = pb.ticketFk JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN parking p ON p.id = sg.parkingFk + JOIN parking p ON p.id = sg.parkingFk GROUP BY pb.ticketFk ) t ON t.ticketFk = pb.ticketFk SET pb.previaParking = t.previaParking; - -- Problemas por ticket + -- Problemas por ticket ALTER TABLE tmp.productionBuffer CHANGE COLUMN `problem` `problem` VARCHAR(255), ADD COLUMN `collectionH` INT, @@ -66406,7 +66671,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 roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.code; @@ -66708,7 +66973,7 @@ BEGIN SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk SET rm.etd = rs.eta; DROP TEMPORARY TABLE tmp.routesMonitor; @@ -70065,10 +70330,10 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `supplierPackaging_ReportSource`( ) BEGIN /** -* Selecciona los embalajes de un proveedor a partir de una fecha +* Create a report with packaging balance * -* @param vFromDated Fecha de la que partir -* @param vSupplierFk Id del proveedor +* @param vFromDated Starting date +* @param vSupplierFk Supplier ID */ SET @vBalance = 0; SET @vItemFk = NULL; @@ -70082,7 +70347,7 @@ BEGIN landed, `in`, `out`, - warehouse, + sref, buyingValue, IF ( NOT (@vItemFk <=> sub.itemFk), @@ -70091,19 +70356,20 @@ BEGIN ) balance, @vItemFk := sub.itemFk previousItemFk FROM ( - SELECT supplierFk, - itemFk, - longName, - supplier, - CONCAT('E',entryFk) entryFk, - landed, - `in`, - `out`, - warehouse, - buyingValue - FROM supplierPackaging - WHERE supplierFk = vSupplierFk - AND landed >= vFromDated + SELECT sp.supplierFk, + sp.itemFk, + sp.longName, + sp.supplier, + CONCAT('E',sp.entryFk) entryFk, + sp.landed, + sp.`in`, + sp.`out`, + e.invoiceNumber sref, + sp.buyingValue + FROM supplierPackaging sp + JOIN entry e ON e.id = sp.entryFk + WHERE sp.supplierFk = vSupplierFk + AND sp.landed >= vFromDated UNION ALL SELECT vSupplierFk, itemFk, @@ -70128,7 +70394,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -70159,6 +70425,7 @@ BEGIN WHERE su.id = vSupplierFk AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY s.itemFk UNION ALL SELECT vSupplierFk, @@ -70169,7 +70436,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -70198,8 +70465,9 @@ BEGIN 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 t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub @@ -70213,7 +70481,7 @@ BEGIN landed, CAST(`in` AS DECIMAL(10,0)) `in`, CAST(`out` AS DECIMAL(10,0)) `out`, - warehouse, + sref, buyingValue, balance FROM tSupplierPackaging @@ -71253,13 +71521,16 @@ BEGIN DECLARE vShipped DATE; DECLARE vWarehouse TINYINT; DECLARE vAlertLevel INT; + DECLARE vAlertLevelFree INT; - SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id + INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree FROM ticket t + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketState ts ON ts.ticketFk = vTicket WHERE t.id = vTicket; - IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; @@ -71283,68 +71554,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 `ticketMissed_List` */; -/*!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 `ticketMissed_List`(vTicketFk INT) -BEGIN - - DECLARE vParkingFk INT; - DECLARE vParked DATETIME; - DECLARE vLevel INT; - DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) - INTO vLevel, vCollectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - LIMIT 1; - - SELECT created, parkingFk - INTO vParked, vParkingFk - FROM vn.ticketParking - WHERE ticketFk = vTicketFk; - - SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia - FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND ( - ( - ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) - OR - ( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) ) - ) - )) -- Etiquetas que no se han escaneado y ya estamos con una posterior - OR - (s.alertLevel > 1 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND tp.created < vParked - AND t.packages <=> 0); - -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 `ticketNotInvoicedByClient` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -71585,64 +71794,66 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) BEGIN - + /** * Averigua los tickets que se han saltado por un error en el proceso encajado * @param vTicketFk Ticket * @param vItemPackingTypeFk Modo de encajado * @return un select con los tickets afectados - */ + */ DECLARE vParkingFk INT; DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vWagon INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) INTO vLevel, vWagon, vCollectionFk FROM vn.ticketCollection tc JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk WHERE ticketFk = vTicketFk ORDER BY c.id DESC LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk WHERE ticketFk = vTicketFk AND s.itemPackingTypeFk = vItemPackingTypeFk AND s.isPackagingArea ; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk + JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.zone z ON z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.state s ON s.id = tst.state + JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' + JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' + WHERE (s.alertLevel < alPacked.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea AND ( ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) OR - ( tc.collectionFk = vCollectionFk + ( tc.collectionFk = vCollectionFk AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) - OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) ) ) ) -- Etiquetas que no se han escaneado y ya estamos con una posterior OR - (s.alertLevel > 1 + (s.alertLevel > alOnPreparation.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea - AND tp.created < vParked + AND tp.created < vParked AND t.packages <=> 0); END ;; DELIMITER ; @@ -71662,64 +71873,28 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* Modifica el estado de un ticket de hoy - * + * * @param vTicketFk el id del ticket * @param vStateCode estado a modificar del ticket - * + * */ - + DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM state s - JOIN ticketStateToday tst ON tst.state = s.id + DECLARE vAlertLevelPacked INT; + + SELECT s.alertLevel, al.id + INTO vAlertLevel, vAlertLevelPacked + FROM state s + JOIN ticketStateToday tst ON tst.state = s.id + JOIN alertLevel al ON al.code = 'PACKED' WHERE tst.ticketFk = vTicketFk LIMIT 1; - - IF vAlertLevel < 2 THEN - + + IF vAlertLevel < vAlertLevelPacked THEN + CALL vn.ticket_setState(vTicketFk, vStateCode); - - 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 = 'NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketStateUpdate` */; -/*!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 = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) -BEGIN - - /* - * @deprecated:utilizar ticket_setState - */ - - DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM vn.state s - JOIN vn.ticketState ts ON ts.stateFk = s.id - WHERE ts.ticketFk = vTicketFk; - - IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN - - INSERT INTO ticketTracking(stateFk, ticketFk, userFk) - SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state - WHERE `code` = vStateCode collate utf8_unicode_ci; END IF; @@ -73157,10 +73332,11 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket SELECT ticketFk FROM tmp.productionBuffer + JOIN alertLevel al ON al.code = 'FREE' WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = 0; + AND alertLevel = al.id; OPEN cur1; @@ -73279,7 +73455,7 @@ BEGIN com.id companyFk, a.id addressFk, c2.defaultAddressFk, - su.id supplierFk, + IFNULL(sat.supplierFk, su.id) supplierFk, t.landed FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id @@ -73289,15 +73465,18 @@ BEGIN JOIN `address` a ON a.id = t.addressFk JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk - JOIN agencyMode am ON am.id = t.agencyModeFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk - JOIN supplierAccount sa ON sa.id = com.supplierAccountFk + JOIN supplierAccount sa ON sa.id = com.supplierAccountFk JOIN supplier su ON su.id = sa.supplierFk LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id + AND wo.isFreelance WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' @@ -82100,23 +82279,6 @@ SET character_set_client = utf8; 1 AS `description` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `Saldos_Prevision` --- - -DROP TABLE IF EXISTS `Saldos_Prevision`; -/*!50001 DROP VIEW IF EXISTS `Saldos_Prevision`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `Saldos_Prevision` AS SELECT - 1 AS `Saldos_Prevision_id`, - 1 AS `Descripcion`, - 1 AS `Importe`, - 1 AS `Fecha`, - 1 AS `Id_Banco`, - 1 AS `empresa_id` */; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `Split_lines` -- @@ -82177,7 +82339,6 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `Observaciones`, 1 AS `Firmado`, - 1 AS `Etiquetasemitidas`, 1 AS `PedidoImpreso`, 1 AS `Hora`, 1 AS `blocked`, @@ -85135,7 +85296,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(`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 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`.`roadmapStopFk` = `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 */; @@ -85171,7 +85332,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(`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 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`.`roadmapStopFk` = `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 */; @@ -85261,7 +85422,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(`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 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`.`roadmapStopFk` = `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 */; @@ -85681,7 +85842,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 `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 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`.`roadmapStopFk` AS `roadmapStopFk`,`t`.`warehouseFk` AS `warehouseFk`,`e`.`created` AS `lastPacked`,`t`.`id` AS `ticketFk` from (((((`roadmapStop` `rs` left join `routesMonitor` `r` on(`rs`.`id` = `r`.`roadmapStopFk`)) 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 */; @@ -85699,7 +85860,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 `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 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`.`roadmapStopFk` 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`.`roadmapStopFk`)) 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 */; @@ -85717,7 +85878,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 `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 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`.`roadmapStopFk`)) 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 */; @@ -85771,7 +85932,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(`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 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`.`roadmapStopFk`)) 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 */; @@ -85789,7 +85950,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`,`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 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`.`roadmapStopFk`)) 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 */; @@ -85825,61 +85986,7 @@ USE `vn`; /*!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` --- - -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control`*/; -/*!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_Control` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `ETD`,`e`.`description` AS `description`,count(distinct if(`e`.`expeditionFk` is null,`e`.`ticketFk`,NULL)) AS `ticketsSinBultos`,count(distinct `e`.`palletFk`) AS `pallets`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionFk`) AS `expeditions`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`eta` */; -/*!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_Detail` --- - -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail`*/; -/*!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_Control_Detail` AS select `e`.`truckFk` AS `id`,`e`.`eta` AS `eta`,`e`.`description` AS `destino`,`e`.`palletFk` AS `pallet`,count(distinct `e`.`routeFk`) AS `routes`,count(distinct `e`.`scanFk`) AS `scans`,count(distinct `e`.`expeditionTruckFk`) AS `destinos`,sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,max(`e`.`lastPacked`) AS `lastPacked` from `expeditionCommon` `e` group by `e`.`truckFk`,`e`.`palletFk` order by sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) desc,`e`.`eta`,`e`.`truckFk` */; -/*!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_Detail_Pallet` --- - -/*!50001 DROP VIEW IF EXISTS `expeditionTruck_Control_Detail_Pallet`*/; -/*!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_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 VIEW `expeditionTruck` AS select `rs`.`id` AS `id`,`rs`.`roadmapFk` AS `roadmapFk`,`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 */; @@ -87852,24 +87959,6 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `Saldos_Prevision` --- - -/*!50001 DROP VIEW IF EXISTS `Saldos_Prevision`*/; -/*!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 `Saldos_Prevision` AS select `fb`.`id` AS `Saldos_Prevision_id`,`fb`.`description` AS `Descripcion`,`fb`.`amount` AS `Importe`,`fb`.`dated` AS `Fecha`,`fb`.`accountingFk` AS `Id_Banco`,`fb`.`companyFk` AS `empresa_id` from `vn`.`forecastedBalance` `fb` */; -/*!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 `Split_lines` -- @@ -87919,7 +88008,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Tickets` AS select `t`.`id` AS `Id_Ticket`,`t`.`clientFk` AS `Id_Cliente`,`t`.`warehouseFk` AS `warehouse_id`,`t`.`shipped` AS `Fecha`,`t`.`landed` AS `landing`,`t`.`nickname` AS `Alias`,`t`.`refFk` AS `Factura`,`t`.`addressFk` AS `Id_Consigna`,`t`.`location` AS `Localizacion`,`t`.`solution` AS `Solucion`,`t`.`routeFk` AS `Id_Ruta`,`t`.`companyFk` AS `empresa_id`,`t`.`agencyModeFk` AS `Id_Agencia`,`t`.`priority` AS `Prioridad`,`t`.`packages` AS `Bultos`,`t`.`isDeleted` AS `isDeleted`,`t`.`created` AS `odbc_date`,`t`.`workerFk` AS `Id_Trabajador`,`t`.`observations` AS `Observaciones`,`t`.`isSigned` AS `Firmado`,`t`.`isLabeled` AS `Etiquetasemitidas`,`t`.`isPrinted` AS `PedidoImpreso`,`t`.`hour` AS `Hora`,`t`.`isBlocked` AS `blocked`,`t`.`hasPriority` AS `priority`,`t`.`isBoxed` AS `boxed`,`t`.`zoneFk` AS `zoneFk`,`t`.`totalWithVat` AS `totalWithVat`,`t`.`totalWithoutVat` AS `totalWithoutVat` from `vn`.`ticket` `t` */; +/*!50001 VIEW `Tickets` AS select `t`.`id` AS `Id_Ticket`,`t`.`clientFk` AS `Id_Cliente`,`t`.`warehouseFk` AS `warehouse_id`,`t`.`shipped` AS `Fecha`,`t`.`landed` AS `landing`,`t`.`nickname` AS `Alias`,`t`.`refFk` AS `Factura`,`t`.`addressFk` AS `Id_Consigna`,`t`.`location` AS `Localizacion`,`t`.`solution` AS `Solucion`,`t`.`routeFk` AS `Id_Ruta`,`t`.`companyFk` AS `empresa_id`,`t`.`agencyModeFk` AS `Id_Agencia`,`t`.`priority` AS `Prioridad`,`t`.`packages` AS `Bultos`,`t`.`isDeleted` AS `isDeleted`,`t`.`created` AS `odbc_date`,`t`.`workerFk` AS `Id_Trabajador`,`t`.`observations` AS `Observaciones`,`t`.`isSigned` AS `Firmado`,`t`.`isPrinted` AS `PedidoImpreso`,`t`.`hour` AS `Hora`,`t`.`isBlocked` AS `blocked`,`t`.`hasPriority` AS `priority`,`t`.`isBoxed` AS `boxed`,`t`.`zoneFk` AS `zoneFk`,`t`.`totalWithVat` AS `totalWithVat`,`t`.`totalWithoutVat` AS `totalWithoutVat` from `vn`.`ticket` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89715,4 +89804,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-06-11 6:35:36 +-- Dump completed on 2024-06-25 7:26:45 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index b2f550bbe..90ff6b30d 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -2140,24 +2140,22 @@ BEGIN END IF; IF !(OLD.started <=> NEW.started AND OLD.ended <=> NEW.ended) THEN - - SELECT COUNT(*) > 0 INTO isOverlapping - FROM business b - WHERE (util.hasDateOverlapped( - NEW.started, - IFNULL(NEW.ended, b.started), - b.started, - IFNULL(b.ended, NEW.started)) - OR (NEW.ended <=> NULL AND b.ended <=> NULL)) - AND b.id <> OLD.id - AND workerFk = OLD.workerFk; + SELECT util.hasDateOverlapped( + started, + ended, + NEW.started, + IFNULL(NEW.ended, b.started) + ) isOverlapped INTO isOverlapping + FROM vn.business b + WHERE workerFk = NEW.workerFK + AND b.id <> NEW.id + ORDER BY isOverlapped DESC + LIMIT 1; IF isOverlapping THEN CALL util.throw ('IS_OVERLAPPING'); END IF; - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -2366,7 +2364,15 @@ trig:BEGIN LEAVE trig; END IF; - CALL entry_isEditable(OLD.entryFk); + IF NOT (NEW.entryFk <=> OLD.entryFk) OR + NOT (NEW.quantity <=> OLD.quantity) OR + NOT (NEW.buyingValue <=> OLD.buyingValue) OR + NOT (NEW.packing <=> OLD.packing) + THEN + + CALL entry_isEditable(OLD.entryFk); + END IF; + SET NEW.editorFk = account.myUser_getId(); SELECT defaultEntry INTO vDefaultEntry @@ -3010,6 +3016,52 @@ 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`.`claimRatio_afterInsert` + AFTER INSERT ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +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`.`claimRatio_afterUpdate` + AFTER UPDATE ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +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`.`claimState_beforeInsert` BEFORE INSERT ON `claimState` FOR EACH ROW @@ -3198,11 +3250,11 @@ BEGIN END IF; END IF; - IF !(NEW.salesPersonFk <=> OLD.salesPersonFk) THEN + IF NOT (NEW.salesPersonFk <=> OLD.salesPersonFk) THEN SET NEW.lastSalesPersonFk = IFNULL(NEW.salesPersonFk, OLD.salesPersonFk); END IF; - IF !(NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN + IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN SET NEW.isTaxDataChecked = 0; END IF; END */;; @@ -3224,13 +3276,36 @@ DELIMITER ;; AFTER UPDATE ON `client` FOR EACH ROW BEGIN - IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN + IF NOT (NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; UPDATE `address` SET isDefaultAddress = TRUE WHERE id = NEW.defaultAddressFk; END IF; + + IF NEW.id <> OLD.id + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.socialName <=> OLD.socialName) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.accountingAccount <=> OLD.accountingAccount) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.fi <=> OLD.fi) + OR NOT (NEW.postcode <=> OLD.postcode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.email <=> OLD.email) + OR NOT (NEW.iban <=> OLD.iban) + OR NOT (NEW.phone <=> OLD.phone) + OR NOT (NEW.mobile <=> OLD.mobile) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'C'; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4203,31 +4278,6 @@ 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`.`deviceProductionConfig_afterUpdate` - AFTER UPDATE ON `deviceProductionConfig` - FOR EACH ROW -BEGIN - IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN - SET @username := (SELECT account.myUser_getName()); - INSERT INTO vn.mail (receiver, subject, body) - VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app', - CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones')); - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_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`.`deviceProductionModels_beforeInsert` BEFORE INSERT ON `deviceProductionModels` FOR EACH ROW @@ -4617,10 +4667,21 @@ BEGIN DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; DECLARE vTotalBuy INT; - - IF NEW.isBooked = OLD.isBooked THEN + + IF NEW.isBooked = OLD.isBooked AND ( + NOT (NEW.supplierFk <=> OLD.supplierFk) OR + NOT (NEW.dated <=> OLD.dated) OR + NOT (NEW.invoiceNumber <=> OLD.invoiceNumber) OR + NOT (NEW.travelFk <=> OLD.travelFk) OR + NOT (NEW.companyFk <=> OLD.companyFk) OR + NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) OR + NOT (NEW.invoiceAmount <=> OLD.invoiceAmount) OR + NOT (NEW.typeFk <=> OLD.typeFk) + ) THEN + CALL entry_isEditable(OLD.id); ELSE + IF NEW.isBooked THEN SELECT COUNT(*) INTO vTotalBuy FROM buy @@ -4894,25 +4955,25 @@ DELIMITER ;; BEFORE INSERT ON `expedition` FOR EACH ROW BEGIN - DECLARE intcounter INT; - DECLARE vShipFk INT; + DECLARE vMaxCounter INT; SET NEW.editorFk = account.myUser_getId(); - IF NEW.freightItemFk IS NOT NULL THEN + IF NEW.freightItemFk IS NOT NULL THEN UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter - FROM expedition e - INNER JOIN ticket t1 ON e.ticketFk = t1.id + SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter + FROM expedition e + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN ticket t1 ON e.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) AND t1.warehouseFk = t2.warehouseFk - WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; - SET NEW.`counter` = intcounter; + SET NEW.`counter` = vMaxCounter; END IF; END */;; DELIMITER ; @@ -8525,6 +8586,44 @@ 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`.`supplier_afterUpdate` + BEFORE UPDATE ON `supplier` + FOR EACH ROW +BEGIN + IF NEW.id <> OLD.id + OR NOT (NEW.name <=> OLD.name) + OR NOT (NEW.street <=> OLD.street) + OR NOT (NEW.account <=> OLD.account) + OR NOT (NEW.nif <=> OLD.nif) + OR NOT (NEW.isVies <=> OLD.isVies) + OR NOT (NEW.provinceFk <=> OLD.provinceFk) + OR NOT (NEW.countryFk <=> OLD.countryFk) + OR NOT (NEW.postCode <=> OLD.postCode) + OR NOT (NEW.city <=> OLD.city) + OR NOT (NEW.taxTypeSageFk <=> OLD.taxTypeSageFk) + OR NOT (NEW.transactionTypeSageFk <=> OLD.transactionTypeSageFk) + OR NOT (NEW.withholdingSageFk <=> OLD.withholdingSageFk) THEN + + UPDATE sage.clientSupplier + SET isSync = FALSE + WHERE idClientSupplier IN (NEW.id, OLD.id) + AND `type` = 'P'; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`supplier_afterDelete` AFTER DELETE ON `supplier` FOR EACH ROW @@ -10825,4 +10924,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-06-11 6:35:55 +-- Dump completed on 2024-06-25 7:27:06