diff --git a/services/db/export-data.cmd b/services/db/export-data.cmd index 222f3157a..3aae81473 100755 --- a/services/db/export-data.cmd +++ b/services/db/export-data.cmd @@ -6,7 +6,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump echo USE `vn`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql echo USE `vn2008`; >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos >> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas>> install/dump/03-dumpedFixtures.sql echo USE `bi`; >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql echo USE `cache`; >> install/dump/03-dumpedFixtures.sql diff --git a/services/db/export-data.sh b/services/db/export-data.sh index 32af5c6ab..054b60729 100755 --- a/services/db/export-data.sh +++ b/services/db/export-data.sh @@ -7,7 +7,7 @@ mysqldump --defaults-file=connect.ini --no-create-info salix ACL >> install/dump echo "USE \`vn\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info vn cplusInvoiceType477 cplusSubjectOp cplusTaxBreak bookingPlanner pgc >> install/dump/03-dumpedFixtures.sql echo "USE \`vn2008\`;" >> install/dump/03-dumpedFixtures.sql -mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos>> install/dump/03-dumpedFixtures.sql +mysqldump --defaults-file=connect.ini --no-create-info vn2008 accion_dits Gastos Tintas tarifa_componentes tarifa_componentes_series state bionic_updating_options Grupos Monedas>> install/dump/03-dumpedFixtures.sql echo "USE \`bi\`;" >> install/dump/03-dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info bi tarifa_componentes tarifa_componentes_series >> install/dump/03-dumpedFixtures.sql echo "USE \`cache\`;" >> install/dump/03-dumpedFixtures.sql diff --git a/services/db/install/dump/01-structure.sql b/services/db/install/dump/01-structure.sql index 0f7f5cc21..e37cd4803 100644 --- a/services/db/install/dump/01-structure.sql +++ b/services/db/install/dump/01-structure.sql @@ -174,7 +174,7 @@ CREATE TABLE `mailAlias` ( `isPublic` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`) -) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; +) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -332,7 +332,7 @@ CREATE TABLE `user` ( KEY `nickname` (`nickname`), KEY `lang` (`lang`), CONSTRAINT `user_ibfk_2` FOREIGN KEY (`role`) REFERENCES `role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=14086 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -348,6 +348,10 @@ DELIMITER ;; FOR EACH ROW BEGIN CALL userCheckName (NEW.`name`); + + IF NEW.nickname = '' THEN + SET NEW.nickname = NEW.`name`; + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -406,6 +410,15 @@ BEGIN `text` = CONCAT(account.userGetName(), ' ha modificado el rol del usuario ', NEW.`name`, ' de ', OLD.role, ' a ', NEW.role); END IF; + IF NOT (NEW.`active` <=> OLD.`active`) + THEN + INSERT INTO vn2008.mail SET + `to` = 'jgallego@verdnatura.es', + `reply_to` = 'jgallego@verdnatura.es', + `subject` = 'active modificado', + `text` = CONCAT(account.userGetName(), ' ha modificado el active del usuario ', + NEW.`name`, ' de ', OLD.active, ' a ', NEW.active); + END IF; END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -611,7 +624,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `USERGETID` */; +/*!50003 DROP FUNCTION IF EXISTS `userGetId` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -1822,7 +1835,7 @@ CREATE DEFINER=`root`@`%` FUNCTION `hmacSha2`(`vAlg` SMALLINT, `vMsg` MEDIUMBLOB DETERMINISTIC BEGIN /** - * HMAC function based on SHA2 vAlgorythms. + * HMAC function based on SHA2 algorythms. */ DECLARE vHashlen INT UNSIGNED; DECLARE vOpad, vIpad TINYBLOB; @@ -1832,7 +1845,7 @@ BEGIN WHEN 256 THEN SET vHashlen = 64; WHEN 384 THEN SET vHashlen = 128; WHEN 512 THEN SET vHashlen = 128; - ELSE CALL throw ('WRONG_vALGORYTHM_IDENTIFICATOR_USED'); + ELSE CALL throw ('WRONG_ALGORYTHM_IDENTIFICATOR_USED'); END CASE; IF LENGTH(vKey) > vHashlen THEN @@ -2293,7 +2306,7 @@ CREATE TABLE `Agencias` ( PRIMARY KEY (`Id_Agencia`), KEY `Agencias` (`Agencia`), KEY `Vista` (`Vista`) -) ENGINE=InnoDB AUTO_INCREMENT=1204 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2312,7 +2325,7 @@ CREATE TABLE `Agencias_dits` ( `value_old` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `value_new` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`idAgencia_dits`) -) ENGINE=InnoDB AUTO_INCREMENT=18349 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20189 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2412,7 +2425,7 @@ CREATE TABLE `Articles` ( CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=307158 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=309776 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2596,7 +2609,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=19884 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20137 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2618,7 +2631,7 @@ CREATE TABLE `Articles_nicho` ( KEY `Articles_nicho_wh_fk` (`warehouse_id`), CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=427675 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=452394 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2689,10 +2702,13 @@ CREATE TABLE `Bancos` ( `warehouse_id` smallint(5) unsigned NOT NULL DEFAULT '1', `entity_id` int(10) unsigned NOT NULL, `activo` tinyint(4) NOT NULL DEFAULT '1', + `currencyFk` tinyint(3) unsigned DEFAULT '1', PRIMARY KEY (`Id_Banco`), KEY `BancosBanco` (`Banco`), KEY `fk_Bancos_entity1_idx` (`entity_id`), KEY `foreignkey1_idx` (`cash`), + KEY `Bancoscurrency_idx` (`currencyFk`), + CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, CONSTRAINT `foreignkey1` FOREIGN KEY (`cash`) REFERENCES `vn`.`accountingType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -2768,6 +2784,8 @@ CREATE TABLE `Cajas` ( `conciliado` int(2) NOT NULL DEFAULT '0', `Proveedores_account_Id` mediumint(8) unsigned NOT NULL, `id_calculated` varchar(90) COLLATE utf8_unicode_ci DEFAULT NULL, + `InForeignValue` decimal(10,2) DEFAULT NULL, + `OutForeignValue` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`Id_Caja`), UNIQUE KEY `id_calculated_UNIQUE` (`id_calculated`), KEY `CajasCajafecha` (`Cajafecha`), @@ -2777,7 +2795,7 @@ CREATE TABLE `Cajas` ( KEY `warehouse_id` (`warehouse_id`), KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=571332 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=579633 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2924,7 +2942,7 @@ CREATE TABLE `Clientes` ( CONSTRAINT `Clientes_ibfk_5` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`chanel_id`) REFERENCES `chanel` (`chanel_id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientes_tipo_id`) REFERENCES `clientes_tipo` (`clientes_tipo_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14086 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -2955,9 +2973,7 @@ BEGIN SET NEW.cuenta = 4300000000 + NEW.Id_Cliente; - IF NEW.pay_met_id = 4 AND NEW.Vencimiento = 0 THEN - SET NEW.Vencimiento = 5; - END IF; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3030,17 +3046,11 @@ BEGIN IF !(NEW.fax <=> OLD.fax) THEN CALL pbx.phoneIsValid (NEW.fax); END IF; - /* - -- Actualiza el log del crédito - IF !(NEW.Credito <=> OLD.Credito) AND IFNULL(NEW.Credito, 0) >= 0 - THEN - INSERT INTO credit SET - Id_Cliente = NEW.Id_Cliente, - amount = NEW.Credito, - Id_Trabajador = vn.getWorker(); - END IF; -*/ + IF NEW.pay_met_id = 4 AND NEW.Vencimiento = 0 THEN + SET NEW.Vencimiento = 5; + END IF; + -- Avisar al comercial si ha llegado la documentación sepa/core IF NEW.sepavnl AND !OLD.sepavnl THEN @@ -3115,7 +3125,7 @@ CREATE TABLE `Clientes_dits` ( PRIMARY KEY (`idClientes_dits`), KEY `idaccion_dits` (`idaccion_dits`), CONSTRAINT `Clientes_dits_ibfk_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=71652 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=71661 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3215,7 +3225,7 @@ CREATE TABLE `Colas` ( CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `Prioridades` (`Id_Prioridad`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_5` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=131852 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=180945 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3297,7 +3307,7 @@ CREATE TABLE `Compres` ( CONSTRAINT `Compres_ibfk_2` FOREIGN KEY (`Id_Cubo`) REFERENCES `Cubos` (`Id_Cubo`) ON UPDATE CASCADE, CONSTRAINT `Compres_ibfk_3` FOREIGN KEY (`container_id`) REFERENCES `container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=247066166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=250691673 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3549,7 +3559,7 @@ CREATE TABLE `Compres_ok` ( KEY `Id_Movimiento` (`Id_Compra`), KEY `Id_Accion` (`Id_Accion`), CONSTRAINT `Compres_ok_ibfk_1` FOREIGN KEY (`Id_Compra`) REFERENCES `Compres` (`Id_Compra`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18717 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3593,7 +3603,7 @@ CREATE TABLE `Consignatarios` ( CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=24745 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24952 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3777,7 +3787,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2612 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2621 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -3970,10 +3980,11 @@ CREATE TABLE `Entradas` ( KEY `empresa_id` (`empresa_id`), KEY `gestdoc_id` (`gestdoc_id`), KEY `recibida_id` (`recibida_id`), + CONSTRAINT `Entradas_fk8` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_1` FOREIGN KEY (`Id_Proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_6` FOREIGN KEY (`travel_id`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `Entradas_ibfk_7` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=139048 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=141068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4008,6 +4019,7 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`EntradasBeforeUpdate` BEFORE UPDATE ON `vn2008`.`Entradas` FOR EACH ROW BEGIN + IF (SELECT Id_Entrada FROM Entradas_Auto WHERE Id_Entrada = NEW.Id_Entrada) AND (NEW.travel_id <> OLD.travel_id) THEN IF (SELECT warehouse_id FROM travel WHERE id = NEW.travel_id) <> (SELECT warehouse_id FROM travel WHERE id = OLD.travel_id) OR @@ -4032,6 +4044,15 @@ BEGIN INSERT INTO Entradas_dits (idaccion_dits,Id_Trabajador,Id_Ticket,value_old,value_new) VALUES (105,get_Trabajador(),NEW.Id_Entrada,OLD.anotadoencaja,NEW.anotadoencaja); END IF; + + IF NEW.Pedida <> FALSE AND OLD.Pedida = FALSE AND + (SELECT COUNT(*) FROM travel WHERE id = NEW.travel_id AND warehouse_id = 5 AND warehouse_id_out = 1) + THEN + INSERT INTO mail(`to`, reply_to, subject, text) + VALUES('madrid@verdnatura.es', 'logistica@verdnatura.es', + 'Preparacion movimiento Madrid', + CONCAT('Se ha empezado a preparar el movimiento ',NEW.Id_Entrada)); + END IF; IF NEW.Id_Proveedor <> OLD.Id_Proveedor THEN IF (SELECT cuenta LIKE '___4______' FROM Proveedores WHERE Id_Proveedor = NEW.Id_Proveedor) THEN @@ -4127,7 +4148,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey_entradas_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2692884 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2754538 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4145,7 +4166,7 @@ CREATE TABLE `Entradas_kop` ( PRIMARY KEY (`Id_Entradas_kop`), KEY `entradas_entradas_kop_idx` (`Id_Entrada`), CONSTRAINT `entradas_entradas_kop` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=729 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4233,7 +4254,7 @@ CREATE TABLE `Equipos` ( PRIMARY KEY (`id`), KEY `trabajador_id` (`trabajador_id`), CONSTRAINT `Equipos_ibfk_1` FOREIGN KEY (`trabajador_id`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=149 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=154 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4388,7 +4409,7 @@ CREATE TABLE `Facturas` ( CONSTRAINT `Facturas_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `vn`.`cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=449931 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=453579 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4606,7 +4627,7 @@ CREATE TABLE `Greuges` ( KEY `Id_Ticket_Greuge_Ticket_idx` (`Id_Ticket`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`Greuges_type_id`) REFERENCES `Greuges_type` (`Greuges_type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2138020 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; +) ENGINE=InnoDB AUTO_INCREMENT=2199011 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4679,6 +4700,8 @@ CREATE TABLE `Impresoras` ( `Impresora` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `referencia` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `2C` tinyint(4) DEFAULT '0', + `isLabeler` tinyint(3) NOT NULL DEFAULT '0', + `description` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id_Impresora`), UNIQUE KEY `referencia` (`referencia`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -4805,7 +4828,7 @@ CREATE TABLE `Movimientos` ( KEY `itemFk_ticketFk` (`Id_Article`,`Id_Ticket`), CONSTRAINT `Movimientos_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `movement_ticket_id` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20397746 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20765563 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -4954,7 +4977,7 @@ CREATE TABLE `Movimientos_mark` ( `Id_Movimiento_mark` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id_Movimiento_mark`), KEY `Id_Movimiento` (`Id_Movimiento`) -) ENGINE=InnoDB AUTO_INCREMENT=9979711 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10393857 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5024,7 +5047,7 @@ CREATE TABLE `Ordenes` ( KEY `Id_Comprador` (`CodCOMPRADOR`), KEY `Id_Movimiento` (`Id_Movimiento`), KEY `Id_Vendedor` (`CodVENDEDOR`) -) ENGINE=InnoDB AUTO_INCREMENT=29084 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=30054 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5134,7 +5157,7 @@ CREATE TABLE `PreciosEspeciales` ( CONSTRAINT `sp_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `{01A99AF1-3D3F-4B15-AC0C-C7A834F319A3}` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `{EE4ADEF6-0AC6-401F-B7C4-D797972FC065}` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=690 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=691 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5196,7 +5219,7 @@ CREATE TABLE `Proveedores` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`pay_dem_id`) REFERENCES `pay_dem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2471 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2487 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5222,7 +5245,7 @@ CREATE TABLE `Proveedores_account` ( KEY `fk_Proveedores_account_entity1_idx` (`entity_id`), KEY `fk_banco_prov_account_idx` (`Id_Banco`), CONSTRAINT `fk_banco_prov_account` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=617 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5313,7 +5336,7 @@ CREATE TABLE `Recibos` ( CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=451596 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=458495 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5404,7 +5427,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2613 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2622 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5424,7 +5447,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1065 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5449,7 +5472,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=170 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5480,7 +5503,7 @@ CREATE TABLE `Rutas` ( KEY `Fecha` (`Fecha`), KEY `gestdoc_id` (`gestdoc_id`), CONSTRAINT `Rutas_ibfk_1` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=37191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=38168 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5542,7 +5565,7 @@ CREATE TABLE `Rutas_Master` ( PRIMARY KEY (`id`), KEY `fk_rutas_warehouse_id_idx` (`warehouse_id`), CONSTRAINT `fk_rutas_warehouse_id` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5633,7 +5656,7 @@ CREATE TABLE `Saldos_Prevision` ( KEY `empresa_prevision_idx` (`empresa_id`), CONSTRAINT `banco_prevision` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `empresa_prevision` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; +) ENGINE=InnoDB AUTO_INCREMENT=97 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5668,7 +5691,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `Compres` (`Id_Compra`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Split_lines_ibfk_1` FOREIGN KEY (`Id_Split`) REFERENCES `Splits` (`Id_Split`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=317891 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=320158 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5686,7 +5709,7 @@ CREATE TABLE `Splits` ( `Notas` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`Id_Split`), KEY `Id_Entrada` (`Id_Entrada`) -) ENGINE=InnoDB AUTO_INCREMENT=36181 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5714,7 +5737,7 @@ CREATE TABLE `Stockcontrol` ( CONSTRAINT `Stockcontrol_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_2` FOREIGN KEY (`Id_Remitente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Stockcontrol_ibfk_3` FOREIGN KEY (`Id_Solver`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=23409 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23454 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5771,7 +5794,7 @@ CREATE TABLE `Tickets` ( CONSTRAINT `Tickets_ibfk_9` FOREIGN KEY (`Id_Ruta`) REFERENCES `Rutas` (`Id_Ruta`) ON UPDATE CASCADE, CONSTRAINT `ticket_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`Factura`) REFERENCES `Facturas` (`Id_Factura`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1821166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1853844 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -5980,7 +6003,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=58060267 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=58637540 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6029,7 +6052,7 @@ CREATE TABLE `Tickets_turno` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`Id_Ticket`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1817962 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1848794 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6182,7 +6205,7 @@ CREATE TABLE `Trabajadores` ( KEY `sub` (`sub`), CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1087 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1106 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6309,7 +6332,7 @@ CREATE TABLE `Vehiculos` ( KEY `provinceFk_idx` (`warehouseFk`), CONSTRAINT `Vehiculos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=373 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=377 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6335,7 +6358,7 @@ CREATE TABLE `Vehiculos_consumo` ( PRIMARY KEY (`Vehiculos_consumo_id`,`Id_Vehiculo`), KEY `fk_Vehiculos_consumo_Vehiculos_idx` (`Id_Vehiculo`), CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `Vehiculos` (`Id_Vehiculo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7724 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; +) ENGINE=InnoDB AUTO_INCREMENT=7981 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntan el importe de los tickets de la gasolinera solred, con quien tenemos un contrato y nos facturan mensualmente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6449,7 +6472,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3270411 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3309704 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6557,7 +6580,7 @@ CREATE TABLE `account_conciliacion` ( KEY `fg_accconciliacion_key1_idx` (`Id_Proveedores_account`), KEY `index_id_calculated` (`id_calculated`), CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=32837 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6741,7 +6764,7 @@ CREATE TABLE `agency_hour` ( CONSTRAINT `agency_hour_ibfk_1` FOREIGN KEY (`agency_id`) REFERENCES `agency` (`agency_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_hour_ibfk_2` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `agency_hour_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4476 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4623 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6907,7 +6930,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2170 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2234 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6984,7 +7007,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2458 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2519 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6997,14 +7020,22 @@ CREATE TABLE `awb` ( DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `awb_ai` AFTER INSERT ON `awb` FOR EACH ROW BEGIN -DECLARE lastrecibida_id INT; -INSERT INTO recibida(proveedor_id,fecha,empresa_id) - VALUES(NEW.transitario_id,CURDATE(),442); -SELECT last_insert_id() into lastrecibida_id; + DECLARE lastrecibida_id INT; + + -- Eliminar cuando funcione el sistema DUA + INSERT INTO recibida(proveedor_id,fecha,empresa_id) + VALUES(NEW.transitario_id,CURDATE(),442); -INSERT INTO awb_recibida(awb_id,recibida_id) - VALUES(NEW.id,lastrecibida_id); + SELECT last_insert_id() into lastrecibida_id; + + INSERT INTO awb_recibida(awb_id,recibida_id) + VALUES(NEW.id,lastrecibida_id); + + -- Sistema DUA + INSERT INTO vn.dua(awbFk) + VALUES(NEW.id); + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7153,7 +7184,7 @@ CREATE TABLE `awb_component_template` ( CONSTRAINT `Id_Moneda` FOREIGN KEY (`Id_Moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk1` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE, CONSTRAINT `role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=498 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=516 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7234,7 +7265,7 @@ CREATE TABLE `awb_gestdoc` ( KEY `awb_gestdoc_gestdoc_fk` (`gestdoc_id`), CONSTRAINT `awb_gestdoc_awb_fk` FOREIGN KEY (`awb_id`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2149 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2185 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7333,7 +7364,7 @@ CREATE TABLE `balance_nest_tree` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Id_Gasto` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=383 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=386 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7352,7 +7383,7 @@ CREATE TABLE `barcodes` ( UNIQUE KEY `Id_Article_2` (`Id_Article`,`code`), KEY `Id_Article` (`Id_Article`), CONSTRAINT `barcodes_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=35128 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=35405 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7493,7 +7524,7 @@ CREATE TABLE `buy_edi` ( KEY `kop` (`kop`), KEY `barcode` (`barcode`), KEY `fec` (`fec`) -) ENGINE=InnoDB AUTO_INCREMENT=670491 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=685476 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7747,7 +7778,7 @@ CREATE TABLE `cl_act` ( CONSTRAINT `cl_act_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `cl_act_ibfk_4` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=79746 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=81934 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7781,7 +7812,7 @@ CREATE TABLE `cl_cau` ( CONSTRAINT `cl_cau_ibfk_7` FOREIGN KEY (`cl_mot_id`) REFERENCES `cl_mot` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_8` FOREIGN KEY (`cl_con_id`) REFERENCES `cl_con` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_cau_ibfk_9` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=43883 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=44635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7835,7 +7866,7 @@ CREATE TABLE `cl_det` ( CONSTRAINT `cl_det_ibfk_6` FOREIGN KEY (`cl_pet_id`) REFERENCES `cl_pet` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_7` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `cl_det_ibfk_8` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=110648 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=113455 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7892,7 +7923,7 @@ CREATE TABLE `cl_main` ( CONSTRAINT `cl_main_ibfk_3` FOREIGN KEY (`cl_est_id`) REFERENCES `cl_est` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_4` FOREIGN KEY (`cl_dep_id`) REFERENCES `cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `cl_main_ibfk_5` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=47348 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=48710 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8005,7 +8036,7 @@ CREATE TABLE `client_observation` ( KEY `Id_Cliente` (`Id_Cliente`), CONSTRAINT `client_observation_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_observation_ibfk_2` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=61164 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=62623 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8057,7 +8088,7 @@ CREATE TABLE `clientes_regalos_lista_enc` ( `warehouse_id` smallint(6) unsigned DEFAULT '1', `province_id` smallint(5) unsigned DEFAULT NULL, PRIMARY KEY (`Id_Regalo`) -) ENGINE=MyISAM AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=177 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8171,7 +8202,7 @@ CREATE TABLE `consignatarios_observation` ( `text` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`consignatarios_observation_id`), UNIQUE KEY `Id_Consigna` (`Id_Consigna`,`observation_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=3047 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=3130 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8215,7 +8246,7 @@ CREATE TABLE `cooler_path_detail` ( `pasillo` varchar(3) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`cooler_path_id`,`pasillo`), UNIQUE KEY `cooler_path_detail_id_UNIQUE` (`cooler_path_detail_id`) -) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=718 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8253,7 +8284,7 @@ CREATE TABLE `credit` ( KEY `credit_ClienteFk` (`Id_Cliente`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=61355 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=62678 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8378,7 +8409,7 @@ CREATE TABLE `device` ( PRIMARY KEY (`device_id`), UNIQUE KEY `device_id_UNIQUE` (`device_id`), UNIQUE KEY `sn_UNIQUE` (`sn`) -) ENGINE=InnoDB AUTO_INCREMENT=200 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=223 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8726,7 +8757,7 @@ CREATE TABLE `entity` ( UNIQUE KEY `bic_UNIQUE` (`bic`), KEY `fg_entity1_idx` (`pais_id`), CONSTRAINT `fg_entity1` FOREIGN KEY (`pais_id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=30004 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; +) ENGINE=InnoDB AUTO_INCREMENT=30006 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8765,7 +8796,7 @@ CREATE TABLE `escritos_det` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `escritos_det_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15054 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15295 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8794,7 +8825,7 @@ CREATE TABLE `expeditions` ( KEY `index4` (`ticket_id`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticket_id`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2322358 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2382388 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8865,26 +8896,6 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`expeditionsAfterUpdate` -AFTER UPDATE ON `expeditions` FOR EACH ROW -BEGIN - -- @deprecated 2018-04-15 - -- CALL cache.barcodes_expeditions_update(NEW.expeditions_id); -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`expeditionsBeforeDelete` BEFORE DELETE ON `expeditions` FOR EACH ROW BEGIN @@ -8935,7 +8946,7 @@ CREATE TABLE `expeditions_deleted` ( KEY `index2` (`EsBulto`), KEY `index3` (`odbc_date`), KEY `index4` (`ticket_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2322229 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2382192 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9074,7 +9085,7 @@ CREATE TABLE `gestdoc` ( UNIQUE KEY `emp_id` (`emp_id`,`orden`,`warehouse_id`), KEY `trabajador_id` (`trabajador_id`), KEY `warehouse_id` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=901233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=951351 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9273,7 +9284,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=63889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65000 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9611,7 +9622,7 @@ CREATE TABLE `mail` ( `recipientFk` int(11) DEFAULT NULL, `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1293169 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=1327017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9654,7 +9665,7 @@ CREATE TABLE `mandato` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`idmandato_tipo`) REFERENCES `mandato_tipo` (`idmandato_tipo`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14887 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9863,7 +9874,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=40437 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=41001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10358,7 +10369,7 @@ CREATE TABLE `price_fixed` ( KEY `date_end` (`date_end`), KEY `warehouse_id` (`warehouse_id`), CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52882 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=53294 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10420,7 +10431,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=4117 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4361 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10495,7 +10506,7 @@ CREATE TABLE `province` ( CONSTRAINT `province_ibfk_1` FOREIGN KEY (`Paises_Id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `province_zone_fk` FOREIGN KEY (`zone`) REFERENCES `zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=192 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=193 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10603,7 +10614,7 @@ CREATE TABLE `recibida` ( CONSTRAINT `recibida_ibfk_5` FOREIGN KEY (`cplusInvoiceType472Fk`) REFERENCES `vn`.`cplusInvoiceType472` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_6` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `vn`.`cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibida_ibfk_7` FOREIGN KEY (`cplusTrascendency472Fk`) REFERENCES `vn`.`cplusTrascendency472` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=66252 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=67273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11102,7 +11113,7 @@ CREATE TABLE `recibida_entrada` ( KEY `Id_Entrada` (`Id_Entrada`), KEY `recibida_id` (`recibida_id`), CONSTRAINT `recibida_entrada_ibfk_2` FOREIGN KEY (`Id_Entrada`) REFERENCES `Entradas` (`Id_Entrada`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=10454 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10674 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11190,7 +11201,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `Gastos` (`Id_Gasto`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=88237 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=89731 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11213,7 +11224,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=85795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=87245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11256,7 +11267,7 @@ CREATE TABLE `recovery` ( KEY `cliente_idx` (`Id_Cliente`), CONSTRAINT `cliente333` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDB AUTO_INCREMENT=256 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11450,7 +11461,7 @@ CREATE TABLE `scan` ( `name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=51494 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=54954 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11490,7 +11501,7 @@ CREATE TABLE `scan_line` ( PRIMARY KEY (`scan_line_id`), KEY `id_scan_id_idx` (`scan_id`), CONSTRAINT `id_scan_id` FOREIGN KEY (`scan_id`) REFERENCES `scan` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=664827 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=704091 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11512,7 +11523,7 @@ CREATE TABLE `sharingcart` ( KEY `Suplent` (`Id_Suplente`), CONSTRAINT `Suplent_key` FOREIGN KEY (`Id_Suplente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1738 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1778 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11685,7 +11696,7 @@ CREATE TABLE `state` ( `code` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11754,7 +11765,7 @@ CREATE TABLE `tarifas` ( PRIMARY KEY (`tarifa_id`), KEY `tarifa_warehouse` (`warehouse_id`), CONSTRAINT `tarifa_warehouse` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=140 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=152 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11967,7 +11978,7 @@ CREATE TABLE `ticket_observation` ( KEY `observation_type_id` (`observation_type_id`), CONSTRAINT `ticket_observation_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticket_observation_ibfk_2` FOREIGN KEY (`observation_type_id`) REFERENCES `observation_type` (`observation_type_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1034859 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1058344 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12090,7 +12101,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouse_id_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `Proveedores` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=103635 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=105228 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -12227,7 +12238,7 @@ CREATE TABLE `travel_dits` ( KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), CONSTRAINT `travel_dits_ibfk_1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=160113 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=164433 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12254,7 +12265,7 @@ CREATE TABLE `travel_pattern` ( CONSTRAINT `travel_pattern_ibfk_3` FOREIGN KEY (`warehouse_out`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=321 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=323 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12634,24 +12645,6 @@ SET character_set_client = utf8; 1 AS `Id_Article`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `v_barcodes_plus` --- - -DROP TABLE IF EXISTS `v_barcodes_plus`; -/*!50001 DROP VIEW IF EXISTS `v_barcodes_plus`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `v_barcodes_plus` AS SELECT - 1 AS `code`, - 1 AS `Id_Article`, - 1 AS `Article`, - 1 AS `Medida`, - 1 AS `Color`, - 1 AS `Categoria`, - 1 AS `Producer`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `v_botanic_export` -- @@ -13619,7 +13612,7 @@ CREATE TABLE `workerTeam` ( PRIMARY KEY (`id`), KEY `user_team_idx` (`user`), CONSTRAINT `user_team` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=128 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16073,37 +16066,44 @@ DELIMITER ; /*!50003 SET character_set_results = utf8 */ ; /*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `account_conciliacion_add`() BEGIN + DECLARE vIsEuroBank BOOLEAN; + + UPDATE account_conciliacion ac + JOIN + ( + SELECT idaccount_conciliacion, @c:= if(@id = id_calculated, @c + 1, 1) contador, + @id:= id_calculated as id_calculated, concat(id_calculated,'(',@c,')') as new_id + FROM account_conciliacion + JOIN + ( + select id_calculated, count(*) rep, @c:= 0, @id:= concat('-',id_calculated) from account_conciliacion + group by id_calculated + having rep > 1 + ) sub using(id_calculated) + ) sub2 using(idaccount_conciliacion) + SET ac.id_calculated = sub2.new_id; -update account_conciliacion ac -join -( - select idaccount_conciliacion, @c:= if(@id = id_calculated, @c + 1, 1) contador - , @id:= id_calculated as id_calculated, concat(id_calculated,'(',@c,')') as new_id from account_conciliacion - join - ( - select id_calculated, count(*) rep, @c:= 0, @id:= concat('-',id_calculated) from account_conciliacion - group by id_calculated - having rep > 1 - ) sub using(id_calculated) -) sub2 using(idaccount_conciliacion) -set ac.id_calculated = sub2.new_id; - - -insert into Cajas(Cajafecha, Partida, Serie, Concepto, Entrada, Salida, Id_Banco, Id_Trabajador, empresa_id, warehouse_id, Proveedores_account_id, id_calculated) -select Fechaoperacion, TRUE, 'MB', ac.Concepto, IF(DebeHaber = 2, importe,null), IF(DebeHaber = 1, importe, null), pa.Id_Banco, 20 - , pa.Id_Proveedor, 1, ac.Id_Proveedores_account,ac.id_calculated -from account_conciliacion ac -join Proveedores_account pa on pa.Id_Proveedores_account = ac.Id_Proveedores_account -left join Cajas c on c.id_calculated = ac.id_calculated -where c.Id_Caja is null; - - - - + SELECT currencyFk = 1 INTO vIsEuroBank + FROM vn.bank b + JOIN Proveedores_account pa ON pa.Id_Banco = b.id + JOIN vn2008.account_conciliacion a ON a.Id_Proveedores_account = pa.Id_Proveedores_account + LIMIT 1; + + INSERT INTO Cajas(Cajafecha, Partida, Serie, Concepto, Entrada, + Salida, Id_Banco,empresa_id, warehouse_id, + Proveedores_account_id, id_calculated, InForeignValue, OutForeignValue) + SELECT Fechaoperacion, TRUE, 'MB', ac.Concepto, IF(DebeHaber = 2 AND vIsEuroBank, importe,null), + IF(DebeHaber = 1 AND vIsEuroBank, importe, null), pa.Id_Banco, pa.Id_Proveedor, 1, + ac.Id_Proveedores_account, ac.id_calculated, IF(DebeHaber = 2 AND NOT vIsEuroBank, importe, null), + IF(DebeHaber = 1 AND NOT vIsEuroBank, importe, null) + FROM account_conciliacion ac + JOIN Proveedores_account pa on pa.Id_Proveedores_account = ac.Id_Proveedores_account + LEFT JOIN Cajas c on c.id_calculated = ac.id_calculated + WHERE c.Id_Caja is null; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -20306,55 +20306,6 @@ CLOSE rs; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `bonus_comparados` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `bonus_comparados`() -BEGIN - -SELECT CodigoTrabajador as Comercial - , T.Fecha - , bs.Id_Ticket - , T.Alias - , bs.Id_Article - , A.Article - , A.Medida - ,A.Categoria - , O.Abreviatura - , bs.amount - , bs.bonus - , amount * bonus * IF(bonus_buenos.bonus_sales_id IS NULL,0,1) as saldo -FROM bonus_sales bs -JOIN Articles A USING(Id_Article) -JOIN Trabajadores USING(Id_Trabajador) -JOIN Tickets T USING(Id_Ticket) -JOIN Clientes C USING(Id_Cliente) -JOIN Origen O ON O.id = A.id_origen -JOIN Permisos P ON bs.Id_Trabajador = P.Id_Trabajador -LEFT JOIN ( - select b.bonus_sales_id - from bonus_sales b - left join Movimientos M using(Id_Ticket, Id_Article) - join Tickets T on T.Id_Ticket = b.Id_Ticket - where Fecha >= '2012-12-01' - and Cantidad > amount / 2 - ) bonus_buenos USING(bonus_sales_id) - -WHERE T.Fecha > '2012-12-01' AND invoice AND Id_Grupo = 6; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -24183,171 +24134,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `createWorkerKK` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `createWorkerKK`( - vName VARCHAR(50), - vCognames VARCHAR(50), - vDNI VARCHAR(9), - vAddress TEXT, - vPostalCode VARCHAR(5), - vTown VARCHAR(25), - vProvince SMALLINT(5), - vCompany SMALLINT(5), - vPhone VARCHAR(11), - vMail VARCHAR(80) CHARSET utf8, - vDniExpiration DATETIME, - vEmployeeBoss INT -) -BEGIN - DECLARE vClient INT; - DECLARE vUser INT; - DECLARE vWorker INT; - DECLARE vWorkerCode VARCHAR(8); - DECLARE vPassword VARCHAR(50); - DECLARE vUsername VARCHAR(50) CHARSET utf8; - DECLARE vOficial INT DEFAULT 1; - DECLARE vDiscount INT DEFAULT 3; - DECLARE vPayMethodFk INT DEFAULT 4; - DECLARE vDueDay INT DEFAULT 5; - DECLARE vDefaultCredit DECIMAL(10, 2) DEFAULT 300.00; - DECLARE vIsTaxDataChecked TINYINT(1) DEFAULT 1; - DECLARE vHasCoreVnl TINYINT(1) DEFAULT 1; - DECLARE vMandateType INT DEFAULT 2; - - -############################################################################## -#### GENERAR CLIENTE -############################################################################## - - -- Comprobar si existe un cliente con el mismo DNI. - SELECT Id_cliente INTO vClient FROM vn2008.Clientes WHERE `if` = vDNI; - - -- Si no existe el cliente creamos uno nuevo. - IF vClient IS NULL THEN - - SELECT (MAX(Id_Cliente) + 1) INTO vClient FROM Clientes WHERE Id_Cliente < 999999; - - INSERT INTO Clientes ( - Id_Cliente, - Cliente, - Domicilio, - `IF`, - Telefono, - province_id, - Poblacion, - CodPostal, - RazonSocial, - Contacto, - Oficial, - Descuento, - Codpos, - pay_met_id, - Vencimiento, - credito, - contabilizado, - coreVnl) - SELECT - vClient, - Concat('TR ', vName, ' ', vCognames), - vAddress, - vDNI, - vPhone, - vProvince, - vTown, - vPostalCode, - CONCAT(vCognames, ' ', vName), - vName, - vOficial, - vDiscount, - vPostalCode, - vPayMethodFk, - vDueDay, - vDefaultCredit, - vIsTaxDataChecked, - vHasCoreVnl; - - INSERT INTO mandato (Id_Cliente, empresa_id, idmandato_tipo) - VALUES (vClient, vCompany, vMandateType); - END IF; - - -############################################################################## -#### GENERAR USUARIO -############################################################################## - - SET vUsername = LCASE(CONCAT(REPLACE(vName, ' ', ''), LEFT(vCognames, 1), MID(vCognames, (LOCATE(' ', vCognames) + 1), 1))); - - -- Generar nombre de usuario hasta que haya uno disponible. - WHILE (SELECT COUNT(*) FROM account.user WHERE `name`= vUsername) DO - SET vUsername = CONCAT(vUsername, (FLOOR(RAND() * 100))); - END WHILE; - - SET vPassword = CONCAT(IF(INSTR(vCognames,' ') = 0, vCognames, LEFT(vCognames, INSTR(vCognames,' ') - 1)), '.' , vClient); - - -- Comprobamos si existe un usuario con el mismo ID de cliente. - IF NOT (SELECT COUNT(*) FROM account.user where id = vClient) THEN - - -- Alta del usuario. - INSERT INTO account.user (id, role, `name`, `password`, active) VALUES (vClient, 1, LCASE(vUsername), MD5(LCASE(vPassword)), 1); - SET vUser = vClient; - INSERT INTO account.account SET id = vClient; - ELSE - - -- Alta del usuario. - INSERT INTO account.user (role, `name`, `password`, active) VALUES (1, LCASE(vUsername), MD5(LCASE(vPassword)), 1); - SET vUser = LAST_INSERT_ID(); - INSERT INTO account.account SET id = vUser; - END IF; - -############################################################################## -#### GENERAR TRABAJADOR -############################################################################## - - SET vWorkerCode = CONCAT(LEFT(vName, 1), LEFT(vCognames, 1), MID(vCognames, (LOCATE(' ', vCognames) + 1), 1)); - - -- Generar código de trabajador hasta que haya uno disponible. - IF (SELECT COUNT(*) FROM Trabajadores WHERE CodigoTrabajador = vWorkerCode) THEN - SET vWorkerCode = "001"; - END IF; - - -- Comprobamos si ya existe un trabajador con el mismo DNI. - IF NOT (SELECT COUNT(*) FROM Trabajadores WHERE dni = vDNI) THEN - - -- Alta en la tabla trabajadores. - INSERT INTO Trabajadores (CodigoTrabajador, Nombre, Apellidos, `Password`, dni, empresa_id, user_id, boss, DniExpiration) - VALUES (vWorkerCode, vName, vCognames, LCASE(vPassword), vDNI, vCompany, vUser, vEmployeeBoss, VDniExpiration); - - SET vWorker = LAST_INSERT_ID(); - ELSE - UPDATE Trabajadores SET user_id = vUser WHERE dni = vDNI; - END IF; - -############################################################################## -#### REENVIO EMAIL -############################################################################## - - IF vMail IS NOT NULL AND NOT (SELECT COUNT(*) FROM account.mailForward WHERE forwardTo = vMail) THEN - INSERT INTO account.mailForward (account, forwardTo) VALUES (vUser, vMail); - UPDATE Trabajadores SET email = CONCAT(vUsername, '@verdnatura.es') WHERE user_id = vUser; - END IF; - - -- Devolver información generada - SELECT vUser, vWorker, vPassword, vUsername; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `credit_update` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -33892,6 +33678,7 @@ BEGIN , tls.productionOrder as state_order , ifnull(tls.alertLevel,0) alert_level , t.boxed as palletized + , rg.deviceId ubicacion FROM tmp.ticket_list tt JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket JOIN Consignatarios CS on CS.Id_Consigna = t.Id_Consigna @@ -33901,6 +33688,7 @@ BEGIN LEFT JOIN vn.ticketState tls on tls.ticket = tt.Id_Ticket LEFT JOIN Trabajadores w on w.Id_Trabajador = tls.worker LEFT JOIN zoneNickname z ON z.warehouse_id = ap.warehouse_id and z.agency_id = ap.agency_id AND z.zona = ap.zona + LEFT JOIN vn.routeGate rg ON rg.routeFk = t.Id_Ruta WHERE t.warehouse_id = vWarehouseId AND a.Vista IN (1,2,3); @@ -33926,7 +33714,7 @@ BEGIN ALTER TABLE tmp.production_buffer ADD Cajas DOUBLE DEFAULT NULL; - +/* UPDATE tmp.production_buffer pb JOIN ( SELECT t.Id_Ticket, sum(floor(m.Cantidad / c.Packing) * bultoCubico) as Cajas @@ -33941,7 +33729,7 @@ BEGIN HAVING Cajas >= 1 ) sub ON sub.Id_Ticket = pb.Id_Ticket SET pb.Cajas = sub.Cajas; - +*/ -- Artificial, Seco y Preservado: Reino 4 ALTER TABLE tmp.production_buffer @@ -36050,25 +35838,24 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `recibidaIvaInsert`(IN vId INT) BEGIN + DELETE FROM recibida_iva WHERE recibida_id = vId; + INSERT INTO recibida_iva(recibida_id, iva_id, bi,gastos_id,divisa) SELECT r.id, CASE - WHEN p.cuenta LIKE '___4______' THEN 71 + WHEN p.cuenta LIKE '___4______' THEN 120 -- 71 2018-04-24 JGF-PAK WHEN p.cuenta LIKE '___1______' THEN 36 WHEN p.cuenta LIKE '___3______' THEN 63 END, - SUM(Costefijo * Cantidad) / IFNULL(rr.rate,1), + SUM(Costefijo * Cantidad) / IFNULL(rr.rate,1) , 6003000000, IF(r.moneda_id = 1,NULL,SUM(Costefijo * Cantidad )) FROM recibida r - JOIN recibida_entrada re ON r.id = re.recibida_id - JOIN Entradas e ON e.Id_Entrada = re.Id_Entrada + JOIN Entradas e ON e.recibida_id = r.id JOIN Proveedores p ON p.Id_Proveedor = e.Id_Proveedor JOIN Compres c ON c.Id_Entrada = e.Id_Entrada JOIN reference_rate rr ON rr.moneda_id = r.moneda_id AND rr.date = r.fecha - LEFT JOIN recibida_iva ri ON re.recibida_id=ri.recibida_id - WHERE re.awb_recibida =vId AND ri.bi IS NULL - GROUP BY e.Id_Entrada, re.awb_recibida; + WHERE r.id = vId; END ;; DELIMITER ; @@ -37118,16 +36905,11 @@ SET rm.`name` = a.Agencia, rm.fecha = r.Fecha, rm.pedidosProduccion = 0, rm.pedidosEncajados = 0, rm.Fecha = r.Fecha; -/* -UPDATE Rutas_monitor rm -JOIN ( - SELECT Id_Ruta, max(landing) as landing - FROM Tickets t - WHERE t.Fecha BETWEEN vDate AND vDateEND - GROUP BY Id_Ruta - ) t ON t.Id_Ruta = rm.Id_Ruta -SET rm.Fecha = t.landing; -*/ + +UPDATE vn2008.Rutas_monitor rm + JOIN vn.routeGate rg ON rg.routeFk = rm.Id_Ruta + SET rm.Ubicacion = rg.deviceId; + UPDATE Rutas_monitor rm JOIN ( SELECT Id_Ruta, count(*) AS pedidosLibres @@ -41013,7 +40795,7 @@ SELECT WHERE tr.landing >= vDateFrom GROUP BY e.Id_Entrada ) sub -ORDER BY landing, travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ; +ORDER BY landing,shipment, travel, IsTravel DESC, (loadPriority > 0) DESC,loadPriority, Agencia, Notas_Eva ; END ;; DELIMITER ; @@ -42836,7 +42618,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerCreate` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerCreatekk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -42846,7 +42628,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerCreate`( +CREATE DEFINER=`root`@`%` PROCEDURE `workerCreatekk`( vName VARCHAR(50), vCognames VARCHAR(50), vDNI VARCHAR(9), @@ -43381,6 +43163,40 @@ SET character_set_client = utf8; 1 AS `isActive`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `agencyModeZone` +-- + +DROP TABLE IF EXISTS `agencyModeZone`; +/*!50001 DROP VIEW IF EXISTS `agencyModeZone`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agencyModeZone` AS SELECT + 1 AS `agencyModeFk`, + 1 AS `zone`, + 1 AS `price`, + 1 AS `itemFk`, + 1 AS `warehouseFk`, + 1 AS `minimCost`, + 1 AS `inflation`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `agencyProvince` +-- + +DROP TABLE IF EXISTS `agencyProvince`; +/*!50001 DROP VIEW IF EXISTS `agencyProvince`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agencyProvince` AS SELECT + 1 AS `provinceFk`, + 1 AS `agencyFk`, + 1 AS `zone`, + 1 AS `warehouseFk`, + 1 AS `route`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `agencyWarehouse` -- @@ -43395,6 +43211,23 @@ SET character_set_client = utf8; 1 AS `agencyType`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `agencyWeekDayBonus` +-- + +DROP TABLE IF EXISTS `agencyWeekDayBonus`; +/*!50001 DROP VIEW IF EXISTS `agencyWeekDayBonus`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `agencyWeekDayBonus` AS SELECT + 1 AS `id`, + 1 AS `warehouseFk`, + 1 AS `agencyFk`, + 1 AS `weekDay`, + 1 AS `zone`, + 1 AS `bonus`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `annualAverageInvoiced` -- @@ -43408,6 +43241,30 @@ SET character_set_client = utf8; 1 AS `invoiced`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `artificialBuffer` +-- + +DROP TABLE IF EXISTS `artificialBuffer`; +/*!50001 DROP VIEW IF EXISTS `artificialBuffer`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `artificialBuffer` AS SELECT + 1 AS `saleFk`, + 1 AS `Modificado`, + 1 AS `ticketFk`, + 1 AS `isPicked`, + 1 AS `itemFk`, + 1 AS `quantity`, + 1 AS `concept`, + 1 AS `size`, + 1 AS `workerCode`, + 1 AS `Nicho`, + 1 AS `Reserva`, + 1 AS `Estado`, + 1 AS `orden`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `autoRadioConfig` -- @@ -43490,7 +43347,8 @@ SET character_set_client = utf8; 1 AS `account`, 1 AS `cash`, 1 AS `entityFk`, - 1 AS `isActive`*/; + 1 AS `isActive`, + 1 AS `currencyFk`*/; SET character_set_client = @saved_cs_client; -- @@ -43582,7 +43440,8 @@ SET character_set_client = utf8; 1 AS `minPrice`, 1 AS `producer`, 1 AS `printedStickers`, - 1 AS `isChecked`*/; + 1 AS `isChecked`, + 1 AS `isIgnored`*/; SET character_set_client = @saved_cs_client; -- @@ -43802,9 +43661,9 @@ CREATE TABLE `clientLog` ( PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), - CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=159527 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=162135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44014,6 +43873,7 @@ CREATE TABLE `config` ( `mdbServer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `fakeEmail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `defaultersMaxAmount` int(10) DEFAULT '200' COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', + `ASIEN` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -44192,7 +44052,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2709 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2735 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -44237,7 +44097,7 @@ CREATE TABLE `creditInsurance` ( PRIMARY KEY (`id`), KEY `CreditInsurance_Fk1_idx` (`creditClassification`), CONSTRAINT `CreditInsurance_Fk1` FOREIGN KEY (`creditClassification`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1821 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=1867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -44323,6 +44183,120 @@ SET character_set_client = utf8; 1 AS `description`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `dua` +-- + +DROP TABLE IF EXISTS `dua`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `dua` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `awbFk` smallint(11) unsigned NOT NULL, + `issued` date DEFAULT NULL, + `operated` date DEFAULT NULL, + `booked` date DEFAULT NULL, + `bookEntried` date DEFAULT NULL, + `gestdocFk` int(11) DEFAULT NULL, + `customsValue` decimal(10,2) DEFAULT NULL, + `companyFk` smallint(5) unsigned NOT NULL DEFAULT '442', + `ASIEN` double DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fk_awb_dua_awb_idx` (`awbFk`), + KEY `fk_dua_gestdoc1_idx` (`gestdocFk`), + KEY `dua_fk4_idx` (`companyFk`), + CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3127 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `duaEntry` +-- + +DROP TABLE IF EXISTS `duaEntry`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `duaEntry` ( + `duaFk` int(11) NOT NULL, + `entryFk` int(11) NOT NULL, + `value` decimal(10,2) DEFAULT NULL, + `customsValue` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`duaFk`,`entryFk`), + KEY `fk_duaEntry_dua1_idx` (`duaFk`), + KEY `fk_duaEntry_Entradas1_idx` (`entryFk`), + CONSTRAINT `fk_duaEntry_Entradas1` FOREIGN KEY (`entryFk`) REFERENCES `vn2008`.`Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_duaEntry_dua1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `duaIntrastat` +-- + +DROP TABLE IF EXISTS `duaIntrastat`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `duaIntrastat` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `duaFk` int(11) NOT NULL, + `intrastatFk` int(8) unsigned NOT NULL, + `amount` decimal(10,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id`), + KEY `duaIntrastat_fk1_idx` (`intrastatFk`), + KEY `duaIntrastat_fk2_idx` (`duaFk`), + CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `vn2008`.`Intrastat` (`Codintrastat`) ON UPDATE CASCADE, + CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4211 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `duaInvoiceIn` +-- + +DROP TABLE IF EXISTS `duaInvoiceIn`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `duaInvoiceIn` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `duaFk` int(11) NOT NULL, + `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `duaFk_UNIQUE` (`duaFk`,`invoiceInFk`), + KEY `duaInvoiceIn_fk1_idx` (`duaFk`), + KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`), + CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `duaInvoiceIn_fk2` FOREIGN KEY (`invoiceInFk`) REFERENCES `vn2008`.`recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4101 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `duaTax` +-- + +DROP TABLE IF EXISTS `duaTax`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `duaTax` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `duaFk` int(11) NOT NULL, + `supplierFk` int(11) NOT NULL, + `taxClassFk` tinyint(3) unsigned NOT NULL, + `base` decimal(10,2) NOT NULL, + `rate` decimal(5,2) NOT NULL, + `tax` decimal(10,2) NOT NULL, + PRIMARY KEY (`id`), + KEY `fk_dua_tax_awb_dua1_idx` (`duaFk`), + KEY `duaTax_fk2_idx` (`supplierFk`), + KEY `duaTax_fk3_idx` (`taxClassFk`), + CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, + CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=561 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `ediGenus` -- @@ -44394,7 +44368,7 @@ SET character_set_client = utf8; 1 AS `currencyFk`, 1 AS `companyFk`, 1 AS `gestDocFk`, - 1 AS `invoiceReceivedFk`*/; + 1 AS `invoiceInFk`*/; SET character_set_client = @saved_cs_client; -- @@ -44416,7 +44390,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Entradas` (`Id_Entrada`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=37679 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42666 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44928,6 +44902,32 @@ SET character_set_client = utf8; 1 AS `created`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `invoiceInTaxBookingAccount` +-- + +DROP TABLE IF EXISTS `invoiceInTaxBookingAccount`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `invoiceInTaxBookingAccount` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `effectived` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `account` varchar(10) COLLATE utf8_unicode_ci NOT NULL, + `taxAreaFk` varchar(15) CHARACTER SET utf8 NOT NULL, + `priority` int(2) unsigned DEFAULT NULL, + `taxClassFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `rate` decimal(5,2) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id`), + KEY `invoiceInTaxBookingAccount_fk1_idx` (`taxAreaFk`), + KEY `invoiceInTaxBookingAccount_fk2_idx` (`taxClassFk`), + KEY `invoiceInTaxBookingAccount_fk3_idx` (`countryFk`), + CONSTRAINT `invoiceInTaxBookingAccount_fk1` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInTaxBookingAccount_fk2` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `invoiceOut` -- @@ -44974,7 +44974,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `vn2008`.`Gastos` (`Id_Gasto`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=57911 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; +) ENGINE=InnoDB AUTO_INCREMENT=62060 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Desglosa la base imponible de una factura en funcion del tipo de gasto/venta'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45017,7 +45017,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=899088 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=912937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45046,7 +45046,11 @@ SET character_set_client = utf8; 1 AS `comment`, 1 AS `relevancy`, 1 AS `image`, - 1 AS `taxClassFk`*/; + 1 AS `generic`, + 1 AS `density`, + 1 AS `taxClassFk`, + 1 AS `minPrice`, + 1 AS `hasMinPrice`*/; SET character_set_client = @saved_cs_client; -- @@ -45224,7 +45228,7 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`itemFk`,`priority`), KEY `tagFk` (`tagFk`,`value`), CONSTRAINT `itemFK` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=295220 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=297897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45285,9 +45289,32 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=466958 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=477035 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `itemTaxCountrySpain` +-- + +DROP TABLE IF EXISTS `itemTaxCountrySpain`; +/*!50001 DROP VIEW IF EXISTS `itemTaxCountrySpain`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemTaxCountrySpain` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `typeFk`, + 1 AS `stems`, + 1 AS `description`, + 1 AS `intrastatFk`, + 1 AS `expenceFk`, + 1 AS `comment`, + 1 AS `relevancy`, + 1 AS `image`, + 1 AS `generic`, + 1 AS `taxClassFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `itemType` -- @@ -45334,6 +45361,26 @@ SET character_set_client = utf8; 1 AS `name`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `itemTypeTag` +-- + +DROP TABLE IF EXISTS `itemTypeTag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemTypeTag` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `tagFk` int(11) NOT NULL, + `priority` int(2) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `itemTypeTagTipo_idx` (`itemTypeFk`), + KEY `itemTypeTagTag_idx` (`tagFk`), + CONSTRAINT `itemTypeTagTag` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `itemTypeTagTipos` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE NO ACTION ON UPDATE NO ACTION +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemVerdecora` -- @@ -45472,7 +45519,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1423622 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1461799 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45494,7 +45541,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=1568835 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1607522 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45953,6 +46000,34 @@ CREATE TABLE `postCode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `preparationException` +-- + +DROP TABLE IF EXISTS `preparationException`; +/*!50001 DROP VIEW IF EXISTS `preparationException`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `preparationException` AS SELECT + 1 AS `exceptionDay`, + 1 AS `warehouseFk`, + 1 AS `percentage`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `preparationPercentage` +-- + +DROP TABLE IF EXISTS `preparationPercentage`; +/*!50001 DROP VIEW IF EXISTS `preparationPercentage`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `preparationPercentage` AS SELECT + 1 AS `weekDay`, + 1 AS `warehouseFk`, + 1 AS `percentage`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `priceBuilder` -- @@ -45973,7 +46048,7 @@ CREATE TABLE `priceBuilder` ( KEY `priceBuilder_fk2_idx` (`userFk`), CONSTRAINT `priceBuilder_fk1` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `priceBuilder_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46006,7 +46081,7 @@ CREATE TABLE `priceBuilderTag` ( KEY `priceBuilderTag_fk2_idx` (`tagFk`), CONSTRAINT `priceBuilderTag_fk1` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `priceBuilderTag_fk2` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46025,7 +46100,7 @@ CREATE TABLE `priceBuilderWarehouse` ( KEY `priceBuilderWarehouse_fk2_idx` (`priceBuilderFk`), CONSTRAINT `priceBuilderWarehouse_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `priceBuilderWarehouse_fk2` FOREIGN KEY (`priceBuilderFk`) REFERENCES `priceBuilder` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46076,6 +46151,23 @@ SET character_set_client = utf8; 1 AS `error`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `printer` +-- + +DROP TABLE IF EXISTS `printer`; +/*!50001 DROP VIEW IF EXISTS `printer`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `printer` AS SELECT + 1 AS `id`, + 1 AS `path`, + 1 AS `name`, + 1 AS `reference`, + 1 AS `isLabeler`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `printingQueue` -- @@ -46098,6 +46190,21 @@ SET character_set_client = utf8; 1 AS `text3`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `printingQueueCheck` +-- + +DROP TABLE IF EXISTS `printingQueueCheck`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `printingQueueCheck` ( + `lastCount` int(11) unsigned NOT NULL DEFAULT '0', + `lastCheckSum` int(11) unsigned NOT NULL DEFAULT '0', + `isAlreadyNotified` tinyint(2) NOT NULL DEFAULT '0', + PRIMARY KEY (`lastCount`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Comprueba que el servidor de impresion no esta parado'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `producer` -- @@ -46228,6 +46335,19 @@ SET character_set_client = utf8; 1 AS `value`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `referenceRateConfig` +-- + +DROP TABLE IF EXISTS `referenceRateConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `referenceRateConfig` ( + `simulatedValue` float unsigned NOT NULL DEFAULT '1.2309', + PRIMARY KEY (`simulatedValue`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `role` -- @@ -46288,6 +46408,7 @@ CREATE TABLE `routeGate` ( `flag` blob, `pallets` int(11) DEFAULT NULL, `lastScanned` datetime DEFAULT NULL, + `ready` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`deviceId`), UNIQUE KEY `routeFk_UNIQUE` (`routeFk`), KEY `routeGate_fk1_idx` (`gateAreaFk`) @@ -46342,7 +46463,7 @@ CREATE TABLE `routeLog` ( `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `description` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=410706 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=451402 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46427,7 +46548,7 @@ CREATE TABLE `sms` ( `status` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=91932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=94150 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46541,6 +46662,21 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +-- +-- Temporary table structure for view `specialPrice` +-- + +DROP TABLE IF EXISTS `specialPrice`; +/*!50001 DROP VIEW IF EXISTS `specialPrice`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `specialPrice` AS SELECT + 1 AS `id`, + 1 AS `clientFk`, + 1 AS `itemFk`, + 1 AS `value`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `state` -- @@ -46576,7 +46712,7 @@ CREATE TABLE `stockBuyed` ( UNIQUE KEY `date_UNIQUE` (`date`,`user`), KEY `stockBuyed_user_idx` (`user`), CONSTRAINT `stockBuyedUserFk` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=275846 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=303448 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46797,7 +46933,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=610728 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=761285 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46831,6 +46967,23 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +-- +-- Temporary table structure for view `ticketNotInvoiced` +-- + +DROP TABLE IF EXISTS `ticketNotInvoiced`; +/*!50001 DROP VIEW IF EXISTS `ticketNotInvoiced`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticketNotInvoiced` AS SELECT + 1 AS `companyFk`, + 1 AS `companyCode`, + 1 AS `clientFk`, + 1 AS `clientName`, + 1 AS `shipped`, + 1 AS `value`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `ticketObservation` -- @@ -46880,7 +47033,7 @@ CREATE TABLE `ticketPackaging` ( KEY `ticketPackaging_fk2_idx` (`packagingFk`), CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17141 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46940,7 +47093,8 @@ SET character_set_client = utf8; 1 AS `productionOrder`, 1 AS `alertLevel`, 1 AS `worker`, - 1 AS `code`*/; + 1 AS `code`, + 1 AS `updated`*/; SET character_set_client = @saved_cs_client; -- @@ -46974,6 +47128,32 @@ CREATE TABLE `ticketTrolley` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `ticketUpdateAction` +-- + +DROP TABLE IF EXISTS `ticketUpdateAction`; +/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticketUpdateAction` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `ticketWeekly` +-- + +DROP TABLE IF EXISTS `ticketWeekly`; +/*!50001 DROP VIEW IF EXISTS `ticketWeekly`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `ticketWeekly` AS SELECT + 1 AS `ticketFk`, + 1 AS `weekDay`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `till` -- @@ -47064,7 +47244,8 @@ SET character_set_client = utf8; 1 AS `ref`, 1 AS `isDelivered`, 1 AS `isReceived`, - 1 AS `m3`*/; + 1 AS `m3`, + 1 AS `kg`*/; SET character_set_client = @saved_cs_client; -- @@ -47205,6 +47386,7 @@ SET character_set_client = utf8; 1 AS `isInventory`, 1 AS `isComparative`, 1 AS `hasComission`, + 1 AS `hasAvailable`, 1 AS `isManaged`*/; SET character_set_client = @saved_cs_client; @@ -47258,6 +47440,26 @@ SET character_set_client = utf8; 1 AS `fiDueDate`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `workerClockLog` +-- + +DROP TABLE IF EXISTS `workerClockLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerClockLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, + `action` set('insert','update','delete','select') COLLATE utf8_unicode_ci NOT NULL, + `creationDate` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `description` text COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `logWorkerClockoriginFk` (`originFk`), + KEY `logWorkerClockuserFk` (`userFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workerDocument` -- @@ -47274,7 +47476,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4106 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4822 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47296,7 +47498,7 @@ CREATE TABLE `workerLog` ( KEY `userFk_idx` (`userFk`), CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `workerFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=2595 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3590 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47331,6 +47533,23 @@ CREATE TABLE `workerTeam_kk` ( ) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `workerTimeControl` +-- + +DROP TABLE IF EXISTS `workerTimeControl`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerTimeControl` ( + `id` int(11) NOT NULL, + `userFk` int(11) NOT NULL, + `timed` datetime NOT NULL, + `manual` tinyint(4) NOT NULL DEFAULT '0', + `order` int(11) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `workingHours` -- @@ -47346,7 +47565,7 @@ CREATE TABLE `workingHours` ( PRIMARY KEY (`id`), KEY `user_working_hour_idx` (`userId`), CONSTRAINT `user_working_hour` FOREIGN KEY (`userId`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=19707 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; +) ENGINE=InnoDB AUTO_INCREMENT=21344 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena horas de Entrada y de Salida del personal'; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -47462,7 +47681,57 @@ CREATE TABLE `zoneNestTree` ( -- Dumping events for database 'vn' -- /*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `ticketClosure` */; +/*!50106 DROP EVENT IF EXISTS `printingQueueChecker` */; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`z-developer`@`%`*/ /*!50106 EVENT `printingQueueChecker` ON SCHEDULE EVERY 10 MINUTE STARTS '2018-05-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO BEGIN + + DECLARE vCurrentCount INT; + DECLARE vCheckSum INT; + DECLARE vIsAlreadyNotified BOOLEAN; + + SELECT COUNT(*), SUM(id) INTO vCurrentCount, vCheckSum + FROM printingQueue WHERE state = 1; + + SELECT isAlreadyNotified INTO vIsAlreadyNotified + FROM printingQueueCheck; + + IF (SELECT lastCount FROM printingQueueCheck) = vCurrentCount AND + (SELECT lastCheckSum FROM printingQueueCheck) = vCheckSum AND + vIsAlreadyNotified = FALSE + THEN + INSERT INTO vn2008.mail (`to`, subject, text) + VALUES ('jgallego@verdnatura.es', + 'servidor de impresion parado', + CONCAT('Hay ', vCurrentCount, ' lineas bloqueadas')); + UPDATE printingQueueCheck SET isAlreadyNotified = TRUE; + END IF; + + IF (SELECT lastCount FROM printingQueueCheck) > vCurrentCount AND + vIsAlreadyNotified = TRUE + THEN + UPDATE printingQueueCheck SET isAlreadyNotified = FALSE; + END IF; + + UPDATE printingQueueCheck + SET lastCount = vCurrentCount, + lastCheckSum = vCheckSum; +END */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `ticketClosure` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; @@ -48122,7 +48391,7 @@ BEGIN AND CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1; SELECT `value` INTO price - FROM vn.especialPrice + FROM vn.specialPrice WHERE itemFk = vItemFk AND clientFk = vClientFk ; RETURN price; @@ -49077,8 +49346,10 @@ CREATE DEFINER=`root`@`%` PROCEDURE `clean`() BEGIN DECLARE vDateShort DATETIME; + DECLARE oneYearAgo DATE; SET vDateShort = TIMESTAMPADD(MONTH, -2, CURDATE()); + SET oneYearAgo = TIMESTAMPADD(YEAR,-1,CURDATE()); DELETE FROM vn.dailyTaskLog WHERE created < vDateShort; @@ -49087,6 +49358,7 @@ BEGIN DELETE FROM vn.message WHERE sendDate < vDateShort; DELETE FROM vn.messageInbox WHERE sendDate < vDateShort; DELETE FROM vn.messageInbox WHERE sendDate < vDateShort; + DELETE FROM vn.workerTimeControl WHERE timed < oneYearAgo; INSERT INTO vn.dailyTaskLog(state) VALUES('clean END'); END ;; @@ -49160,7 +49432,12 @@ BEGIN vIsTaxDataChecked, vHasCoreVnl, FALSE - ); + ) ON duplicate key update + payMethodFk = vPayMethodFk, + dueDay = vDueDay, + credit = vDefaultCredit, + isTaxDataChecked = vIsTaxDataChecked, + hasCoreVnl = vHasCoreVnl; INSERT INTO mandate (clientFk, companyFk, mandateTypeFk) VALUES (vUserFk, vCompanyFk, vMandateTypeFk); @@ -49200,6 +49477,193 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `clonTravelComplete` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `clonTravelComplete`(IN vTravelFk INT, IN vDateStart date, IN vDateEnd date, IN vRef varchar(255)) +BEGIN + + DECLARE vTravelNew INT; + DECLARE vEntryNew INT; + DECLARE vDone BIT DEFAULT 0; + DECLARE vAuxEntryFk INT; + DECLARE vRsEntry CURSOR FOR + SELECT e.id + FROM vn.entry e + JOIN vn.travel t + ON t.id = e.travelFk + WHERE e.travelFk = vTravelFk; + + DECLARE vRsBuy CURSOR FOR + SELECT b.* + FROM vn.buy b + JOIN vn.entry e + ON b.entryFk = e.id + WHERE e.travelFk = vTravelNew and b.entryFk=entryNew + ORDER BY e.id; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + INSERT INTO vn.travel (shipped,landed, warehouseInFk, warehouseOutFk, agencyFk, ref, isDelivered, isReceived, m3) + SELECT vDateStart, vDateEnd,warehouseInFk, warehouseOutFk, agencyFk, vRef, isDelivered, isReceived, m3 + FROM vn.travel + WHERE id = vTravelFk; + + SET vTravelNew = LAST_INSERT_ID(); + SET vDone = 0; + OPEN vRsEntry ; + FETCH vRsEntry INTO vAuxEntryFk; + + WHILE NOT vDone DO + INSERT INTO vn.entry (supplierFk, + ref, + isInventory, + isConfirmed, + isOrdered, + isRaid, + commission, + created, + evaNotes, + travelFk, + currencyFk, + companyFk, + gestDocFk, + invoiceInFk) + SELECT supplierFk, + ref, + isInventory, + isConfirmed, + isOrdered, + isRaid, + commission, + created, + evaNotes, + vTravelNew, + currencyFk, + companyFk, + gestDocFk, + invoiceInFk + FROM vn.entry + WHERE id = vAuxEntryFk; + + SET vEntryNew = LAST_INSERT_ID(); + + /* INSERT INTO vn.buy ( + entryFk, + itemFk, + amount, + buyingValue, + quantity, + packageFk, + stickers, + freightValue, + packageValue, + comissionValue, + packing, + grouping, + groupingMode, + location, + price1, + price2, + price3, + minPrice, + producer, + printedStickers, + isCkecked) + SELECT + vEntryNew, + itemFk, + amount, + buyingValue, + quantity, + packageFk, + stickers, + freightValue, + packageValue, + comissionValue, + packing, + grouping, + groupingMode, + location, + price1, + price2, + price3, + minPrice, + producer, + printedStickers, + isCkecked + FROM buy + WHERE entryFk = vAuxEntryFk;*/ + + INSERT INTO vn2008.Compres (Id_Entrada, + Id_Article, + Cantidad, + Costefijo, + Id_Cubo, + Etiquetas, + Portefijo, + Embalajefijo, + Comisionfija, + Packing, + grouping, + caja, + Nicho, + Tarifa1, + Tarifa2, + Tarifa3, + PVP, + Productor, + Vida, + punteo) + SELECT vEntryNew, + Id_Article, + Cantidad, + Costefijo, + Id_Cubo, + Etiquetas, + Portefijo, + Embalajefijo, + Comisionfija, + Packing, + grouping, + caja, + Nicho, + Tarifa1, + Tarifa2, + Tarifa3, + PVP, + Productor, + Vida, + punteo + FROM vn2008.Compres + WHERE Id_Entrada = vAuxEntryFk; + + + FETCH vRsEntry INTO vAuxEntryFk; + END WHILE; + CLOSE vRsEntry; + COMMIT; + END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `copyComponentsFromSaleList` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49288,6 +49752,402 @@ BEGIN INSERT INTO vn2008.Trabajadores(Nombre, Apellidos, boss, CodigoTrabajador, user_id) SELECT vFirstName, vSurnames, vWorkerPako, vWorkerCode, vUserId; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `duaEntryValueUpdate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `duaEntryValueUpdate`(vDuaFk INT) +BEGIN + + UPDATE duaEntry de + JOIN ( + SELECT b.entryFk, sum(b.quantity * b.buyingValue) as total + FROM buy b + JOIN duaEntry de ON de.entryFk = b.entryFk + WHERE duaFk = vDuaFk + GROUP BY b.entryFk + ) sub ON sub.entryFk = de.entryFk + SET de.value = sub.total + WHERE duaFk = vDuaFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `duaInvoiceInBooking` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `duaInvoiceInBooking`(vDuaFk INT) +BEGIN + + + DECLARE done BOOL DEFAULT FALSE; + DECLARE vInvoiceFk INT; + DECLARE vASIEN BIGINT DEFAULT 0; + DECLARE vCounter INT DEFAULT 0; + + DECLARE rs CURSOR FOR + SELECT e.invoiceInFk + FROM entry e + JOIN duaEntry de ON de.entryFk = e.id + JOIN invoiceIn ii ON ii.id = e.invoiceInFk + WHERE de.duaFk = vDuaFk + AND de.customsValue + AND ii.isBooked = FALSE; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; + + OPEN rs; + + UPDATE invoiceIn ii + JOIN entry e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + SET ii.isBooked = TRUE, + ii.booked = IFNULL(ii.booked,d.booked), + ii.operated = IFNULL(ii.operated,d.operated), + ii.issued = IFNULL(ii.issued,d.issued), + ii.bookEntried = IFNULL(ii.bookEntried,d.bookEntried), + e.isConfirmed = TRUE + WHERE d.id = vDuaFk; + + SELECT IFNULL(ASIEN,0) INTO vASIEN + FROM dua + WHERE id = vDuaFk; + + FETCH rs INTO vInvoiceFk; + + WHILE NOT done DO + + CALL invoiceInBookingMain(vInvoiceFk); + + IF vCounter > 0 OR vASIEN > 0 THEN + + UPDATE vn2008.XDiario x + JOIN config c ON c.ASIEN = x.ASIEN + SET x.ASIEN = vASIEN; + + ELSE + + SELECT ASIEN INTO vASIEN FROM config; + + END IF; + + SET vCounter = vCounter + 1; + + FETCH rs INTO vInvoiceFk; + + END WHILE; + + CLOSE rs; + + UPDATE dua + SET ASIEN = vASIEN + WHERE id = vDuaFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `duaParcialMake` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `duaParcialMake`(vDuaFk INT) +BEGIN + + DECLARE vNewDuaFk INT; + + INSERT INTO dua(awbFk,companyFk) + SELECT awbFk,companyFk + FROM dua + WHERE id = vDuaFk; + + SELECT LAST_INSERT_ID() INTO vNewDuaFk; + + INSERT INTO duaEntry(duaFk, entryFk, value, customsValue) + SELECT vNewDuaFk, entryFk, value, value - customsValue + FROM duaEntry + WHERE duaFk = vDuaFk + AND value != customsValue; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `duaTaxBooking` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `duaTaxBooking`(vDuaFk INT) +BEGIN + + DECLARE vBookNumber INT; + DECLARE vBookDated DATE; + DECLARE vDiff DECIMAL(10,2); + DECLARE vApunte BIGINT; + + SELECT IFNULL(d.ASIEN,MAX(x.ASIEN) + 1 ) + INTO vBookNumber + FROM vn2008.XDiario x + LEFT JOIN dua d ON d.id = vDuaFk ; + + SELECT IFNULL(bookEntried, CURDATE()) INTO vBookDated + FROM dua + WHERE id = vDuaFk; + + -- Apunte de la aduana + + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + CONCEPTO, + EUROHABER, + SERIE, + empresa_id) + + SELECT + vBookNumber, + d.bookEntried, + '4700000999', + CONCAT('DUA ',d.code), + sum(di.amount * tr.rate / 100) EUROHABER, + 'R', + d.companyFk + FROM duaIntrastat di + JOIN intrastat ist ON ist.id = di.intrastatFk + JOIN (SELECT rate, taxClassFk + FROM + (SELECT rate, taxClassFk + FROM invoiceInTaxBookingAccount ta + WHERE ta.effectived <= vBookDated + ORDER BY ta.effectived DESC + ) tba + GROUP BY taxClassFk + ) tr ON tr.taxClassFk = ist.taxClassFk + JOIN dua d ON d.id = di.duaFk + WHERE di.duaFk = vDuaFk; + + -- Apuntes por tipo de IVA y proveedor + + INSERT INTO vn2008.XDiario( + ASIEN, + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + FECHA_EX, + FECHA_OP, + FACTURAEX, + NFACTICK, + L340, + LDIFADUAN, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id, + FECREGCON + ) + + SELECT + vBookNumber ASIEN, + vBookDated FECHA, + tr.account SUBCTA, + inv.account CONTRA, + dt.tax EURODEBE, + dt.base BASEEURO, + CONCAT('COMPRA s/fra ',inv.supplierRef,':',LEFT(inv.name, 10)) CONCEPTO, + inv.serialNumber FACTURA, + dt.rate IVA, + '*' AUXILIAR, + 'W' SERIE, + d.issued FECHA_EX, + d.operated FECHA_OP, + d.code FACTURAEX, + 1 NFACTICK, + 1 L340, + TRUE LDIFADUAN, + 1 TIPOCLAVE, + 1 TIPOEXENCI, + 1 TIPONOSUJE, + 5 TIPOFACT, + 1 TIPORECTIF, + 4 TERIDNIF, + inv.nif TERNIF, + inv.name TERNOM, + d.companyFk, + IFNULL(d.bookEntried, d.booked) FECREGCON + FROM duaTax dt + JOIN dua d ON dt.duaFk = d.id + JOIN (SELECT account, rate + FROM + (SELECT rate, account + FROM invoiceInTaxBookingAccount ta + WHERE ta.effectived <= vBookDated + AND taxAreaFk = 'WORLD' + ORDER BY ta.effectived DESC + ) tba + GROUP BY rate + ) tr ON tr.rate = dt.rate + JOIN + (SELECT s.account, ii.supplierRef, s.name, ii.id as serialNumber, s.nif, s.id + FROM duaEntry de + JOIN entry e ON e.id = de.entryFk + JOIN invoiceIn ii ON ii.id = e.invoiceInFk + JOIN supplier s ON s.id = ii.supplierFk + GROUP BY s.id + ) inv ON inv.id = dt.supplierFk + WHERE d.id = vDuaFk; + + SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte + FROM vn2008.XDiario + WHERE ASIEN = vBookNumber; + + UPDATE vn2008.XDiario + SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA, + EURODEBE = EURODEBE - vDiff + WHERE id = vApunte; + + UPDATE vn.dua + SET ASIEN = vBookNumber + WHERE id = vDuaFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `duaTaxUpdate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `duaTaxUpdate`(vDuaFk INT) +BEGIN + + DECLARE vSPAIN INT DEFAULT 1; + DECLARE vDated DATE; + DECLARE vTotalDUABase DECIMAL(10,2); + + SELECT IFNULL(operated, CURDATE()) INTO vDated + FROM dua + WHERE id = vDuaFk; + + SELECT sum(amount) INTO vTotalDUABase + FROM duaIntrastat + WHERE duaFk = vDuaFk; + + DELETE FROM duaTax + WHERE duaFk = vDuaFk; + + INSERT INTO duaTax(duaFk, supplierFk, taxClassFk, base) + SELECT vDuaFk, supplierFk, taxClassFk, sum(sub.Base) as Base + FROM intrastat ist + JOIN + (SELECT + e.supplierFk, + i.intrastatFk, + CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) * di.amount/ tei.Base AS DECIMAL(10,2)) as Base + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN duaEntry de ON de.entryFk = e.id + JOIN + ( + SELECT i.intrastatFk, + CAST(sum(b.quantity * b.buyingValue * de.customsValue / de.value) AS DECIMAL(10,2)) as Base + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN entry e ON e.id = b.entryFk + JOIN duaEntry de ON de.entryFk = e.id + WHERE de.duaFk = vDuaFk + GROUP BY i.intrastatFk + + ) tei ON tei.intrastatFk = i.intrastatFk + JOIN + ( + SELECT intrastatFk, sum(amount) as amount + FROM duaIntrastat + WHERE duaFk = vDuaFk + GROUP BY intrastatFK + ) di ON di.intrastatFk = i.intrastatFk + WHERE de.duaFk = vDuaFk + GROUP BY e.supplierFk, i.intrastatFk + HAVING Base + ) sub ON ist.id = sub.intrastatFk + GROUP BY ist.taxClassFk, sub.supplierFk; + + UPDATE duaTax dt + JOIN + (SELECT taxClassFk, rate + FROM + (SELECT taxClassFk, rate + FROM invoiceInTaxBookingAccount + WHERE effectived <= vDated + AND countryFk = vSPAIN + ORDER BY effectived DESC + ) ba1 + GROUP BY taxClassFk + ) ba2 ON dt.taxClassFk = ba2.taxClassFk + SET dt.rate = ba2.rate, + dt.tax = dt.base * ba2.rate / 100; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49614,101 +50474,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `getDebtKk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `getDebtKk`(vDate DATE) -BEGIN -/** - * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list - * - * @deprecated usar vn.clientGetDebt - * @table tmp.client_list - * @param vDate Fecha maxima de los registros - * @treturn tmp.risk - */ - DECLARE vDateIni DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 5, CURDATE()); - DECLARE vDateEnd DATETIME; - DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; - - SET vDateEnd = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.clientList2; - CREATE TEMPORARY TABLE tmp.clientList2 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.clientList3; - CREATE TEMPORARY TABLE tmp.clientList3 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS vn2008.ticket_tmp; - CREATE TEMPORARY TABLE vn2008.ticket_tmp - (INDEX (ticket_id)) - ENGINE = MEMORY - SELECT id ticket_id, cl.Id_Cliente - FROM ticket t - JOIN tmp.clientList2 cl ON t.clientFk = cl.Id_Cliente - WHERE refFk IS NULL - AND shipped BETWEEN vDateIni AND vDateEnd; - - CALL vn2008.ticket_total; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - CREATE TEMPORARY TABLE tmp.risk - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT Id_Cliente, SUM(amount) risk - FROM vn2008.Clientes c - JOIN ( - SELECT customer_id, SUM(amount) amount - FROM bi.customer_risk cr - JOIN tmp.client_list on tmp.client_list.Id_Cliente = cr.customer_id - GROUP BY customer_id - UNION ALL - SELECT Id_Cliente, SUM(Entregado) - FROM vn2008.Recibos - JOIN tmp.clientList2 using(Id_Cliente) - WHERE Fechacobro > vDateIni - GROUP BY Id_Cliente - UNION ALL - SELECT t.Id_Cliente, total - FROM vn2008.ticket_total tt - JOIN vn2008.ticket_tmp t ON tt.ticket_id = t.ticket_id - UNION ALL - SELECT t.clientFk customer_id, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction t - JOIN tmp.clientList3 l ON l.Id_Cliente = t.clientFk - WHERE t.receiptFk IS NULL - AND t.status = 'ok' - GROUP BY t.clientFk - ) t ON c.Id_Cliente = t.customer_id - WHERE c.activo != FALSE - GROUP BY c.Id_Cliente; - - DROP TEMPORARY TABLE - vn2008.ticket_tmp, - vn2008.ticket_total, - tmp.clientList2, - tmp.clientList3; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `getItemVisibleAvailable` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -49719,26 +50484,35 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `getItemVisibleAvailable`(IN vItem INT,IN vDate DATE,IN vWarehouse TINYINT,IN isForcedToRecalculate BOOLEAN) +CREATE DEFINER=`root`@`%` PROCEDURE `getItemVisibleAvailable`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) BEGIN - - DECLARE vCacheVisibleCalculated INTEGER; - DECLARE vCacheAvailableCalculated INTEGER; + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; - CALL cache.visible_refresh(vCacheVisibleCalculated, isForcedToRecalculate, vWarehouse); - CALL cache.available_refresh(vCacheAvailableCalculated, isForcedToRecalculate, vWarehouse, vDate); + -- FIXME: Android app is always passing %TRUE for #vRefresh, this leads to DB performance issues + CALL cache.visible_refresh(vVisibleCalc, vRefresh, vWarehouse); + CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/, vWarehouse, vDate); - SELECT a.Id_Article, a.Article, a.Medida, a.Tallos, a.caja, O.Abreviatura as origen, a.Color, tipo_id, - itemPlacementGet(vItem, vWarehouse) Nicho, - a.Categoria, p.`name` as producer, v.visible, av.available, an.reserve + SELECT a.Id_Article, a.Article, a.Medida, a.Tallos, + a.caja, O.Abreviatura AS origen, a.Color, tipo_id, + an.Nicho, a.Categoria, p.`name` AS producer, + v.visible, av.available, an.reserve FROM vn2008.Articles a - LEFT JOIN vn2008.Articles_nicho an ON a.Id_Article = an.Id_Article AND an.warehouse_id = vWarehouse - LEFT JOIN vn2008.Origen O ON O.id = a.id_origen - LEFT JOIN vn2008.producer p ON p.producer_id = a.producer_id - LEFT JOIN cache.visible v ON (vItem IS NULL OR v.item_id = vItem) AND v.calc_id = vCacheVisibleCalculated - LEFT JOIN cache.available av ON (vItem IS NULL OR av.item_id = vItem) AND av.calc_id = vCacheAvailableCalculated + LEFT JOIN vn2008.Articles_nicho an + ON a.Id_Article = an.Id_Article AND an.warehouse_id = vWarehouse + LEFT JOIN cache.visible v + ON v.item_id = a.Id_Article AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av + ON av.item_id = a.Id_Article AND av.calc_id = vAvailableCalc + LEFT JOIN vn2008.Origen O + ON O.id = a.id_origen + LEFT JOIN vn2008.producer p + ON p.producer_id = a.producer_id WHERE (vItem IS NULL OR a.Id_Article = vItem); - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -50586,7 +51360,7 @@ BEGIN JOIN taxCode tc ON tc.id = it.taxCodeFk JOIN taxType tt ON tt.id = tc.taxTypeFk JOIN invoiceInSerial iis ON iis.code = tt.serial - JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id + JOIN taxCode tcLink ON tcLink.link = tc.link AND tc.id != tcLink.id AND tc.link JOIN expence e ON e.id = it.expenceFk AND e.taxTypeFk = tc.taxTypeFk WHERE tc.isActive GROUP BY tcLink.rate, e.id; @@ -50597,6 +51371,9 @@ BEGIN SET ii.serialNumber = vSerialNumber, ii.isBooked = TRUE; + + UPDATE vn.config + SET ASIEN = vBookNumber; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -52798,8 +53575,9 @@ BEGIN FROM vn2008.Tickets t JOIN vn2008.Tickets_state ts ON t.Id_Ticket = ts.Id_Ticket JOIN vncontrol.inter i ON i.inter_id = ts.inter_id - JOIN vn2008.state s ON i.state_id = s.id AND s.alert_level = 0 + JOIN vn2008.state s ON i.state_id = s.id AND s.alert_level < 2 WHERE t.Fecha BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND t.warehouse_id IN (1,44) AND Id_Ruta GROUP BY Id_Ruta ) t ON t.Id_Ruta = rg.routeFk @@ -52809,7 +53587,8 @@ BEGIN rg.freeTickets = t.pedidosLibres, rg.pallets = rc.pallets, rg.lastScanned = rc.lastScanned, - rg.displayText = IF(rg.routeFk is null, rg.displayText, rg.routeFk MOD 1000); + rg.displayText = IF(rg.routeFk is null, rg.displayText, rg.routeFk MOD 1000), + rg.ready = IF(rg.freeTickets, FALSE, rg.ready); END ;; @@ -54110,6 +54889,153 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketGetProblems` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetProblems`() +BEGIN +/* + * Necesita la tabla tmp.ticket_list + * + */ + DECLARE vWarehouse INT; + DECLARE vDate DATE; + DECLARE vAvailableCache INT; + DECLARE vVisibleCache INT; + DECLARE vDone INT DEFAULT 0; + + DECLARE vCursor CURSOR FOR + SELECT DISTINCT warehouseFk, date(shipped) + FROM tmp.ticket_list tt + JOIN vn.ticket t ON tt.Id_Ticket = t.id + AND DATE(t.shipped) BETWEEN CURDATE() AND TIMESTAMPADD(DAY,1.9,CURDATE()); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.buffer_problems; + CREATE TEMPORARY TABLE tmp.buffer_problems ( + Id_Ticket INT(11), + problem VARCHAR(50), + INDEX (Id_Ticket) + ) + ENGINE = MEMORY; + + + -- CONGELADO + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + SELECT DISTINCT tt.Id_Ticket, 'CONGELADO' + FROM tmp.ticket_list tt + JOIN vn.client c ON c.id = tt.Id_Cliente + WHERE c.isFreezed; + + -- eliminamos tickets con problemas para no volverlos a mirar + DROP TEMPORARY TABLE IF EXISTS tmp.ticketListFiltered; + + CREATE TEMPORARY TABLE tmp.ticketListFiltered + (PRIMARY KEY (Id_Ticket)) + ENGINE = MEMORY + SELECT tt.Id_Ticket, c.id + FROM tmp.ticket_list tt + JOIN vn.client c ON c.id = tt.Id_Cliente + WHERE c.isFreezed = 0; + + -- RIESGO + CALL vn2008.risk_vs_client_list(CURDATE()); + + + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + SELECT DISTINCT tt.Id_Ticket, 'RIESGO' + FROM tmp.ticketListFiltered tt + JOIN vn.ticket t ON t.id = tt.Id_Ticket + JOIN vn.agencyMode a ON t.agencyModeFk = a.id + JOIN tmp.risk r ON r.Id_Cliente = t.clientFk + JOIN vn.client c ON c.id = t.clientFk + WHERE r.risk > c.credit + 10 + AND a.deliveryMethodFk != 3; -- para que las recogidas se preparen + + -- eliminamos tickets con problemas para no volverlos a mirar + DELETE tlf FROM tmp.ticketListFiltered tlf + JOIN tmp.buffer_problems bf ON tlf.Id_Ticket = bf.Id_Ticket; + + -- CODIGO 100 + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + SELECT DISTINCT tt.Id_Ticket, 'COD 100' + FROM tmp.ticket_list tt + JOIN sale s ON s.ticketFk = tt.Id_Ticket + WHERE s.itemFk = 100; + + -- eliminamos tickets con problemas para no volverlos a mirar + DELETE tlf FROM tmp.ticketListFiltered tlf + JOIN tmp.buffer_problems bf ON tlf.Id_Ticket = bf.Id_Ticket; + + OPEN vCursor; + + WHILE NOT vDone + DO + FETCH vCursor INTO vWarehouse, vDate ; + + CALL cache.visible_refresh(vVisibleCache,FALSE,vWarehouse); + CALL cache.available_refresh(vAvailableCache,FALSE,vWarehouse,vDate); + + -- El disponible es menor que 0 + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + SELECT tt.Id_Ticket, i.name + -- CONCAT(IF( M.Cantidad < IFNULL(v.visible,0) , 'NO HAY ','FALTARÁ ' ), Article) + FROM tmp.ticket_list tt + JOIN vn.ticket t ON t.id = tt.Id_Ticket + LEFT JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN cache.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + WHERE date(t.shipped) = vDate + AND categoryFk != 6 + AND s.quantity > IFNULL(v.visible,0) + AND IFNULL(av.available,0) < 0 + AND s.isPicked = FALSE + AND NOT i.generic + AND vWarehouse = t.warehouseFk; + + -- eliminamos tickets con problemas para no volverlos a mirar + DELETE tlf FROM tmp.ticketListFiltered tlf + JOIN tmp.buffer_problems bf ON tlf.Id_Ticket = bf.Id_Ticket; + + -- Amarillo: El disponible es mayor que cero y la cantidad supera el visible, estando aun sin preparar + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + SELECT tt.Id_Ticket, CONCAT('RETRASO ', i.name) + FROM tmp.ticket_list tt + JOIN vn.ticket t ON t.id = tt.Id_Ticket + LEFT JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it on it.id = i.typeFk + LEFT JOIN cache.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache + LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache + WHERE IFNULL(av.available,0) >= 0 + AND s.quantity > IFNULL(v.visible,0) + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND it.categoryFk != 6 + AND date(t.shipped) = vDate + AND NOT i.generic + AND CURDATE() = vDate + AND t.warehouseFk = vWarehouse; + END WHILE; + + CLOSE vCursor; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketGetTax` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54467,6 +55393,45 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticketNotInvoicedByClient` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketNotInvoicedByClient`(vClientFk INT) +BEGIN + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + + CREATE TEMPORARY TABLE tmp.ticket + SELECT id ticketFk + FROM ticket + WHERE refFk IS NULL + AND clientFk = vClientFk + AND shipped > '2001-01-01'; + + CALL vn.ticketGetTotal; + + SELECT c.id, + c.name as Cliente, + t.shipped as Fecha, + t.id as Id_Ticket, + CAST(tt.total AS DECIMAL(10,2)) as Importe + FROM tmp.ticketTotal tt + JOIN ticket t ON t.id = tt.ticketFk + JOIN client c ON c.id = t.ClientFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketToInvoiceByAddress` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54673,25 +55638,24 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketVolume`(IN vTicketId INT) BEGIN - DECLARE vWarehouseId INTEGER; - DECLARE vShippedDate DATE; + DECLARE vWarehouseId INTEGER; + DECLARE vShippedDate DATE; - DROP TEMPORARY TABLE IF EXISTS ticketVolume; - SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; + DROP TEMPORARY TABLE IF EXISTS ticketVolume; + SELECT warehouseFk, shipped INTO vWarehouseId,vShippedDate FROM vn.ticket WHERE id = vTicketId; - CREATE TEMPORARY TABLE IF NOT EXISTS ticketVolume ENGINE MEMORY + CREATE TEMPORARY TABLE IF NOT EXISTS ticketVolume ENGINE MEMORY - SELECT itemFk,quantity, concept, VolUd as m3_uni, volume as m3, @m3:= @m3 + ifnull(volume,0) as m3_total - FROM - ( - SELECT round(r.cm3 / 1000000,3) as VolUd ,s.quantity, round(r.cm3 * s.quantity / 1000000,3) as volume, - s.itemFk, s.concept, @m3:= 0, @vol:=0, t.agencyModeFk - FROM sale s - JOIN vn.ticket t on t.id = s.ticketFk - JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk - WHERE s.ticketFk = vTicketId - ) sub; - + SELECT itemFk, saleFk, quantity, concept, VolUd as m3_uni, volume as m3, volume * quantity as volumeTimesQuantity, @m3:= @m3 + ifnull(volume,0) as m3_total + FROM + ( + SELECT round(r.cm3 / 1000000,3) as VolUd ,s.quantity, round(r.cm3 * s.quantity / 1000000,3) as volume, + s.itemFk, s.id AS saleFk, s.concept, @m3:= 0, @vol:=0, t.agencyModeFk + FROM sale s + JOIN vn.ticket t on t.id = s.ticketFk + JOIN bi.rotacion r ON r.Id_Article = s.itemFk AND r.warehouse_id = t.warehouseFk + WHERE s.ticketFk = vTicketId + ) sub; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54863,10 +55827,66 @@ BEGIN SET role = 2 WHERE id = vUserId; - UPDATE `client` - SET credit = 0 - WHERE id = vUserId; + UPDATE `client` c + JOIN payMethod p ON p.name = 'CONTADO' + SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE + WHERE c.id = 206; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlNonDays` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlNonDays`() +BEGIN + + SELECT userFk, date(timed) as Fecha , MAX(`order`) as maxOrder, c.name as worker + FROM workerTimeControl wtc + JOIN client c ON c.id = wtc.userFk + WHERE timed < CURDATE() + GROUP BY userFk, date(timed) + HAVING maxOrder mod 2 = 1; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControlSetOrder` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControlSetOrder`() +BEGIN + + SET @order := 1; + SET @userFk := 0; + SET @day := 0; + + UPDATE workerTimeControl + SET `order` = IF(userFk = @userFk AND day(timed) = @day, @order := @order + 1, @order := 1), + userFk = @userFk := userFk, + manual = manual + (0 * @day := day(timed)) + ORDER BY userFk, timed; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55233,7 +56253,7 @@ CREATE TABLE `batch` ( KEY `buy_edi_id` (`buy_edi_id`), CONSTRAINT `batch_ibfk_1` FOREIGN KEY (`message_id`) REFERENCES `message` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `batch_ibfk_2` FOREIGN KEY (`buy_edi_id`) REFERENCES `vn2008`.`buy_edi` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=302648 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=313545 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -55571,7 +56591,7 @@ CREATE TABLE `message` ( UNIQUE KEY `mail_id` (`mail_id`), KEY `sender_id` (`sender_id`), CONSTRAINT `message_ibfk_2` FOREIGN KEY (`sender_id`) REFERENCES `mail` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=323473 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=334992 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56313,6 +57333,61 @@ CREATE TABLE `fondo_maniobra` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `indicators` +-- + +DROP TABLE IF EXISTS `indicators`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `indicators` ( + `updated` date NOT NULL, + `lastYearSales` int(11) DEFAULT NULL, + `totalGreuge` int(11) DEFAULT NULL, + `latePaymentRate` decimal(5,4) DEFAULT NULL, + `countEmployee` int(11) DEFAULT NULL, + `averageMana` int(11) DEFAULT NULL, + `bankingPool` int(11) DEFAULT NULL, + `lastMonthActiveClients` int(11) DEFAULT NULL, + `lastMonthLostClients` int(11) DEFAULT NULL, + `lastMonthNewClients` int(11) DEFAULT NULL, + `lastMonthWebBuyingRate` decimal(5,4) DEFAULT NULL, + PRIMARY KEY (`updated`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los valores actuales para una consulta diaria rápida por los directivos.'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `lastIndicators` +-- + +DROP TABLE IF EXISTS `lastIndicators`; +/*!50001 DROP VIEW IF EXISTS `lastIndicators`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `lastIndicators` AS SELECT + 1 AS `updated`, + 1 AS `lastYearSales`, + 1 AS `incLastYearSales`, + 1 AS `totalGreuge`, + 1 AS `incTotalGreuge`, + 1 AS `latePaymentRate`, + 1 AS `incLatePaymentRate`, + 1 AS `countEmployee`, + 1 AS `incCountEmployee`, + 1 AS `averageMana`, + 1 AS `incAverageMana`, + 1 AS `bankingPool`, + 1 AS `incbankingPool`, + 1 AS `lastMonthActiveClients`, + 1 AS `incLastMonthActiveClients`, + 1 AS `lastMonthLostClients`, + 1 AS `incLastMonthLostClients`, + 1 AS `lastMonthNewClients`, + 1 AS `incLastMonthNewClients`, + 1 AS `lastMonthWebBuyingRate`, + 1 AS `incLastMonthWebBuyingRate`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `m3` -- @@ -56422,7 +57497,7 @@ CREATE TABLE `nightTask` ( `schema` varchar(45) COLLATE utf8_unicode_ci NOT NULL, `procedure` varchar(100) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -56554,13 +57629,13 @@ CREATE TABLE `ventas` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `ventasComponentes` +-- Table structure for table `ventasComponentes_kk` -- -DROP TABLE IF EXISTS `ventasComponentes`; +DROP TABLE IF EXISTS `ventasComponentes_kk`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ventasComponentes` ( +CREATE TABLE `ventasComponentes_kk` ( `Fecha` varchar(10) CHARACTER SET utf8 NOT NULL DEFAULT '', `Id_Componente` int(11) NOT NULL, `Importe` decimal(10,2) DEFAULT NULL @@ -56587,6 +57662,19 @@ CREATE TABLE `ventas_contables` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `workerMana` +-- + +DROP TABLE IF EXISTS `workerMana`; +/*!50001 DROP VIEW IF EXISTS `workerMana`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `workerMana` AS SELECT + 1 AS `workerFk`, + 1 AS `amount`*/; +SET character_set_client = @saved_cs_client; + -- -- Dumping events for database 'bs' -- @@ -57280,6 +58368,180 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; ALTER DATABASE `bs` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +/*!50003 DROP PROCEDURE IF EXISTS `indicatorsUpdate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `indicatorsUpdate`(vDated DATE) +BEGIN + + DECLARE oneYearBefore DATE DEFAULT TIMESTAMPADD(YEAR,-1,vDated); + DECLARE twoMonthsBefore DATE DEFAULT TIMESTAMPADD(DAY,-60,vDated); + DECLARE oneMonthBefore DATE DEFAULT TIMESTAMPADD(DAY,-30,vDated); + + + REPLACE indicators(updated) + VALUES(vDated); + + -- Ventas totales del ultimo año + UPDATE indicators + SET lastYearSales = + ( + SELECT SUM(importe + recargo) + FROM bs.ventas v + JOIN vn2008.empresa e ON e.id = v.empresa_id + JOIN vn2008.empresa_grupo eg ON eg.empresa_grupo_id = e.empresa_grupo + WHERE fecha BETWEEN oneYearBefore AND vDated + AND eg.grupo = 'Verdnatura' + ) + WHERE updated = vDated; + + -- Greuge total acumulado + UPDATE indicators + SET totalGreuge = + ( + SELECT SUM(amount) + FROM vn.greuge + WHERE shipped <= vDated + ) + WHERE updated = vDated; + + + -- Tasa de morosidad con respecto a las ventas del último mes + UPDATE indicators + SET latePaymentRate = + (SELECT SUM(amount) FROM bi.defaulters WHERE date = vDated and amount > 0) + / + ( SELECT SUM(importe + recargo) FROM bs.ventas WHERE fecha BETWEEN oneMonthBefore AND vDated) + WHERE updated = vDated; + + -- Número de trabajadores activos + UPDATE indicators + SET countEmployee = + (SELECT count(*) + FROM account.user + WHERE role NOT IN (2, 6, 3, 31,32) + AND active + ) + WHERE updated = vDated; + + -- Maná medio acumulado por comercial + UPDATE indicators + SET averageMana = + (SELECT avg(used) + FROM bs.mana_spellers + ) + WHERE updated = vDated; + + -- Número de clientes que han comprado en los últimos 30 dias + UPDATE indicators + SET lastMonthActiveClients = + (SELECT COUNT(DISTINCT t.clientFk) + FROM vn.ticket t + WHERE t.shipped BETWEEN oneMonthBefore AND vDated + ) + WHERE updated = vDated; + + -- Número de clientes que no han comprado en los últimos 30 dias, pero compraron en los 30 anteriores + UPDATE indicators + SET lastMonthLostClients = + (SELECT COUNT(lm.clientFk) + FROM + ( + SELECT DISTINCT t.clientFk + FROM vn.ticket t + WHERE t.shipped BETWEEN oneMonthBefore AND vDated + ) cm + RIGHT JOIN + ( + SELECT DISTINCT t.clientFk + FROM vn.ticket t + WHERE t.shipped >= twoMonthsBefore + AND t.shipped < oneMonthBefore + ) lm ON lm.clientFk = cm.clientFk + WHERE cm.clientFk IS NULL + ) + WHERE updated = vDated; + + -- Número de clientes que han comprado en los últimos 30 dias, pero no compraron en los 30 anteriores + UPDATE indicators + SET lastMonthNewClients = + (SELECT COUNT(cm.clientFk) + FROM + ( + SELECT DISTINCT t.clientFk + FROM vn.ticket t + WHERE t.shipped BETWEEN oneMonthBefore AND vDated + ) cm + LEFT JOIN + ( + SELECT DISTINCT t.clientFk + FROM vn.ticket t + WHERE t.shipped >= twoMonthsBefore + AND t.shipped < oneMonthBefore + ) lm ON lm.clientFk = cm.clientFk + WHERE lm.clientFk IS NULL + ) + WHERE updated = vDated; + + -- Porcentaje de autopedidos sobre los pedidos totales + UPDATE indicators + SET lastMonthWebBuyingRate = + ( SELECT (SUM(source_app != '') - SUM(source_app = 'TPV')) / SUM(source_app != '') + FROM hedera.`order` + WHERE date_send BETWEEN oneMonthBefore AND vDated + ) + WHERE updated = vDated; + + + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `indicatorsUpdateLauncher` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `indicatorsUpdateLauncher`() +BEGIN + + DECLARE vDated DATE; + + SELECT IFNULL(TIMESTAMPADD(DAY,1,MAX(updated)), '2018-04-01') + INTO vDated + FROM bs.indicators; + + WHILE vDated < CURDATE() DO + + CALL indicatorsUpdate(vDated); + + SELECT TIMESTAMPADD(DAY,1,MAX(updated)) + INTO vDated + FROM bs.indicators; + + END WHILE; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `m3Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57315,70 +58577,6 @@ BEGIN WHERE v.fecha BETWEEN datSTART AND datEND GROUP BY t.warehouseFk, v.fecha, a.provinceFk; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `manaCustomerFill_kk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `manaCustomerFill_kk`() -BEGIN - - -/* Rellena la tabla caché bs.manaCustomer desde 0 -* -* Utilizar para reconstruirla en caso de que se corrompa. -* -*/ - -DECLARE vFromDated DATE; -DECLARE vToDated DATETIME DEFAULT '2015-12-31 23:59:59'; -DECLARE isDone BOOLEAN DEFAULT FALSE; - -DELETE FROM bs.manaCustomer; - -WHILE NOT isDone DO - - SELECT TIMESTAMPADD(DAY,1,vToDated), TIMESTAMPADD(MONTH, 1, vToDated) - INTO vFromDated, vToDated; - - IF vToDated >= CURDATE() THEN - - SET vToDated = TIMESTAMPADD(SECOND,-1,CURDATE()); - SET isDone = TRUE; - - END IF; - - INSERT INTO bs.manaCustomer(Id_Cliente, Mana) - SELECT Id_Cliente, newMana - FROM - (SELECT cs.Id_Cliente, - sum(Cantidad * Valor) as newMana - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m using(Id_Ticket) - JOIN vn2008.Movimientos_componentes mc using(Id_Movimiento) - WHERE Id_Componente IN (39, 37) -- maná auto y maná - AND Fecha BETWEEN vFromDated AND vToDated - GROUP BY cs.Id_Cliente - ) t1 - ON DUPLICATE KEY UPDATE Mana = Mana + newMana; - - SELECT vFromDated, vToDated; - -END WHILE; - - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57510,7 +58708,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `nightly_tasks` */; +/*!50003 DROP PROCEDURE IF EXISTS `nightly_tasks_kk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -57520,7 +58718,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `nightly_tasks`() +CREATE DEFINER=`root`@`%` PROCEDURE `nightly_tasks_kk`() BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN @@ -57856,75 +59054,59 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ventas_add`(IN datSTART DATETIME, IN datEND DATETIME) BEGIN + DECLARE vStartingPeriod INT; + DECLARE vStartingDate DATETIME; + DECLARE vEndingDate DATETIME; + DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; -DECLARE vStartingPeriod INT; -DECLARE vStartingDate DATETIME; -DECLARE vEndingDate DATETIME; -DECLARE TIPO_PATRIMONIAL INT DEFAULT 188; - -SET datEND = vn2008.dayend(datEND); -SET vStartingDate = GREATEST('2015-10-01',datSTART); -SET vEndingDate = vn2008.dayend(vStartingDate); - -DELETE FROM ventas -WHERE fecha between vStartingDate and datEND; - -WHILE vEndingDate <= datEND DO - - --- Ventes bioniques - SELECT vStartingDate,vEndingDate, datEND; - - REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id) - SELECT Id_Movimiento - , sum( IF(base, Cantidad * Valor, 0) ) as importe - , sum( IF(base, 0, Cantidad * Valor) ) as recargo - , vStartingDate - , a.tipo_id - , cs.Id_Cliente - , t.empresa_id - FROM vn2008.Movimientos_componentes mc - JOIN bi.tarifa_componentes tc using(Id_Componente) - JOIN bi.tarifa_componentes_series tcs using(tarifa_componentes_series_id) - JOIN vn2008.Movimientos m using(Id_Movimiento) - JOIN vn2008.Articles a using(Id_Article) - JOIN vn2008.Tipos tp using(tipo_id) - JOIN vn2008.reinos r on r.id = tp.reino_id - JOIN vn2008.Tickets t using(Id_Ticket) - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - JOIN vn2008.empresa e on e.id = empresa_id - WHERE t.Fecha between vStartingDate and vEndingDate - AND datEND >= '2015-10-01' - AND ( - c.`Real` != 0 - OR c.Razonsocial = 'MIRIAM FERRER TORIBIO' - OR c.Razonsocial = 'VERDNATURA COMPLEMENTOS' - ) - AND Cantidad <> 0 - AND a.tipo_id != TIPO_PATRIMONIAL - AND c.Id_Trabajador IS NOT NULL - AND m.Descuento <> 100 - AND (m.Id_Article = 98 or m.Id_Article = 95 or r.mercancia != 0) - GROUP BY mc.Id_Movimiento - HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0; - -/* -UPDATE vn2008.Movimientos m -JOIN bs.ventas v ON v.Id_Movimiento = m.Id_Movimiento -SET m.Costfixat = IFNULL(round(v.importe/m.Cantidad,2),0) -WHERE v.fecha between vStartingDate and vEndingDate; -*/ - - SET vStartingDate = TIMESTAMPADD(DAY,1, vStartingDate); + SET datEND = util.dayEnd(datEND); + SET vStartingDate = GREATEST('2015-10-01',datSTART); SET vEndingDate = vn2008.dayend(vStartingDate); - -END WHILE; - + DELETE + FROM ventas + WHERE fecha between vStartingDate and datEND; + WHILE vEndingDate <= datEND DO + + REPLACE ventas(Id_Movimiento, importe, recargo, fecha, tipo_id, Id_Cliente, empresa_id) + SELECT Id_Movimiento, + sum( IF(base, Cantidad * Valor, 0) ) as importe, + sum( IF(base, 0, Cantidad * Valor) ) as recargo, + vStartingDate, + a.tipo_id, + cs.Id_Cliente, + t.empresa_id + FROM vn2008.Movimientos_componentes mc + JOIN bi.tarifa_componentes tc using(Id_Componente) + JOIN bi.tarifa_componentes_series tcs using(tarifa_componentes_series_id) + JOIN vn2008.Movimientos m using(Id_Movimiento) + JOIN vn2008.Articles a using(Id_Article) + JOIN vn2008.Tipos tp using(tipo_id) + JOIN vn2008.reinos r on r.id = tp.reino_id + JOIN vn2008.Tickets t using(Id_Ticket) + JOIN vn2008.Consignatarios cs using(Id_Consigna) + JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente + -- JOIN vn2008.empresa e on e.id = empresa_id + WHERE t.Fecha between vStartingDate and vEndingDate + AND datEND >= '2015-10-01' + AND ( + c.`Real` != 0 + OR c.Razonsocial = 'MIRIAM FERRER TORIBIO' + OR c.Razonsocial = 'VERDNATURA COMPLEMENTOS' + ) + AND m.Cantidad <> 0 + AND a.tipo_id != TIPO_PATRIMONIAL + AND c.Id_Trabajador IS NOT NULL + AND m.Descuento <> 100 + AND (m.Id_Article = 98 or m.Id_Article = 95 or r.mercancia != 0) + GROUP BY mc.Id_Movimiento + HAVING IFNULL(importe,0) <> 0 OR IFNULL(recargo,0) <> 0; + SET vStartingDate = TIMESTAMPADD(DAY,1, vStartingDate); + SET vEndingDate = util.dayEnd(vStartingDate); + END WHILE; END ;; DELIMITER ; @@ -58332,23 +59514,6 @@ CREATE TABLE `Ticket_Portes` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `VelocityKK` --- - -DROP TABLE IF EXISTS `VelocityKK`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `VelocityKK` ( - `tipo_id` int(11) NOT NULL, - `Fecha` datetime NOT NULL, - `Disponible` int(11) DEFAULT NULL, - `Visible` int(11) DEFAULT NULL, - `velocity_id` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`velocity_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `XDiario_ALL` -- @@ -60078,94 +61243,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `defaultingkk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `defaultingkk`(IN vDate DATE) -BEGIN - DECLARE done BIT DEFAULT 0; - DECLARE vClient INT; - DECLARE vAmount INT; - DECLARE vDateInvoice DATE; - DECLARE vAmountInvoice DECIMAL(10,2); - DECLARE vDueDay INT; - DECLARE vGraceDays INT; - DECLARE defaulters CURSOR FOR - SELECT client, amount, Vencimiento, graceDays FROM bi.defaulters d - JOIN vn2008.Clientes c ON c.Id_Cliente = d.client - JOIN vn2008.pay_met pm ON pm.id = c.pay_met_id - WHERE hasChanged AND date = vDate; - - DECLARE invoices CURSOR FOR - SELECT Fecha, importe FROM vn2008.Facturas f - WHERE f.Fecha >= '2016-01-01' AND f.Id_Cliente = vClient ORDER BY f.Fecha DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; - -- Control - - INSERT INTO vn2008.daily_task_log(consulta) VALUES('defaulting'); - - DELETE FROM bi.defaulters WHERE date = vDate; - - INSERT INTO bi.defaulters(client, date, amount) - SELECT customer_id, vDate, FLOOR(SUM(amount)) AS amount - FROM bi.customerRiskOverdue - GROUP BY customer_id; - - -- marcamos si ha cambiado y heredamos la fecha defaulterSince - UPDATE bi.defaulters d - JOIN ( - SELECT client, amount , defaulterSince FROM bi.defaulters - WHERE date = TIMESTAMPADD(DAY,-1, vDate) - GROUP BY client - ) yesterday using(client) - SET d.hasChanged = IF(d.amount <> yesterday.amount, 1, 0), - d.defaulterSince = yesterday.defaulterSince - WHERE d.date = vDate ; - - OPEN defaulters; - defaulters: BEGIN - REPEAT - FETCH defaulters INTO vClient,vAmount, vDueDay, vGraceDays; - OPEN invoices; - invoices:BEGIN - REPEAT - - FETCH invoices INTO vDateInvoice, vAmountInvoice; - IF TIMESTAMPADD(DAY, vGraceDays, vn2008.paymentday(vDateInvoice, vDueDay)) <= vDate THEN - SET vAmount = vAmount - vAmountInvoice; - IF vAmount < 0 THEN - UPDATE defaulters SET defaulterSince = vn2008.paymentday(vDateInvoice, vDueDay) - WHERE client = vClient and date = vDate; - SET vAmount = 0; - LEAVE invoices; - END IF; - END IF; - UNTIL done END REPEAT; - END invoices; - CLOSE invoices; - UNTIL done OR vClient IS NULL END REPEAT; - END defaulters; - CLOSE defaulters; - DELETE FROM bi.defaulting WHERE date = vDate; - - INSERT INTO bi.defaulting(date, amount) - SELECT vDate, SUM(amount) - FROM bi.defaulters - WHERE date = vDate and amount > 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 DROP PROCEDURE IF EXISTS `defaulting_launcher` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -61367,216 +62444,6 @@ BEGIN END WHILE; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_add2kk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_add2kk`(intNUMDAYS INTEGER) -BEGIN - -DECLARE datSTART,datEND DATETIME; --- Seleccionamos los tickets a tratar añadiendolos a la tabla bi.ticket - - SET @@session.max_sp_recursion_depth=250; -- Habilito la recursión en mysql hasta un límite de 250. - SET datSTART = TIMESTAMPADD(DAY, -intNUMDAYS, CURDATE()); - - - SET datEND = vn2008.DAYEND(datSTART); - - - - - -- Actualiza el valor de costfixat en Movimientos a efectos estadisticos -update vn2008.Movimientos m -join -( -select Id_Movimiento, round(IFNULL(sum(Valor) , IFNULL( Preu * (100 - m.Descuento) /100,0 ) ),2) as Cost -from vn2008.Tickets t -join vn2008.Movimientos m using(Id_Ticket) -left join vn2008.Movimientos_componentes mc using(Id_Movimiento) -join bi.tarifa_componentes tc using(Id_Componente) -join bi.tarifa_componentes_series tcs on tcs.tarifa_componentes_series_id = tc.tarifa_componentes_series_id AND tcs.base -where t.Fecha between datSTART AND datEND -group by Id_Movimiento -) sub using(Id_Movimiento) -set CostFixat = Cost; - - - - - REPLACE INTO bi.ticket(Id_Ticket,Id_Cliente,`date`, tipo_id, `year`,`week`,`month`,`day`,`view`,amount,Id_Trabajador,Id_propietario ) - SELECT t.Id_Ticket,c.Id_Cliente,t.Fecha `date`,tipo_id, year(Fecha) as `year`, vn2008.vnweek(Fecha) as `week`, - month(Fecha) as `month`,vn2008.vnday(Fecha) as `day`, A.Vista `view`, - IFNULL( round( sum(cantidad * Preu * (100 - m.Descuento)/100) ,2) ,0) as amount, - c.Id_Trabajador, c.Id_Trabajador - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.warehouse W ON W.id = t.warehouse_id - INNER JOIN vn2008.Clientes c on cs.Id_Cliente = c.Id_Cliente - INNER JOIN vn2008.Movimientos m USING(Id_Ticket) - INNER JOIN vn2008.Articles USING(Id_Article) - INNER JOIN vn2008.Agencias A on A.Id_Agencia = t.Id_Agencia - INNER JOIN vn2008.Tipos TP USING(tipo_id) - WHERE Fecha BETWEEN datSTART AND datEND - AND NOT W.fuente - AND c.`Real` - AND (reino_id <> 6 OR m.Id_Article IN (95,98)) - GROUP BY t.Id_Ticket,tipo_id ; - - /* - UPDATE bi.ticket - JOIN vn2008.Tickets using(Id_Ticket) - JOIN vn2008.Agencias using(Id_Agencia) - JOIN vn2008.agency_warehouse aw using(agency_id,warehouse_id) - SET `view` = aw.Vista - WHERE Tickets.Fecha BETWEEN datSTART AND datEND; - */ - - - - IF (intNUMDAYS>0) THEN - CALL `bi`.`ticket_add2` (intNUMDAYS-1); - END IF; - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_addkk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_addkk`(intNUMDAYS INTEGER) -BEGIN - -DECLARE datSTART DATETIME; - - IF (intNUMDAYS > 0) THEN - SET datSTART = TIMESTAMPADD(DAY, -intNUMDAYS, CURDATE()); - DELETE FROM bi.ticket where `date` >= datSTART ; - CALL `bi`.`ticket_add2` (intNUMDAYS); - DELETE FROM bi.ticket where `date` < '2001-01-01'; - END IF; - -UPDATE bi.ticket bt -JOIN vn2008.Tickets USING(Id_Ticket) -JOIN vn2008.Consignatarios C USING(Id_Consigna) -SET bt.Id_Cliente = C.Id_Cliente -, bt.Id_Trabajador = @idT := vn2008.Averiguar_ComercialCliente_Id(C.Id_Cliente,bt.date) -, bt.Id_propietario = @idT -WHERE Tickets.Id_Cliente = 31 AND bt.date >= datSTART; - - --- Almacena los tickets que comisionan, para consultas rapidas - -truncate table bi.f_tvc; - -insert into bi.f_tvc -select Id_Ticket -from vn2008.Tickets t -join vn2008.Consignatarios cs using(Id_Consigna) -join vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente -join vn2008.warehouse w on w.id = t.warehouse_id -where c.`Real` = TRUE -and w.comisionantes = TRUE; - - - - --- Quita las horas de los tickets del mes anterior -IF DAY(CURDATE()) = 15 THEN - update vn2008.Tickets - set Fecha = date(Fecha) - where Fecha between TIMESTAMPADD(DAY,-46,CURDATE()) and TIMESTAMPADD(DAY, -1 - DAY(CURDATE()), CURDATE()); - END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticket_add_bydaykk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_add_bydaykk`(datFEC DATE) -BEGIN - - DECLARE datSTART DATETIME; - DECLARE datEND DATETIME; - --- Seleccionamos los tickets a tratar añadiendolos a la tabla bi.ticket - - SET @@session.max_sp_recursion_depth=2500; -- Habilito la recursión en mysql hasta un límite de 2500. - - SET datSTART = DATE(datFEC); - SET datEND = TIMESTAMPADD(DAY,30,datSTART); - - DELETE FROM bi.ticket WHERE `date` between datSTART and datEND; - - INSERT INTO bi.ticket(Id_Ticket,`date`, tipo_id, `year`,`week`,`month`,`view`,amount,Id_Trabajador, Id_Cliente, Id_Propietario ) - SELECT t.Id_Ticket,t.Fecha `date`,tipo_id, vn2008.vnyear(Fecha) as `year`, vn2008.vnweek(Fecha) as `week`, - vn2008.vnmonth(Fecha) as `month`, A.Vista `view`, IFNULL(round(sum(cantidad * preu * (100 - m.Descuento)/100),2),0) as amount, - c.Id_Trabajador, c.Id_Cliente, ifnull(c.Id_Trabajador,20) - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.warehouse W ON W.id = t.warehouse_id - INNER JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - INNER JOIN vn2008.Movimientos m USING(Id_Ticket) - INNER JOIN vn2008.Articles USING(Id_Article) - INNER JOIN vn2008.Agencias A on A.Id_Agencia = t.Id_Agencia - INNER JOIN vn2008.Tipos TP USING(tipo_id) - LEFT JOIN vn2008.reinos r ON r.id = TP.reino_id - WHERE Fecha >= datSTART - AND Fecha < datEND - AND NOT W.fuente - AND (invoice or t.Id_Cliente in (5,31)) - AND r.display <> 0 - GROUP BY t.Id_Ticket,tipo_id - ON DUPLICATE KEY UPDATE amount = amount, - `view` = `view`, - `date` = `date`, - `week` = `week`, - `year` = `year`, - `month` = `month`, - tipo_id = tipo_id, - Id_Trabajador = Id_Trabajador, - Id_Cliente = Id_Cliente, - Id_Propietario = ifnull(Id_Trabajador,20); - - UPDATE bi.ticket - JOIN vn2008.Tickets using(Id_Ticket) - JOIN vn2008.Agencias using(Id_Agencia) - JOIN vn2008.agency_warehouse aw using(agency_id,warehouse_id) - SET `view` = aw.Vista - WHERE Tickets.Fecha BETWEEN datSTART AND datEND; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61789,7 +62656,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=MyISAM AUTO_INCREMENT=191006 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=195413 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62055,7 +62922,7 @@ CREATE TABLE `queueMember` ( KEY `extension` (`extension`), CONSTRAINT `queueMember_ibfk_1` FOREIGN KEY (`queue`) REFERENCES `queue` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `queueMember_ibfk_2` FOREIGN KEY (`extension`) REFERENCES `sip` (`extension`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=728 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue members'; +) ENGINE=InnoDB AUTO_INCREMENT=734 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Queue members'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62531,25 +63398,6 @@ CREATE TABLE `available` ( ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `barcodes` --- - -DROP TABLE IF EXISTS `barcodes`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `barcodes` ( - `code` varchar(22) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', - `Id_Article` int(11) NOT NULL DEFAULT '0', - `Article` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Medida` int(10) unsigned DEFAULT NULL, - `Color` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `Categoria` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `Producer` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`code`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `cache` -- @@ -62587,7 +63435,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=103982 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=116434 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63191,205 +64039,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `barcodes_articles_update` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `barcodes_articles_update`() -BEGIN - -REPLACE cache.barcodes - - SELECT - `Articles`.`Id_Article` AS `code`, - `Articles`.`Id_Article` AS `Id_Article`, - `Articles`.`Article` AS `Article`, - `Articles`.`Medida` AS `Medida`, - `Articles`.`Color` AS `Color`, - `Articles`.`Categoria` AS `Categoria`, - `p`.`name` AS `Producer` - FROM - vn2008.Articles - LEFT JOIN vn2008.`producer` `p` using(producer_id); - - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -/*!50003 DROP PROCEDURE IF EXISTS `barcodes_barcodes_update` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `barcodes_barcodes_update`() -BEGIN - -REPLACE cache.barcodes - - SELECT - `barcodes`.`code` AS `code`, - `barcodes`.`Id_Article` AS `Id_Article`, - `Articles`.`Article` AS `Article`, - `Articles`.`Medida` AS `Medida`, - `Articles`.`Color` AS `Color`, - `Articles`.`Categoria` AS `Categoria`, - `p`.`name` AS `Producer` - FROM - vn2008.`barcodes` - JOIN - vn2008.Articles using(Id_Article) - LEFT JOIN vn2008.`producer` `p` using(producer_id); - - - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -/*!50003 DROP PROCEDURE IF EXISTS `barcodes_compres_update` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `barcodes_compres_update`() -BEGIN - -REPLACE cache.barcodes - - SELECT - Compres.`Id_Compra` AS `code`, - Compres.`Id_Article` AS `Id_Article`, - `Articles`.`Article` AS `Article`, - `Articles`.`Medida` AS `Medida`, - `Articles`.`Color` AS `Color`, - `Articles`.`Categoria` AS `Categoria`, - producer.`name` AS `Producer` - - - FROM - vn2008.Compres - JOIN vn2008.Articles using(Id_Article) - LEFT JOIN vn2008.producer using(producer_id) - JOIN vn2008.Entradas using(Id_Entrada) - JOIN vn2008.travel on travel.id = travel_id - WHERE - landing >= TIMESTAMPADD(WEEK, -2, CURDATE()) - ; - - - -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 */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -/*!50003 DROP PROCEDURE IF EXISTS `barcodes_expeditions_update` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `barcodes_expeditions_update`(IN idExpedition BIGINT) -BEGIN - -REPLACE cache.barcodes - - SELECT - `e`.`expeditions_id` AS `code`, - `Tickets`.`Id_Ruta` AS `Id_Article`, - `Tickets`.`Alias` AS `Article`, - `Tickets`.`Bultos` AS `Medida`, - `Tickets`.`Id_Ruta` AS `Color`, - `w`.`name` AS `Categoria`, - `a`.`Agencia` AS `Producer` - FROM - vn2008.expeditions `e` - JOIN vn2008.Tickets ON `Tickets`.`Id_Ticket` = `e`.`ticket_id` - JOIN vn2008.warehouse `w` ON `w`.`id` = `Tickets`.`warehouse_id` - JOIN vn2008.Rutas `r` ON `r`.`Id_Ruta` = `Tickets`.`Id_Ruta` - JOIN vn2008.Agencias `a` ON `a`.`Id_Agencia` = `r`.`Id_Agencia` - WHERE - idExpedition IN (e.expeditions_id,0) - AND - `Tickets`.`Fecha` >= (CURDATE() + INTERVAL -(2) DAY) - - - ; - - - -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 */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -/*!50003 DROP PROCEDURE IF EXISTS `barcodes_update` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `barcodes_update`() -BEGIN - - declare allExpeditions int default 0; - - call barcodes_articles_update; - - call barcodes_barcodes_update; - - call barcodes_compres_update; - - call barcodes_expeditions_update(allExpeditions); - -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 */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `cacheCalcClean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -63778,99 +64427,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `departure_timing_kk` */; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `departure_timing_kk`() -BEGIN - -DECLARE done BOOL DEFAULT FALSE; -DECLARE rsDeparture INT; -DECLARE rsHoras DECIMAL(5,2); -DECLARE rsInicio DECIMAL(5,2); -DECLARE resto DECIMAL(5,2); -DECLARE horasProd DECIMAL(5,2); -DECLARE inicioProd DECIMAL(5,2) DEFAULT 24.00; -DECLARE myTime DECIMAL(5,2); -DECLARE departureLimit INT; -DECLARE myWarehouse INT; -DECLARE myMinSpeed DECIMAL(10,2); - - -DECLARE rs CURSOR FOR - SELECT Departure - , Sum(pb.m3)/(GREATEST(v.m3, 100)/1.3) AS Horas - , curDate()+(Departure-Sum(pb.m3)/(GREATEST(v.m3, 100)/1.3))/24 AS InicioPreparacion - FROM tmp.production_buffer pb - JOIN vn2008.v_encajado_ultima_hora v ON v.warehouse_id = pb.warehouse_id - WHERE Fecha = CURDATE() - AND alert_level < 2 - AND IFNULL(Departure,0) > 0 - GROUP BY Departure - ORDER BY Departure DESC; - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -SELECT IFNULL(minSpeed,0) INTO myMinSpeed -FROM cache.departure_limit -WHERE warehouse_id = myWarehouse -AND fecha = CURDATE(); - -SET myTime = HOUR(now()) + MINUTE(now()) / 60; - -SELECT warehouse_id INTO myWarehouse -FROM tmp.production_buffer -LIMIT 1; - -OPEN rs; - -FETCH rs INTO rsDeparture, rsHoras , rsInicio; - -WHILE NOT done DO - - SET resto = IF(inicioProd < rsDeparture, rsDeparture - inicioProd,0); - - SET inicioProd = rsDeparture - rsHoras; - - IF inicioProd - resto < myTime THEN - - SET done = TRUE; - - ELSE - - SET departureLimit = rsDeparture; - - FETCH rs INTO rsDeparture, rsHoras , rsInicio; - - END IF; - -END WHILE; - -IF departureLimit > 0 THEN - - REPLACE cache.departure_limit(warehouse_id, fecha, hora, minSpeed) - VALUES (myWarehouse, CURDATE(), departureLimit, myMinSpeed); - -END IF; - -CLOSE rs; - - -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 */ ; -ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 DROP PROCEDURE IF EXISTS `equaliza` */; ALTER DATABASE `cache` CHARACTER SET utf8 COLLATE utf8_general_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -64185,100 +64741,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `sales_refreshkk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `sales_refreshkk`() -proc:BEGIN - - DECLARE v_calc INT; - DECLARE v_refresh BOOL DEFAULT TRUE; - DECLARE datMONTH INT; - DECLARE datYEAR INT; - - CALL cache_calc_start (v_calc, v_refresh, 'sales', NULL); - - IF !v_refresh - THEN - LEAVE proc; - END IF; - - - SELECT MONTH(CURDATE()) INTO datMONTH; - SELECT YEAR(CURDATE()) INTO datYEAR; - - -- preparamos una tabla con los meses y años que interesan - DROP TEMPORARY TABLE IF EXISTS tmp.periods; - CREATE TEMPORARY TABLE tmp.periods - select distinct month, year(date) as year - from vn2008.time - where date <= CURDATE() - order by year desc, month desc - limit 3; - - -- borramos los datos para evitar flecos - DELETE s.* - FROM bi.sales s - join tmp.periods using(year,month); - - -- insertamos las ventas de cada comercial - REPLACE bi.sales(Id_Trabajador, year, month, weight, boss_id) - select v.Id_Trabajador, year, month, round(sum(total)) as weight, IFNULL(j.boss_id,20) - from bi.v_ticket_total v - join tmp.periods using(year,month) - left join (SELECT jerarquia.boss_id, jerarquia.worker_id - FROM vn2008.jerarquia - ) j on j.worker_id = v.Id_Trabajador - group by v.Id_Trabajador, year, month; - - - - -- caso especial: Claudi ajuda a Josep a llegar a los 1200 euros de comision - /* - update bi.sales - set boss_aid = 34285 - weight - where Id_Trabajador = 378 - and year >= 2015 - and month > datmonth -2; - - update bi.sales s - join - (select year, month, boss_aid - from bi.sales - where Id_Trabajador = 378 - and year >= 2015 - and month > datmonth -2) sub using(year,month) - set s.boss_aid = s.boss_aid - sub.boss_aid - where Id_Trabajador = 208 - and year >= 2015 - and month > datmonth -2; - */ - - - - --- ahora, las comisiones - -update bi.sales s -set comision = weight * 0.029; - - DROP TEMPORARY TABLE IF EXISTS tmp.periods; - - CALL cache_calc_end (v_calc); - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `stock_refresh` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64500,7 +64962,7 @@ CREATE TABLE `ACL` ( `principalType` set('ROLE','USER') COLLATE utf8_unicode_ci DEFAULT 'ROLE', `principalId` varchar(512) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=78 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -65243,7 +65705,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn2008`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=9913042 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10446149 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -65258,6 +65720,34 @@ DELIMITER ;; BEFORE INSERT ON `inter` FOR EACH ROW BEGIN + /* PAK 08/05/18 Los sacadores no deben de poner los tickets en revisión */ + DECLARE vIsSacador BOOLEAN; + + IF NEW.state_id = 6 THEN -- Revisión + + SELECT (COUNT(*) > 0) INTO vIsSacador + FROM inter + WHERE state_id = 5 -- Preparacion + AND Id_Trabajador = NEW.Id_Trabajador + AND Id_Ticket = NEW.Id_Ticket; + + IF vIsSacador THEN + + SET NEW.state_id = 5; + + END IF; + + END IF; + + /* PAK 08/05/18 Los tickets no se pueden marcar como servidos en el futuro */ + IF NEW.state_id = 16 AND (SELECT date(shipped) FROM vn.ticket WHERE id = NEW.Id_Ticket) > CURDATE() THEN -- Entregado + + SET NEW.state_id = 22; -- ¿ Fecha ? + + END IF; + + /* 08/05/18 PAK Este código parece fósil. Lo comento. + DECLARE contados INT; DECLARE vSupervisor INT; @@ -65265,7 +65755,7 @@ BEGIN SET NEW.Id_Supervisor = IFNULL(vSupervisor,20); - IF NEW.state_id = 5 + IF NEW.state_id = 5 -- Preparación THEN SELECT count(Id_Ticket) INTO contados FROM vncontrol.inter @@ -65278,6 +65768,7 @@ BEGIN CALL util.throw ('FALLO_AL_INSERTAR'); END IF; END IF; + */ END */;; DELIMITER ; @@ -65420,64 +65911,6 @@ BEGIN INSERT INTO vncontrol.dailyTaskLog(state) VALUES('clean END'); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ResumenKK` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ResumenKK`() -BEGIN - -select accion, CodigoTrabajador, semana, Pedidos, Lineas -from accion -join -( - SELECT * FROM - ( - select count(*) as Pedidos, semana, Id_Trabajador, accion_id - from - (select distinct * - from - ( - select vn2008.semana(odbc_date) as semana - ,Id_Trabajador - ,accion_id - ,Id_Ticket - from vncontrol.inter - ) sub - ) sub2 - group by semana, Id_Trabajador, accion_id - ) subpedidos - - inner join - ( - - select semana, Id_Trabajador, accion_id, count(*) as Lineas - from vn2008.Movimientos - inner join - ( - select distinct vn2008.semana(odbc_date) as semana, Id_Ticket, Id_Trabajador, accion_id from vncontrol.inter - ) vnc using(Id_Ticket) - group by semana, Id_Trabajador, accion_id - - ) sublineas using(semana, Id_Trabajador, accion_id) - -) sub3 using(accion_id) - -join vn2008.Trabajadores using(Id_Trabajador) -; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66081,7 +66514,7 @@ CREATE TABLE `news` ( KEY `tag` (`tag`), CONSTRAINT `news_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `account`.`account` (`id`) ON UPDATE CASCADE, CONSTRAINT `news_ibfk_2` FOREIGN KEY (`tag`) REFERENCES `newsTag` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13005 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13009 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66132,7 +66565,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn2008`.`Vistas` (`vista_id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1333914 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1375499 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66231,7 +66664,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8239607 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8480264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -66645,7 +67078,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn2008`.`Recibos` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=204034 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=212107 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66693,7 +67126,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgent`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgent`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1222729 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1248001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66713,7 +67146,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agent`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agent`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2634752 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2708559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66738,7 +67171,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccess`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visit`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccess`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1753573 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1783294 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -66758,7 +67191,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`user`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`access`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2528896 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2596223 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67553,75 +67986,78 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS filter; CREATE TEMPORARY TABLE filter - (INDEX (item_id)) - ENGINE = MEMORY - SELECT Id_Article item_id FROM vn2008.Articles - WHERE tipo_id = vType - AND (vFilter IS NULL OR Article LIKE vFilter); + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT id itemFk FROM vn.item + WHERE typeFk = vType + AND (vFilter IS NULL OR `name` LIKE vFilter); - DROP TEMPORARY TABLE IF EXISTS current_stock; - CREATE TEMPORARY TABLE current_stock - (INDEX (item_id)) - ENGINE = MEMORY - SELECT item_id, SUM(Cantidad) amount FROM - ( - SELECT Id_Article item_id, Cantidad - FROM vn2008.Compres c - JOIN vn2008.Entradas e USING(Id_Entrada) - JOIN vn2008.travel t ON t.id = e.travel_id - WHERE landing BETWEEN vDateInv AND vDate - AND warehouse_id = vWh - AND NOT Redada - UNION ALL - SELECT Id_Article, -Cantidad - FROM vn2008.Compres c - JOIN vn2008.Entradas e USING(Id_Entrada) - JOIN vn2008.travel t ON t.id = e.travel_id - WHERE shipment BETWEEN vDateInv AND CURDATE() - AND warehouse_id_out = vWh - AND NOT Redada - AND delivered - UNION ALL - SELECT m.Id_Article, -m.Cantidad - FROM vn2008.Movimientos m - JOIN vn2008.Tickets t USING(Id_Ticket) - JOIN vn.ticketState s ON s.ticket = t.Id_Ticket - WHERE t.Fecha BETWEEN vDateInv AND CURDATE() - AND t.warehouse_id = vWh - AND (t.Etiquetasemitidas OR s.alertLevel = 3) - ) t - GROUP BY item_id - HAVING amount > 0; + DROP TEMPORARY TABLE IF EXISTS currentStock; + CREATE TEMPORARY TABLE currentStock + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(amount) amount + FROM ( + SELECT b.itemFk, b.amount + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDateInv AND vDate + AND t.warehouseInFk = vWh + AND NOT e.isRaid + UNION ALL + SELECT b.itemFk, -b.amount + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.shipped BETWEEN vDateInv AND CURDATE() + AND t.warehouseOutFk = vWh + AND NOT e.isRaid + AND t.isDelivered + UNION ALL + SELECT m.itemFk, -m.quantity + FROM vn.sale m + JOIN vn.ticket t ON t.id = m.ticketFk + JOIN vn.ticketState s ON s.ticket = t.id + WHERE t.shipped BETWEEN vDateInv AND CURDATE() + AND t.warehouseFk = vWh + AND s.alertLevel = 3 + ) t + GROUP BY itemFk + HAVING amount > 0; DROP TEMPORARY TABLE IF EXISTS tmp; CREATE TEMPORARY TABLE tmp - (INDEX (item_id)) - ENGINE = MEMORY - SELECT * FROM - ( - SELECT c.Id_Article item_id, c.Id_Compra id, c.Id_Cubo, c.packing - FROM vn2008.Compres c - JOIN vn2008.Entradas e USING(Id_Entrada) - JOIN vn2008.travel t ON t.id = e.travel_id - WHERE t.landing BETWEEN vDateInv AND vDate - AND c.Novincular = FALSE - AND c.Tarifa2 >= 0 - AND Id_Cubo IS NOT NULL - ORDER BY t.warehouse_id = 1 DESC, t.landing DESC - ) t GROUP BY item_id; + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT * + FROM ( + SELECT b.itemFk, b.packageFk, b.packing + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDateInv AND vDate + AND NOT b.isIgnored + AND b.price2 >= 0 + AND b.packageFk IS NOT NULL + ORDER BY t.warehouseInFk = 1 DESC, t.landed DESC + ) t GROUP BY itemFk; DROP TEMPORARY TABLE IF EXISTS result; CREATE TEMPORARY TABLE result - ENGINE = MEMORY - SELECT a.Id_Article, IF(vPrefixLen > 0, SUBSTRING(a.Article, vPrefixLen), a.Article) Article, - t.packing, CEIL(s.amount / t.packing) etiquetas, t.Id_Cubo, IF(c.z > 0, c.z, 0) z, c.x, c.y, a.Nicho - FROM vn2008.Articles a - JOIN filter f ON f.item_id = a.Id_Article - JOIN current_stock s ON s.item_id = a.Id_Article - LEFT JOIN tmp t ON t.item_id = a.Id_Article - LEFT JOIN vn2008.Cubos c ON c.Id_Cubo = t.Id_Cubo - WHERE CEIL(s.amount / t.packing) > 0 - AND c.box; + ENGINE = MEMORY + SELECT i.id Id_Article, + IF(vPrefixLen > 0, SUBSTRING(i.`name`, vPrefixLen), i.`name`) Article, + t.packing, p.id Id_Cubo, IF(p.depth > 0, p.depth, 0) z, p.width x, p.height y, + CEIL(s.amount / t.packing) etiquetas + FROM vn.item i + 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.package p ON p.id = t.packageFk + WHERE CEIL(s.amount / t.packing) > 0 + -- FIXME: Column vn2008.Cubos.box not included in view vn.package + /* AND p.box */; IF vUseIds THEN @@ -67634,7 +68070,7 @@ BEGIN DROP TEMPORARY TABLE filter, - current_stock, + currentStock, tmp, result; END ;; @@ -67745,7 +68181,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `item_list`(v_warehouse SMALLINT, v_shipping BEGIN DECLARE v_calc INT; - CALL cache.available_refresh (v_calc, TRUE, v_warehouse, v_shipping); + CALL cache.available_refresh (v_calc, FALSE, v_warehouse, v_shipping); CALL vn2008.item_last_buy_ (v_warehouse, v_shipping); SELECT a.Id_Article, a.Article, a.Categoria, a.Medida, a.Tallos, @@ -70790,24 +71226,6 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `v_barcodes_plus` --- - -/*!50001 DROP VIEW IF EXISTS `v_barcodes_plus`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_barcodes_plus` AS select `cache`.`barcodes`.`code` AS `code`,`cache`.`barcodes`.`Id_Article` AS `Id_Article`,`cache`.`barcodes`.`Article` AS `Article`,`cache`.`barcodes`.`Medida` AS `Medida`,`cache`.`barcodes`.`Color` AS `Color`,`cache`.`barcodes`.`Categoria` AS `Categoria`,`cache`.`barcodes`.`Producer` AS `Producer` from `cache`.`barcodes` */; -/*!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 `v_botanic_export` -- @@ -71624,6 +72042,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `agencyModeZone` +-- + +/*!50001 DROP VIEW IF EXISTS `agencyModeZone`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `agencyModeZone` AS select `a`.`Id_Agencia` AS `agencyModeFk`,`a`.`zona` AS `zone`,`a`.`price` AS `price`,`a`.`Id_Article` AS `itemFk`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`porte_minimo` AS `minimCost`,`a`.`inflacion` AS `inflation` from `vn2008`.`Agencias_zonas` `a` */; +/*!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 `agencyProvince` +-- + +/*!50001 DROP VIEW IF EXISTS `agencyProvince`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `agencyProvince` AS select `a`.`province_id` AS `provinceFk`,`a`.`agency_id` AS `agencyFk`,`a`.`zona` AS `zone`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`route` AS `route` from `vn2008`.`Agencias_province` `a` */; +/*!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 `agencyWarehouse` -- @@ -71642,6 +72096,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `agencyWeekDayBonus` +-- + +/*!50001 DROP VIEW IF EXISTS `agencyWeekDayBonus`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `agencyWeekDayBonus` AS select `a`.`id` AS `id`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`agency_id` AS `agencyFk`,`a`.`weekDay` AS `weekDay`,`a`.`zona` AS `zone`,`a`.`bonus` AS `bonus` from `vn2008`.`agency_weekday_bonus` `a` */; +/*!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 `annualAverageInvoiced` -- @@ -71660,6 +72132,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `artificialBuffer` +-- + +/*!50001 DROP VIEW IF EXISTS `artificialBuffer`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `artificialBuffer` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,`s`.`isPicked` AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`w`.`workerCode` AS `workerCode`,`ip`.`code` AS `Nicho`,`ip`.`reserve` AS `Reserva`,`st`.`name` AS `Estado`,`st`.`order` AS `orden` from (((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemType` `it` on((`it`.`id` = `i`.`typeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`itemPlacement` `ip` on(((`ip`.`itemFk` = `s`.`itemFk`) and (`ip`.`warehouseFk` = `t`.`warehouseFk`)))) join `vn`.`worker` `w` on((`w`.`id` = `tst`.`worker`))) where ((`t`.`shipped` >= `util`.`yesterday`()) and (ascii(`ip`.`code`) = ascii('5')) and (`t`.`warehouseFk` = 44) and (`st`.`order` between 3 and 6)) order by `st`.`order` desc,`tst`.`updated` */; +/*!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 `awb` -- @@ -71691,7 +72181,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `bank` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `cash`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive` from `vn2008`.`Bancos` `b` */; +/*!50001 VIEW `bank` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `cash`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive`,`b`.`currencyFk` AS `currencyFk` from `vn2008`.`Bancos` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -71745,7 +72235,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `buy` AS select `c`.`Id_Compra` AS `id`,`c`.`Id_Entrada` AS `entryFk`,`c`.`Id_Article` AS `itemFk`,`c`.`Cantidad` AS `amount`,`c`.`Costefijo` AS `buyingValue`,`c`.`Cantidad` AS `quantity`,`c`.`Id_Cubo` AS `packageFk`,`c`.`Etiquetas` AS `stickers`,`c`.`Portefijo` AS `freightValue`,`c`.`Embalajefijo` AS `packageValue`,`c`.`Comisionfija` AS `comissionValue`,`c`.`Packing` AS `packing`,`c`.`grouping` AS `grouping`,`c`.`caja` AS `groupingMode`,`c`.`Nicho` AS `location`,`c`.`Tarifa1` AS `price1`,`c`.`Tarifa2` AS `price2`,`c`.`Tarifa3` AS `price3`,`c`.`PVP` AS `minPrice`,`c`.`Productor` AS `producer`,`c`.`Vida` AS `printedStickers`,`c`.`punteo` AS `isChecked` from `vn2008`.`Compres` `c` */; +/*!50001 VIEW `buy` AS select `c`.`Id_Compra` AS `id`,`c`.`Id_Entrada` AS `entryFk`,`c`.`Id_Article` AS `itemFk`,`c`.`Cantidad` AS `amount`,`c`.`Costefijo` AS `buyingValue`,`c`.`Cantidad` AS `quantity`,`c`.`Id_Cubo` AS `packageFk`,`c`.`Etiquetas` AS `stickers`,`c`.`Portefijo` AS `freightValue`,`c`.`Embalajefijo` AS `packageValue`,`c`.`Comisionfija` AS `comissionValue`,`c`.`Packing` AS `packing`,`c`.`grouping` AS `grouping`,`c`.`caja` AS `groupingMode`,`c`.`Nicho` AS `location`,`c`.`Tarifa1` AS `price1`,`c`.`Tarifa2` AS `price2`,`c`.`Tarifa3` AS `price3`,`c`.`PVP` AS `minPrice`,`c`.`Productor` AS `producer`,`c`.`Vida` AS `printedStickers`,`c`.`punteo` AS `isChecked`,`c`.`Novincular` AS `isIgnored` from `vn2008`.`Compres` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -72195,7 +72685,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `entry` AS select `e`.`Id_Entrada` AS `id`,`e`.`Id_Proveedor` AS `supplierFk`,`e`.`Referencia` AS `ref`,`e`.`Inventario` AS `isInventory`,`e`.`Confirmada` AS `isConfirmed`,`e`.`Pedida` AS `isOrdered`,`e`.`Redada` AS `isRaid`,`e`.`comision` AS `commission`,`e`.`odbc_date` AS `created`,`e`.`Notas_Eva` AS `evaNotes`,`e`.`travel_id` AS `travelFk`,`e`.`Id_Moneda` AS `currencyFk`,`e`.`empresa_id` AS `companyFk`,`e`.`gestdoc_id` AS `gestDocFk`,`e`.`recibida_id` AS `invoiceReceivedFk` from `vn2008`.`Entradas` `e` */; +/*!50001 VIEW `entry` AS select `e`.`Id_Entrada` AS `id`,`e`.`Id_Proveedor` AS `supplierFk`,`e`.`Referencia` AS `ref`,`e`.`Inventario` AS `isInventory`,`e`.`Confirmada` AS `isConfirmed`,`e`.`Pedida` AS `isOrdered`,`e`.`Redada` AS `isRaid`,`e`.`comision` AS `commission`,`e`.`odbc_date` AS `created`,`e`.`Notas_Eva` AS `evaNotes`,`e`.`travel_id` AS `travelFk`,`e`.`Id_Moneda` AS `currencyFk`,`e`.`empresa_id` AS `companyFk`,`e`.`gestdoc_id` AS `gestDocFk`,`e`.`recibida_id` AS `invoiceInFk` from `vn2008`.`Entradas` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -72321,7 +72811,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(`rr`.`value` as decimal(10,4)) AS `rateECB` from (`vn`.`exchangeReportSourcePrevious` `e` join `vn`.`referenceRate` `rr` on((`rr`.`dated` = `e`.`dated`))) group by `e`.`dated` order by `e`.`dated` */; +/*!50001 VIEW `exchangeReportSource` AS select `e`.`dated` AS `dated`,cast(sum(`e`.`amountIn`) as decimal(10,2)) AS `amountIn`,cast(sum(`e`.`rateIn`) as decimal(10,4)) AS `rateIn`,cast(sum(`e`.`amountOut`) as decimal(10,2)) AS `amountOut`,cast(sum(`e`.`rateOut`) as decimal(10,4)) AS `rateOut`,cast(sum(`e`.`amountEntry`) as decimal(10,2)) AS `amountEntry`,cast(sum(`e`.`rateEntry`) as decimal(10,4)) AS `rateEntry`,cast(ifnull(`rr`.`value`,`rrc`.`simulatedValue`) as decimal(10,4)) AS `rateECB` from ((`vn`.`exchangeReportSourcePrevious` `e` left join `vn`.`referenceRate` `rr` on((`rr`.`dated` = `e`.`dated`))) join `vn`.`referenceRateConfig` `rrc` on(1)) group by `e`.`dated` order by `e`.`dated` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -72699,7 +73189,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`iva_group_id` AS `taxClassFk` from `vn2008`.`Articles` `t` */; +/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice` from `vn2008`.`Articles` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -72830,6 +73320,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `itemTaxCountrySpain` +-- + +/*!50001 DROP VIEW IF EXISTS `itemTaxCountrySpain`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `itemTaxCountrySpain` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Tallos` AS `stems`,`t`.`description` AS `description`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`expenceFk` AS `expenceFk`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`itc`.`taxClassFk` AS `taxClassFk` from (`vn2008`.`Articles` `t` join `vn`.`itemTaxCountry` `itc` on((`t`.`Id_Article` = `itc`.`itemFk`))) where (`itc`.`countryFk` = 1) */; +/*!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 `itemType` -- @@ -73226,6 +73734,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `preparationException` +-- + +/*!50001 DROP VIEW IF EXISTS `preparationException`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `preparationException` AS select `p`.`exception_day` AS `exceptionDay`,`p`.`warehouse_id` AS `warehouseFk`,`p`.`percentage` AS `percentage` from `vn2008`.`preparation_exception` `p` */; +/*!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 `preparationPercentage` +-- + +/*!50001 DROP VIEW IF EXISTS `preparationPercentage`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `preparationPercentage` AS select `p`.`week_day` AS `weekDay`,`p`.`warehouse_id` AS `warehouseFk`,`p`.`percentage` AS `percentage` from `vn2008`.`preparation_percentage` `p` */; +/*!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 `priceBuilderDistinctTags` -- @@ -73280,6 +73824,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `printer` +-- + +/*!50001 DROP VIEW IF EXISTS `printer`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `printer` AS select `i`.`Id_Impresora` AS `id`,`i`.`Ruta` AS `path`,`i`.`Impresora` AS `name`,`i`.`referencia` AS `reference`,`i`.`isLabeler` AS `isLabeler`,`i`.`description` AS `description` from `vn2008`.`Impresoras` `i` */; +/*!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 `printingQueue` -- @@ -73455,7 +74017,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `routesControl` AS select `t`.`Id_Ruta` AS `routeFk`,count(`e`.`expeditions_id`) AS `expeditions`,count(`sl`.`scan_line_id`) AS `scanned`,count(distinct `sl`.`scan_id`) AS `pallets`,max(`sl`.`odbc_date`) AS `lastScanned` from ((`vn2008`.`Tickets` `t` join `vn2008`.`expeditions` `e` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) left join `vn2008`.`scan_line` `sl` on((`e`.`expeditions_id` = `sl`.`code`))) where (`t`.`Fecha` >= (curdate() + interval -(1) day)) group by `t`.`Id_Ruta` */; +/*!50001 VIEW `routesControl` AS select `t`.`Id_Ruta` AS `routeFk`,count(`e`.`expeditions_id`) AS `expeditions`,count(`sl`.`scan_line_id`) AS `scanned`,count(distinct `sl`.`scan_id`) AS `pallets`,max(`sl`.`odbc_date`) AS `lastScanned` from ((`vn2008`.`Tickets` `t` join `vn2008`.`expeditions` `e` on((`t`.`Id_Ticket` = `e`.`ticket_id`))) left join `vn2008`.`scan_line` `sl` on((`e`.`expeditions_id` = `sl`.`code`))) where (`t`.`Fecha` >= curdate()) group by `t`.`Id_Ruta` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -73514,6 +74076,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `specialPrice` +-- + +/*!50001 DROP VIEW IF EXISTS `specialPrice`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `specialPrice` AS select `p`.`Id_PrecioEspecial` AS `id`,`p`.`Id_Cliente` AS `clientFk`,`p`.`Id_Article` AS `itemFk`,`p`.`PrecioEspecial` AS `value` from `vn2008`.`PreciosEspeciales` `p` */; +/*!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 `state` -- @@ -73676,6 +74256,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `ticketNotInvoiced` +-- + +/*!50001 DROP VIEW IF EXISTS `ticketNotInvoiced`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketNotInvoiced` AS select `t`.`companyFk` AS `companyFk`,`cm`.`code` AS `companyCode`,`t`.`clientFk` AS `clientFk`,`c`.`name` AS `clientName`,`t`.`shipped` AS `shipped`,cast(sum((((`s`.`quantity` * `s`.`price`) * (100 - `s`.`discount`)) / 100)) as decimal(10,2)) AS `value` from (((`vn`.`ticket` `t` join `vn`.`sale` `s` on((`s`.`ticketFk` = `t`.`id`))) join `vn`.`client` `c` on((`c`.`id` = `t`.`clientFk`))) join `vn`.`company` `cm` on((`cm`.`id` = `t`.`companyFk`))) where (isnull(`t`.`refFk`) and (`t`.`shipped` > '2017-01-01')) group by `t`.`id` */; +/*!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 `ticketObservation` -- @@ -73725,7 +74323,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; +/*!50001 VIEW `ticketStateToday` AS select `ts`.`ticket` AS `ticket`,`ts`.`state` AS `state`,`ts`.`productionOrder` AS `productionOrder`,`ts`.`alertLevel` AS `alertLevel`,`ts`.`worker` AS `worker`,`ts`.`code` AS `code`,`ts`.`updated` AS `updated` from (`vn`.`ticketState` `ts` join `vn`.`ticket` `t` on((`t`.`id` = `ts`.`ticket`))) where (`t`.`shipped` between curdate() and `MIDNIGHT`(curdate())) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -73748,6 +74346,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `ticketUpdateAction` +-- + +/*!50001 DROP VIEW IF EXISTS `ticketUpdateAction`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketUpdateAction` AS select `b`.`buo_id` AS `id`,`b`.`description` AS `description` from `vn2008`.`bionic_updating_options` `b` */; +/*!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 `ticketWeekly` +-- + +/*!50001 DROP VIEW IF EXISTS `ticketWeekly`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `ticketWeekly` AS select `t`.`Id_Ticket` AS `ticketFk`,`t`.`weekDay` AS `weekDay` from `vn2008`.`Tickets_turno` `t` */; +/*!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 `till` -- @@ -73797,7 +74431,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `travel` AS select `t`.`id` AS `id`,`t`.`shipment` AS `shipped`,`t`.`shipment_hour` AS `shipmentHour`,`t`.`landing` AS `landed`,`t`.`landing_hour` AS `landingHour`,`t`.`warehouse_id` AS `warehouseInFk`,`t`.`warehouse_id_out` AS `warehouseOutFk`,`t`.`agency_id` AS `agencyFk`,`t`.`ref` AS `ref`,`t`.`delivered` AS `isDelivered`,`t`.`received` AS `isReceived`,`t`.`m3` AS `m3` from `vn2008`.`travel` `t` */; +/*!50001 VIEW `travel` AS select `t`.`id` AS `id`,`t`.`shipment` AS `shipped`,`t`.`shipment_hour` AS `shipmentHour`,`t`.`landing` AS `landed`,`t`.`landing_hour` AS `landingHour`,`t`.`warehouse_id` AS `warehouseInFk`,`t`.`warehouse_id_out` AS `warehouseOutFk`,`t`.`agency_id` AS `agencyFk`,`t`.`ref` AS `ref`,`t`.`delivered` AS `isDelivered`,`t`.`received` AS `isReceived`,`t`.`m3` AS `m3`,`t`.`kg` AS `kg` from `vn2008`.`travel` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -73941,7 +74575,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`inventario` AS `isInventory`,`t`.`is_comparative` AS `isComparative`,`t`.`comisionantes` AS `hasComission`,`t`.`isManaged` AS `isManaged` from `vn2008`.`warehouse` `t` */; +/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`inventario` AS `isInventory`,`t`.`is_comparative` AS `isComparative`,`t`.`comisionantes` AS `hasComission`,`t`.`reserve` AS `hasAvailable`,`t`.`isManaged` AS `isManaged` from `vn2008`.`warehouse` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -74030,6 +74664,24 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `lastIndicators` +-- + +/*!50001 DROP VIEW IF EXISTS `lastIndicators`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `lastIndicators` AS select `i`.`updated` AS `updated`,`i`.`lastYearSales` AS `lastYearSales`,(`i`.`lastYearSales` - `yi`.`lastYearSales`) AS `incLastYearSales`,`i`.`totalGreuge` AS `totalGreuge`,(`i`.`totalGreuge` - `yi`.`totalGreuge`) AS `incTotalGreuge`,`i`.`latePaymentRate` AS `latePaymentRate`,(`i`.`latePaymentRate` - `yi`.`latePaymentRate`) AS `incLatePaymentRate`,`i`.`countEmployee` AS `countEmployee`,(`i`.`countEmployee` - `yi`.`countEmployee`) AS `incCountEmployee`,`i`.`averageMana` AS `averageMana`,(`i`.`averageMana` - `yi`.`averageMana`) AS `incAverageMana`,`i`.`bankingPool` AS `bankingPool`,(`i`.`bankingPool` - `yi`.`bankingPool`) AS `incbankingPool`,`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,(`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients`) AS `incLastMonthActiveClients`,`i`.`lastMonthLostClients` AS `lastMonthLostClients`,(`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients`) AS `incLastMonthLostClients`,`i`.`lastMonthNewClients` AS `lastMonthNewClients`,(`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients`) AS `incLastMonthNewClients`,`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,(`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate`) AS `incLastMonthWebBuyingRate` from (`indicators` `i` join `indicators` `yi` on((`yi`.`updated` = (select (max(`indicators`.`updated`) + interval -(1) day) from `indicators`)))) where (`i`.`updated` = (select max(`indicators`.`updated`) from `indicators`)) */; +/*!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 `v_ventas` -- @@ -74048,6 +74700,24 @@ USE `bs`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `workerMana` +-- + +/*!50001 DROP VIEW IF EXISTS `workerMana`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `workerMana` AS select `m`.`Id_Trabajador` AS `workerFk`,`m`.`used` AS `amount` from `mana_spellers` `m` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Current Database: `bi` -- @@ -75261,4 +75931,4 @@ USE `stock`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-16 12:39:15 +-- Dump completed on 2018-05-10 8:30:48 diff --git a/services/db/install/dump/03-dumpedFixtures.sql b/services/db/install/dump/03-dumpedFixtures.sql index 47f64d495..ac23201e0 100644 --- a/services/db/install/dump/03-dumpedFixtures.sql +++ b/services/db/install/dump/03-dumpedFixtures.sql @@ -55,7 +55,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:50 +-- Dump completed on 2018-05-10 11:06:50 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -80,7 +80,7 @@ USE `salix`; LOCK TABLES `ACL` WRITE; /*!40000 ALTER TABLE `ACL` DISABLE KEYS */; -INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(52,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(57,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(58,'CreditClassification','*','WRITE','ALLOW','ROLE','creditInsurance'),(59,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(60,'CreditInsurance','*','WRITE','ALLOW','ROLE','creditInsurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','*','ALLOW','ROLE','employee'),(66,'TicketTracking','*','*','ALLOW','ROLE','employee'),(67,'TicketState','*','*','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','READ','ALLOW','ROLE','employee'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (1,'Account','*','*','ALLOW','ROLE','employee'),(3,'Address','*','*','ALLOW','ROLE','employee'),(5,'AgencyService','*','READ','ALLOW','ROLE','employee'),(7,'Client','*','*','ALLOW','ROLE','employee'),(9,'ClientObservation','*','*','ALLOW','ROLE','employee'),(11,'ContactChannel','*','READ','ALLOW','ROLE','employee'),(13,'Employee','*','READ','ALLOW','ROLE','employee'),(14,'PayMethod','*','READ','ALLOW','ROLE','employee'),(16,'FakeProduction','*','READ','ALLOW','ROLE','employee'),(17,'Warehouse','* ','READ','ALLOW','ROLE','employee'),(18,'State','*','READ','ALLOW','ROLE','employee'),(20,'TicketState','*','*','ALLOW','ROLE','employee'),(24,'Delivery','*','READ','ALLOW','ROLE','employee'),(25,'Zone','*','READ','ALLOW','ROLE','employee'),(26,'ClientCredit','*','*','ALLOW','ROLE','employee'),(27,'ClientCreditLimit','*','READ','ALLOW','ROLE','employee'),(28,'ClientObservation','*','READ','ALLOW','ROLE','employee'),(30,'GreugeType','*','READ','ALLOW','ROLE','employee'),(31,'Mandate','*','READ','ALLOW','ROLE','employee'),(32,'MandateType','*','READ','ALLOW','ROLE','employee'),(33,'Company','*','READ','ALLOW','ROLE','employee'),(34,'Greuge','*','READ','ALLOW','ROLE','employee'),(35,'AddressObservation','*','*','ALLOW','ROLE','employee'),(36,'ObservationType','*','*','ALLOW','ROLE','employee'),(37,'Greuge','*','WRITE','ALLOW','ROLE','employee'),(38,'AgencyMode','*','READ','ALLOW','ROLE','employee'),(39,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(40,'ItemBotanical','*','WRITE','ALLOW','ROLE','buyer'),(41,'ItemBotanical','*','READ','ALLOW','ROLE','employee'),(42,'ItemPlacement','*','WRITE','ALLOW','ROLE','buyer'),(43,'ItemPlacement','*','WRITE','ALLOW','ROLE','replenisher'),(44,'ItemPlacement','*','READ','ALLOW','ROLE','employee'),(45,'ItemBarcode','*','READ','ALLOW','ROLE','employee'),(46,'ItemBarcode','*','WRITE','ALLOW','ROLE','buyer'),(47,'ItemBarcode','*','WRITE','ALLOW','ROLE','replenisher'),(48,'ItemNiche','*','READ','ALLOW','ROLE','employee'),(49,'ItemNiche','*','WRITE','ALLOW','ROLE','buyer'),(50,'ItemNiche','*','WRITE','ALLOW','ROLE','replenisher'),(51,'ItemTag','*','READ','ALLOW','ROLE','employee'),(52,'ItemTag','*','WRITE','ALLOW','ROLE','buyer'),(53,'Item','*','READ','ALLOW','ROLE','employee'),(54,'Item','*','WRITE','ALLOW','ROLE','buyer'),(55,'Recovery','*','READ','ALLOW','ROLE','employee'),(56,'Recovery','*','WRITE','ALLOW','ROLE','administrative'),(57,'CreditClassification','*','READ','ALLOW','ROLE','employee'),(58,'CreditClassification','*','WRITE','ALLOW','ROLE','creditInsurance'),(59,'CreditInsurance','*','READ','ALLOW','ROLE','employee'),(60,'CreditInsurance','*','WRITE','ALLOW','ROLE','creditInsurance'),(61,'InvoiceOut','*','READ','ALLOW','ROLE','employee'),(62,'Ticket','*','*','ALLOW','ROLE','employee'),(63,'TicketObservation','*','*','ALLOW','ROLE','employee'),(64,'Route','*','READ','ALLOW','ROLE','employee'),(65,'Sale','*','*','ALLOW','ROLE','employee'),(66,'TicketTracking','*','*','ALLOW','ROLE','employee'),(67,'TicketState','*','*','ALLOW','ROLE','employee'),(68,'TicketPackaging','*','*','ALLOW','ROLE','employee'),(69,'Packaging','*','READ','ALLOW','ROLE','employee'),(70,'Packaging','*','WRITE','ALLOW','ROLE','logistic'),(71,'SaleChecked','*','READ','ALLOW','ROLE','employee'),(72,'SaleComponent','*','READ','ALLOW','ROLE','employee'),(73,'Expedition','*','READ','ALLOW','ROLE','employee'),(74,'Expedition','*','READ','ALLOW','ROLE','employee'),(75,'Expedition','*','WRITE','ALLOW','ROLE','production'),(76,'AnnualAverageInvoiced','*','READ','ALLOW','ROLE','employee'),(77,'WorkerMana','*','READ','ALLOW','ROLE','employee'); /*!40000 ALTER TABLE `ACL` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -93,7 +93,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:50 +-- Dump completed on 2018-05-10 11:06:50 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -171,7 +171,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:50 +-- Dump completed on 2018-05-10 11:06:50 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -206,7 +206,7 @@ UNLOCK TABLES; LOCK TABLES `Gastos` WRITE; /*!40000 ALTER TABLE `Gastos` DISABLE KEYS */; -INSERT INTO `Gastos` VALUES ('2000000000',1,'Inmovilizado pendiente',1,0,0),('2000000000',3,'Compra de bienes de inmovilizado',1,0,0),('2600000000',1,'Fianzas',0,0,0),('4600000000',1,'Anticipos de remuneraciones',1,0,0),('4600000001',1,'Anticpos de remuneración',1,0,0),('4751000000',0,'Retenciones',0,1,0),('4751000000',1,'Retenciones',0,1,0),('4751000000',6,'Retencion',0,0,0),('5200000006',1,'Deudas a c/p CRA',1,0,0),('5200000008',0,'Prestamo CP Transolver IVECO 269',1,0,0),('5200000008',1,'Prestamo Transolver 201600269',1,0,0),('5200000009',0,'Prestamo CP Transolver IVECO 270',1,0,0),('5200000009',1,'Prestamo Transolver 201600270',1,0,0),('5200000010',0,'Prestamo CP Transolver IVECO 271',1,0,0),('5200000010',1,'Prestamo Transolver 201600271',1,0,0),('5200000011',1,'Prestamo Transolver 339',0,0,0),('5200000012',1,'Prestamo Transolver 340',1,0,0),('5200000013',1,'Prestamo Transolver 341',1,0,0),('5200000014',1,'Prestamo a c/p BBVA 600.000€',1,0,0),('5200000022',1,'Linea comercio exterior',1,0,0),('5240000001',1,'Leasing BBVA',1,0,0),('5240002032',1,'Leasing Iveco',1,0,0),('5240002066',1,'Leasing c/p Man',1,0,0),('5240002104',1,'Leasing c/p La caixa 3 vehículos',1,0,0),('5325000003',6,'Prestamo a partes vinculadas',0,0,0),('5660000001',1,'Suplidos',0,0,0),('5660000001',20,'Suplidos',1,0,0),('5660000002',0,'Suplidos',0,0,0),('5660000002',1,'Suplidos Transitarios nacionales',1,0,0),('5660000003',1,'Deposito c/p Ebury',1,0,0),('5660000003',4,'Deposito Ebury',0,0,0),('5660000004',4,'Deposito Global Reach',0,0,0),('6001000000',1,'Compras a terceros nacional',1,0,0),('6001000000',18,'Compras a terceros nacional',1,0,0),('6001000000',19,'Compras a terceros nacional',1,0,0),('6001000001',1,'Adquisiones en Europa',0,0,0),('6001000001',3,'Adquisición en Europa',1,0,0),('6002000000',1,'Transportes de compras',1,0,0),('6002000001',1,'Tranportes de compra Europa',1,0,0),('6002000001',4,'Transportes de compras Europa',1,0,0),('6002000567',0,'Transporte de compras VNH',1,0,0),('6003000000',1,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000000',5,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000000',6,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000567',0,'Compra de mercancia extracomunitaria VNH',1,0,0),('6004000000',1,'Transporte compras Sudamérica',1,0,0),('6004000000',4,'Transporte compras Sudamérica',1,0,0),('6004000000',6,'Transporte compras Sudamérica',1,0,0),('6010000000',1,'Materias primas',1,0,0),('6020000000',1,'Otros aprovisionamientos',1,0,0),('6020000001',1,'Embalajes',1,0,0),('6020000002',1,'Otros aprov. Taller artíficial',1,0,0),('6090000000',6,'Rappels por compras',1,0,0),('6100000000',0,'Variacion existencias',1,0,0),('6210000000',1,'Arrendamientos',1,0,0),('6210000001',1,'Arrendamiento vehículo',1,0,0),('6210000001',4,'Gastos de arrendamiento vehículos',1,0,0),('6210000002',1,'Arrendamiento nave',1,0,0),('6210000003',1,'Arrendamiento espacio virtual-informatic',1,0,0),('6210000004',1,'Arrendamiento elementos para el proceso de informa',1,0,0),('6210000005',1,'Arrendamiento CC y banddejas',1,0,0),('6210000567',0,'Alquiler VNH',1,0,0),('6220000000',1,'Reparaciones y conservacion',1,0,0),('6220000001',1,'Reparación-Informatica',1,0,0),('6220000001',4,'Reparacion y mantenimiento informatica',1,0,0),('6220000003',1,'Reparación-Vehiculos',1,0,0),('6220000004',1,'Reparación-Instalaciones',1,0,0),('6220000005',1,'Reparación y mantenimineto CCs',1,0,0),('6220000006',1,'Repracion y conser maquinaria',1,0,0),('6230000000',1,'Servicios de profesionales independientes',1,0,0),('6230000000',4,'Servicio de profesionales',0,0,0),('6230000000',6,'Servicios de profesionales',1,0,0),('6230000001',1,'Servicios por gestión de ventas',1,0,0),('6230000001',4,'Servicios por gestión de ventas',1,0,0),('6240000000',1,'Transportes',1,0,0),('6240000000',4,'Transportes de ventas',1,0,0),('6240000567',0,'Transporte ventas VNH',1,0,0),('6250000000',1,'Primas de seguros',1,0,0),('6250000000',4,'Prima de Seguros',1,0,0),('6250000001',1,'Primas de seguros-Personales',1,0,0),('6250000002',1,'Primas de seguros-Colectivos',1,0,0),('6250000003',1,'Primas de seguros-Vehiculos',1,0,0),('6250000004',1,'Primas de seguros-Inmuebles',1,0,0),('6250000567',0,'Seguros VNH',1,0,0),('6260000000',1,'Gastos bancarios',1,0,0),('6260000000',4,'Gastos bancarios',0,0,0),('6260000001',1,'Gastos bancarios datafono',1,0,0),('6260000002',1,'Gastos bancarios transferencia nacional',1,0,0),('6260000003',1,'Gastos bancarios transferencia Europa',1,0,0),('6260000004',1,'Gastos bancarios transferencia divisas',1,0,0),('6260000567',0,'Gastos bancarios VNH',1,0,0),('6270000000',1,'Publicidad y RRPP',1,0,0),('6270000000',3,'Publicidad, propaganda y RR PP',1,0,0),('6270000000',6,'Publicidad',1,0,0),('6270000000',14,'Publicidad, propaganda RRPP',1,0,0),('6270000001',1,'Patrocinio',0,0,0),('6280000000',1,'Suministros',1,0,0),('6280000001',1,'Telefonos',1,0,0),('6280000002',1,'Gasoil',1,0,0),('6280000003',1,'Suministros-Electricidad',1,0,0),('6280000004',1,'Internet',1,0,0),('6280000567',0,'Suministros VNH',1,0,0),('6280001567',0,'Suministros telefono VNH',1,0,0),('6280003567',0,'Suministro luz VNH',1,0,0),('6290000000',1,'Otros servicios',1,0,0),('6290000001',1,'Material de oficina',1,0,0),('6290000002',1,'Gastos en formacion',1,0,0),('6290000003',1,'Asesoria juridica',1,0,0),('6290000004',4,'Otros servicios UE',1,0,0),('6290000005',1,'Gastos varios-Correos',1,0,0),('6290000006',6,'Otros servicios extranjero',1,0,0),('6290000007',1,'Gastos pequeño material',1,0,0),('6290000007',3,'Compras pequeño material',1,0,0),('6290000007',6,'Pequeño material',1,0,0),('6290000008',1,'Gastos varios-uniformes personal',1,0,0),('6290000008',3,'Compra uniformes',1,0,0),('6290000009',1,'Gastos-CC Container',1,0,0),('6290000010',1,'Gastos formación clientes',1,0,0),('6290000012',1,'Gastos gestión contra-reembolsos',1,0,0),('6290000013',1,'Arrendamiento Vilassar',1,0,0),('6290000014',1,'Gasto laboral espresas ETT',1,0,0),('6290000015',1,'Gasto compra terminales moviles y similares',1,0,0),('6290000015',3,'Gasto compra terminales moviles y similares',1,0,0),('6290000015',6,'Gasto compra terminales moviles y similares',1,0,0),('6290000016',1,'Gasto gestión cobro ventas',1,0,0),('6290000553',1,'Gastos viaje administrador',1,0,0),('6290000553',4,'Gastos viaje administrador-gerente',1,0,0),('6290000553',6,'Gastos viaje administrador',1,0,0),('6290001000',1,'Gastos de viaje',1,0,0),('6290001000',4,'Gastos viajes otros departamentos',1,0,0),('6290001000',6,'Gastos viaje personal otros departamentos',1,0,0),('6290001001',1,'Gastos R.R.P.P. Gerente',1,0,0),('6290001002',1,'Gastos R.R.P.P. Comerciales',1,0,0),('6290001567',0,'Gastos material oficina',1,0,0),('6300000000',1,'Impuesto de sociedades',1,0,0),('6310000000',1,'Otros tributos',1,0,0),('6380000000',1,'Ajustes positivos s/b Bº',1,0,0),('6400000000',0,'Sueldos y salarios',1,0,0),('6400000000',1,'Salarios',0,0,0),('6400000001',0,'Productividad',1,0,0),('6400000567',0,'Salarios VNH',1,0,0),('6410000001',1,'Indemnizaciones',1,0,0),('6420000000',0,'Seguridad Social a cargo de la empresa',1,0,0),('6420000000',1,'Seguridad Social',0,0,0),('6490000000',1,'Otros gastos sociales',1,0,0),('6500000000',1,'Impagados definitivos',1,0,0),('6620000000',0,'Intereses Bancarios',1,0,0),('6620000001',1,'Intereses Leasing BBVA Dic 2017',1,0,0),('6620000006',1,'Intereses deuda prestamo CRA',1,0,0),('6620000007',1,'Intereses La Caixa linea comercio exterior',1,0,0),('6620000007',16,'Intereses La Caixa Linea Comercio Exterior',0,0,0),('6620000008',1,'Intereses Prestamos Transolver 2016',1,0,0),('6620000011',1,'Intereses BBVA linea comercio exterior',1,0,0),('6620000014',1,'Intereses Prestamo BBVA',1,0,0),('6620000015',1,'Interés Póliza Deutsche Bank',0,0,0),('6620000023',1,'Intereses Bnakinter Póliza Comercio Exterior',0,0,0),('6620002032',1,'Intereses Leaing Iveco',1,0,0),('6620002066',1,'Leasing Intereses Man',1,0,0),('6620002104',1,'Intereses Leasing La caixa 3 vehículos',1,0,0),('6681000000',1,'Diferencia negativa tipo de cambio',1,0,0),('6681000000',4,'Diferencia negativa tipo de cambio',0,0,0),('6681000000',6,'Diferencia negativa tipo de cambio',1,0,0),('6681000567',0,'Diferencias de cambio VNH',1,0,0),('6690000000',1,'Otros gastos financieros',1,0,0),('6690000000',6,'Gastos financieros',1,0,0),('6720000000',16,'Perdidas procedentes de inversiones',0,0,0),('6780000000',1,'Gastos extraordinarios',1,0,0),('6780000001',1,'Gastos no deducibles',1,0,0),('6780000001',16,'Gasto no deducible',0,0,0),('6800000000',1,'Amortización inmovilizado intangible',1,0,0),('6800000001',0,'Amortizacion inmovilizado material',1,0,0),('6810000000',0,'Amortizaciones inmovilizado',1,0,0),('6810000000',1,'Amortizacion inmovilizado material',1,0,0),('7000000000',0,'Ventas',1,0,0),('7000000001',1,'Venta entre empresas',1,0,0),('7000010000',0,'Terceros Flor',1,0,0),('7000020000',0,'Terceros Planta',1,0,0),('7000030000',0,'Terceros Complementos',1,0,0),('7000040000',0,'Terceros Artificial',1,0,0),('7000050000',0,'Terceros Verdes',1,0,0),('7000060000',0,'Terceros Otros',1,0,0),('7000070000',0,'Terceros Confección',1,0,0),('7000080000',1,'Terceros Logística',1,0,0),('7001000000',1,'Mercaderia',1,0,1),('7001010000',0,'Grupo Flor',1,0,0),('7001020000',0,'Grupo Planta',1,0,0),('7001030000',0,'Grupo Complementos',1,0,0),('7001040000',0,'Grupo Artificial',1,0,0),('7001050000',0,'Grupo Verdes',1,0,0),('7001060000',0,'Grupo Otros',1,0,0),('7001070000',0,'Grupo Confección',1,0,0),('7001080000',1,'Grupo Logística',1,0,0),('7002010000',0,'Asociados Flor',1,0,0),('7002020000',0,'Asociados Planta',1,0,0),('7002030000',0,'Asociados Complementos',1,0,0),('7002040000',0,'Asociados Artificial',1,0,0),('7002050000',0,'Asociados Verdes',1,0,0),('7002060000',0,'Asociados Otros',1,0,0),('7002070000',0,'Asociados Confección',1,0,0),('7002080000',1,'Asociados Logística',1,0,0),('7040000000',1,'Embalajes',1,0,1),('7050000000',1,'Prestacion de servicios',1,0,1),('7400000000',1,'Subvenciones, donaciones a la explotacion',1,0,0),('7550000000',0,'Ingresos por serivicios al personal',1,0,0),('7680000000',0,'Diferencias positivas de cambio',1,0,0),('7680000000',1,'Diferenica positiva tipo de cambio',1,0,0),('7690000000',1,'Otros ingresos financieros',1,0,0),('7780000000',1,'Ingresos excepcionales',1,0,0),('7780000000',16,'Ingreso extraordinario',0,0,0),('7780000001',1,'Indemnizaciones transporte',1,0,0),('7780000001',4,'Indemnizaciones agencias transporte',1,0,0),('7780000001',5,'Indemnizaciones agencias transporte',1,0,0),('7780000001',6,'Indemnizaciones transporte',1,0,0),('7940000000',16,'Reversión impagos',0,0,0); +INSERT INTO `Gastos` VALUES ('2000000000',1,'Inmovilizado pendiente',1,0,0),('2000000000',3,'Compra de bienes de inmovilizado',1,0,0),('2600000000',1,'Fianzas',0,0,0),('4600000000',1,'Anticipos de remuneraciones',1,0,0),('4600000001',1,'Anticpos de remuneración',1,0,0),('4751000000',0,'Retenciones',0,1,0),('4751000000',1,'Retenciones',0,1,0),('4751000000',6,'Retencion',0,0,0),('5200000006',1,'Deudas a c/p CRA',1,0,0),('5200000008',0,'Prestamo CP Transolver IVECO 269',1,0,0),('5200000008',1,'Prestamo Transolver 201600269',1,0,0),('5200000009',0,'Prestamo CP Transolver IVECO 270',1,0,0),('5200000009',1,'Prestamo Transolver 201600270',1,0,0),('5200000010',0,'Prestamo CP Transolver IVECO 271',1,0,0),('5200000010',1,'Prestamo Transolver 201600271',1,0,0),('5200000011',1,'Prestamo Transolver 339',0,0,0),('5200000012',1,'Prestamo Transolver 340',1,0,0),('5200000013',1,'Prestamo Transolver 341',1,0,0),('5200000014',1,'Prestamo a c/p BBVA 600.000€',1,0,0),('5200000022',1,'Linea comercio exterior',1,0,0),('5240000001',1,'Leasing BBVA',1,0,0),('5240002032',1,'Leasing Iveco',1,0,0),('5240002066',1,'Leasing c/p Man',1,0,0),('5240002104',1,'Leasing c/p La caixa 3 vehículos',1,0,0),('5325000003',6,'Prestamo a partes vinculadas',0,0,0),('5660000001',1,'Suplidos',0,0,0),('5660000001',20,'Suplidos',1,0,0),('5660000002',0,'Suplidos',0,0,0),('5660000002',1,'Suplidos Transitarios nacionales',1,0,0),('5660000003',1,'Deposito c/p Ebury',1,0,0),('5660000003',4,'Deposito Ebury',0,0,0),('5660000004',4,'Deposito Global Reach',0,0,0),('6001000000',1,'Compras a terceros nacional',1,0,0),('6001000000',18,'Compras a terceros nacional',1,0,0),('6001000000',19,'Compras a terceros nacional',1,0,0),('6001000001',1,'Adquisiones en Europa',0,0,0),('6001000001',3,'Adquisición en Europa',1,0,0),('6002000000',1,'Transportes de compras',1,0,0),('6002000001',1,'Tranportes de compra Europa',1,0,0),('6002000001',4,'Transportes de compras Europa',1,0,0),('6002000567',0,'Transporte de compras VNH',1,0,0),('6003000000',1,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000000',5,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000000',6,'Adquisición mercancia Extracomunitaria',1,0,0),('6003000567',0,'Compra de mercancia extracomunitaria VNH',1,0,0),('6004000000',1,'Transporte compras Sudamérica',1,0,0),('6004000000',4,'Transporte compras Sudamérica',1,0,0),('6004000000',6,'Transporte compras Sudamérica',1,0,0),('6010000000',1,'Materias primas',1,0,0),('6020000000',1,'Otros aprovisionamientos',1,0,0),('6020000001',1,'Embalajes',1,0,0),('6020000002',1,'Otros aprov. Taller artíficial',1,0,0),('6070000000',1,'Trabajos de produccion encargados a terceros',1,0,0),('6090000000',6,'Rappels por compras',1,0,0),('6100000000',0,'Variacion existencias',1,0,0),('6210000000',1,'Arrendamientos',1,0,0),('6210000001',1,'Arrendamiento vehículo',1,0,0),('6210000001',4,'Gastos de arrendamiento vehículos',1,0,0),('6210000002',1,'Arrendamiento nave',1,0,0),('6210000003',1,'Arrendamiento espacio virtual-informatic',1,0,0),('6210000004',1,'Arrendamiento elementos para el proceso de informa',1,0,0),('6210000005',1,'Arrendamiento CC y banddejas',1,0,0),('6210000567',0,'Alquiler VNH',1,0,0),('6220000000',1,'Reparaciones y conservacion',1,0,0),('6220000001',1,'Reparación-Informatica',1,0,0),('6220000001',4,'Reparacion y mantenimiento informatica',1,0,0),('6220000003',1,'Reparación-Vehiculos',1,0,0),('6220000004',1,'Reparación-Instalaciones',1,0,0),('6220000005',1,'Reparación y mantenimineto CCs',1,0,0),('6220000006',1,'Repracion y conser maquinaria',1,0,0),('6230000000',1,'Servicios de profesionales independientes',1,0,0),('6230000000',4,'Servicio de profesionales',0,0,0),('6230000000',6,'Servicios de profesionales',1,0,0),('6230000001',1,'Servicios por gestión de ventas',1,0,0),('6230000001',4,'Servicios por gestión de ventas',1,0,0),('6240000000',1,'Transportes',1,0,0),('6240000000',4,'Transportes de ventas',1,0,0),('6240000001',1,'Transporte ventas troncal',1,0,0),('6240000567',0,'Transporte ventas VNH',1,0,0),('6250000000',1,'Primas de seguros',1,0,0),('6250000000',4,'Prima de Seguros',1,0,0),('6250000001',1,'Primas de seguros-Personales',1,0,0),('6250000002',1,'Primas de seguros-Colectivos',1,0,0),('6250000003',1,'Primas de seguros-Vehiculos',1,0,0),('6250000004',1,'Primas de seguros-Inmuebles',1,0,0),('6250000567',0,'Seguros VNH',1,0,0),('6260000000',1,'Gastos bancarios',1,0,0),('6260000000',4,'Gastos bancarios',0,0,0),('6260000001',1,'Gastos bancarios datafono',1,0,0),('6260000002',1,'Gastos bancarios transferencia nacional',1,0,0),('6260000003',1,'Gastos bancarios transferencia Europa',1,0,0),('6260000004',1,'Gastos bancarios transferencia divisas',1,0,0),('6260000567',0,'Gastos bancarios VNH',1,0,0),('6270000000',1,'Publicidad y RRPP',1,0,0),('6270000000',3,'Publicidad, propaganda y RR PP',1,0,0),('6270000000',6,'Publicidad',1,0,0),('6270000000',14,'Publicidad, propaganda RRPP',1,0,0),('6270000001',1,'Patrocinio',0,0,0),('6280000000',1,'Suministros',1,0,0),('6280000001',1,'Telefonos',1,0,0),('6280000002',1,'Gasoil',1,0,0),('6280000003',1,'Suministros-Electricidad',1,0,0),('6280000004',1,'Internet',1,0,0),('6280000567',0,'Suministros VNH',1,0,0),('6280001567',0,'Suministros telefono VNH',1,0,0),('6280003567',0,'Suministro luz VNH',1,0,0),('6290000000',1,'Otros servicios',1,0,0),('6290000001',1,'Material de oficina',1,0,0),('6290000002',1,'Gastos en formacion',1,0,0),('6290000003',1,'Asesoria juridica',1,0,0),('6290000004',4,'Otros servicios UE',1,0,0),('6290000005',1,'Gastos varios-Correos',1,0,0),('6290000006',6,'Otros servicios extranjero',1,0,0),('6290000007',1,'Gastos pequeño material',1,0,0),('6290000007',3,'Compras pequeño material',1,0,0),('6290000007',6,'Pequeño material',1,0,0),('6290000008',1,'Gastos varios-uniformes personal',1,0,0),('6290000008',3,'Compra uniformes',1,0,0),('6290000009',1,'Gastos-CC Container',1,0,0),('6290000010',1,'Gastos formación clientes',1,0,0),('6290000012',1,'Gastos gestión contra-reembolsos',1,0,0),('6290000013',1,'Arrendamiento Vilassar',1,0,0),('6290000014',1,'Gasto laboral espresas ETT',1,0,0),('6290000015',1,'Gasto compra terminales moviles y similares',1,0,0),('6290000015',3,'Gasto compra terminales moviles y similares',1,0,0),('6290000015',6,'Gasto compra terminales moviles y similares',1,0,0),('6290000016',1,'Gasto gestión cobro ventas',1,0,0),('6290000553',1,'Gastos viaje administrador',1,0,0),('6290000553',4,'Gastos viaje administrador-gerente',1,0,0),('6290000553',6,'Gastos viaje administrador',1,0,0),('6290001000',1,'Gastos de viaje',1,0,0),('6290001000',4,'Gastos viajes otros departamentos',1,0,0),('6290001000',6,'Gastos viaje personal otros departamentos',1,0,0),('6290001001',1,'Gastos R.R.P.P. Gerente',1,0,0),('6290001002',1,'Gastos R.R.P.P. Comerciales',1,0,0),('6290001567',0,'Gastos material oficina',1,0,0),('6300000000',1,'Impuesto de sociedades',1,0,0),('6310000000',1,'Otros tributos',1,0,0),('6380000000',1,'Ajustes positivos s/b Bº',1,0,0),('6400000000',0,'Sueldos y salarios',1,0,0),('6400000000',1,'Salarios',0,0,0),('6400000001',0,'Productividad',1,0,0),('6400000567',0,'Salarios VNH',1,0,0),('6410000001',1,'Indemnizaciones',1,0,0),('6420000000',0,'Seguridad Social a cargo de la empresa',1,0,0),('6420000000',1,'Seguridad Social',0,0,0),('6490000000',1,'Otros gastos sociales',1,0,0),('6500000000',1,'Impagados definitivos',1,0,0),('6620000000',0,'Intereses Bancarios',1,0,0),('6620000001',1,'Intereses Leasing BBVA Dic 2017',1,0,0),('6620000006',1,'Intereses deuda prestamo CRA',1,0,0),('6620000007',1,'Intereses La Caixa linea comercio exterior',1,0,0),('6620000007',16,'Intereses La Caixa Linea Comercio Exterior',0,0,0),('6620000008',1,'Intereses Prestamos Transolver 2016',1,0,0),('6620000011',1,'Intereses BBVA linea comercio exterior',1,0,0),('6620000014',1,'Intereses Prestamo BBVA',1,0,0),('6620000015',1,'Interés Póliza Deutsche Bank',0,0,0),('6620000023',1,'Intereses Bankinter Póliza Comercio Exterior',0,0,0),('6620002032',1,'Intereses Leaing Iveco',1,0,0),('6620002066',1,'Leasing Intereses Man',1,0,0),('6620002104',1,'Intereses Leasing La caixa 3 vehículos',1,0,0),('6681000000',1,'Diferencia negativa tipo de cambio',1,0,0),('6681000000',4,'Diferencia negativa tipo de cambio',0,0,0),('6681000000',6,'Diferencia negativa tipo de cambio',1,0,0),('6681000567',0,'Diferencias de cambio VNH',1,0,0),('6690000000',1,'Otros gastos financieros',1,0,0),('6690000000',6,'Gastos financieros',1,0,0),('6720000000',16,'Perdidas procedentes de inversiones',0,0,0),('6780000000',1,'Gastos extraordinarios',1,0,0),('6780000001',1,'Gastos no deducibles',1,0,0),('6780000001',16,'Gasto no deducible',0,0,0),('6800000000',1,'Amortización inmovilizado intangible',1,0,0),('6800000001',0,'Amortizacion inmovilizado material',1,0,0),('6810000000',0,'Amortizaciones inmovilizado',1,0,0),('6810000000',1,'Amortizacion inmovilizado material',1,0,0),('7000000000',0,'Ventas',1,0,0),('7000000001',1,'Venta entre empresas',1,0,0),('7000010000',0,'Terceros Flor',1,0,0),('7000020000',0,'Terceros Planta',1,0,0),('7000030000',0,'Terceros Complementos',1,0,0),('7000040000',0,'Terceros Artificial',1,0,0),('7000050000',0,'Terceros Verdes',1,0,0),('7000060000',0,'Terceros Otros',1,0,0),('7000070000',0,'Terceros Confección',1,0,0),('7000080000',1,'Terceros Logística',1,0,0),('7001000000',1,'Mercaderia',1,0,1),('7001010000',0,'Grupo Flor',1,0,0),('7001020000',0,'Grupo Planta',1,0,0),('7001030000',0,'Grupo Complementos',1,0,0),('7001040000',0,'Grupo Artificial',1,0,0),('7001050000',0,'Grupo Verdes',1,0,0),('7001060000',0,'Grupo Otros',1,0,0),('7001070000',0,'Grupo Confección',1,0,0),('7001080000',1,'Grupo Logística',1,0,0),('7002010000',0,'Asociados Flor',1,0,0),('7002020000',0,'Asociados Planta',1,0,0),('7002030000',0,'Asociados Complementos',1,0,0),('7002040000',0,'Asociados Artificial',1,0,0),('7002050000',0,'Asociados Verdes',1,0,0),('7002060000',0,'Asociados Otros',1,0,0),('7002070000',0,'Asociados Confección',1,0,0),('7002080000',1,'Asociados Logística',1,0,0),('7040000000',1,'Embalajes',1,0,1),('7050000000',1,'Prestacion de servicios',1,0,1),('7400000000',1,'Subvenciones, donaciones a la explotacion',1,0,0),('7550000000',0,'Ingresos por serivicios al personal',1,0,0),('7680000000',0,'Diferencias positivas de cambio',1,0,0),('7680000000',1,'Diferenica positiva tipo de cambio',1,0,0),('7690000000',1,'Otros ingresos financieros',1,0,0),('7780000000',1,'Ingresos excepcionales',1,0,0),('7780000000',16,'Ingreso extraordinario',0,0,0),('7780000001',1,'Indemnizaciones transporte',1,0,0),('7780000001',4,'Indemnizaciones agencias transporte',1,0,0),('7780000001',5,'Indemnizaciones agencias transporte',1,0,0),('7780000001',6,'Indemnizaciones transporte',1,0,0),('7940000000',16,'Reversión impagos',0,0,0); /*!40000 ALTER TABLE `Gastos` ENABLE KEYS */; UNLOCK TABLES; @@ -226,7 +226,7 @@ UNLOCK TABLES; LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING'),(2,'Libre',1,0,'FREE'),(3,'OK',3,0,'OK'),(4,'Impreso',4,1,'PRINTED'),(5,'Preparación',5,1,'ON_PREPARATION'),(6,'En Revisión',7,1,'ON_CHECKING'),(7,'Sin Acabar',2,0,'NOT_READY'),(8,'Revisado',8,1,'CHECKED'),(9,'Encajando',9,1,'PACKING'),(10,'Encajado',10,2,'PACKED'),(11,'Facturado',0,0,'INVOICED'),(12,'Bloqueado',0,0,'BLOCKED'),(13,'En Reparto',11,3,'ON_DELIVERY'),(14,'Preparado',6,1,'PREPARED'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP'),(16,'Entregado',13,3,'DELIVERED'),(17,'Eliminado',14,3,'ERASED'),(20,'Asignado',4,1,'PICKER_DESIGNED'),(21,'Retornado',4,1,'PRINTED_BACK'),(22,'¿Fecha?',2,0,'WRONG_DATE'); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING'),(2,'Libre',1,0,'FREE'),(3,'OK',3,0,'OK'),(4,'Impreso',4,1,'PRINTED'),(5,'Preparación',5,1,'ON_PREPARATION'),(6,'En Revisión',7,1,'ON_CHECKING'),(7,'Sin Acabar',2,0,'NOT_READY'),(8,'Revisado',8,1,'CHECKED'),(9,'Encajando',9,1,'PACKING'),(10,'Encajado',10,2,'PACKED'),(11,'Facturado',0,0,'INVOICED'),(12,'Bloqueado',0,0,'BLOCKED'),(13,'En Reparto',11,3,'ON_DELIVERY'),(14,'Preparado',6,1,'PREPARED'),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP'),(16,'Entregado',13,3,'DELIVERED'),(17,'Eliminado',14,3,'ERASED'),(20,'Asignado',4,1,'PICKER_DESIGNED'),(21,'Retornado',4,1,'PRINTED_BACK'),(22,'¿Fecha?',2,0,'WRONG_DATE'),(23,'URGENTE',2,0,'LAST_CALL'); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; @@ -249,6 +249,16 @@ LOCK TABLES `Grupos` WRITE; INSERT INTO `Grupos` VALUES (1,'administrative','Contabilidad',5),(2,'administrator','Administradores',5),(3,'advancedUser','Usuarios avanzados',5),(4,'developer','Informaticos',4),(5,'clientManagement','Gestion Clientes',4),(6,'salesPerson','Comerciales',4),(7,'wages','Salarios',5),(8,'salesPersonDirector','Dir Comercial',4),(9,'advancedSalesPerson','Comercial avanzado',4),(10,'','Compradores',4),(11,'','Control descuentos',4),(12,'takeOrder','Sacador',1),(13,'packer','Encajador',2),(14,' deliveryMan','Repartidor',3),(15,'','No Recalcular',4),(17,'other','Otros',4),(18,'','Operaciones',4),(19,'','Visa',5),(20,'market','Mercado',4),(21,'','Gerencia',5),(22,'','ComercialExclusivo',4),(23,'','Responsables Entradas',5),(24,'teamBoss','Jefes de equipo',4),(25,'','Responsables Encajado',0),(26,'confection','Confeccion',0),(27,'claims','Reclamaciones',0),(28,'','Ranking Carteras Limpias',0),(29,'','No bionicos',0),(30,'','Tirar a Faltas',0),(31,'','Greuges',0),(32,'','Responsables Agencias',0),(33,'','Entradas EXPRESS',0),(34,'','Sustituciones',0),(35,'router','Enrutador',4); /*!40000 ALTER TABLE `Grupos` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `Monedas` +-- + +LOCK TABLES `Monedas` WRITE; +/*!40000 ALTER TABLE `Monedas` DISABLE KEYS */; +INSERT INTO `Monedas` VALUES (1,'EUR','Euro',1),(2,'USD','Dollar USA',1.4),(3,'GBP','Libra',1),(4,'JPY','Yen Japones',1); +/*!40000 ALTER TABLE `Monedas` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -259,7 +269,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:51 +-- Dump completed on 2018-05-10 11:06:50 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -307,7 +317,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:51 +-- Dump completed on 2018-05-10 11:06:50 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- @@ -332,7 +342,7 @@ USE `cache`; LOCK TABLES `cache` WRITE; /*!40000 ALTER TABLE `cache` DISABLE KEYS */; -INSERT INTO `cache` VALUES (1,'equalizator','00:15:00'),(2,'available','00:06:00'),(3,'stock','00:10:00'),(4,'last_buy','08:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:05:00'),(7,'sales','00:03:00'),(8,'visible','00:03:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:15:00'); +INSERT INTO `cache` VALUES (1,'equalizator','00:15:00'),(2,'available','00:05:00'),(3,'stock','00:10:00'),(4,'last_buy','08:30:00'),(5,'weekly_sales','12:00:00'),(6,'bionic','00:05:00'),(7,'sales','00:03:00'),(8,'visible','00:06:00'),(9,'item_range','00:03:00'),(10,'barcodes','01:00:00'),(11,'prod_graphic','00:15:00'); /*!40000 ALTER TABLE `cache` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -345,4 +355,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-04-29 11:48:51 +-- Dump completed on 2018-05-10 11:06:51 diff --git a/services/db/install/dump/fixtures.sql b/services/db/install/dump/fixtures.sql index 826d9d194..7125d156a 100644 --- a/services/db/install/dump/fixtures.sql +++ b/services/db/install/dump/fixtures.sql @@ -293,8 +293,8 @@ INSERT INTO `vn`.`invoiceOut`(`id`, `ref`, `serial`, `amount`, `issued`,`clientF ( 1, 'T1111111' , 'T', 500 , DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 101, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), ( 2, 'V2222222' , 'V', 350.50 , DATE_ADD(CURDATE(), INTERVAL -1 MONTH), 102, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), ( 3, 'E3333333' , 'E', 90.30 , CURDATE(), 103, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), - ( 3, 'E4444444' , 'E', 290.30 , DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 103, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), - ( 3, 'E5555555' , 'E', 190.30 , DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 103, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1); + ( 4, 'E4444444' , 'E', 290.30 , DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 103, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1), + ( 5, 'E5555555' , 'E', 190.30 , DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 103, CURDATE(), 442, CURDATE(), CURDATE(), 8, 1); INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `clientFk`,`nickname`, `addressFk`, `refFk`) VALUES