diff --git a/services/db/.gitignore b/db/.gitignore similarity index 100% rename from services/db/.gitignore rename to db/.gitignore diff --git a/services/db/Dockerfile b/db/Dockerfile similarity index 100% rename from services/db/Dockerfile rename to db/Dockerfile diff --git a/db/connect.tpl.ini b/db/connect.tpl.ini new file mode 100644 index 000000000..2db13e969 --- /dev/null +++ b/db/connect.tpl.ini @@ -0,0 +1,7 @@ +[client] +enable_cleartext_plugin = ON +host = localhost +port = 3306 +user = root +password = password +ssl-mode = DISABLED diff --git a/services/db/docker-start.sh b/db/docker-start.sh similarity index 100% rename from services/db/docker-start.sh rename to db/docker-start.sh diff --git a/services/db/export-data.sh b/db/export-data.sh similarity index 95% rename from services/db/export-data.sh rename to db/export-data.sh index 4e1f049d5..aa3000d9d 100755 --- a/services/db/export-data.sh +++ b/db/export-data.sh @@ -1,5 +1,4 @@ #!/bin/bash -#IMPORTANT Any changes in this file are to applyed to mirror file export-data.cmd echo "USE \`account\`;" > install/dump/dumpedFixtures.sql mysqldump --defaults-file=connect.ini --no-create-info account role roleRole roleInherit >> install/dump/dumpedFixtures.sql echo "USE \`salix\`;" >> install/dump/dumpedFixtures.sql diff --git a/services/db/export-structure.sh b/db/export-structure.sh similarity index 100% rename from services/db/export-structure.sh rename to db/export-structure.sh diff --git a/services/db/import-changes.js b/db/import-changes.js similarity index 100% rename from services/db/import-changes.js rename to db/import-changes.js diff --git a/services/db/import-fixtures.js b/db/import-fixtures.js similarity index 100% rename from services/db/import-fixtures.js rename to db/import-fixtures.js diff --git a/services/db/install/boot.sh b/db/install/boot.sh similarity index 100% rename from services/db/install/boot.sh rename to db/install/boot.sh diff --git a/services/db/install/changes/1-orderGetTotal.sql b/db/install/changes/1-orderGetTotal.sql similarity index 100% rename from services/db/install/changes/1-orderGetTotal.sql rename to db/install/changes/1-orderGetTotal.sql diff --git a/services/db/install/changes/2-orderGetTotal.sql b/db/install/changes/2-orderGetTotal.sql similarity index 100% rename from services/db/install/changes/2-orderGetTotal.sql rename to db/install/changes/2-orderGetTotal.sql diff --git a/services/db/install/changes/3-orderGetTax.sql b/db/install/changes/3-orderGetTax.sql similarity index 100% rename from services/db/install/changes/3-orderGetTax.sql rename to db/install/changes/3-orderGetTax.sql diff --git a/services/db/install/changes/4-addressAfterUpdate.sql b/db/install/changes/4-addressAfterUpdate.sql similarity index 100% rename from services/db/install/changes/4-addressAfterUpdate.sql rename to db/install/changes/4-addressAfterUpdate.sql diff --git a/services/db/install/changes/5-addressBeforeInsert.sql b/db/install/changes/5-addressBeforeInsert.sql similarity index 100% rename from services/db/install/changes/5-addressBeforeInsert.sql rename to db/install/changes/5-addressBeforeInsert.sql diff --git a/services/db/install/changes/6-addressBeforeUpdate.sql b/db/install/changes/6-addressBeforeUpdate.sql similarity index 100% rename from services/db/install/changes/6-addressBeforeUpdate.sql rename to db/install/changes/6-addressBeforeUpdate.sql diff --git a/services/db/install/changes/7-clientAfterInsert.sql b/db/install/changes/7-clientAfterInsert.sql similarity index 100% rename from services/db/install/changes/7-clientAfterInsert.sql rename to db/install/changes/7-clientAfterInsert.sql diff --git a/services/db/install/changes/8-clientAfterUpdate.sql b/db/install/changes/8-clientAfterUpdate.sql similarity index 79% rename from services/db/install/changes/8-clientAfterUpdate.sql rename to db/install/changes/8-clientAfterUpdate.sql index 914b7c4d0..ee877b0a2 100644 --- a/services/db/install/changes/8-clientAfterUpdate.sql +++ b/db/install/changes/8-clientAfterUpdate.sql @@ -11,8 +11,7 @@ BEGIN UPDATE Consignatarios SET predeterminada = FALSE WHERE Id_cliente = NEW.Id_cliente; - UPDATE Consignatarios SET predeterminada = TRUE - WHERE Id_consigna = NEW.default_address; + END IF; END$$ DELIMITER ; diff --git a/services/db/install/changes/9-migrateDefaultAddress.sql b/db/install/changes/9-migrateDefaultAddress.sql similarity index 100% rename from services/db/install/changes/9-migrateDefaultAddress.sql rename to db/install/changes/9-migrateDefaultAddress.sql diff --git a/services/db/install/dump/dumpedFixtures.sql b/db/install/dump/dumpedFixtures.sql similarity index 99% rename from services/db/install/dump/dumpedFixtures.sql rename to db/install/dump/dumpedFixtures.sql index 0e3957b07..9eb199ce7 100644 --- a/services/db/install/dump/dumpedFixtures.sql +++ b/db/install/dump/dumpedFixtures.sql @@ -1,7 +1,7 @@ USE `account`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: account +-- Host: test-db.verdnatura.es Database: account -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -55,11 +55,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:26 +-- Dump completed on 2019-03-01 13:31:23 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: salix +-- Host: test-db.verdnatura.es Database: salix -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -103,11 +103,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:26 +-- Dump completed on 2019-03-01 13:31:23 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: vn +-- Host: test-db.verdnatura.es Database: vn -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -201,11 +201,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:26 +-- Dump completed on 2019-03-01 13:31:23 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: vn2008 +-- Host: test-db.verdnatura.es Database: vn2008 -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -399,11 +399,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:27 +-- Dump completed on 2019-03-01 13:31:24 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: bi +-- Host: test-db.verdnatura.es Database: bi -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -447,11 +447,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:27 +-- Dump completed on 2019-03-01 13:31:24 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: cache +-- Host: test-db.verdnatura.es Database: cache -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -485,11 +485,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:27 +-- Dump completed on 2019-03-01 13:31:24 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: hedera +-- Host: test-db.verdnatura.es Database: hedera -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -543,11 +543,11 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:27 +-- Dump completed on 2019-03-01 13:31:24 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: postgresql +-- Host: test-db.verdnatura.es Database: postgresql -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -618,7 +618,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,861,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20006,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2843,5),(6,'Vilassar',88,88014,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,NULL,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,865,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20006,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2843,5),(6,'Vilassar',88,88014,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,NULL,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -631,4 +631,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:31:27 +-- Dump completed on 2019-03-01 13:31:24 diff --git a/services/db/install/dump/fixtures.sql b/db/install/dump/fixtures.sql similarity index 96% rename from services/db/install/dump/fixtures.sql rename to db/install/dump/fixtures.sql index 51928eb7c..2488c231b 100644 --- a/services/db/install/dump/fixtures.sql +++ b/db/install/dump/fixtures.sql @@ -1,3 +1,5 @@ + + ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1; @@ -8,7 +10,7 @@ INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active` SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@verdnatura.es') FROM `account`.`role`; -INSERT INTO `vn`.`worker`(`id`,`workerCode`, `firstName`, `name`, `userFk`) +INSERT INTO `vn2008`.`Trabajadores`(`Id_Trabajador`,`CodigoTrabajador`, `Nombre`, `Apellidos`, `user_id`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id FROM `vn`.`user`; @@ -29,7 +31,7 @@ INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`,`lan (111, 'Missing', 'ac754a330530832ba1bf7687f577da91', 2 , 0, NULL, 'es'), (112, 'Trash', 'ac754a330530832ba1bf7687f577da91', 2 , 0, NULL, 'es'); - INSERT INTO `vn`.`worker`(`workerCode`, `id`, `firstName`, `name`, `userFk`) + INSERT INTO `vn2008`.`Trabajadores`(`CodigoTrabajador`, `Id_Trabajador`, `Nombre`, `Apellidos`, `user_id`) VALUES ('LGN', 106, 'David Charles', 'Haller', 106), ('ANT', 107, 'Hank' , 'Pym' , 107), @@ -209,52 +211,52 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) ( 103, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), ( 104, -30, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)); -INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`) +INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES - (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0), - (2, 'Petter Parker', '20 Ingram Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0), - (3, 'Clark Kent', '344 Clinton Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0), - (4, 'Tony Stark', '10880 Malibu Point', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0), - (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0), - (6, 'DavidCharlesHaller', 'Evil hideout', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0), - (7, 'Hank Pym', 'Anthill', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0), - (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0), - (9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0), - (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0), - (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0), - (101, 'address 01', 'Somewhere in Thailand', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (102, 'address 02', 'Somewhere in Poland', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0), - (103, 'address 03', 'Somewhere in Japan', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0), - (104, 'address 04', 'Somewhere in Spain', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0), - (105, 'address 05', 'Somewhere in Potugal', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0), - (106, 'address 06', 'Somewhere in UK', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0), - (107, 'address 07', 'Somewhere in Valencia', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0), - (108, 'address 08', 'Somewhere in Silla', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0), - (109, 'address 09', 'Somewhere in London', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (110, 'address 10', 'Somewhere in Algemesi', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (111, 'address 11', 'Somewhere in Carlet', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (112, 'address 12', 'Somewhere in Campanar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (113, 'address 13', 'Somewhere in Malilla', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (114, 'address 14', 'Somewhere in France', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (115, 'address 15', 'Somewhere in Birmingham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (116, 'address 16', 'Somewhere in Scotland', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (117, 'address 17', 'Somewhere in nowhere', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (118, 'address 18', 'Somewhere over the rainbow', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (119, 'address 19', 'Somewhere in Alberic', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (120, 'address 20', 'Somewhere in Montortal', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0), - (121, 'address 21', 'the bat cave', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0), - (122, 'address 22', 'NY roofs', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0), - (123, 'address 23', 'The phone box', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0), - (124, 'address 24', 'Stark tower', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0), - (125, 'address 25', 'The plastic cell', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0), - (126, 'address 26', 'Many places', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0), - (127, 'address 27', 'Your pocket', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0), - (128, 'address 28', 'Cerebro', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0), - (129, 'address 29', 'Luke Cages Bar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0), - (130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0), - (131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0), - (132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0); + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 1), + (3, 'Clark Kent', '344 Clinton Street', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0, 1), + (4, 'Tony Stark', '10880 Malibu Point', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0, 1), + (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0, 1), + (6, 'DavidCharlesHaller', 'Evil hideout', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0, 1), + (7, 'Hank Pym', 'Anthill', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0, 1), + (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 1), + (9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 1), + (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 1), + (11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 1), + (12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 1), + (101, 'address 01', 'Somewhere in Thailand', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (102, 'address 02', 'Somewhere in Poland', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0), + (103, 'address 03', 'Somewhere in Japan', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0), + (104, 'address 04', 'Somewhere in Spain', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0), + (105, 'address 05', 'Somewhere in Potugal', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0, 0), + (106, 'address 06', 'Somewhere in UK', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0, 0), + (107, 'address 07', 'Somewhere in Valencia', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0, 0), + (108, 'address 08', 'Somewhere in Silla', 'Silla', 46460, 1, 5555555555, 666666666, 1, 109, 2, NULL, NULL, 0, 0), + (109, 'address 09', 'Somewhere in London', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (110, 'address 10', 'Somewhere in Algemesi', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (111, 'address 11', 'Somewhere in Carlet', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (112, 'address 12', 'Somewhere in Campanar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (113, 'address 13', 'Somewhere in Malilla', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (114, 'address 14', 'Somewhere in France', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (115, 'address 15', 'Somewhere in Birmingham', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (116, 'address 16', 'Somewhere in Scotland', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (117, 'address 17', 'Somewhere in nowhere', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (118, 'address 18', 'Somewhere over the rainbow', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (119, 'address 19', 'Somewhere in Alberic', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (120, 'address 20', 'Somewhere in Montortal', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0), + (121, 'address 21', 'the bat cave', 'Silla', 46460, 1, 1111111111, 222222222, 1, 101, 2, NULL, NULL, 0, 0), + (122, 'address 22', 'NY roofs', 'Silla', 46460, 1, 1111111111, 222222222, 1, 102, 2, NULL, NULL, 0, 0), + (123, 'address 23', 'The phone box', 'Silla', 46460, 1, 1111111111, 222222222, 1, 103, 2, NULL, NULL, 0, 0), + (124, 'address 24', 'Stark tower', 'Silla', 46460, 1, 1111111111, 222222222, 1, 104, 2, NULL, NULL, 0, 0), + (125, 'address 25', 'The plastic cell', 'Silla', 46460, 1, 1111111111, 222222222, 1, 105, 2, NULL, NULL, 0, 0), + (126, 'address 26', 'Many places', 'Silla', 46460, 1, 1111111111, 222222222, 1, 106, 2, NULL, NULL, 0, 0), + (127, 'address 27', 'Your pocket', 'Silla', 46460, 1, 1111111111, 222222222, 1, 107, 2, NULL, NULL, 0, 0), + (128, 'address 28', 'Cerebro', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 0), + (129, 'address 29', 'Luke Cages Bar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 0), + (130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0, 0), + (131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 0), + (132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 0); UPDATE `vn`.`client` SET defaultAddressFk = 1 WHERE id = 101; UPDATE `vn`.`client` SET defaultAddressFk = 2 WHERE id = 102; @@ -294,15 +296,15 @@ INSERT INTO `vn`.`clientCreditLimit`(`id`, `maxAmount`, `roleFk`) INSERT INTO `vn`.`clientObservation`(`id`, `clientFk`, `workerFk`, `text`, `created`) VALUES - (1, 101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()), - (2, 102, 1, 'With great power, comes great responsibility', CURDATE()), - (3, 103, 3, 'this is a job for Super-Man!', CURDATE()), - (4, 104, 3, 'yes... I am Iron-Man', CURDATE()), - (5, 105, 5, 'They do understand. Our mutant powers make us superior', CURDATE()), - (6, 106, 5, 'My name is Legion, for we are many!', CURDATE()), - (7, 107, 9, 'I think our first move should be calling the Avengers..', CURDATE()), - (8, 108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', CURDATE()), - (9, 109, 20, 'HULK SMASH! ...', CURDATE()), + (1, 101, 1, 'Madness, as you know, is like gravity, all it takes is a little push', CURDATE()), + (2, 102, 1, 'With great power, comes great responsibility', CURDATE()), + (3, 103, 3, 'this is a job for Super-Man!', CURDATE()), + (4, 104, 3, 'yes... I am Iron-Man', CURDATE()), + (5, 105, 5, 'They do understand. Our mutant powers make us superior', CURDATE()), + (6, 106, 5, 'My name is Legion, for we are many!', CURDATE()), + (7, 107, 9, 'I think our first move should be calling the Avengers..', CURDATE()), + (8, 108, 9, 'Just because someone stumbles and loses their path, does not mean they are lost forever.', CURDATE()), + (9, 109, 20, 'HULK SMASH! ...', CURDATE()), (10, 110, 20, 'They say everyone is born a hero. But if you let it, life will push you over the line until you are the villain.', CURDATE()); INSERT INTO `vn`.`observationType`(`id`,`description`) diff --git a/services/db/install/dump/mysqlPlugins.sql b/db/install/dump/mysqlPlugins.sql similarity index 100% rename from services/db/install/dump/mysqlPlugins.sql rename to db/install/dump/mysqlPlugins.sql diff --git a/services/db/install/dump/structure.sql b/db/install/dump/structure.sql similarity index 99% rename from services/db/install/dump/structure.sql rename to db/install/dump/structure.sql index 87eac7dd2..70588d75f 100644 --- a/services/db/install/dump/structure.sql +++ b/db/install/dump/structure.sql @@ -1,6 +1,6 @@ -- MySQL dump 10.13 Distrib 5.7.21, for osx10.13 (x86_64) -- --- Host: db.verdnatura.es Database: account +-- Host: test-db.verdnatura.es Database: account -- ------------------------------------------------------ -- Server version 5.6.25-4-log @@ -363,7 +363,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=15235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=15285 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 */ ; @@ -2459,7 +2459,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=33842 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=34158 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2562,6 +2562,7 @@ CREATE TABLE `Articles` ( `compression` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', `minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3', `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0', + `lastPrice` decimal(10,2) DEFAULT '0.00', PRIMARY KEY (`Id_Article`), KEY `Article` (`Article`), KEY `Color` (`Color`), @@ -2577,7 +2578,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=339073 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=339584 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 */ ; @@ -2759,7 +2760,7 @@ CREATE TABLE `Articles_dits` ( KEY `fgkey1_idx` (`idaccion_dits`), KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=21234 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21244 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2782,7 +2783,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=684547 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=687346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2908,7 +2909,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=662913 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=664380 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 */ ; @@ -3040,7 +3041,7 @@ CREATE TABLE `Clientes` ( 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, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientes_tipo` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=15235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15285 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 */ ; @@ -3323,7 +3324,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=51 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3405,7 +3406,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=294584200 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=295179612 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 */ ; @@ -3456,6 +3457,9 @@ bi:BEGIN IF NEW.caja IS NULL THEN SET NEW.caja = IFNULL(vIsBox, NEW.caja); END IF; + + UPDATE vn.item SET isActive = 1 WHERE id = NEW.Id_Article ; + END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -3694,7 +3698,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=26827 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=26883 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 */ ; @@ -3878,7 +3882,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2687 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2688 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 */ ; @@ -4075,7 +4079,7 @@ CREATE TABLE `Entradas` ( 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=161274 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=161601 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 */ ; @@ -4236,7 +4240,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=3355095 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3365684 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4254,7 +4258,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=949 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=975 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4498,7 +4502,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=486326 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=486361 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 */ ; @@ -4677,7 +4681,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=2812086 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=FIXED; +) ENGINE=InnoDB AUTO_INCREMENT=2817960 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 */ ; @@ -4878,7 +4882,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=23718595 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=23749175 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 */ ; @@ -5036,7 +5040,7 @@ CREATE TABLE `Movimientos_mark` ( KEY `Id_Movimiento` (`Id_Movimiento`), KEY `fgnStateFk_idx` (`stateFk`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=14671117 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14754870 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 */ ; @@ -5141,7 +5145,7 @@ CREATE TABLE `Ordenes` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=39329 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=39488 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 */ ; @@ -5245,7 +5249,7 @@ CREATE TABLE `Pagares` ( KEY `empresa_id` (`kk_empresa_id`), KEY `pago_id` (`pago_id`), CONSTRAINT `Pagares_ibfk_2` FOREIGN KEY (`pago_id`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2860 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2862 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5371,7 +5375,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=2706 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2712 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5397,7 +5401,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=727 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=730 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5488,7 +5492,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=541888 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=542659 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 */ ; @@ -5579,7 +5583,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2686 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2687 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5624,7 +5628,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5655,7 +5659,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=48213 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=48347 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 */ ; @@ -5843,7 +5847,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=346779 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=347007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5861,7 +5865,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=36555 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5889,7 +5893,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=24022 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24024 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5947,7 +5951,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=2154348 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2158859 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 */ ; @@ -6143,7 +6147,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=64383332 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64394157 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 */ ; @@ -6224,7 +6228,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=2149105 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2156930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -6293,7 +6297,7 @@ CREATE TABLE `Tipos` ( CONSTRAINT `Tipos_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, CONSTRAINT `Trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=243 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; +) ENGINE=InnoDB AUTO_INCREMENT=244 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Protege la tabla tipos de updates para los 4 parámetros de los compradores, en funcion del valor del campo CodigoRojo de tblContadores.'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -6381,7 +6385,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=1248 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1254 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 */ ; @@ -6534,7 +6538,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=10505 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=10520 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 */; -- @@ -6648,7 +6652,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=3667051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3669159 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 */ ; @@ -6756,7 +6760,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=19697 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20237 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 */ ; @@ -6923,7 +6927,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=5229 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5290 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 */ ; @@ -7089,7 +7093,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=3001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3013 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7167,7 +7171,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=3020 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3030 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 */ ; @@ -7446,7 +7450,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=2652 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2662 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7565,7 +7569,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=38974 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=39059 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7709,7 +7713,7 @@ CREATE TABLE `buy_edi` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=847565 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=850125 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7942,7 +7946,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=101012 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=101261 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7976,7 +7980,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=52682 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=52803 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8026,7 +8030,7 @@ CREATE TABLE `cl_det` ( KEY `cl_main_id` (`cl_main_id`), 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=136361 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=136574 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -8114,7 +8118,7 @@ CREATE TABLE `cl_main` ( 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, CONSTRAINT `cl_main_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `Tickets` (`Id_Ticket`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59436 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=59576 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8230,7 +8234,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=72114 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=72248 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8398,7 +8402,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=3636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=3646 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8480,7 +8484,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=72941 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=73104 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9006,7 +9010,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=16994 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=17011 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9036,7 +9040,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=2869719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2876446 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 */ ; @@ -9280,7 +9284,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=1173730 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1176798 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9479,7 +9483,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=73362 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=73411 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9818,7 +9822,7 @@ CREATE TABLE `mail` ( `recipientFk` int(11) DEFAULT NULL, `plainTextBody` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1613146 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=1618503 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9876,7 +9880,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=16144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16150 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 */ ; @@ -10085,7 +10089,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=47066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=47163 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 */ ; @@ -10582,7 +10586,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=60563 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=60631 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 */ ; @@ -10644,7 +10648,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=6983 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7065 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10813,7 +10817,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=77748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=77896 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 */ ; @@ -11402,7 +11406,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=120822 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=121033 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11425,7 +11429,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=118216 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=118410 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 */ ; @@ -11649,7 +11653,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=83299 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=83737 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 */; -- @@ -11689,7 +11693,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=1033735 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1038812 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11711,7 +11715,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=1982 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1987 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 */ ; @@ -11789,7 +11793,7 @@ CREATE TABLE `sharingclient` ( KEY `Client` (`Id_Cliente`), CONSTRAINT `Clients_key` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=50 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 */ ; @@ -11888,6 +11892,21 @@ CREATE TABLE `state` ( ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `subordinate` +-- + +DROP TABLE IF EXISTS `subordinate`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `subordinate` ( + `Id_Trabajador` bigint(11) DEFAULT NULL, + `visited` int(1) NOT NULL DEFAULT '0', + `boss` int(1) NOT NULL DEFAULT '0', + KEY `Id_Trabajador` (`Id_Trabajador`) +) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `tag` -- @@ -12167,7 +12186,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=1282191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1285707 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12291,7 +12310,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_cargueras` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=123995 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=124354 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 */ ; @@ -12428,7 +12447,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=207305 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=207917 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20700,152 +20719,151 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `buy_split`(v_buy INT, v_fv_entry INT, v_pca_entry INT) -BEGIN - DECLARE v_item INT; - DECLARE v_packing INT; - DECLARE v_remaining INT; - DECLARE v_labels INT; - DECLARE v_remainder INT; - DECLARE v_is_buy INT; - DECLARE v_id INT; - DECLARE v_amount INT; - DECLARE v_done BOOL DEFAULT FALSE; - - DECLARE cur CURSOR FOR - SELECT TRUE, c.Id_Compra, c.Cantidad - IFNULL((c.Vida * c.Packing), 0) - FROM Compres c - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - JOIN travel t ON t.id = e.travel_id - WHERE c.Id_Article = v_item - AND t.shipment = CURDATE() AND t.warehouse_id_out IN (7, 40) - AND t.warehouse_id NOT IN (44, 1) - AND NOT e.redada AND NOT e.Inventario - AND IFNULL(c.Vida, 0) < c.Etiquetas - LOCK IN SHARE MODE - UNION ALL - SELECT FALSE, m.Id_Movimiento, m.Cantidad - IFNULL(l.stem, 0) - FROM Movimientos m - JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket - LEFT JOIN movement_label l ON l.Id_Movimiento = m.Id_Movimiento - WHERE m.Id_Article = v_item - AND t.Fecha = CURDATE() AND t.warehouse_id IN (7, 40) - AND NOT t.Etiquetasemitidas - AND IFNULL(l.stem, 0) < m.Cantidad - LOCK IN SHARE MODE; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET v_done = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - -- Obtiene los datos de la compra - - SELECT Id_Article, Packing, Cantidad - INTO v_item, v_packing, v_remaining - FROM Compres WHERE Id_Compra = v_buy; - - -- Crea splits de los tickets - - DROP TEMPORARY TABLE IF EXISTS tmp.split; - CREATE TEMPORARY TABLE tmp.split - ( - is_buy BOOL, - id INT, - labels INT, - remainder INT - ) - ENGINE = MEMORY; - - OPEN cur; - - l: LOOP - SET v_done = FALSE; - FETCH cur INTO v_is_buy, v_id, v_amount; - - IF v_done OR v_remaining = 0 THEN - LEAVE l; - END IF; - - SET v_amount = LEAST(v_amount, v_remaining); - SET v_remaining = v_remaining - v_amount; - SET v_labels = v_amount DIV v_packing; - - INSERT INTO tmp.split - VALUES (v_is_buy, v_id, v_labels, v_amount % v_packing); - - IF v_is_buy - THEN - UPDATE Compres - SET Vida = Vida + v_labels - WHERE Id_Compra = v_id; - ELSE - INSERT INTO movement_label - SET - Id_Movimiento = v_id, - stem = v_amount, - label = v_labels - ON DUPLICATE KEY UPDATE - stem = stem + VALUES(stem), - label = label + VALUES(label); - END IF; - END LOOP; - - CLOSE cur; - - -- Crea los movimientos de almacén a silla - - CALL buy_transfer (v_buy, v_fv_entry, v_pca_entry); - - UPDATE Compres SET dispatched = Vida * Packing - WHERE Id_Compra = v_buy; - - -- Devuelve los splits creados - - DROP TEMPORARY TABLE IF EXISTS tmp.aux; - CREATE TEMPORARY TABLE tmp.aux - ENGINE = MEMORY - SELECT s.labels, s.remainder, w.`name` destination, - a.Id_Article, a.Article, a.Medida - FROM tmp.split s - JOIN Compres c ON c.Id_Compra = s.id - JOIN Articles a ON a.Id_Article = c.Id_Article - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - JOIN travel t ON t.id = e.travel_id - JOIN warehouse w ON t.warehouse_id = w.id - WHERE s.is_buy; - - INSERT INTO tmp.aux - SELECT s.labels, s.remainder, o.Consignatario, - a.Id_Article, a.Article, a.Medida - FROM tmp.split s - JOIN Movimientos m ON m.Id_Movimiento = s.id - JOIN Articles a ON a.Id_Article = m.Id_Article - JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN Consignatarios o ON o.Id_Consigna = t.Id_Consigna - WHERE NOT s.is_buy; - - SELECT * FROM tmp.aux; - - -- Limpia y confirma cambios - - DROP TEMPORARY TABLE - tmp.split, - tmp.aux; - - COMMIT; +CREATE DEFINER=`root`@`%` PROCEDURE `buy_split`(IN `v_buy` INT, IN `v_fv_entry` INT, IN `v_pca_entry` INT) +BEGIN + DECLARE v_item INT; + DECLARE v_packing INT; + DECLARE v_remaining INT; + DECLARE v_labels INT; + DECLARE v_remainder INT; + DECLARE v_is_buy INT; + DECLARE v_id INT; + DECLARE v_amount INT; + DECLARE v_done BOOL DEFAULT FALSE; + + DECLARE cur CURSOR FOR + SELECT TRUE, c.Id_Compra, c.Cantidad - IFNULL((c.Vida * c.Packing), 0) + FROM Compres c + JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada + JOIN travel t ON t.id = e.travel_id + WHERE c.Id_Article = v_item + AND t.shipment = CURDATE() AND t.warehouse_id_out IN (7, 40) + AND t.warehouse_id NOT IN (44, 1) + AND NOT e.redada AND NOT e.Inventario + AND IFNULL(c.Vida, 0) < c.Etiquetas + UNION ALL + SELECT FALSE, m.Id_Movimiento, m.Cantidad - IFNULL(l.stem, 0) + FROM Movimientos m + JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket + LEFT JOIN movement_label l ON l.Id_Movimiento = m.Id_Movimiento + WHERE m.Id_Article = v_item + AND t.Fecha = CURDATE() AND t.warehouse_id IN (7, 40) + AND NOT t.Etiquetasemitidas + AND IFNULL(l.stem, 0) < m.Cantidad + LOCK IN SHARE MODE; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET v_done = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + -- Obtiene los datos de la compra + + SELECT Id_Article, Packing, Cantidad + INTO v_item, v_packing, v_remaining + FROM Compres WHERE Id_Compra = v_buy; + + -- Crea splits de los tickets + + DROP TEMPORARY TABLE IF EXISTS tmp.split; + CREATE TEMPORARY TABLE tmp.split + ( + is_buy BOOL, + id INT, + labels INT, + remainder INT + ) + ENGINE = MEMORY; + + OPEN cur; + + l: LOOP + SET v_done = FALSE; + FETCH cur INTO v_is_buy, v_id, v_amount; + + IF v_done OR v_remaining = 0 THEN + LEAVE l; + END IF; + + SET v_amount = LEAST(v_amount, v_remaining); + SET v_remaining = v_remaining - v_amount; + SET v_labels = v_amount DIV v_packing; + + INSERT INTO tmp.split + VALUES (v_is_buy, v_id, v_labels, v_amount % v_packing); + + IF v_is_buy + THEN + UPDATE Compres + SET Vida = Vida + v_labels + WHERE Id_Compra = v_id; + ELSE + INSERT INTO movement_label + SET + Id_Movimiento = v_id, + stem = v_amount, + label = v_labels + ON DUPLICATE KEY UPDATE + stem = stem + VALUES(stem), + label = label + VALUES(label); + END IF; + END LOOP; + + CLOSE cur; + + -- Crea los movimientos de almacén a silla + + CALL buy_transfer (v_buy, v_fv_entry, v_pca_entry); + + UPDATE Compres SET dispatched = Vida * Packing + WHERE Id_Compra = v_buy; + + -- Devuelve los splits creados + + DROP TEMPORARY TABLE IF EXISTS tmp.aux; + CREATE TEMPORARY TABLE tmp.aux + ENGINE = MEMORY + SELECT s.labels, s.remainder, w.`name` destination, + a.Id_Article, a.Article, a.Medida + FROM tmp.split s + JOIN Compres c ON c.Id_Compra = s.id + JOIN Articles a ON a.Id_Article = c.Id_Article + JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada + JOIN travel t ON t.id = e.travel_id + JOIN warehouse w ON t.warehouse_id = w.id + WHERE s.is_buy; + + INSERT INTO tmp.aux + SELECT s.labels, s.remainder, o.Consignatario, + a.Id_Article, a.Article, a.Medida + FROM tmp.split s + JOIN Movimientos m ON m.Id_Movimiento = s.id + JOIN Articles a ON a.Id_Article = m.Id_Article + JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN Consignatarios o ON o.Id_Consigna = t.Id_Consigna + WHERE NOT s.is_buy; + + SELECT * FROM tmp.aux; + + -- Limpia y confirma cambios + + DROP TEMPORARY TABLE + tmp.split, + tmp.aux; + + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -21103,68 +21121,133 @@ BEGIN CALL buy_tarifas_table(idENTRADA); - SELECT AG.m3 * sum( etiquetas * IFNULL(((AG.m3 * cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) ,0) ) / - sum(etiquetas * IFNULL(((AG.m3 * ( A.density / 167 ) * cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) ,0)) INTO m3i - FROM Compres C - JOIN Articles A USING(Id_Article) - JOIN Entradas E USING(Id_Entrada) - JOIN Tipos TP USING(tipo_id) - JOIN travel TR ON TR.id = E.travel_id - JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia - WHERE E.Id_Entrada = idENTRADA; - - - UPDATE Compres C - LEFT JOIN Cubos CB USING(Id_Cubo) - JOIN Articles A USING(Id_Article) - JOIN Entradas E USING(Id_Entrada) - LEFT JOIN recibida_entrada re on E.Id_Entrada = re.Id_Entrada - LEFT JOIN awb_recibida ar ON re.awb_recibida = ar.recibida_id - LEFT JOIN v_awb_volumen va ON va.awb_id = ar.awb_id - JOIN Tipos TP USING(tipo_id) - JOIN travel TR ON TR.id = E.travel_id - JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia - JOIN tblTARIFAS TC + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING(Id_Entrada) + LEFT JOIN vn.duaEntry de on E.Id_Entrada = de.entryFk + LEFT JOIN vn.dua d ON d.id = de.duaFk + LEFT JOIN v_awb_volumen va ON va.awb_id = d.awbFk + JOIN Tipos TP USING(tipo_id) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + JOIN tblTARIFAS TC - SET C.Portefijo = @PF:= - IF (va.importe, + SET C.Portefijo = @PF:= + IF (va.importe, - round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), - - ROUND(IFNULL(((AG.m3 * @cm3:= cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) / C.Packing,0),3) - ), + round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + + ROUND(IFNULL(((AG.m3 * @cm3:= cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) / C.Packing,0),3) + ), - C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), + C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), - C.Embalajefijo = @EF:= IF(CB.Retornable != 0, 0, ROUND(IFNULL( CB.Valor / C.Packing ,0),3)), + C.Embalajefijo = @EF:= IF(CB.Retornable != 0, 0, ROUND(IFNULL( CB.Valor / C.Packing ,0),3)), - C.Tarifa3 = @t3:= IF(TC.t3 = 0, C.Costefijo,ROUND((C.Costefijo + @CF + @EF + @PF) / ((100 - TC.t3 - TP.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + C.Tarifa3 = @t3:= IF(TC.t3 = 0, C.Costefijo,ROUND((C.Costefijo + @CF + @EF + @PF) / ((100 - TC.t3 - TP.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 - C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100)),2), + C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100)),2), - C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) - - WHERE C.Id_Entrada = idENTRADA ; + C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) + WHERE C.Id_Entrada = idENTRADA; CASE wh_id WHEN 41 THEN -- Canarias - UPDATE Compres - SET Tarifa2 = Tarifa3 - WHERE Id_Entrada = idENTRADA; - ELSE + UPDATE Compres + SET Tarifa2 = Tarifa3 + WHERE Id_Entrada = idENTRADA; + ELSE - BEGIN - END; + BEGIN + END; END CASE; -- priceBuilder call buy_tarifas_priceBuilder_Entry(idENTRADA); +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 `buy_tarifas_entryTest` */; +/*!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`@`localhost` PROCEDURE `buy_tarifas_entryTest`(IN entryFk INT(11)) +BEGIN + DECLARE datINV DATE; + DECLARE wh_id INT; + DECLARE m3i INTEGER; + + + SELECT warehouse_id INTO wh_id + FROM Entradas + JOIN travel ON travel.id = travel_id + WHERE Id_Entrada = entryFk; + + CALL buy_tarifas_table(entryFk); + + UPDATE Compres C + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING(Id_Entrada) + LEFT JOIN vn.duaEntry de on E.Id_Entrada = de.entryFk + LEFT JOIN vn.dua d ON d.id = de.duaFk + LEFT JOIN v_awb_volumen va ON va.awb_id = d.awbFk + JOIN Tipos TP USING(tipo_id) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + JOIN tblTARIFAS TC + + SET C.Portefijo = @PF:= + IF (va.importe, + + round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + + ROUND(IFNULL(((AG.m3 * @cm3:= cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) / C.Packing,0),3) + ), + + C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), + + C.Embalajefijo = @EF:= IF(CB.Retornable != 0, 0, ROUND(IFNULL( CB.Valor / C.Packing ,0),3)), + + C.Tarifa3 = @t3:= IF(TC.t3 = 0, C.Costefijo,ROUND((C.Costefijo + @CF + @EF + @PF) / ((100 - TC.t3 - TP.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + + C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100)),2), + + C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) + + WHERE C.Id_Entrada = entryFk; + + CASE wh_id + + WHEN 41 THEN -- Canarias + + UPDATE Compres + SET Tarifa2 = Tarifa3 + WHERE Id_Entrada = entryFk; + ELSE + + BEGIN + END; + + END CASE; + + -- priceBuilder + call buy_tarifas_priceBuilder_Entry(entryFk); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -23555,7 +23638,7 @@ BEGIN ( 'CREATE TEMPORARY TABLE tmp.comparative ENGINE = MEMORY SELECT - an.nicho, p.name Productor, C.Packing, C.Costefijo, C.caja + an.nicho, p.name Productor, C.Packing, A.lastPrice AS CosteFijo, C.caja ,A.Color, Id_Tipo as Tipo,A.tipo_id, o.Abreviatura as Origen, A.Categoria ,A.Tallos, A.Medida, A.Article, TR.CodigoTrabajador @@ -25648,148 +25731,148 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `F5`(IN idT BIGINT) -BEGIN -SELECT C.calidad, - LEFT(Article, 4) as Subtipo, - barcode, - 'ASEGURADO' AS asegurado, -/*CASE A.tipo_id -WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),'RAMAJE',R.Reino) -WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),'RAMAJE',R.Reino) -WHEN 69 THEN IF(M.Id_Article IN (41),'RAMAJE',R.Reino) -WHEN 72 THEN IF(M.Id_Article IN (238),'RAMAJE',R.Reino) -WHEN 2 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 122 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 12 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 13 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 14 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 15 THEN 'CYMBIDIUMS & ANTHURIUMS' -WHEN 71 THEN IF(LEFT(Article,2) = 'HC','Flor',R.Reino) -WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),'CYMBIDIUMS & ANTHURIUMS',R.Reino) -WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%','CYMBIDIUMS & ANTHURIUMS',R.Reino) -WHEN 86 THEN 'Flor' -ELSE R.Reino -END as*/ Reino, - /* -CASE A.tipo_id -WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),-1,R.orden) -WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),-1,R.orden) -WHEN 69 THEN IF(M.Id_Article IN (41),-1,R.orden) -WHEN 72 THEN IF(M.Id_Article IN (238),-1,R.orden) -WHEN 2 THEN 0 -WHEN 122 THEN 0 -WHEN 12 THEN 0 -WHEN 13 THEN 0 -WHEN 14 THEN 0 -WHEN 15 THEN 0 -WHEN 71 THEN IF(LEFT(Article,2) = 'HC',1,R.orden) -WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),0,R.orden) -WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%',0,R.orden) -WHEN 86 THEN 1 -ELSE R.orden -END as*/R.orden, - CS.Consignatario, - T.Id_Cliente, - NULL AS Id_Trabajador, - T.Id_Ticket, - T.Fecha, - M.Id_Article, - M.Cantidad, - M.quantity, - M.Cantidad / IF(nz(Gro.Grouping) = 0,1,nz(Gro.Grouping)) as Paquetes, - IF(sis.vHasBeenPrepared, CONCAT(' ----- PREPARADO ----- ', M.Concepte), M.Concepte) as Concepte, - A.Medida, - A.Color, - A.Categoria, - O.Abreviatura as Origen, - T.Localizacion, - CT.CodigoTrabajador as Vendedor, - T.Bultos, - T.Observaciones, - Ag.Agencia Tipo, - NULL AS CodigoTrabajador, - M.OK, - M.Reservado, - A.Tallos, - Gro.Grouping, - IF(`transaction`,right(concat('000000' ,M.Id_Article),6),M.Id_Movimiento) Id_Movimiento, - IF(sis.vHasBeenPrepared,'RES',an.Nicho) as Nicho, - 'PEDIDO ASEGURADO' AS MSG, - T.Id_Ruta, - RT.Id_Vehiculo, - observation_type_id, - group_concat(IF(observation_type_id = 1,text,'') SEPARATOR '') 'sacador', - group_concat(IF(observation_type_id = 2,text,'') SEPARATOR '') 'encajador', - A.Foto, - M.Id_Movimiento movement_id, - lpad(IF(sis.vHasBeenPrepared,99999,ifnull(cooler_path_detail_id, an.Nicho)),5,'0') as path, - M.Descuento,M.Preu, mm.valor as Preparado, mm.original_quantity - , p.`name` producer, - T.warehouse_id, - ST.id as idStowaway, - STP.shipFk as isStowaway, - CS.POBLACION -- JGF 2016-02-16 -FROM - - Tickets T - LEFT JOIN Movimientos M USING(Id_Ticket) - LEFT JOIN (SELECT DISTINCT saleFk, TRUE as vHasBeenPrepared - FROM vn.saleItemShelving sis - JOIN vn.sale s ON s.id = sis.saleFk - WHERE s.ticketFk = idT - AND sis.quantity > 0 - ) sis ON sis.saleFk = M.Id_Movimiento - LEFT JOIN Articles A on A.Id_Article = M.Id_Article - LEFT JOIN Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = T.warehouse_id - LEFT JOIN producer p on p.producer_id = A.producer_id -- JGF 2016-02-16 - LEFT JOIN cooler_path_detail c on left(an.Nicho,3) = pasillo - LEFT JOIN Origen O ON A.id_origen = O.id - LEFT JOIN Clientes C USING(Id_Cliente) - LEFT JOIN Trabajadores CT ON C.Id_Trabajador = CT.Id_Trabajador - INNER JOIN Consignatarios CS ON T.Id_Consigna = CS.Id_Consigna - INNER JOIN Agencias Ag ON Ag.Id_Agencia = T.Id_Agencia - LEFT JOIN ( - SELECT Id_Article, code as barcode - FROM barcodes - GROUP BY Id_Article - ) BC ON BC.Id_Article = A.Id_Article - LEFT JOIN Tipos TP USING(tipo_id) - LEFT JOIN reinos R ON TP.reino_id = R.id - LEFT JOIN Rutas RT USING(Id_Ruta) - LEFT JOIN ticket_observation tobs ON T.Id_Ticket = tobs.Id_ticket - AND (tobs.observation_type_id = 1 or tobs.observation_type_id = 2) - - LEFT JOIN ( - SELECT Id_Article, Grouping - FROM ( - SELECT landing, Id_Article, CASE caja - WHEN 0 THEN 1 - WHEN 2 THEN Packing - ELSE Grouping - END as Grouping - FROM Compres C - JOIN Entradas E USING(Id_Entrada) - JOIN travel TR ON TR.id = travel_id - WHERE warehouse_id = (SELECT warehouse_id FROM Tickets WHERE Id_Ticket = idT) - AND landing between (SELECT FechaInventario FROM tblContadores LIMIT 1) AND (SELECT date(Fecha) FROM Tickets WHERE Id_Ticket = idT) - ORDER BY landing DESC - ) GR1 - GROUP BY Id_Article - - ) Gro ON Gro.Id_Article = M.Id_Article - LEFT JOIN Movimientos_mark mm ON mm.Id_Movimiento = M.Id_Movimiento - LEFT JOIN vn.stowaway ST ON ST.shipFk = idT - LEFT JOIN vn.stowaway STP on STP.id = idT - - WHERE T.Id_Ticket = idT - group by M.Id_Movimiento; +CREATE DEFINER=`root`@`%` PROCEDURE `F5`(IN `idT` BIGINT) +BEGIN +SELECT C.calidad, + LEFT(Article, 4) as Subtipo, + barcode, + 'ASEGURADO' AS asegurado, +/*CASE A.tipo_id +WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),'RAMAJE',R.Reino) +WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),'RAMAJE',R.Reino) +WHEN 69 THEN IF(M.Id_Article IN (41),'RAMAJE',R.Reino) +WHEN 72 THEN IF(M.Id_Article IN (238),'RAMAJE',R.Reino) +WHEN 2 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 122 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 12 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 13 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 14 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 15 THEN 'CYMBIDIUMS & ANTHURIUMS' +WHEN 71 THEN IF(LEFT(Article,2) = 'HC','Flor',R.Reino) +WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),'CYMBIDIUMS & ANTHURIUMS',R.Reino) +WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%','CYMBIDIUMS & ANTHURIUMS',R.Reino) +WHEN 86 THEN 'Flor' +ELSE R.Reino +END as*/ Reino, + /* +CASE A.tipo_id +WHEN 75 THEN IF(M.Id_Article IN (120,2388,20100,16,10,130,104851,1,56,238,104850,104849,2),-1,R.orden) +WHEN 68 THEN IF(M.Id_Article IN (11539,10,14),-1,R.orden) +WHEN 69 THEN IF(M.Id_Article IN (41),-1,R.orden) +WHEN 72 THEN IF(M.Id_Article IN (238),-1,R.orden) +WHEN 2 THEN 0 +WHEN 122 THEN 0 +WHEN 12 THEN 0 +WHEN 13 THEN 0 +WHEN 14 THEN 0 +WHEN 15 THEN 0 +WHEN 71 THEN IF(LEFT(Article,2) = 'HC',1,R.orden) +WHEN 19 THEN IF(LEFT(Article,3) IN ('HEL','GIN'),0,R.orden) +WHEN 70 THEN IF(Article like '%red beauty%' or Article like '%clarinervium%',0,R.orden) +WHEN 86 THEN 1 +ELSE R.orden +END as*/R.orden, + CS.Consignatario, + T.Id_Cliente, + NULL AS Id_Trabajador, + T.Id_Ticket, + T.Fecha, + M.Id_Article, + M.Cantidad, + M.quantity, + M.Cantidad / IF(nz(Gro.Grouping) = 0,1,nz(Gro.Grouping)) as Paquetes, + IF(sis.vHasBeenPrepared, CONCAT(' ----- PREPARADO ----- ', M.Concepte), M.Concepte) as Concepte, + A.Medida, + A.Color, + A.Categoria, + O.Abreviatura as Origen, + T.Localizacion, + CT.CodigoTrabajador as Vendedor, + T.Bultos, + T.Observaciones, + Ag.Agencia Tipo, + NULL AS CodigoTrabajador, + M.OK, + M.Reservado, + A.Tallos, + Gro.Grouping, + IF(`transaction`,right(concat('000000' ,M.Id_Article),6),M.Id_Movimiento) Id_Movimiento, + IF(sis.vHasBeenPrepared,'RES',an.Nicho) as Nicho, + 'PEDIDO ASEGURADO' AS MSG, + T.Id_Ruta, + RT.Id_Vehiculo, + observation_type_id, + group_concat(IF(observation_type_id = 1,text,'') SEPARATOR '') 'sacador', + group_concat(IF(observation_type_id = 2,text,'') SEPARATOR '') 'encajador', + A.Foto, + M.Id_Movimiento movement_id, + lpad(IF(sis.vHasBeenPrepared,99999,ifnull(cooler_path_detail_id, an.Nicho)),5,'0') as path, + M.Descuento,M.Preu, mm.valor as Preparado, mm.original_quantity + , p.`name` producer, + T.warehouse_id, + ST.id as idStowaway, + STP.shipFk as isStowaway, + CS.POBLACION -- JGF 2016-02-16 +FROM + + Tickets T + LEFT JOIN Movimientos M USING(Id_Ticket) + LEFT JOIN (SELECT DISTINCT saleFk, TRUE as vHasBeenPrepared + FROM vn.saleItemShelving sis + JOIN vn.sale s ON s.id = sis.saleFk + WHERE s.ticketFk = idT + AND sis.quantity > 0 + ) sis ON sis.saleFk = M.Id_Movimiento + LEFT JOIN Articles A on A.Id_Article = M.Id_Article + LEFT JOIN Articles_nicho an ON A.Id_Article = an.Id_Article AND an.warehouse_id = T.warehouse_id + LEFT JOIN producer p on p.producer_id = A.producer_id -- JGF 2016-02-16 + LEFT JOIN cooler_path_detail c on left(an.Nicho,3) = pasillo + LEFT JOIN Origen O ON A.id_origen = O.id + LEFT JOIN Clientes C USING(Id_Cliente) + LEFT JOIN Trabajadores CT ON C.Id_Trabajador = CT.Id_Trabajador + INNER JOIN Consignatarios CS ON T.Id_Consigna = CS.Id_Consigna + INNER JOIN Agencias Ag ON Ag.Id_Agencia = T.Id_Agencia + LEFT JOIN ( + SELECT Id_Article, code as barcode + FROM barcodes + GROUP BY Id_Article + ) BC ON BC.Id_Article = A.Id_Article + LEFT JOIN Tipos TP USING(tipo_id) + LEFT JOIN reinos R ON TP.reino_id = R.id + LEFT JOIN Rutas RT USING(Id_Ruta) + LEFT JOIN ticket_observation tobs ON T.Id_Ticket = tobs.Id_ticket + AND (tobs.observation_type_id = 1 or tobs.observation_type_id = 2) + + LEFT JOIN ( + SELECT Id_Article, `Grouping` + FROM ( + SELECT landing, Id_Article, CASE caja + WHEN 0 THEN 1 + WHEN 2 THEN Packing + ELSE `Grouping` + END as `Grouping` + FROM Compres C + JOIN Entradas E USING(Id_Entrada) + JOIN travel TR ON TR.id = travel_id + WHERE warehouse_id = (SELECT warehouse_id FROM Tickets WHERE Id_Ticket = idT) + AND landing between (SELECT FechaInventario FROM tblContadores LIMIT 1) AND (SELECT date(Fecha) FROM Tickets WHERE Id_Ticket = idT) + ORDER BY landing DESC + ) GR1 + GROUP BY Id_Article + + ) Gro ON Gro.Id_Article = M.Id_Article + LEFT JOIN Movimientos_mark mm ON mm.Id_Movimiento = M.Id_Movimiento + LEFT JOIN vn.stowaway ST ON ST.shipFk = idT + LEFT JOIN vn.stowaway STP on STP.id = idT + + WHERE T.Id_Ticket = idT + group by M.Id_Movimiento; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -28838,70 +28921,66 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `item_catalog`( - v_wh INT - ,v_date DATE - ,v_customer INT -) -BEGIN - DECLARE v_cache SMALLINT; - - CALL item_cache (v_cache, 'a', v_wh, v_date); - - DROP TEMPORARY TABLE IF EXISTS item_catalog; - - CREATE TEMPORARY TABLE item_catalog - (KEY (item_id)) - ENGINE = MEMORY - SELECT - b.item_id - ,b.available - ,b.fixed - ,IFNULL(p.PrecioEspecial,( - CASE c.Descuento - WHEN 0 THEN b.rate_0 - WHEN 1 THEN b.rate_1 - WHEN 2 THEN b.rate_2 - WHEN 3 THEN b.rate_3 - ELSE NULL - END - )) AS price - ,be.S1 s1 - ,be.S2 s2 - ,0 discount - ,CASE co.caja WHEN 0 THEN 1 WHEN 2 THEN co.packing ELSE co.grouping END AS grouping - FROM cache_a b - JOIN Clientes c - ON c.Id_cliente = v_customer - JOIN Articles a - ON a.Id_Article = b.item_id - JOIN Tipos t - ON t.tipo_id = a.tipo_id - JOIN reinos r - ON r.id = t.reino_id - JOIN Compres co - ON co.Id_Compra = b.buy_id - LEFT JOIN buy_edi be - ON be.id = co.buy_edi_id - LEFT JOIN PreciosEspeciales p - ON p.Id_Cliente = v_customer AND b.item_id = p.Id_Article - WHERE b.available > 0 AND b.cache_id = v_cache; - -- ON be.compra_id = co.compra_id - -- Cliente Te gustan las flores - - IF NOT v_customer = 3064 - THEN - DELETE c - FROM item_catalog c - JOIN Articles ON item_id = Id_Article - WHERE tipo_id = 105; - END IF; +CREATE DEFINER=`root`@`%` PROCEDURE `item_catalog`(IN `v_wh` INT, IN `v_date` DATE, IN `v_customer` INT) +BEGIN + DECLARE v_cache SMALLINT; + + CALL item_cache (v_cache, 'a', v_wh, v_date); + + DROP TEMPORARY TABLE IF EXISTS item_catalog; + + CREATE TEMPORARY TABLE item_catalog + (KEY (item_id)) + ENGINE = MEMORY + SELECT + b.item_id + ,b.available + ,b.fixed + ,IFNULL(p.PrecioEspecial,( + CASE c.Descuento + WHEN 0 THEN b.rate_0 + WHEN 1 THEN b.rate_1 + WHEN 2 THEN b.rate_2 + WHEN 3 THEN b.rate_3 + ELSE NULL + END + )) AS price + ,be.S1 s1 + ,be.S2 s2 + ,0 discount + ,CASE co.caja WHEN 0 THEN 1 WHEN 2 THEN co.packing ELSE co.grouping END AS `grouping` + FROM cache_a b + JOIN Clientes c + ON c.Id_cliente = v_customer + JOIN Articles a + ON a.Id_Article = b.item_id + JOIN Tipos t + ON t.tipo_id = a.tipo_id + JOIN reinos r + ON r.id = t.reino_id + JOIN Compres co + ON co.Id_Compra = b.buy_id + LEFT JOIN buy_edi be + ON be.id = co.buy_edi_id + LEFT JOIN PreciosEspeciales p + ON p.Id_Cliente = v_customer AND b.item_id = p.Id_Article + WHERE b.available > 0 AND b.cache_id = v_cache; + -- ON be.compra_id = co.compra_id + -- Cliente Te gustan las flores + + IF NOT v_customer = 3064 + THEN + DELETE c + FROM item_catalog c + JOIN Articles ON item_id = Id_Article + WHERE tipo_id = 105; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -31659,10 +31738,12 @@ BEGIN -- Código 100 - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) + INSERT INTO tmp.buffer_problems(Id_Ticket, problem) SELECT DISTINCT tt.Id_Ticket, 'COD 100' FROM tmp.ticket_list tt - JOIN vn.ticketRequest tr on tr.ticketFk = tt.Id_Ticket; + JOIN vn.ticketRequest tr on tr.ticketFk = tt.Id_Ticket + WHERE tr.isOK IS NULL; + /* INSERT INTO tmp.buffer_problems(Id_Ticket, problem) SELECT DISTINCT tt.Id_Ticket, 'COD 100' @@ -39803,87 +39884,87 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ubicator_test`(IN i_wh TINYINT, IN d_fecha DATE,IN filtro VARCHAR(255)) -BEGIN - - - DECLARE date_inv DATE; - - -DROP TEMPORARY TABLE IF EXISTS stock_actual; -DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_ubicator_stock; - - -SELECT FechaInventario INTO date_inv - FROM tblContadores LIMIT 1; - - -CREATE TEMPORARY TABLE stock_actual -SELECT Id_Article article_id,SUM(Cantidad) amount FROM ( - SELECT Id_Article,Cantidad - FROM Compres c - JOIN Entradas e USING(Id_Entrada) - JOIN travel t ON t.id = e.travel_id - WHERE landing BETWEEN date_inv AND d_fecha - AND warehouse_id = i_wh AND NOT Redada - - UNION ALL - - SELECT Id_Article,-Cantidad - FROM Compres c - JOIN Entradas e USING(Id_Entrada) - JOIN travel t ON t.id = e.travel_id - WHERE shipment BETWEEN date_inv AND timestampadd(DAY,-1,d_fecha) - AND warehouse_id_out = i_wh AND NOT Redada - - UNION ALL - - SELECT Id_Article, -Cantidad - FROM Movimientos m - JOIN Tickets t USING(Id_Ticket) - WHERE Fecha BETWEEN date_inv AND timestampadd(DAY,-1,d_fecha) - AND warehouse_id = i_wh - - - -) t GROUP BY article_id; - -/* -SELECT * from stock_actual;*/ - --- TEMPORARY -CALL util.exec (sql_printf(' - CREATE TEMPORARY TABLE IF NOT EXISTS vn2008.tmp_ubicator_stock AS - SELECT A.Id_Article,A.Article, T.Id_Cubo,IF(Z > 0,Z,0) as z,x,y, - CEIL(S.Suma/T.grouping) as etiquetas,A.Medida,A.Nicho - FROM vn2008.Articles A - INNER JOIN - (SELECT article_id, amount as SUMA - FROM vn2008.stock_actual - WHERE amount > 0 - ) as S ON S.article_id = A.Id_Article - LEFT JOIN ( - SELECT * FROM ( - SELECT c.Id_Article item_id, c.Id_Compra id, c.Id_Cubo,c.grouping - FROM vn2008.Compres c INNER JOIN vn2008.Entradas e USING(Id_Entrada) - INNER JOIN vn2008.travel t ON t.id = e.travel_id - WHERE t.landing BETWEEN vn2008.date_inv() AND CURDATE() - AND c.Novincular = FALSE - AND c.Tarifa2 >= 0 AND Id_Cubo IS NOT NULL - ORDER BY 1 = t.warehouse_id DESC, t.landing DESC - ) t1 GROUP BY item_id - ) as T ON T.item_id = A.Id_Article - LEFT JOIN vn2008.Cubos C USING(Id_Cubo) - WHERE %s AND CEIL(S.Suma/T.grouping) > 0',filtro)); - - - +CREATE DEFINER=`root`@`%` PROCEDURE `ubicator_test`(IN `i_wh` TINYINT, IN `d_fecha` DATE, IN `filtro` VARCHAR(255)) +BEGIN + + + DECLARE date_inv DATE; + + +DROP TEMPORARY TABLE IF EXISTS stock_actual; +DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_ubicator_stock; + + +SELECT FechaInventario INTO date_inv + FROM tblContadores LIMIT 1; + + +CREATE TEMPORARY TABLE stock_actual +SELECT Id_Article article_id,SUM(Cantidad) amount FROM ( + SELECT Id_Article,Cantidad + FROM Compres c + JOIN Entradas e USING(Id_Entrada) + JOIN travel t ON t.id = e.travel_id + WHERE landing BETWEEN date_inv AND d_fecha + AND warehouse_id = i_wh AND NOT Redada + + UNION ALL + + SELECT Id_Article,-Cantidad + FROM Compres c + JOIN Entradas e USING(Id_Entrada) + JOIN travel t ON t.id = e.travel_id + WHERE shipment BETWEEN date_inv AND timestampadd(DAY,-1,d_fecha) + AND warehouse_id_out = i_wh AND NOT Redada + + UNION ALL + + SELECT Id_Article, -Cantidad + FROM Movimientos m + JOIN Tickets t USING(Id_Ticket) + WHERE Fecha BETWEEN date_inv AND timestampadd(DAY,-1,d_fecha) + AND warehouse_id = i_wh + + + +) t GROUP BY article_id; + +/* +SELECT * from stock_actual;*/ + +-- TEMPORARY +CALL util.exec (sql_printf(' + CREATE TEMPORARY TABLE IF NOT EXISTS vn2008.tmp_ubicator_stock AS + SELECT A.Id_Article,A.Article, T.Id_Cubo,IF(Z > 0,Z,0) as z,x,y, + CEIL(S.Suma/T.grouping) as etiquetas,A.Medida,A.Nicho + FROM vn2008.Articles A + INNER JOIN + (SELECT article_id, amount as SUMA + FROM vn2008.stock_actual + WHERE amount > 0 + ) as S ON S.article_id = A.Id_Article + LEFT JOIN ( + SELECT * FROM ( + SELECT c.Id_Article item_id, c.Id_Compra id, c.Id_Cubo,c.`grouping` + FROM vn2008.Compres c INNER JOIN vn2008.Entradas e USING(Id_Entrada) + INNER JOIN vn2008.travel t ON t.id = e.travel_id + WHERE t.landing BETWEEN vn2008.date_inv() AND CURDATE() + AND c.Novincular = FALSE + AND c.Tarifa2 >= 0 AND Id_Cubo IS NOT NULL + ORDER BY 1 = t.warehouse_id DESC, t.landing DESC + ) t1 GROUP BY item_id + ) as T ON T.item_id = A.Id_Article + LEFT JOIN vn2008.Cubos C USING(Id_Cubo) + WHERE %s AND CEIL(S.Suma/T.grouping) > 0',filtro)); + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41105,7 +41186,7 @@ CREATE TABLE `autoRadioLogCall` ( PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=276 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -41632,7 +41713,7 @@ CREATE TABLE `clientContact` ( `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4110 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4111 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -41706,7 +41787,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), 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=193436 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=194129 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42146,7 +42227,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=3027 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3030 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 */ ; @@ -42191,7 +42272,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=2476 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=2482 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 */ ; @@ -42418,7 +42499,7 @@ CREATE TABLE `dua` ( 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=3668 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3678 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42459,7 +42540,7 @@ CREATE TABLE `duaIntrastat` ( 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=5596 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=5610 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42479,7 +42560,7 @@ CREATE TABLE `duaInvoiceIn` ( 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=4571 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Facturas asociadas a la declaración aduanera, básicamente la del agente transitario'; +) ENGINE=InnoDB AUTO_INCREMENT=4578 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 */; -- @@ -42504,7 +42585,7 @@ CREATE TABLE `duaTax` ( 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=4077 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4096 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42600,7 +42681,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=115260 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=116120 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42613,6 +42694,7 @@ DROP TABLE IF EXISTS `envialiaAgency`; CREATE TABLE `envialiaAgency` ( `id` varchar(6) COLLATE utf8_unicode_ci NOT NULL, `route` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `agencyName` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -42633,7 +42715,7 @@ CREATE TABLE `envialiaCity` ( PRIMARY KEY (`id`), KEY `agencyFk` (`agencyFk`), KEY `postalCode` (`postalCode`) -) ENGINE=InnoDB AUTO_INCREMENT=568028 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=818150 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43045,7 +43127,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5873 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43316,7 +43398,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=97995 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=98057 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 */; -- @@ -43359,7 +43441,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=1036811 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1036853 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43410,7 +43492,8 @@ SET character_set_client = utf8; 1 AS `tag10`, 1 AS `value10`, 1 AS `minimum`, - 1 AS `upToDown`*/; + 1 AS `upToDown`, + 1 AS `lastPrice`*/; SET character_set_client = @saved_cs_client; -- @@ -43597,7 +43680,7 @@ CREATE TABLE `itemPlacementSupply` ( CONSTRAINT `itemPlacementSupply_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk3` FOREIGN KEY (`repoUserFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=304 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=473 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43621,7 +43704,8 @@ SET character_set_client = utf8; 1 AS `subName`, 1 AS `size`, 1 AS `workerCode`, - 1 AS `repoCode`*/; + 1 AS `repoCode`, + 1 AS `parking`*/; SET character_set_client = @saved_cs_client; -- @@ -43668,7 +43752,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=56267 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; +) ENGINE=InnoDB AUTO_INCREMENT=56846 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla utilizada para localizar los artículos dentro de los carros. Usado para la gestión del almacén en el altillo '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43742,7 +43826,7 @@ CREATE TABLE `itemShelvingPlacementSupply` ( KEY `itemShelvingPlacementSupply_fk3_idx` (`userFk`), CONSTRAINT `itemShelvingPlacementSupply_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB AUTO_INCREMENT=213 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43789,7 +43873,7 @@ CREATE TABLE `itemShelvingSale` ( CONSTRAINT `itemShelvingSale_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk2` FOREIGN KEY (`saleFk`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle del producto que se retira de los carros, relacionando la linea de movimiento correspondiente'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -43873,7 +43957,7 @@ CREATE TABLE `itemTag` ( KEY `priorityItem` (`priority`,`itemFk`), KEY `value` (`value`), CONSTRAINT `itemFK` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1056325 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1069550 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 */ ; @@ -44001,7 +44085,7 @@ 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=634049 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=638708 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 */; -- @@ -44310,7 +44394,7 @@ CREATE TABLE `medicalReview` ( KEY `frgnkWorker_idx` (`workerFk`), CONSTRAINT `frgcenter` FOREIGN KEY (`centerFk`) REFERENCES `medicalCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnkWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=168 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44331,7 +44415,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1760701 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1764066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44353,7 +44437,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=1924670 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1928245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -44587,7 +44671,7 @@ CREATE TABLE `parking` ( UNIQUE KEY `code_UNIQUE` (`code`), KEY `parking_fk1_idx` (`sectorFk`), CONSTRAINT `parking_fk1` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=24703 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=24718 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -45365,7 +45449,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=782063 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=786536 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45470,7 +45554,7 @@ CREATE TABLE `saleItemShelving` ( `ubication` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `saleItemShelving_fk1_idx` (`itemShelvingFk`) -) ENGINE=InnoDB AUTO_INCREMENT=25393 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25629 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45603,7 +45687,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=121987 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=122260 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45768,7 +45852,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=551680 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=558024 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -45831,6 +45915,26 @@ SET character_set_client = utf8; 1 AS `bankEntityFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `supplierPackaging` +-- + +DROP TABLE IF EXISTS `supplierPackaging`; +/*!50001 DROP VIEW IF EXISTS `supplierPackaging`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `supplierPackaging` AS SELECT + 1 AS `supplierFk`, + 1 AS `itemFk`, + 1 AS `longName`, + 1 AS `supplier`, + 1 AS `entryFk`, + 1 AS `landed`, + 1 AS `in`, + 1 AS `out`, + 1 AS `almacen`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `tag` -- @@ -46060,7 +46164,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_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4598889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4637235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46132,7 +46236,7 @@ CREATE TABLE `ticketPackaging` ( 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, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=53567 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=53851 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 */ ; @@ -46457,7 +46561,7 @@ CREATE TABLE `trainingCourse` ( CONSTRAINT `frgnCenter` FOREIGN KEY (`centerFk`) REFERENCES `trainingCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnTrainingCourseType` FOREIGN KEY (`trainingCourseTypeFk`) REFERENCES `trainingCourseType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=242 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB AUTO_INCREMENT=243 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46708,7 +46812,9 @@ SET character_set_client = utf8; 1 AS `bossFk`, 1 AS `photo`, 1 AS `fi`, - 1 AS `fiDueDate`*/; + 1 AS `fiDueDate`, + 1 AS `code`, + 1 AS `lastName`*/; SET character_set_client = @saved_cs_client; -- @@ -46780,7 +46886,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=9274 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46830,7 +46936,7 @@ CREATE TABLE `workerJourney` ( UNIQUE KEY `userFk_UNIQUE` (`userFk`,`dated`), KEY `fk_workerJourney_user_idx` (`userFk`), CONSTRAINT `fk_workerJourney_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=19389293 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20228093 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46852,7 +46958,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=8514 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8634 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -46915,7 +47021,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2069015 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=2109507 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -47638,7 +47744,7 @@ CREATE DEFINER=`root`@`%` FUNCTION `clientTaxArea`(vClientId INT, vCompanyId INT BEGIN /** * Devuelve el area de un cliente, - * intracomunitario, extracomunitario y nacional. + * intracomunitario, extracomunitario o nacional. * * @param vClient Id del cliente * @param vCompanyFk Compañia desde la que se factura @@ -48224,15 +48330,15 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8 COLLATE utf8_unicode_ci +CREATE DEFINER=`root`@`%` FUNCTION `getWorkerCode`() RETURNS varchar(3) CHARSET utf8 BEGIN - DECLARE vUserCode VARCHAR(3); - - SELECT workerCode INTO vUserCode - FROM worker - WHERE userFk = account.userGetId(); - - RETURN vUserCode; +DECLARE vUserCode VARCHAR(3) CHARSET utf8 COLLATE utf8_unicode_ci; + +SELECT workerCode INTO vUserCode +FROM worker +WHERE userFk = account.userGetId(); + +RETURN vUserCode; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49621,7 +49727,7 @@ BEGIN `s`.`quantity` AS `quantity`, `s`.`concept` AS `concept`, `i`.`size` AS `size`, - `w`.`workerCode` AS `workerCode`, + `w`.`code` AS `workerCode`, `ip`.`code` AS `Nicho`, `ip`.`reserve` AS `Reserva`, `st`.`name` AS `Estado`, @@ -49849,7 +49955,7 @@ BEGIN LEFT JOIN vn.itemShelving it ON it.shelvingFk = s.code SET it.visible = 0 WHERE it.shelvingFk IS NULL; - + CALL vn.ticketPackagingRecovery; INSERT INTO vn.dailyTaskLog(state) VALUES('clean END'); @@ -51808,6 +51914,34 @@ 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 `getDayExpeditions` */; +/*!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 `getDayExpeditions`() +BEGIN + + SELECT + e.expeditions_id as expeditionFk, + date_format(e.odbc_date,'%Y-%m-%d') as expeditionDate, + e.ticket_id as ticketFk, + t.routeFk as routeFk + FROM vn2008.expeditions e + INNER JOIN vn.ticket t ON t.id = e.ticket_id + WHERE DATE(odbc_date) = 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 */ ; /*!50003 DROP PROCEDURE IF EXISTS `getDeliveryWorkers` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54521,7 +54655,7 @@ BEGIN FROM vn.itemPlacementSupplyList ipsl WHERE Saldo > 0 AND (repoUserFk is NULL OR repoUserFk = getUser()) - ORDER BY priority DESC, created + ORDER BY priority ASC, parking DESC, created LIMIT 1; UPDATE vn.itemPlacementSupply @@ -54815,22 +54949,22 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemSearchShelving`(vShelvingFk VARCHAR(3)) -BEGIN - - SELECT p.column as col , p.row - FROM vn.shelving s - INNER JOIN parking p - ON s.parkingFk = p.id - WHERE s.code = vShelvingFk; - - +CREATE DEFINER=`root`@`%` PROCEDURE `itemSearchShelving`(IN `vShelvingFk` VARCHAR(3)) +BEGIN + + SELECT p.column as col , p.`row` + FROM vn.shelving s + INNER JOIN parking p + ON s.parkingFk = p.id + WHERE s.code = vShelvingFk; + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -54974,25 +55108,25 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingList`(vShelvingFk VARCHAR(8)) -BEGIN - - /*MODIFICADA POR QUIQUE: OBTENEMOS DEEP Y PARKING*/ - SELECT ish.itemFk as item, - IFNULL(i.longName, CONCAT(i.name, ' ',i.size)) as description, - ish.visible as visible, - ceil(ish.visible/ish.packing) as stickers, - ish.packing as packing, - p.`column` as col, - p.row as row, - ish.id, - s.priority - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - INNER JOIN vn.shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci - LEFT JOIN vn.parking p ON s.parkingFk = p.id - WHERE ish.shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci; - +CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingList`(IN `vShelvingFk` VARCHAR(8)) +BEGIN + + /*MODIFICADA POR QUIQUE: OBTENEMOS DEEP Y PARKING*/ + SELECT ish.itemFk as item, + IFNULL(i.longName, CONCAT(i.name, ' ',i.size)) as description, + ish.visible as visible, + ceil(ish.visible/ish.packing) as stickers, + ish.packing as packing, + p.`column` as col, + p.`row` as `row`, + ish.id, + s.priority + FROM vn.itemShelving ish + JOIN vn.item i ON i.id = ish.itemFk + INNER JOIN vn.shelving s ON vShelvingFk = s.code COLLATE utf8_unicode_ci + LEFT JOIN vn.parking p ON s.parkingFk = p.id + WHERE ish.shelvingFk COLLATE utf8_unicode_ci =vShelvingFk COLLATE utf8_unicode_ci; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55142,8 +55276,10 @@ BEGIN getUser()); UPDATE vn.itemShelving - SET quantity = quantity - vQuantity, visible = visible - vQuantity, available = available - vQuantity - WHERE id = vItemShelvingFk; + SET quantity = quantity - vQuantity, + visible = visible - vQuantity, + available = available - vQuantity + WHERE id = vItemShelvingFk; END ;; @@ -55599,6 +55735,12 @@ BEGIN saleFk, vQuantity, getUser()); + + UPDATE vn.itemShelving + SET quantity = quantity - vQuantity, + visible = visible - vQuantity, + available = available - vQuantity + WHERE id = vItemShelvingFk; END ;; DELIMITER ; @@ -57469,84 +57611,84 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake`(vTicketFk INT, vSectorFk INT) -BEGIN - - SET @rest:= CAST(0 AS DECIMAL(10,0)); - SET @saleFk := CAST(0 AS DECIMAL(10,0)); - SET @reserved := CAST(0 AS DECIMAL(10,0)); - - UPDATE vn.itemShelving ish - JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id - JOIN sale s ON s.id = sis.saleFk - SET ish.visible = sis.quantity + ish.visible, - ish.available = sis.quantity + ish.visible - WHERE s.ticketFk = vTicketFk; - - DELETE sis.* - FROM saleItemShelving sis - JOIN sale s ON s.id = sis.saleFk - WHERE s.ticketFk = vTicketFk; - - INSERT INTO saleItemShelving( saleFk, - itemShelvingFk, - quantity, - ubication) - SELECT saleFk, - itemShelvingFk, - CAST(Reserved as DECIMAL(10,0)) as Reserved, - ubication - FROM - (SELECT saleFk, - itemShelvingFk, - ubication, - @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta, - @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved, - @rest := @rest - @reserved, - @saleFk := saleFk - FROM - ( SELECT s.id as saleFk, - ish.created, - ish.id as itemShelvingFk, - ish.available, - s.quantity, - ish.packing, - CONCAT(p.`column`, '-',p.row,': ', sh.code ) as ubication - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk - JOIN vn.parking p ON p.sectorFk = sc.id - JOIN vn.shelving sh ON sh.parkingFk = p.id - JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk - WHERE t.id = vTicketFk - AND sc.id = vSectorFk - AND s.quantity MOD ish.packing = 0 - AND s.quantity >= ish.packing - ORDER BY s.id, - sh.priority DESC, - ish.packing DESC, - ish.created - ) sub - ) sub2 - WHERE Reserved > 0; - - UPDATE vn.itemShelving ish - JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id - JOIN vn.sale s ON s.id = sis.saleFk - SET ish.available = ish.visible - sis.quantity, - ish.visible = ish.visible - sis.quantity - WHERE s.ticketFk = vTicketFk - AND s.isPicked = FALSE; - - CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE); - - +CREATE DEFINER=`root`@`%` PROCEDURE `saleItemShelvingMake`(IN `vTicketFk` INT, IN `vSectorFk` INT) +BEGIN + + SET @rest:= CAST(0 AS DECIMAL(10,0)); + SET @saleFk := CAST(0 AS DECIMAL(10,0)); + SET @reserved := CAST(0 AS DECIMAL(10,0)); + + UPDATE vn.itemShelving ish + JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id + JOIN sale s ON s.id = sis.saleFk + SET ish.visible = sis.quantity + ish.visible, + ish.available = sis.quantity + ish.visible + WHERE s.ticketFk = vTicketFk; + + DELETE sis.* + FROM saleItemShelving sis + JOIN sale s ON s.id = sis.saleFk + WHERE s.ticketFk = vTicketFk; + + INSERT INTO saleItemShelving( saleFk, + itemShelvingFk, + quantity, + ubication) + SELECT saleFk, + itemShelvingFk, + CAST(Reserved as DECIMAL(10,0)) as Reserved, + ubication + FROM + (SELECT saleFk, + itemShelvingFk, + ubication, + @rest := IF(@saleFk = saleFk, @rest, quantity) as Falta, + @reserved := IF(available < @rest, available, IF(@rest < packing,0,@rest)) as Reserved, + @rest := @rest - @reserved, + @saleFk := saleFk + FROM + ( SELECT s.id as saleFk, + ish.created, + ish.id as itemShelvingFk, + ish.available, + s.quantity, + ish.packing, + CONCAT(p.`column`, '-',p.`row`,': ', sh.code ) as ubication + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.sector sc ON sc.warehouseFk = t.warehouseFk + JOIN vn.parking p ON p.sectorFk = sc.id + JOIN vn.shelving sh ON sh.parkingFk = p.id + JOIN vn.itemShelving ish ON ish.shelvingFk = sh.code AND ish.itemFk = s.itemFk + WHERE t.id = vTicketFk + AND sc.id = vSectorFk + AND s.quantity MOD ish.packing = 0 + AND s.quantity >= ish.packing + ORDER BY s.id, + sh.priority DESC, + ish.packing DESC, + ish.created + ) sub + ) sub2 + WHERE Reserved > 0; + + UPDATE vn.itemShelving ish + JOIN vn.saleItemShelving sis ON sis.itemShelvingFk = ish.id + JOIN vn.sale s ON s.id = sis.saleFk + SET ish.available = ish.visible - sis.quantity, + ish.visible = ish.visible - sis.quantity + WHERE s.ticketFk = vTicketFk + AND s.isPicked = FALSE; + + CALL vn.saleItemShelvingIsPicked(vTicketFk, TRUE); + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57939,57 +58081,62 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `shelvingPark`(vShelvingFk VARCHAR(8), vParkingCode VARCHAR(8)) -BEGIN - - DECLARE vParkingFk INT DEFAULT 0; - DECLARE idParking INT; - DECLARE vColumn VARCHAR(3); +CREATE DEFINER=`root`@`%` PROCEDURE `shelvingPark`(IN `vShelvingFk` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) +BEGIN + + DECLARE vParkingFk INT DEFAULT 0; + DECLARE idParking INT; + DECLARE vColumn VARCHAR(3); DECLARE vRow VARCHAR(2); + DECLARE vReturn VARCHAR(50); + + /*ELIMINAR ESPACIOS*/ + SET vParkingCode = replace(vParkingCode,' ','') ; + + /*SINO EXISTE EL PARKING LO CREAMOS*/ + SELECT id INTO idParking + FROM vn.parking + WHERE code = vParkingCode COLLATE utf8_unicode_ci; + + IF idParking IS NULL THEN + IF LOCATE('-',vParkingCode) = 4 THEN + SELECT SUBSTRING_INDEX(vParkingCode,'-',1) INTO vColumn; + SELECT SUBSTRING_INDEX(vParkingCode,'-',-1) INTO vRow; + INSERT INTO vn.parking(`column`,`row`,code,sectorFk) + VALUES(vColumn,vRow,vParkingCode,2); + END IF; + END IF; + /*FIN INSERTAR PARKING*/ + + + SELECT id INTO vParkingFk + FROM vn.parking + WHERE `code` = vParkingCode COLLATE utf8_unicode_ci; + + IF length(vShelvingFk) > 6 THEN - /*ELIMINAR ESPACIOS*/ - SET vParkingCode = replace(vParkingCode,' ','') ; - - /*SINO EXISTE EL PARKING LO CREAMOS*/ - SELECT id INTO idParking - FROM vn.parking - WHERE code = vParkingCode COLLATE utf8_unicode_ci; - - IF idParking IS NULL THEN - IF LOCATE('-',vParkingCode) = 4 THEN - SELECT SUBSTRING_INDEX(vParkingCode,'-',1) INTO vColumn; - SELECT SUBSTRING_INDEX(vParkingCode,'-',-1) INTO vRow; - INSERT INTO vn.parking(`column`,row,code,sectorFk) - VALUES(vColumn,vRow,vParkingCode,2); - END IF; - END IF; - /*FIN INSERTAR PARKING*/ - - - SELECT id INTO vParkingFk - FROM vn.parking - WHERE `code` = vParkingCode COLLATE utf8_unicode_ci; - - IF length(vShelvingFk) > 6 THEN - - REPLACE vn.shelving(code, parkingFk, isPrinted, parked) + + REPLACE vn.shelving(code, parkingFk, isPrinted, parked) VALUES(vShelvingFk, vParkingFk, TRUE, NOW()); - SELECT TRUE; - - ELSE + CALL vn.ticketStatePrevious(vShelvingFk); + + ELSE - UPDATE vn.shelving - SET parkingFk = vParkingFk, parked = NOW() + + UPDATE vn.shelving + SET parkingFk = vParkingFk, parked = NOW() WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - SELECT (COUNT(*) > 0) AS IsUpdated + + SELECT (COUNT(*) > 0) AS IsUpdated FROM vn.shelving WHERE parkingFk = vParkingFk - AND `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - + AND `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60032,47 +60179,49 @@ BEGIN WHERE clientFk = vClientId AND isDefaultAddress; END IF; - INSERT INTO vn2008.Tickets ( - Id_Cliente, - Fecha, - Id_Consigna, - Id_Agencia, - Alias, - warehouse_id, - Id_Ruta, - empresa_id, - landing - ) - SELECT - vClientId, - vShipped, - a.id, - IF(vAgencyType, vAgencyType, a.agencyModeFk), - a.nickname, - vWarehouseId, - IF(vRouteFk,vRouteFk,NULL), - vCompanyFk, - vlanded - FROM address a - JOIN agencyMode am ON am.id = a.agencyModeFk - WHERE a.id = vAddressFk; + INSERT INTO vn2008.Tickets ( + Id_Cliente, + Fecha, + Id_Consigna, + Id_Agencia, + Alias, + warehouse_id, + Id_Ruta, + empresa_id, + landing + ) + SELECT + vClientId, + vShipped, + a.id, + IF(vAgencyType, vAgencyType, a.agencyModeFk), + a.nickname, + vWarehouseId, + IF(vRouteFk,vRouteFk,NULL), + vCompanyFk, + vlanded + FROM address a + JOIN agencyMode am ON am.id = a.agencyModeFk + WHERE a.id = vAddressFk; - SET vNewTicket = LAST_INSERT_ID(); + SET vNewTicket = LAST_INSERT_ID(); - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vNewTicket, ao.observationTypeFk, ao.description - FROM addressObservation ao - JOIN address a ON a.id = ao.addressFk - WHERE a.id = vAddressFk; + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN address a ON a.id = ao.addressFk + WHERE a.id = vAddressFk; - CALL logAddWithUser(vNewTicket, vUserId, 'insert', 'ticket', CONCAT('Ha creado el ticket', ' ', vNewTicket)); + -- CALL logAddWithUser(vNewTicket, vUserId, 'insert', 'ticket', CONCAT('Ha creado el ticket', ' ', vNewTicket)); + INSERT INTO vn.ticketLog + SET originFk = vNewTicket, userFk = vUserId, `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket); - IF (SELECT isCreatedAsServed FROM vn.client WHERE id = vClientId ) <> FALSE THEN - INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) - SELECT id, vNewTicket, getWorker() - FROM state - WHERE `code` = 'DELIVERED'; - END IF; + IF (SELECT isCreatedAsServed FROM vn.client WHERE id = vClientId ) <> FALSE THEN + INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador) + SELECT id, vNewTicket, getWorker() + FROM state + WHERE `code` = 'DELIVERED'; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60126,7 +60275,7 @@ 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 = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetProblems`() BEGIN @@ -60199,7 +60348,8 @@ BEGIN INSERT INTO tmp.ticketProblems(ticketFk, problem) SELECT DISTINCT tl.ticketFk, 'Code 100' FROM tmp.ticketList tl - JOIN vn.ticketRequest tr on tr.ticketFk = tl.ticketFk; + JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk + WHERE tr.isOK IS NULL; /* INSERT INTO tmp.ticketProblems(ticketFk, problem) SELECT DISTINCT tl.ticketFk, 'Code 100' @@ -60746,13 +60896,13 @@ OPEN rs; FETCH rs INTO vTicketFk, vClientFk, vWarehouseFk, vShipped, vAddressFk,vCompanyFk; WHILE NOT done DO - + CALL vn.ticketCreate(vClientFk,vShipped,vWarehouseFk,vCompanyFk,vAddressFk,vAgenciaEmbalajesFk,NULL,vShipped,vTicketNewFk); - + UPDATE vn.ticketPackaging set ticketFk = vTicketNewFk WHERE ticketFk = vTicketFk; - + CALL vn.ticketStateUpdate(vTicketNewFk, 'DELIVERED'); - + INSERT INTO vn.sale(ticketFk, itemFk, concept) VALUES(vTicketNewFk,90,CONCAT('Embalajes ',vTicketFk)); FETCH rs INTO vTicketFk, vClientFk, vWarehouseFk, vShipped, vAddressFk,vCompanyFk; @@ -60819,6 +60969,7 @@ BEGIN DECLARE vControlFk INT; DECLARE vLastWorkerFk INT; + DECLARE vStateId INT; SELECT MAX(inter_id) INTO vControlFk FROM vncontrol.inter @@ -60841,16 +60992,22 @@ BEGIN LIMIT 1; INSERT INTO vncontrol.inter(state_id, Id_Ticket, Id_Trabajador, Id_Supervisor) - SELECT state_id , Id_Ticket, vLastWorkerFk, vn.getWorker() + SELECT state_id, Id_Ticket, vLastWorkerFk, vn.getWorker() FROM vncontrol.inter WHERE inter_id = vControlFk; + + SELECT state_id INTO vStateId + FROM vncontrol.inter + WHERE inter_id = vControlFk; + END IF; - SELECT `name` - FROM vn.state - WHERE id = (SELECT state_id - FROM vncontrol.inter - WHERE inter_id = vControlFk); + DELETE FROM vn2008.Movimientos_mark + WHERE Id_Movimiento IN (SELECT Id_Movimiento FROM vn2008.Movimientos WHERE Id_Ticket = vTicketFk) + AND valor <> 1 + AND stateFk = 26; + + SELECT TRUE AS IsUpdated; END ;; DELIMITER ; @@ -61359,7 +61516,7 @@ BEGIN * */ - INSERT INTO worker (workerCode, firstName, name, fi, userFk, bossFk) + INSERT INTO vn2008.Trabajadores(CodigoTrabajador, Nombre, Apellidos, dni, user_id, boss) VALUES (vWorkerCode, vFirstname, vSurnames, vFi, vUserFk, vBossFk); END ;; DELIMITER ; @@ -62459,7 +62616,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=430639 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=432480 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62560,7 +62717,7 @@ CREATE TABLE `deliveryInformation` ( KEY `fgbSupplyResponse_idx2` (`FirstOrderDateTime`), KEY `fgbSupplyResponse_idx3` (`LatestOrderDateTime`), CONSTRAINT `fgbSupplyResponse` FOREIGN KEY (`supplyResponseID`) REFERENCES `supplyResponse` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15020505 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15212514 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62863,7 +63020,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=453393 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=455151 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63086,7 +63243,7 @@ CREATE TABLE `supplyResponse` ( `MarketFormCode` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '"002" Standard Sales\n"005" Catalogue (optional)\n"001" Committed (optional)\n"003" Buffer (optional, Clock Pre Sales) ', PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`) -) ENGINE=InnoDB AUTO_INCREMENT=4537930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4629106 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63300,165 +63457,165 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ediLoad`(vEdi INT) -BEGIN - DECLARE vRef INT; - DECLARE vBuy INT; - DECLARE vItem INT; - DECLARE vQty INT; - DECLARE vPackage INT; - DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; - - -- Carga los datos necesarios del EKT - - SELECT ref, qty, package INTO vRef, vQty, vPackage - FROM vn2008.buy_edi e - LEFT JOIN item i ON e.ref = i.id - WHERE e.id = vEdi; - - -- Inserta el cubo si no existe - - IF vPackage = 800 - THEN - SET vPackage = 800 + vQty; - - INSERT IGNORE INTO vn2008.Cubos SET - Id_Cubo = vPackage, - x = 7200 / vQty, - y = 1; - ELSE - INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) - SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) - FROM bucket WHERE bucket_id = vPackage; - - IF ROW_COUNT() > 0 - THEN - INSERT INTO vn2008.mail SET - `subject` = 'Cubo añadido', - `text` = CONCAT('Se ha añadido el cubo: ', vPackage), - `to` = 'ekt@verdnatura.es'; - END IF; - END IF; - - -- Intenta obtener el artículo en base a los atributos holandeses - - INSERT IGNORE INTO item_track SET - item_id = vRef; - - SELECT c.Id_Compra, c.Id_Article INTO vBuy, vItem - FROM vn2008.buy_edi e - JOIN item_track t ON t.item_id = e.ref - LEFT JOIN vn2008.buy_edi l ON l.ref = e.ref - LEFT JOIN vn2008.Compres c ON c.buy_edi_id = l.id - JOIN vn2008.config cfg - WHERE e.id = vEdi - AND l.id != vEdi - AND c.Id_Article != cfg.generic_item - AND IF(t.s1, l.s1 = e.s1, TRUE) - AND IF(t.s2, l.s2 = e.s2, TRUE) - AND IF(t.s3, l.s3 = e.s3, TRUE) - AND IF(t.s4, l.s4 = e.s4, TRUE) - AND IF(t.s5, l.s5 = e.s5, TRUE) - AND IF(t.s6, l.s6 = e.s6, TRUE) - AND IF(t.kop, l.kop = e.kop, TRUE) - AND IF(t.pac, l.pac = e.pac, TRUE) - AND IF(t.cat, l.cat = e.cat, TRUE) - AND IF(t.ori, l.ori = e.ori, TRUE) - AND IF(t.pro, l.pro = e.pro, TRUE) - AND IF(t.sub, l.sub = e.sub, TRUE) - AND IF(t.package, l.package = e.package, TRUE) - AND c.Id_Article < 170000 - ORDER BY l.now DESC, c.Id_Compra ASC LIMIT 1; - - -- Determina si el articulo se vende por lotes - - IF vItem - THEN - SELECT COUNT(*) > 0 INTO vIsLot - FROM vn2008.Articles a - LEFT JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - WHERE a.Id_Article = vItem - AND t.`transaction`; - - -- Si el articulo se vende por lotes se inserta un nuevo artículo - - IF vIsLot - THEN - INSERT INTO vn2008.Articles ( - Article - ,Medida - ,Categoria - ,Id_Origen - ,iva_group_id - ,Foto - ,Color - ,Codintrastat - ,tipo_id - ,Tallos - ) - SELECT - i.`name` - ,IFNULL(e.s1, e.pac) - ,e.cat - ,IFNULL(o.id, 17) - ,IFNULL(a.iva_group_id, 1) - ,a.Foto - ,a.Color - ,a.Codintrastat - ,IFNULL(a.tipo_id, 10) - ,IF(a.tipo_id = 15, 0, 1) - FROM vn2008.buy_edi e - LEFT JOIN item i ON i.id = e.ref - LEFT JOIN vn2008.Origen o ON o.Abreviatura = e.ori - LEFT JOIN vn2008.Articles a ON a.Id_Article = vItem - WHERE e.id = vEdi; - - SET vItem = LAST_INSERT_ID(); - END IF; - END IF; - - -- Inserta la compra asociada al EKT - - INSERT INTO vn2008.Compres - ( - Id_Entrada - ,buy_edi_id - ,Costefijo - ,Id_Article - ,grouping - ,caja - ,Packing - ,Cantidad - ,Productor - ,Etiquetas - ,Id_Cubo - ) - SELECT - cfg.edi_entry - ,vEdi - ,(@t := IF(a.Tallos, a.Tallos, 1)) * e.pri - ,IFNULL(vItem, cfg.generic_item) - ,IFNULL(c.grouping, e.pac) - ,vForceToPacking - ,@pac := e.pac / @t - ,@pac * e.qty - ,s.company_name - ,e.qty - ,IFNULL(c.Id_Cubo, e.package) - FROM vn2008.buy_edi e - LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy - LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article - LEFT JOIN supplier s ON e.pro = s.supplier_id - JOIN vn2008.config cfg - WHERE e.id = vEdi - LIMIT 1; +CREATE DEFINER=`root`@`%` PROCEDURE `ediLoad`(IN `vEdi` INT) +BEGIN + DECLARE vRef INT; + DECLARE vBuy INT; + DECLARE vItem INT; + DECLARE vQty INT; + DECLARE vPackage INT; + DECLARE vIsLot BOOLEAN; + DECLARE vForceToPacking INT DEFAULT 2; + + -- Carga los datos necesarios del EKT + + SELECT ref, qty, package INTO vRef, vQty, vPackage + FROM vn2008.buy_edi e + LEFT JOIN item i ON e.ref = i.id + WHERE e.id = vEdi; + + -- Inserta el cubo si no existe + + IF vPackage = 800 + THEN + SET vPackage = 800 + vQty; + + INSERT IGNORE INTO vn2008.Cubos SET + Id_Cubo = vPackage, + x = 7200 / vQty, + y = 1; + ELSE + INSERT IGNORE INTO vn2008.Cubos (Id_Cubo, X, Y, Z) + SELECT bucket_id, ROUND(x_size/10), ROUND(y_size/10), ROUND(z_size/10) + FROM bucket WHERE bucket_id = vPackage; + + IF ROW_COUNT() > 0 + THEN + INSERT INTO vn2008.mail SET + `subject` = 'Cubo añadido', + `text` = CONCAT('Se ha añadido el cubo: ', vPackage), + `to` = 'ekt@verdnatura.es'; + END IF; + END IF; + + -- Intenta obtener el artículo en base a los atributos holandeses + + INSERT IGNORE INTO item_track SET + item_id = vRef; + + SELECT c.Id_Compra, c.Id_Article INTO vBuy, vItem + FROM vn2008.buy_edi e + JOIN item_track t ON t.item_id = e.ref + LEFT JOIN vn2008.buy_edi l ON l.ref = e.ref + LEFT JOIN vn2008.Compres c ON c.buy_edi_id = l.id + JOIN vn2008.config cfg + WHERE e.id = vEdi + AND l.id != vEdi + AND c.Id_Article != cfg.generic_item + AND IF(t.s1, l.s1 = e.s1, TRUE) + AND IF(t.s2, l.s2 = e.s2, TRUE) + AND IF(t.s3, l.s3 = e.s3, TRUE) + AND IF(t.s4, l.s4 = e.s4, TRUE) + AND IF(t.s5, l.s5 = e.s5, TRUE) + AND IF(t.s6, l.s6 = e.s6, TRUE) + AND IF(t.kop, l.kop = e.kop, TRUE) + AND IF(t.pac, l.pac = e.pac, TRUE) + AND IF(t.cat, l.cat = e.cat, TRUE) + AND IF(t.ori, l.ori = e.ori, TRUE) + AND IF(t.pro, l.pro = e.pro, TRUE) + AND IF(t.sub, l.sub = e.sub, TRUE) + AND IF(t.package, l.package = e.package, TRUE) + AND c.Id_Article < 170000 + ORDER BY l.now DESC, c.Id_Compra ASC LIMIT 1; + + -- Determina si el articulo se vende por lotes + + IF vItem + THEN + SELECT COUNT(*) > 0 INTO vIsLot + FROM vn2008.Articles a + LEFT JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id + WHERE a.Id_Article = vItem + AND t.`transaction`; + + -- Si el articulo se vende por lotes se inserta un nuevo artículo + + IF vIsLot + THEN + INSERT INTO vn2008.Articles ( + Article + ,Medida + ,Categoria + ,Id_Origen + ,iva_group_id + ,Foto + ,Color + ,Codintrastat + ,tipo_id + ,Tallos + ) + SELECT + i.`name` + ,IFNULL(e.s1, e.pac) + ,e.cat + ,IFNULL(o.id, 17) + ,IFNULL(a.iva_group_id, 1) + ,a.Foto + ,a.Color + ,a.Codintrastat + ,IFNULL(a.tipo_id, 10) + ,IF(a.tipo_id = 15, 0, 1) + FROM vn2008.buy_edi e + LEFT JOIN item i ON i.id = e.ref + LEFT JOIN vn2008.Origen o ON o.Abreviatura = e.ori + LEFT JOIN vn2008.Articles a ON a.Id_Article = vItem + WHERE e.id = vEdi; + + SET vItem = LAST_INSERT_ID(); + END IF; + END IF; + + -- Inserta la compra asociada al EKT + + INSERT INTO vn2008.Compres + ( + Id_Entrada + ,buy_edi_id + ,Costefijo + ,Id_Article + ,`grouping` + ,caja + ,Packing + ,Cantidad + ,Productor + ,Etiquetas + ,Id_Cubo + ) + SELECT + cfg.edi_entry + ,vEdi + ,(@t := IF(a.Tallos, a.Tallos, 1)) * e.pri + ,IFNULL(vItem, cfg.generic_item) + ,IFNULL(c.grouping, e.pac) + ,vForceToPacking + ,@pac := e.pac / @t + ,@pac * e.qty + ,s.company_name + ,e.qty + ,IFNULL(c.Id_Cubo, e.package) + FROM vn2008.buy_edi e + LEFT JOIN vn2008.Compres c ON c.Id_Compra = vBuy + LEFT JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article + LEFT JOIN supplier s ON e.pro = s.supplier_id + JOIN vn2008.config cfg + WHERE e.id = vEdi + LIMIT 1; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63629,8 +63786,8 @@ CREATE TABLE `departmentCost` ( `workerHours` decimal(10,1) DEFAULT NULL, `labourCost` decimal(10,0) DEFAULT NULL, `dated` date NOT NULL, - PRIMARY KEY (`departmentFk`,`dated`), - CONSTRAINT `departmentCost_fk1` FOREIGN KEY (`departmentFk`) REFERENCES `postgresql`.`department_kk` (`department_id`) ON UPDATE CASCADE + KEY `departmentCost_fk1_idx` (`departmentFk`), + CONSTRAINT `departmentCost_fk1` FOREIGN KEY (`departmentFk`) REFERENCES `vn2008`.`department` (`department_id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -64021,7 +64178,7 @@ CREATE TABLE `productivity` ( `numPaletizadores` int(11) NOT NULL DEFAULT '0', `costPaletizado` double NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=18555675 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19107758 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -64612,8 +64769,8 @@ IF DAY(CURDATE()) = 6 THEN SELECT c.id, c.name as clientName, maxIssued as lastInvoiced, - w.workerCode, - b.workerCode as Boss, + w.code, + b.code as Boss, CASE WHEN IFNULL(maxIssued,'2000-01-01') < @tercerAviso THEN 'Tercer Aviso' WHEN maxIssued < @segundoAviso THEN 'Segundo Aviso' @@ -66370,22 +66527,6 @@ CREATE TABLE `Last_buy_id` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `Last_buy_idBackUpKk` --- - -DROP TABLE IF EXISTS `Last_buy_idBackUpKk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Last_buy_idBackUpKk` ( - `Id_Article` int(11) NOT NULL DEFAULT '90', - `Id_Compra` int(11) NOT NULL DEFAULT '0', - `warehouse_id` smallint(6) unsigned NOT NULL, - PRIMARY KEY (`Id_Article`,`warehouse_id`), - UNIQUE KEY `Id_Compra_UNIQUE` (`Id_Compra`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `Radar` -- @@ -68062,7 +68203,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `defaultersFromDate`(IN vDate DATE) BEGIN -SELECT t1.*, c.Cliente, w.workerCode, c.pay_met_id,c.Vencimiento +SELECT t1.*, c.Cliente, w.code, c.pay_met_id,c.Vencimiento FROM ( -- Filtramos aquellos clientes cuyo saldo se ha incrementado de ayer a hoy select * from( @@ -68097,6 +68238,104 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `defaulting`(IN vDate DATE) +BEGIN +/*JGF para usar el campo vencimiento de facturas*/ + DECLARE vDone BOOLEAN; + DECLARE vClient INT; + DECLARE vAmount INT; + DECLARE vDued DATE; + DECLARE vAmountInvoice DECIMAL(10,2); + DECLARE vGraceDays INT; + DECLARE defaulters CURSOR FOR + SELECT client, amount, 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 Vencimiento, 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 vDone = TRUE; + -- 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 * FROM( + SELECT client, amount , defaulterSince FROM bi.defaulters + WHERE date <= TIMESTAMPADD(DAY,-1, vDate) + ORDER BY date DESC) t 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: LOOP + SET vDone = FALSE; + SET vAmount = 0; + FETCH defaulters INTO vClient,vAmount, vGraceDays; + IF vDone THEN + LEAVE defaulters; + END IF; + OPEN invoices; + invoices:LOOP + + FETCH invoices INTO vDued, vAmountInvoice; + IF vDone THEN + LEAVE invoices; + END IF; + + IF TIMESTAMPADD(DAY, vGraceDays, vDued) <= vDate THEN + SET vAmount = vAmount - vAmountInvoice; + IF vAmount <= 0 THEN + + UPDATE defaulters SET defaulterSince = vDued + WHERE client = vClient and date = vDate; + + SET vAmount = 0; + LEAVE invoices; + END IF; + END IF; + END LOOP; + CLOSE invoices; + END LOOP; + 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; + + CALL vn.clientFreeze(); +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 `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 vDone BOOLEAN; DECLARE vClient INT; @@ -69738,7 +69977,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=MyISAM AUTO_INCREMENT=255264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=257001 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -70533,7 +70772,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=277039 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=279870 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -72287,7 +72526,7 @@ CREATE TABLE `userConfigView` ( `configuration` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `uniqueUser_TableCode` (`userFk`,`tableCode`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -72439,11 +72678,12 @@ CREATE TABLE `inter` ( KEY `responsable` (`Id_Supervisor`), KEY `ticket` (`Id_Ticket`), KEY `inter_state` (`state_id`), + KEY `inter_id` (`Id_Ticket`,`inter_id`) USING BTREE, CONSTRAINT `currante` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, 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=15382595 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=15462470 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 */ ; @@ -73264,7 +73504,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=13053 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13054 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73315,7 +73555,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=1773621 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1779395 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73417,7 +73657,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=10767677 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10799021 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 */ ; @@ -73777,7 +74017,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=286513 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=287580 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73812,7 +74052,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=1617420 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1624249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73832,7 +74072,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=3551171 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3565746 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73857,7 +74097,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=2200364 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2208561 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -73877,7 +74117,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=3216863 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3227028 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -74772,45 +75012,45 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemGetList`(vWarehouse SMALLINT, vShipping DATE, vCategory INT, vRate TINYINT) -BEGIN - DECLARE vCalc INT; - - CALL cache.available_refresh(vCalc, FALSE, vWarehouse, vShipping); - CALL vn2008.item_last_buy_(vWarehouse, vShipping); - - SELECT a.id, a.`name`, a.category, a.size, a.stems, a.inkFk, a.typeFk, a.image, - c.available, o.`name` origin, t.`name` `type`, - CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing - ELSE b.grouping - END AS grouping, - CASE vRate - WHEN 1 THEN b.price1 - WHEN 2 THEN b.price2 - WHEN 3 THEN b.price3 - ELSE NULL - END AS price - FROM cache.available c - JOIN vn.item a ON a.id = c.item_id - JOIN vn.itemType t ON t.id = a.typeFk - JOIN vn.itemCategory r ON r.id = t.categoryFk - LEFT JOIN vn.origin o ON o.id = a.originFk - JOIN vn2008.t_item_last_buy l ON l.item_id = a.id - JOIN vn.buy b ON b.id = l.buy_id - WHERE c.calc_id = vCalc - AND c.available > 0 - AND a.id != 90 - AND r.display - AND (vCategory IS NULL OR vCategory = r.id) - ORDER BY a.typeFk, a.`name`, a.size; +CREATE DEFINER=`root`@`%` PROCEDURE `itemGetList`(IN `vWarehouse` SMALLINT, IN `vShipping` DATE, IN `vCategory` INT, IN `vRate` TINYINT) +BEGIN + DECLARE vCalc INT; + + CALL cache.available_refresh(vCalc, FALSE, vWarehouse, vShipping); + CALL vn2008.item_last_buy_(vWarehouse, vShipping); + + SELECT a.id, a.`name`, a.category, a.size, a.stems, a.inkFk, a.typeFk, a.image, + c.available, o.`name` origin, t.`name` `type`, + CASE b.groupingMode + WHEN 0 THEN 1 + WHEN 2 THEN b.packing + ELSE b.`grouping` + END AS `grouping`, + CASE vRate + WHEN 1 THEN b.price1 + WHEN 2 THEN b.price2 + WHEN 3 THEN b.price3 + ELSE NULL + END AS price + FROM cache.available c + JOIN vn.item a ON a.id = c.item_id + JOIN vn.itemType t ON t.id = a.typeFk + JOIN vn.itemCategory r ON r.id = t.categoryFk + LEFT JOIN vn.origin o ON o.id = a.originFk + JOIN vn2008.t_item_last_buy l ON l.item_id = a.id + JOIN vn.buy b ON b.id = l.buy_id + WHERE c.calc_id = vCalc + AND c.available > 0 + AND a.id != 90 + AND r.display + AND (vCategory IS NULL OR vCategory = r.id) + ORDER BY a.typeFk, a.`name`, a.size; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75302,111 +75542,111 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `orderAddItem`(IN `vOrder` INT, IN `vWarehouse` INT, IN `vItem` INT, IN `vAmount` INT) -BEGIN - DECLARE vRow INT; - DECLARE vAdd INT; - DECLARE vAvailable INT; - DECLARE vDone BOOL; - DECLARE vGrouping INT; - DECLARE vRate INT; - DECLARE vShipment DATE; - DECLARE vPrice DECIMAL(10,2); - DECLARE vDate DATE; - DECLARE vAddress INT; - DECLARE vAgencyMode INT; - DECLARE cur CURSOR FOR - SELECT grouping, price, rate - FROM tmp.bionic_price - WHERE warehouse_id = vWarehouse - AND item_id = vItem - ORDER BY grouping DESC; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SELECT date_send, address_id, agency_id - INTO vDate, vAddress, vAgencyMode - FROM `order` - WHERE id = vOrder; - - CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem); - - START TRANSACTION; - - SELECT shipped INTO vShipment - FROM tmp.travel_tree - WHERE warehouseFk = vWarehouse; - - SELECT available INTO vAvailable - FROM tmp.bionic_lot - WHERE warehouse_id = vWarehouse - AND item_id = vItem; - - IF vAmount > IFNULL(vAvailable, 0) - THEN - CALL util.throw ('ORDER_ROW_UNAVAILABLE'); - END IF; - - OPEN cur; - - l: LOOP - SET vDone = FALSE; - FETCH cur INTO vGrouping, vPrice, vRate; - - IF vDone THEN - LEAVE l; - END IF; - - SET vAdd = vAmount - MOD(vAmount, vGrouping); - SET vAmount = vAmount - vAdd; - - IF vAdd = 0 THEN - ITERATE l; - END IF; - - INSERT INTO order_row SET - order_id = vOrder, - item_id = vItem, - warehouse_id = vWarehouse, - shipment = vShipment, - rate = vRate, - amount = vAdd, - price = vPrice; - - SET vRow = LAST_INSERT_ID(); - - INSERT INTO order_component (order_row_id, component_id, price) - SELECT vRow, c.component_id, c.cost - FROM tmp.bionic_component c - JOIN bi.tarifa_componentes t - ON t.Id_Componente = c.component_id - AND (t.tarifa_class IS NULL OR t.tarifa_class = vRate) - WHERE c.warehouse_id = vWarehouse - AND c.item_id = vItem; - END LOOP; - - CLOSE cur; - - IF vAmount > 0 - THEN - CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING'); - END IF; - - COMMIT; - CALL vn2008.bionic_free (); +BEGIN + DECLARE vRow INT; + DECLARE vAdd INT; + DECLARE vAvailable INT; + DECLARE vDone BOOL; + DECLARE vGrouping INT; + DECLARE vRate INT; + DECLARE vShipment DATE; + DECLARE vPrice DECIMAL(10,2); + DECLARE vDate DATE; + DECLARE vAddress INT; + DECLARE vAgencyMode INT; + DECLARE cur CURSOR FOR + SELECT `grouping`, price, rate + FROM tmp.bionic_price + WHERE warehouse_id = vWarehouse + AND item_id = vItem + ORDER BY grouping DESC; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT date_send, address_id, agency_id + INTO vDate, vAddress, vAgencyMode + FROM `order` + WHERE id = vOrder; + + CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem); + + START TRANSACTION; + + SELECT shipped INTO vShipment + FROM tmp.travel_tree + WHERE warehouseFk = vWarehouse; + + SELECT available INTO vAvailable + FROM tmp.bionic_lot + WHERE warehouse_id = vWarehouse + AND item_id = vItem; + + IF vAmount > IFNULL(vAvailable, 0) + THEN + CALL util.throw ('ORDER_ROW_UNAVAILABLE'); + END IF; + + OPEN cur; + + l: LOOP + SET vDone = FALSE; + FETCH cur INTO vGrouping, vPrice, vRate; + + IF vDone THEN + LEAVE l; + END IF; + + SET vAdd = vAmount - MOD(vAmount, vGrouping); + SET vAmount = vAmount - vAdd; + + IF vAdd = 0 THEN + ITERATE l; + END IF; + + INSERT INTO order_row SET + order_id = vOrder, + item_id = vItem, + warehouse_id = vWarehouse, + shipment = vShipment, + rate = vRate, + amount = vAdd, + price = vPrice; + + SET vRow = LAST_INSERT_ID(); + + INSERT INTO order_component (order_row_id, component_id, price) + SELECT vRow, c.component_id, c.cost + FROM tmp.bionic_component c + JOIN bi.tarifa_componentes t + ON t.Id_Componente = c.component_id + AND (t.tarifa_class IS NULL OR t.tarifa_class = vRate) + WHERE c.warehouse_id = vWarehouse + AND c.item_id = vItem; + END LOOP; + + CLOSE cur; + + IF vAmount > 0 + THEN + CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING'); + END IF; + + COMMIT; + CALL vn2008.bionic_free (); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -77337,7 +77577,7 @@ CREATE TABLE `address` ( KEY `address_town_id_idx` (`town_id`), CONSTRAINT `address_ibfk_1` FOREIGN KEY (`address_type_id`) REFERENCES `address_type` (`address_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `address_ibfk_2` FOREIGN KEY (`town_id`) REFERENCES `town` (`town_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=756 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=761 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -77400,7 +77640,7 @@ CREATE TABLE `bank_account` ( CONSTRAINT `bank_account_bank_account_type_id_fkey` FOREIGN KEY (`bank_account_type_id`) REFERENCES `bank_account_type` (`bank_account_type_id`) ON UPDATE CASCADE, CONSTRAINT `bank_account_nation_id_fkey` FOREIGN KEY (`nation_id`) REFERENCES `nation` (`nation_id`) ON UPDATE CASCADE, CONSTRAINT `bank_profile` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=742 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=748 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -77543,7 +77783,7 @@ CREATE TABLE `business` ( KEY `bussiness_provider` (`provider_id`), CONSTRAINT `business_client` FOREIGN KEY (`client_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bussiness_provider` FOREIGN KEY (`provider_id`) REFERENCES `profile` (`profile_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2283 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2295 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -77958,29 +78198,6 @@ CREATE TABLE `delivery_expedition` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `department_kk` --- - -DROP TABLE IF EXISTS `department_kk`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `department_kk` ( - `department_id` int(11) NOT NULL AUTO_INCREMENT, - `company_id` int(11) NOT NULL, - `father_id` int(11) DEFAULT NULL, - `boss_id` int(11) NOT NULL, - `name` varchar(40) NOT NULL, - `x` int(11) DEFAULT NULL, - `y` int(11) DEFAULT NULL, - `production` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY (`department_id`), - KEY `department_boss_id_idx` (`boss_id`), - KEY `department_company_id_idx` (`company_id`), - CONSTRAINT `dep_org_ibfk_3` FOREIGN KEY (`company_id`) REFERENCES `person` (`person_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `discount_type` -- @@ -78140,7 +78357,7 @@ CREATE TABLE `income_employee` ( KEY `fperson_id` (`person_id`), CONSTRAINT `fincometype_id` FOREIGN KEY (`id_incomeType`) REFERENCES `incometype_employee` (`id_incometype`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fperson_id` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=60199 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=61237 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78566,7 +78783,7 @@ CREATE TABLE `media` ( PRIMARY KEY (`media_id`), KEY `media_media_type_id_idx` (`media_type_id`), CONSTRAINT `media_ibfk_1` FOREIGN KEY (`media_type_id`) REFERENCES `media_type` (`media_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=928 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=935 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78921,7 +79138,7 @@ CREATE TABLE `person` ( UNIQUE KEY `person_nif_key` (`nif`), KEY `index1` (`person_id`,`name`,`nickname`,`firstname`), KEY `person_worker` (`id_trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=984 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=990 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78972,7 +79189,7 @@ CREATE TABLE `profile` ( KEY `profile_person_id_idx` (`person_id`), KEY `profile_profile_type_id_idx` (`profile_type_id`), CONSTRAINT `person_fk` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=862 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=868 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -78989,7 +79206,7 @@ CREATE TABLE `profile_address` ( PRIMARY KEY (`profile_address_id`), KEY `profile_address_address_id_idx` (`address_id`), KEY `profile_address_profile_id_idx` (`profile_id`) -) ENGINE=InnoDB AUTO_INCREMENT=93 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=98 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -79008,7 +79225,7 @@ CREATE TABLE `profile_media` ( KEY `profile_media_profile_id_idx` (`profile_id`), CONSTRAINT `fk_profile_media_media1` FOREIGN KEY (`media_id`) REFERENCES `media` (`media_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `media_ibfk_20` FOREIGN KEY (`profile_id`) REFERENCES `profile` (`profile_id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1076 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1083 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -82792,7 +83009,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`.`caja` AS `box`,`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`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown` 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`.`caja` AS `box`,`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`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown`,`t`.`lastPrice` AS `lastPrice` 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 */; @@ -82918,7 +83135,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`workerCode` AS `workerCode`,`rw`.`workerCode` AS `repoCode` from (((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`id` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) group by `ips`.`id` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`workerCode` AS `workerCode`,`rw`.`workerCode` AS `repoCode`,`p`.`code` AS `parking` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`id` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`id` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemShelvingFk` = `ish`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) group by `ips`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -82990,7 +83207,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum((`ish`.`visible` - `issr`.`removed`)) AS `visible`,min(`ish`.`packing`) AS `packing`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; +/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -83949,6 +84166,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `supplierPackaging` +-- + +/*!50001 DROP VIEW IF EXISTS `supplierPackaging`*/; +/*!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 `supplierPackaging` AS select `e`.`supplierFk` AS `supplierFk`,`b`.`itemFk` AS `itemFk`,`i`.`longName` AS `longName`,`s`.`name` AS `supplier`,`b`.`entryFk` AS `entryFk`,`tr`.`landed` AS `landed`,-(least(`b`.`quantity`,0)) AS `in`,greatest(`b`.`quantity`,0) AS `out`,`w`.`name` AS `almacen` from ((((((`vn`.`buy` `b` join `vn`.`item` `i` on((`i`.`id` = `b`.`itemFk`))) join `vn`.`packaging` `p` on((`p`.`itemFk` = `i`.`id`))) join `vn`.`entry` `e` on((`e`.`id` = `b`.`entryFk`))) join `vn`.`supplier` `s` on((`s`.`id` = `e`.`supplierFk`))) join `vn`.`travel` `tr` on((`tr`.`id` = `e`.`travelFk`))) join `vn`.`warehouse` `w` on((`w`.`id` = `tr`.`warehouseInFk`))) where `p`.`isPackageReturnable` */; +/*!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 `tagL10n` -- @@ -84178,7 +84413,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketToPrepare` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,(`mk`.`original_quantity` - sum(ifnull(`is`.`quantity`,0))) AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,hour(`t`.`shipped`) AS `Hora`,hour(`t`.`shipped`) AS `Departure`,minute(`t`.`shipped`) AS `Minuto`,`am`.`agencyFk` AS `agency_id`,`t`.`warehouseFk` AS `warehouse_id`,`a`.`provinceFk` AS `province_id`,`is`.`quantity` AS `picked` from ((((((`vn2008`.`Movimientos_mark` `mk` join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSale` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) where ((`mk`.`stateFk` = 26) and (`mk`.`valor` <> 1)) */; +/*!50001 VIEW `ticketToPrepare` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,`mk`.`original_quantity` AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,hour(`t`.`shipped`) AS `Hora`,hour(`t`.`shipped`) AS `Departure`,minute(`t`.`shipped`) AS `Minuto`,`am`.`agencyFk` AS `agency_id`,`t`.`warehouseFk` AS `warehouse_id`,`a`.`provinceFk` AS `province_id`,`is`.`quantity` AS `picked` from ((((((`vn2008`.`Movimientos_mark` `mk` join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSale` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) where ((`mk`.`stateFk` = 26) and (`mk`.`valor` <> 1)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -84466,7 +84701,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `worker` AS select `t`.`Id_Trabajador` AS `id`,`t`.`CodigoTrabajador` AS `workerCode`,`t`.`Nombre` AS `firstName`,`t`.`Apellidos` AS `name`,`t`.`user_id` AS `userFk`,`t`.`phone` AS `phone`,`t`.`boss` AS `bossFk`,`t`.`Foto` AS `photo`,`t`.`dni` AS `fi`,`t`.`DniExpiration` AS `fiDueDate` from `vn2008`.`Trabajadores` `t` */; +/*!50001 VIEW `worker` AS select `t`.`Id_Trabajador` AS `id`,`t`.`CodigoTrabajador` AS `workerCode`,`t`.`Nombre` AS `firstName`,`t`.`Apellidos` AS `name`,`t`.`user_id` AS `userFk`,`t`.`phone` AS `phone`,`t`.`boss` AS `bossFk`,`t`.`Foto` AS `photo`,`t`.`dni` AS `fi`,`t`.`DniExpiration` AS `fiDueDate`,`t`.`CodigoTrabajador` AS `code`,`t`.`Apellidos` AS `lastName` from `vn2008`.`Trabajadores` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85446,4 +85681,4 @@ USE `postgresql`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-02-25 8:32:00 +-- Dump completed on 2019-03-01 13:39:22 diff --git a/services/db/install/dump/truncateAll.sql b/db/install/dump/truncateAll.sql similarity index 100% rename from services/db/install/dump/truncateAll.sql rename to db/install/dump/truncateAll.sql diff --git a/services/db/tests.js b/db/tests.js similarity index 92% rename from services/db/tests.js rename to db/tests.js index bf2f45b2e..74ea9a80b 100644 --- a/services/db/tests.js +++ b/db/tests.js @@ -18,11 +18,11 @@ let jasmine = new Jasmine(); let SpecReporter = require('jasmine-spec-reporter').SpecReporter; let serviceSpecs = [ - './db/tests/**/*[sS]pec.js' + './tests/**/*[sS]pec.js' ]; jasmine.loadConfig({ - spec_dir: 'services', + spec_dir: 'db', spec_files: serviceSpecs, helpers: [] }); diff --git a/services/db/tests/cache/last_buy_refresh.spec.js b/db/tests/cache/last_buy_refresh.spec.js similarity index 100% rename from services/db/tests/cache/last_buy_refresh.spec.js rename to db/tests/cache/last_buy_refresh.spec.js diff --git a/services/db/tests/vn/buyUltimate.spec.js b/db/tests/vn/buyUltimate.spec.js similarity index 100% rename from services/db/tests/vn/buyUltimate.spec.js rename to db/tests/vn/buyUltimate.spec.js diff --git a/services/db/tests/vn/buyUltimateFromInterval.spec.js b/db/tests/vn/buyUltimateFromInterval.spec.js similarity index 100% rename from services/db/tests/vn/buyUltimateFromInterval.spec.js rename to db/tests/vn/buyUltimateFromInterval.spec.js diff --git a/services/db/tests/vn/logAddWithUser.spec.js b/db/tests/vn/logAddWithUser.spec.js similarity index 100% rename from services/db/tests/vn/logAddWithUser.spec.js rename to db/tests/vn/logAddWithUser.spec.js diff --git a/services/db/tests/vn/ticketCalculateClon.spec.js b/db/tests/vn/ticketCalculateClon.spec.js similarity index 100% rename from services/db/tests/vn/ticketCalculateClon.spec.js rename to db/tests/vn/ticketCalculateClon.spec.js diff --git a/services/db/tests/vn/ticketComponentUpdateSale.spec.js b/db/tests/vn/ticketComponentUpdateSale.spec.js similarity index 100% rename from services/db/tests/vn/ticketComponentUpdateSale.spec.js rename to db/tests/vn/ticketComponentUpdateSale.spec.js diff --git a/services/db/tests/vn/ticketCreateWithUser.spec.js b/db/tests/vn/ticketCreateWithUser.spec.js similarity index 99% rename from services/db/tests/vn/ticketCreateWithUser.spec.js rename to db/tests/vn/ticketCreateWithUser.spec.js index 52a8a1183..e5ff299a7 100644 --- a/services/db/tests/vn/ticketCreateWithUser.spec.js +++ b/db/tests/vn/ticketCreateWithUser.spec.js @@ -183,6 +183,7 @@ describe('ticket ticketCreateWithUser()', () => { params.landed, params.userId ]); + stmts.push(stmt); let ticketAddressIndex = stmts.push(`SELECT addressFk FROM vn.ticket WHERE id = @newTicketId`) - 1; @@ -191,12 +192,9 @@ describe('ticket ticketCreateWithUser()', () => { params.clientFk, ]); let clientDefaultAddressIndex = stmts.push(stmt) - 1; - stmts.push('ROLLBACK'); - let sql = ParameterizedSQL.join(stmts, ';'); let result = await app.models.Ticket.rawStmt(sql); - let ticketAddress = result[ticketAddressIndex][0]; let clientDefaultAddress = result[clientDefaultAddressIndex][0]; diff --git a/front/core/styles/salixfont.css b/front/core/styles/salixfont.css index 8e9a02963..67ff48cb5 100644 --- a/front/core/styles/salixfont.css +++ b/front/core/styles/salixfont.css @@ -23,240 +23,240 @@ -moz-osx-font-smoothing: grayscale; } -.icon-pets:before { - content: "\e94e"; -} -.icon-100:before { - content: "\e940"; -} -.icon-accessory:before { - content: "\e90a"; -} -.icon-actions:before { - content: "\e900"; -} -.icon-addperson:before { +.icon-tax:before { content: "\e901"; } -.icon-albaran:before { +.icon-notes:before { content: "\e902"; } -.icon-apps:before { - content: "\e948"; -} -.icon-artificial:before { +.icon-lineas:before { content: "\e903"; } -.icon-barcode:before { +.icon-languaje:before { content: "\e904"; } -.icon-basket:before { - content: "\e942"; -} -.icon-bin:before { +.icon-greuge:before { content: "\e905"; } -.icon-botanical:before { +.icon-100:before { content: "\e906"; } -.icon-bucket:before { +.icon-History:before { content: "\e907"; } -.icon-claims:before { +.icon-Inactivo:before { content: "\e908"; } -.icon-clone:before { +.icon-person:before { content: "\e909"; } -.icon-columnadd:before { - content: "\e944"; +.icon-actions:before { + content: "\e90a"; } -.icon-columndelete:before { - content: "\e90f"; -} -.icon-components:before { +.icon-addperson:before { content: "\e90b"; } -.icon-consignatarios:before { - content: "\e90d"; -} -.icon-control:before { - content: "\e93f"; -} -.icon-credit:before { - content: "\e90e"; -} -.icon-delivery:before { - content: "\e910"; -} -.icon-details:before { - content: "\e911"; -} -.icon-disabled:before { - content: "\e91b"; -} -.icon-doc:before { - content: "\e913"; -} -.icon-entry:before { - content: "\e914"; -} -.icon-exit:before { - content: "\e947"; -} -.icon-eye:before { - content: "\e915"; -} -.icon-fiscal:before { - content: "\e912"; -} -.icon-flower:before { - content: "\e916"; -} -.icon-frozen:before { - content: "\e917"; -} -.icon-greenery:before { - content: "\e93c"; -} -.icon-greuge:before { - content: "\e918"; -} -.icon-grid:before { - content: "\e919"; -} -.icon-handmade:before { +.icon-albaran:before { content: "\e90c"; } -.icon-history:before { +.icon-apps:before { + content: "\e90d"; +} +.icon-artificial:before { + content: "\e90e"; +} +.icon-barcode:before { + content: "\e90f"; +} +.icon-basket:before { + content: "\e910"; +} +.icon-bin:before { + content: "\e911"; +} +.icon-botanical:before { + content: "\e912"; +} +.icon-claims:before { + content: "\e913"; +} +.icon-clone:before { + content: "\e914"; +} +.icon-columnadd:before { + content: "\e915"; +} +.icon-columndelete:before { + content: "\e916"; +} +.icon-complementos:before { + content: "\e917"; +} +.icon-components:before { + content: "\e918"; +} +.icon-confeccion:before { + content: "\e919"; +} +.icon-consignatarios:before { content: "\e91a"; } -.icon-info:before { - content: "\e949"; +.icon-control:before { + content: "\e91b"; } -.icon-invoices1:before { - content: "\e94a"; -} -.icon-invoices:before { +.icon-credit:before { content: "\e91c"; } -.icon-item:before { - content: "\e941"; -} -.icon-languaje:before { +.icon-deleteline:before { content: "\e91d"; } -.icon-linedelete:before { - content: "\e946"; -} -.icon-lines:before { +.icon-delivery:before { content: "\e91e"; } -.icon-linesplit:before { - content: "\e945"; +.icon-details:before { + content: "\e900"; } -.icon-linesprepaired:before { - content: "\e94b"; -} -.icon-logout:before { +.icon-dfiscales:before { content: "\e91f"; } -.icon-mana:before { +.icon-doc:before { content: "\e920"; } -.icon-mandatory:before { +.icon-entrada:before { content: "\e921"; } -.icon-niche:before { +.icon-eye:before { content: "\e922"; } -.icon-no036:before { +.icon-flor:before { content: "\e923"; } -.icon-notes:before { +.icon-frozen:before { content: "\e924"; } -.icon-noweb:before { +.icon-grid:before { content: "\e925"; } -.icon-onlinepayment:before { +.icon-headercol:before { content: "\e926"; } -.icon-package:before { +.icon-info:before { content: "\e927"; } -.icon-payment:before { +.icon-item:before { content: "\e928"; } -.icon-person:before { +.icon-linesprepaired:before { content: "\e929"; } -.icon-photo:before { +.icon-logout:before { content: "\e92a"; } -.icon-plant:before { +.icon-mana:before { content: "\e92b"; } -.icon-recovery:before { - content: "\e92d"; -} -.icon-regentry:before { - content: "\e92e"; -} -.icon-reserve:before { - content: "\e92f"; -} -.icon-revision:before { - content: "\e94c"; -} -.icon-risk:before { - content: "\e930"; -} -.icon-services:before { - content: "\e94d"; -} -.icon-settings:before { - content: "\e931"; -} -.icon-sms:before { - content: "\e932"; -} -.icon-solclaim:before { - content: "\e933"; -} -.icon-solunion:before { - content: "\e934"; -} -.icon-splur:before { - content: "\e935"; -} -.icon-stowaway:before { +.icon-mandatory:before { content: "\e92c"; } -.icon-supplier:before { +.icon-newalbaran:before { + content: "\e92d"; +} +.icon-newinvoices:before { + content: "\e92e"; +} +.icon-niche:before { + content: "\e92f"; +} +.icon-no036:before { + content: "\e930"; +} +.icon-noweb:before { + content: "\e931"; +} +.icon-onlinepayment:before { + content: "\e932"; +} +.icon-package:before { + content: "\e933"; +} +.icon-payment:before { + content: "\e934"; +} +.icon-pets:before { + content: "\e935"; +} +.icon-photo:before { content: "\e936"; } -.icon-tags:before { +.icon-planta:before { content: "\e937"; } -.icon-tax:before { +.icon-recovery:before { content: "\e938"; } -.icon-ticket:before { +.icon-regentry:before { content: "\e939"; } -.icon-traceability:before { +.icon-reserva:before { content: "\e93a"; } -.icon-transaction:before { +.icon-revision:before { content: "\e93b"; } -.icon-volume:before { +.icon-riesgo:before { + content: "\e93c"; +} +.icon-services:before { content: "\e93d"; } -.icon-web:before { +.icon-settings:before { content: "\e93e"; } -.icon-worker:before { +.icon-sign:before { + content: "\e93f"; +} +.icon-sms:before { + content: "\e940"; +} +.icon-solclaim:before { + content: "\e941"; +} +.icon-solunion:before { + content: "\e942"; +} +.icon-splitline:before { content: "\e943"; +} +.icon-stowaway:before { + content: "\e944"; +} +.icon-supplier:before { + content: "\e945"; +} +.icon-tags:before { + content: "\e946"; +} +.icon-ticket:before { + content: "\e947"; +} +.icon-traceability:before { + content: "\e948"; +} +.icon-transaction:before { + content: "\e949"; +} +.icon-unavailable:before { + content: "\e94a"; +} +.icon-verde:before { + content: "\e94b"; +} +.icon-volume:before { + content: "\e94c"; +} +.icon-web:before { + content: "\e94d"; +} +.icon-worker:before { + content: "\e94e"; } \ No newline at end of file diff --git a/front/core/styles/salixfont.eot b/front/core/styles/salixfont.eot index c816a300f..d02e74ae4 100644 Binary files a/front/core/styles/salixfont.eot and b/front/core/styles/salixfont.eot differ diff --git a/front/core/styles/salixfont.svg b/front/core/styles/salixfont.svg index d6654ec1e..9c99d9457 100644 --- a/front/core/styles/salixfont.svg +++ b/front/core/styles/salixfont.svg @@ -3,87 +3,87 @@ \ No newline at end of file diff --git a/front/core/styles/salixfont.ttf b/front/core/styles/salixfont.ttf index 7c0ac2492..229075e35 100644 Binary files a/front/core/styles/salixfont.ttf and b/front/core/styles/salixfont.ttf differ diff --git a/front/core/styles/salixfont.woff b/front/core/styles/salixfont.woff index 2a9a880f5..97f55da68 100644 Binary files a/front/core/styles/salixfont.woff and b/front/core/styles/salixfont.woff differ diff --git a/gulpfile.js b/gulpfile.js index dfc91c050..af6a6980b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -355,7 +355,7 @@ async function docker() { let d = new Date(); let pad = v => v < 10 ? '0' + v : v; let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; - await execP(`docker build --build-arg STAMP=${stamp} -t salix-db ./services/db`); + await execP(`docker build --build-arg STAMP=${stamp} -t salix-db ./db`); let dockerArgs = `--name ${containerId} -p 3306:${dbConf.port}`; diff --git a/modules/item/front/descriptor/index.html b/modules/item/front/descriptor/index.html index d0c89e9e1..c139ad3d9 100644 --- a/modules/item/front/descriptor/index.html +++ b/modules/item/front/descriptor/index.html @@ -57,6 +57,13 @@ value="{{tag.value}}"> +