From ee3a83ac0ac4504f51d5dc465ed21cd306b3a354 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 19 Nov 2019 13:40:29 +0100 Subject: [PATCH 01/12] update structure and fixtures --- db/dump/dumpedFixtures.sql | 40 +- db/dump/fixtures.sql | 8 +- db/dump/structure.sql | 1874 +++++++++++++++++++++--------------- 3 files changed, 1100 insertions(+), 822 deletions(-) diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 96e49e2dd..f51938668 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -1,6 +1,6 @@ USE `util`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: util -- ------------------------------------------------------ @@ -36,9 +36,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:47 +-- Dump completed on 2019-11-19 13:07:53 USE `account`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -71,7 +71,7 @@ UNLOCK TABLES; LOCK TABLES `roleInherit` WRITE; /*!40000 ALTER TABLE `roleInherit` DISABLE KEYS */; -INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(65,35),(49,36),(61,36),(17,37),(38,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); +INSERT INTO `roleInherit` VALUES (9,0),(66,0),(5,1),(13,1),(18,1),(31,1),(32,1),(34,1),(35,1),(37,1),(40,1),(42,1),(44,1),(47,1),(51,1),(53,1),(54,1),(56,1),(58,1),(1,2),(1,3),(30,5),(39,5),(60,5),(11,6),(1,11),(2,11),(3,11),(16,13),(20,13),(21,13),(22,13),(34,13),(41,13),(43,13),(45,13),(48,13),(50,13),(52,13),(55,13),(57,13),(59,13),(61,13),(16,15),(20,16),(21,18),(52,19),(65,19),(17,20),(30,20),(5,21),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(41,35),(52,35),(65,35),(49,36),(61,36),(17,37),(38,37),(17,39),(41,40),(43,42),(36,44),(45,44),(36,47),(48,47),(50,49),(60,50),(65,50),(52,51),(21,53),(30,53),(55,54),(57,56),(15,57),(39,57),(50,57),(60,57),(49,58),(59,58),(50,59),(17,64),(30,64),(38,64),(20,65); /*!40000 ALTER TABLE `roleInherit` ENABLE KEYS */; UNLOCK TABLES; @@ -81,7 +81,7 @@ UNLOCK TABLES; LOCK TABLES `roleRole` WRITE; /*!40000 ALTER TABLE `roleRole` DISABLE KEYS */; -INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,15),(15,35),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66); +INSERT INTO `roleRole` VALUES (0,0),(0,1),(0,2),(0,3),(0,5),(0,6),(0,9),(0,11),(0,13),(0,15),(0,16),(0,17),(0,18),(0,19),(0,20),(0,21),(0,22),(0,30),(0,31),(0,32),(0,33),(0,34),(0,35),(0,36),(0,37),(0,38),(0,39),(0,40),(0,41),(0,42),(0,43),(0,44),(0,45),(0,47),(0,48),(0,49),(0,50),(0,51),(0,52),(0,53),(0,54),(0,55),(0,56),(0,57),(0,58),(0,59),(0,60),(0,61),(0,62),(0,64),(0,65),(0,66),(1,1),(1,2),(1,3),(1,6),(1,11),(2,2),(2,6),(2,11),(3,3),(3,6),(3,11),(5,1),(5,2),(5,3),(5,5),(5,6),(5,11),(5,13),(5,18),(5,21),(5,33),(5,53),(6,6),(9,0),(9,1),(9,2),(9,3),(9,5),(9,6),(9,9),(9,11),(9,13),(9,15),(9,16),(9,17),(9,18),(9,19),(9,20),(9,21),(9,22),(9,30),(9,31),(9,32),(9,33),(9,34),(9,35),(9,36),(9,37),(9,38),(9,39),(9,40),(9,41),(9,42),(9,43),(9,44),(9,45),(9,47),(9,48),(9,49),(9,50),(9,51),(9,52),(9,53),(9,54),(9,55),(9,56),(9,57),(9,58),(9,59),(9,60),(9,61),(9,62),(9,64),(9,65),(9,66),(11,6),(11,11),(13,1),(13,2),(13,3),(13,6),(13,11),(13,13),(15,1),(15,2),(15,3),(15,6),(15,11),(15,13),(15,15),(15,35),(15,56),(15,57),(16,1),(16,2),(16,3),(16,6),(16,11),(16,13),(16,15),(16,16),(16,35),(16,56),(16,57),(17,1),(17,2),(17,3),(17,5),(17,6),(17,11),(17,13),(17,15),(17,16),(17,17),(17,18),(17,19),(17,20),(17,21),(17,33),(17,35),(17,36),(17,37),(17,39),(17,44),(17,47),(17,49),(17,50),(17,53),(17,56),(17,57),(17,58),(17,59),(17,64),(17,65),(18,1),(18,2),(18,3),(18,6),(18,11),(18,18),(19,1),(19,2),(19,3),(19,6),(19,11),(19,13),(19,18),(19,19),(19,21),(19,53),(20,1),(20,2),(20,3),(20,6),(20,11),(20,13),(20,15),(20,16),(20,18),(20,19),(20,20),(20,21),(20,35),(20,36),(20,44),(20,47),(20,49),(20,50),(20,53),(20,56),(20,57),(20,58),(20,59),(20,65),(21,1),(21,2),(21,3),(21,6),(21,11),(21,13),(21,18),(21,21),(21,53),(22,1),(22,2),(22,3),(22,6),(22,11),(22,13),(22,18),(22,21),(22,22),(22,53),(30,1),(30,2),(30,3),(30,5),(30,6),(30,11),(30,13),(30,15),(30,16),(30,18),(30,19),(30,20),(30,21),(30,22),(30,30),(30,33),(30,35),(30,36),(30,44),(30,47),(30,49),(30,50),(30,53),(30,56),(30,57),(30,58),(30,59),(30,64),(30,65),(31,1),(31,2),(31,3),(31,6),(31,11),(31,31),(32,1),(32,2),(32,3),(32,6),(32,11),(32,32),(33,33),(34,1),(34,2),(34,3),(34,6),(34,11),(34,13),(34,33),(34,34),(35,1),(35,2),(35,3),(35,6),(35,11),(35,35),(36,1),(36,2),(36,3),(36,6),(36,11),(36,36),(36,44),(36,47),(37,1),(37,2),(37,3),(37,6),(37,11),(37,37),(38,1),(38,2),(38,3),(38,6),(38,11),(38,37),(38,38),(38,64),(39,1),(39,2),(39,3),(39,5),(39,6),(39,11),(39,13),(39,18),(39,21),(39,33),(39,39),(39,53),(39,56),(39,57),(40,1),(40,2),(40,3),(40,6),(40,11),(40,40),(41,1),(41,2),(41,3),(41,6),(41,11),(41,13),(41,35),(41,40),(41,41),(42,1),(42,2),(42,3),(42,6),(42,11),(42,42),(43,1),(43,2),(43,3),(43,6),(43,11),(43,13),(43,42),(43,43),(44,1),(44,2),(44,3),(44,6),(44,11),(44,44),(45,1),(45,2),(45,3),(45,6),(45,11),(45,13),(45,44),(45,45),(47,1),(47,2),(47,3),(47,6),(47,11),(47,47),(48,1),(48,2),(48,3),(48,6),(48,11),(48,13),(48,47),(48,48),(49,1),(49,2),(49,3),(49,6),(49,11),(49,36),(49,44),(49,47),(49,49),(49,58),(50,1),(50,2),(50,3),(50,6),(50,11),(50,13),(50,36),(50,44),(50,47),(50,49),(50,50),(50,56),(50,57),(50,58),(50,59),(51,1),(51,2),(51,3),(51,6),(51,11),(51,51),(52,1),(52,2),(52,3),(52,6),(52,11),(52,13),(52,18),(52,19),(52,21),(52,35),(52,51),(52,52),(52,53),(53,1),(53,2),(53,3),(53,6),(53,11),(53,53),(54,1),(54,2),(54,3),(54,6),(54,11),(54,54),(55,1),(55,2),(55,3),(55,6),(55,11),(55,13),(55,54),(55,55),(56,1),(56,2),(56,3),(56,6),(56,11),(56,56),(57,1),(57,2),(57,3),(57,6),(57,11),(57,13),(57,56),(57,57),(58,1),(58,2),(58,3),(58,6),(58,11),(58,58),(59,1),(59,2),(59,3),(59,6),(59,11),(59,13),(59,58),(59,59),(60,1),(60,2),(60,3),(60,5),(60,6),(60,11),(60,13),(60,18),(60,21),(60,33),(60,36),(60,44),(60,47),(60,49),(60,50),(60,53),(60,56),(60,57),(60,58),(60,59),(60,60),(61,1),(61,2),(61,3),(61,6),(61,11),(61,13),(61,36),(61,44),(61,47),(61,61),(62,62),(64,64),(65,1),(65,2),(65,3),(65,6),(65,11),(65,13),(65,18),(65,19),(65,21),(65,35),(65,36),(65,44),(65,47),(65,49),(65,50),(65,53),(65,56),(65,57),(65,58),(65,59),(65,65),(66,0),(66,1),(66,2),(66,3),(66,5),(66,6),(66,9),(66,11),(66,13),(66,15),(66,16),(66,17),(66,18),(66,19),(66,20),(66,21),(66,22),(66,30),(66,31),(66,32),(66,33),(66,34),(66,35),(66,36),(66,37),(66,38),(66,39),(66,40),(66,41),(66,42),(66,43),(66,44),(66,45),(66,47),(66,48),(66,49),(66,50),(66,51),(66,52),(66,53),(66,54),(66,55),(66,56),(66,57),(66,58),(66,59),(66,60),(66,61),(66,62),(66,64),(66,65),(66,66); /*!40000 ALTER TABLE `roleRole` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -94,9 +94,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `salix`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: salix -- ------------------------------------------------------ @@ -142,9 +142,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `vn`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: vn -- ------------------------------------------------------ @@ -310,9 +310,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `vn2008`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: vn2008 -- ------------------------------------------------------ @@ -388,9 +388,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `bi`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: bi -- ------------------------------------------------------ @@ -436,9 +436,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `cache`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: cache -- ------------------------------------------------------ @@ -474,9 +474,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:53 USE `hedera`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: hedera -- ------------------------------------------------------ @@ -532,9 +532,9 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:54 USE `postgresql`; --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: postgresql -- ------------------------------------------------------ @@ -620,4 +620,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-13 10:04:48 +-- Dump completed on 2019-11-19 13:07:54 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7f7305133..21413d329 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -558,9 +558,9 @@ INSERT INTO `vn`.`vehicle`(`id`, `numberPlate`, `tradeMark`, `model`, `companyFk (5, '4444-IMK', 'STARK INDUSTRIES', 'MARK-XLII', 442, 1, 'Iron-Man Heavy Armor MARK-XLII', 13, 1), (6, '5555-IMK', 'STARK INDUSTRIES', 'MARK-XLV', 442, 1, 'Iron-Man Heavy Armor MARK-XLV', 12, 0); -INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`) +INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, `inventoried`) VALUES - (1, 'beta-server', 'nightmare@mydomain.com', '200'); + (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(CURDATE(),INTERVAL -1 MONTH)); INSERT INTO `vn`.`greugeType`(`id`, `name`) VALUES @@ -1117,10 +1117,6 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`package (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()); -INSERT INTO `vn2008`.`tblContadores`(`id`,`FechaInventario`) - VALUES - (1,DATE_ADD(CURDATE(),INTERVAL -1 MONTH)); - INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`) VALUES (1, 'AGENCY', 'Agencia'), diff --git a/db/dump/structure.sql b/db/dump/structure.sql index ca43d8456..e3484d410 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -1,4 +1,4 @@ --- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.7.28, for Linux (x86_64) -- -- Host: db.verdnatura.es Database: account -- ------------------------------------------------------ @@ -365,7 +365,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=16839 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=16879 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 */ ; @@ -1977,7 +1977,7 @@ CREATE TABLE `analisis_ventas` ( `Importe` double NOT NULL, PRIMARY KEY (`id`), KEY `Año` (`Año`,`Semana`) -) ENGINE=InnoDB AUTO_INCREMENT=109501928 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=112778678 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2458,7 +2458,7 @@ CREATE TABLE `rutasBoard` ( KEY `rutasBoard_ix1` (`year`), KEY `rutasBoard_ix2` (`month`), KEY `rutasBoard_ix3` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=188316 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=198546 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5396,29 +5396,6 @@ SET character_set_client = utf8; 1 AS `lastYearWeekSales`*/; SET character_set_client = @saved_cs_client; --- --- Table structure for table `m3` --- - -DROP TABLE IF EXISTS `m3`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `m3` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` date NOT NULL, - `provinceFk` smallint(5) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', - `m3` decimal(10,2) DEFAULT NULL, - `year` int(11) DEFAULT NULL, - `month` int(11) DEFAULT NULL, - `week` int(11) DEFAULT NULL, - `day` int(11) DEFAULT NULL, - `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `euros` decimal(10,2) DEFAULT '0.00', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=362726 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `m3Silla` -- @@ -5438,6 +5415,29 @@ SET character_set_client = utf8; 1 AS `Euros`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `m3__` +-- + +DROP TABLE IF EXISTS `m3__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m3__` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fecha` date NOT NULL, + `provinceFk` smallint(5) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', + `m3` decimal(10,2) DEFAULT NULL, + `year` int(11) DEFAULT NULL, + `month` int(11) DEFAULT NULL, + `week` int(11) DEFAULT NULL, + `day` int(11) DEFAULT NULL, + `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `euros` decimal(10,2) DEFAULT '0.00', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=368864 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `m3analisis` -- @@ -5688,7 +5688,7 @@ CREATE TABLE `payMethodClient` ( KEY `FkDateClientPayMethod` (`dated`,`clientFk`), CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn`.`payMethod` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5715076 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=5829757 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5763,7 +5763,7 @@ CREATE TABLE `productivity` ( `m3PCA` double NOT NULL DEFAULT '0', `m3Artificial` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=60211350 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=61099748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7016,17 +7016,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `m3Add` */; +/*!50003 DROP PROCEDURE IF EXISTS `m3Add__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `m3Add`() +CREATE DEFINER=`root`@`%` PROCEDURE `m3Add__`() BEGIN DECLARE datSTART DATE; @@ -8918,7 +8918,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=433218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=436254 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8986,7 +8986,7 @@ CREATE TABLE `prod_graphic_source` ( `alert_level` int(11) NOT NULL DEFAULT '0', `Agencia` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2223649 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2234381 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10033,7 +10033,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=24045723 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24314205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10091,7 +10091,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1104278 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1111068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10112,7 +10112,7 @@ CREATE TABLE `exchange` ( KEY `buy_edi_id` (`ektFk`), CONSTRAINT `exchange_ibfk_1` FOREIGN KEY (`mailFk`) REFERENCES `mail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `exchange_ibfk_2` FOREIGN KEY (`ektFk`) REFERENCES `ekt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=645075 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=651748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10374,7 +10374,7 @@ CREATE TABLE `mail` ( UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`senderFk`) REFERENCES `mailSender` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=675160 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=681655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10630,7 +10630,7 @@ CREATE TABLE `supplyResponse` ( PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' -) ENGINE=InnoDB AUTO_INCREMENT=8800750 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8917792 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11327,7 +11327,7 @@ CREATE TABLE `image` ( PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=169206 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=171273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11891,7 +11891,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=13072 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13074 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 */ ; @@ -12008,7 +12008,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2233655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2244750 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 */ ; @@ -12127,7 +12127,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13387246 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13453850 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 */ ; @@ -12551,7 +12551,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) 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=370350 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=372339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12586,7 +12586,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgentFk`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgentFk`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1997562 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2005986 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12606,7 +12606,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agentFk`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agentFk`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4455059 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4478440 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12631,7 +12631,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccessFk`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visitFk`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccessFk`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2641996 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2652592 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12651,7 +12651,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`userFk`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`accessFk`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3903218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3922066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -15488,16 +15488,16 @@ BEGIN LEFT JOIN tpvTransaction t ON t.id = vOrder WHERE m.id = vMerchant; - INSERT INTO vn2008.Recibos + INSERT INTO vn.receipt SET - Entregado = vAmount / 100 - ,Fechacobro = vDate - ,Id_Trabajador = vEmployee - ,Id_Banco = vBank - ,Id_Cliente = vCustomer - ,empresa_id = vCompany - ,Id_Factura = vConcept - ,conciliado = TRUE; + amountPaid = vAmount / 100 + ,payed = vDate + ,workerFk = vEmployee + ,bankFk = vBank + ,clientFk = vCustomer + ,companyFk = vCompany + ,invoiceFk = vConcept + ,isConciliate = TRUE; SET vReceipt = LAST_INSERT_ID(); SET vStatus = 'ok'; @@ -16389,7 +16389,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDB AUTO_INCREMENT=314233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=315692 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17220,7 +17220,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=935 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=936 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17275,7 +17275,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=3004 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=3017 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17490,7 +17490,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=73477 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=73578 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17524,7 +17524,7 @@ CREATE TABLE `journey` ( PRIMARY KEY (`journey_id`), KEY `fki_business_journey` (`business_id`), CONSTRAINT `business_journey` FOREIGN KEY (`business_id`) REFERENCES `business_labour` (`business_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2523 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2630 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17560,7 +17560,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=1162 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1167 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17728,7 +17728,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=1323 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1328 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20102,6 +20102,210 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `vn` /*!40100 DEFAULT CHARACTER SET utf USE `vn`; +-- +-- Table structure for table `XDiario` +-- + +DROP TABLE IF EXISTS `XDiario`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `XDiario` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ASIEN` double DEFAULT NULL, + `FECHA` datetime DEFAULT NULL, + `SUBCTA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `CONTRA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `CONCEPTO` varchar(50) CHARACTER SET utf8 DEFAULT NULL, + `EURODEBE` decimal(10,2) DEFAULT NULL, + `EUROHABER` decimal(10,2) DEFAULT NULL, + `BASEEURO` decimal(10,2) DEFAULT NULL, + `SERIE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `FACTURA` varchar(8) COLLATE utf8_unicode_ci DEFAULT '0', + `BASEIMPO` decimal(10,2) DEFAULT NULL, + `IVA` decimal(10,2) DEFAULT NULL, + `RECEQUIV` decimal(10,2) DEFAULT '0.00', + `DOCUMENTO` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `DEPARTA` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, + `CLAVE` int(11) DEFAULT NULL, + `ESTADO` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `NCASADO` decimal(10,2) DEFAULT NULL, + `TCASADO` decimal(10,2) DEFAULT NULL, + `TRANS` decimal(10,2) DEFAULT NULL, + `CAMBIO` decimal(10,2) DEFAULT NULL, + `DEBEME` decimal(10,2) DEFAULT NULL, + `HABERME` decimal(10,2) DEFAULT NULL, + `PTAHABER` decimal(10,2) DEFAULT NULL, + `AUXILIAR` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `SUCURSAL` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, + `PTADEBE` decimal(10,2) DEFAULT NULL, + `CODDIVISA` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, + `IMPAUXME` decimal(10,2) DEFAULT NULL, + `MONEDAUSO` varchar(1) COLLATE utf8_unicode_ci DEFAULT '2', + `NOCONV` tinyint(1) NOT NULL DEFAULT '0', + `NUMEROINV` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `NFACTICK` tinyint(1) NOT NULL DEFAULT '1', + `TERIDNIF` tinyint(1) NOT NULL DEFAULT '2', + `TERNIF` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'I.F.', + `TERNOM` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Nombre Importador', + `OPBIENES` tinyint(1) NOT NULL DEFAULT '1', + `TIPOFAC` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `TIPOIVA` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, + `L340` tinyint(2) NOT NULL DEFAULT '0', + `enlazado` tinyint(1) NOT NULL DEFAULT '0', + `FECHA_EX` date DEFAULT NULL COMMENT 'FEcha de expedicion de la factura', + `LRECT349` tinyint(1) NOT NULL DEFAULT '0', + `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', + `LDIFADUAN` tinyint(4) NOT NULL DEFAULT '0', + `METAL` tinyint(1) NOT NULL DEFAULT '0', + `METALIMP` decimal(10,2) NOT NULL DEFAULT '0.00', + `CLIENTE` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `METALEJE` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, + `FECHA_OP` date DEFAULT NULL COMMENT 'FEcha de operacion', + `FACTURAEX` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Numero de factura del proveedor', + `TIPOCLAVE` int(3) DEFAULT NULL, + `TIPOEXENCI` int(3) DEFAULT NULL, + `TIPONOSUJE` int(3) DEFAULT NULL, + `TIPOFACT` int(3) DEFAULT NULL, + `TIPORECTIF` int(3) DEFAULT NULL, + `SERIE_RT` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, + `FACTU_RT` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `BASEIMP_RT` decimal(10,2) DEFAULT NULL, + `BASEIMP_RF` decimal(10,2) DEFAULT NULL, + `RECTIFICA` int(1) NOT NULL DEFAULT '0', + `FECHA_RT` date DEFAULT NULL, + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `FECREGCON` date DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `empresa_id` (`empresa_id`), + CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4053991 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`XDiario_beforeInsert` BEFORE INSERT ON `XDiario` FOR EACH ROW +BEGIN +/* + IF NEW.EURODEBE < 0 THEN + + SET NEW.EUROHABER = - NEW.EURODEBE; + SET NEW.EURODEBE = NULL; + + END IF; + + IF NEW.EUROHABER < 0 THEN + + SET NEW.EURODEBE = - NEW.EUROHABER; + SET NEW.EUROHABER = NULL; + + END IF; + + IF NEW.DEBEME < 0 THEN + + SET NEW.HABERME = - NEW.DEBEME; + SET NEW.DEBEME = NULL; + + END IF; + + IF NEW.HABERME < 0 THEN + + SET NEW.DEBEME = - NEW.HABERME; + SET NEW.HABERME = NULL; + END IF; + */ +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + +-- +-- Temporary table structure for view `XDiario__` +-- + +DROP TABLE IF EXISTS `XDiario__`; +/*!50001 DROP VIEW IF EXISTS `XDiario__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `XDiario__` AS SELECT + 1 AS `id`, + 1 AS `ASIEN`, + 1 AS `FECHA`, + 1 AS `SUBCTA`, + 1 AS `CONTRA`, + 1 AS `CONCEPTO`, + 1 AS `EURODEBE`, + 1 AS `EUROHABER`, + 1 AS `BASEEURO`, + 1 AS `SERIE`, + 1 AS `FACTURA`, + 1 AS `BASEIMPO`, + 1 AS `IVA`, + 1 AS `RECEQUIV`, + 1 AS `DOCUMENTO`, + 1 AS `DEPARTA`, + 1 AS `CLAVE`, + 1 AS `ESTADO`, + 1 AS `NCASADO`, + 1 AS `TCASADO`, + 1 AS `TRANS`, + 1 AS `CAMBIO`, + 1 AS `DEBEME`, + 1 AS `HABERME`, + 1 AS `PTAHABER`, + 1 AS `AUXILIAR`, + 1 AS `SUCURSAL`, + 1 AS `PTADEBE`, + 1 AS `CODDIVISA`, + 1 AS `IMPAUXME`, + 1 AS `MONEDAUSO`, + 1 AS `NOCONV`, + 1 AS `NUMEROINV`, + 1 AS `TIPOOPE`, + 1 AS `NFACTICK`, + 1 AS `TERIDNIF`, + 1 AS `TERNIF`, + 1 AS `TERNOM`, + 1 AS `OPBIENES`, + 1 AS `TIPOFAC`, + 1 AS `TIPOIVA`, + 1 AS `L340`, + 1 AS `enlazado`, + 1 AS `FECHA_EX`, + 1 AS `LRECT349`, + 1 AS `empresa_id`, + 1 AS `LDIFADUAN`, + 1 AS `METAL`, + 1 AS `METALIMP`, + 1 AS `CLIENTE`, + 1 AS `METALEJE`, + 1 AS `FECHA_OP`, + 1 AS `FACTURAEX`, + 1 AS `TIPOCLAVE`, + 1 AS `TIPOEXENCI`, + 1 AS `TIPONOSUJE`, + 1 AS `TIPOFACT`, + 1 AS `TIPORECTIF`, + 1 AS `SERIE_RT`, + 1 AS `FACTU_RT`, + 1 AS `BASEIMP_RT`, + 1 AS `BASEIMP_RF`, + 1 AS `RECTIFICA`, + 1 AS `FECHA_RT`, + 1 AS `created`, + 1 AS `updated`, + 1 AS `FECREGCON`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `__taxClassCode` -- @@ -20256,7 +20460,7 @@ CREATE TABLE `address` ( CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=29531 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=29594 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 */ ; @@ -20376,24 +20580,9 @@ CREATE TABLE `addressObservation` ( KEY `addressObservationFgn_idx` (`observationTypeFk`), CONSTRAINT `addressFgn` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4175 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=4196 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `addressObservation__` --- - -DROP TABLE IF EXISTS `addressObservation__`; -/*!50001 DROP VIEW IF EXISTS `addressObservation__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `addressObservation__` AS SELECT - 1 AS `id`, - 1 AS `addressFk`, - 1 AS `observationTypeFk`, - 1 AS `description`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `address__` -- @@ -20674,7 +20863,7 @@ CREATE TABLE `autoRadioLogCall` ( PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=1737 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1774 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20691,7 +20880,7 @@ CREATE TABLE `autonomousRegion` ( `countryFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `countryFk` (`countryFk`), - CONSTRAINT `countryFk` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `countryFk` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -20769,8 +20958,8 @@ CREATE TABLE `bankEntity` ( PRIMARY KEY (`id`), UNIQUE KEY `bic_UNIQUE` (`bic`), KEY `fg_entity1_idx` (`countryFk`), - CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=30050 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; + CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=30051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20810,11 +20999,11 @@ CREATE TABLE `bookingPlanner` ( KEY `pgcFk_bookingPlanner_idx` (`pgcFk`), KEY `taxClassFk` (`taxClassFk`), KEY `countryFk` (`countryFk`), - KEY `bookingPlannerTaxArea` (`taxAreaFk`), + KEY `bookingPlannerIdx3` (`taxAreaFk`,`taxClassFk`,`countryFk`), CONSTRAINT `bookingPlannerTaxArea` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON UPDATE CASCADE, CONSTRAINT `bookingPlanner_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bookingPlanner_ibfk_2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE CASCADE + CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -20913,7 +21102,7 @@ CREATE TABLE `buy` ( CONSTRAINT `buy_ibfk_3` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=350459346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=352192921 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 */ ; @@ -21056,9 +21245,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -21223,7 +21412,7 @@ CREATE TABLE `claim` ( CONSTRAINT `claim_ibfk_3` FOREIGN KEY (`claimStateFk`) REFERENCES `claimState` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_4` FOREIGN KEY (`claimDepartmentFk`) REFERENCES `vn2008`.`cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=71188 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=71448 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21245,7 +21434,7 @@ CREATE TABLE `claimBeginning` ( KEY `cl_main_id` (`claimFk`), CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=156398 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=156853 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 */ ; @@ -21355,7 +21544,7 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_7` FOREIGN KEY (`claimReasonFk`) REFERENCES `claimReason` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_8` FOREIGN KEY (`claimResultFk`) REFERENCES `claimResult` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=61219 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=61379 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21416,7 +21605,7 @@ CREATE TABLE `claimEnd` ( CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=119366 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=119692 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21460,7 +21649,7 @@ CREATE TABLE `claimLog` ( KEY `userFk` (`userFk`), CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6455 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21731,14 +21920,14 @@ CREATE TABLE `client` ( KEY `fk_Clientes_entity_idx` (`bankEntityFk`), KEY `typeFk` (`typeFk`), CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`contactChannelFk`) REFERENCES `contactChannel` (`id`) ON UPDATE CASCADE, - CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `client_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_2` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `client_ibfk_3` FOREIGN KEY (`salesPersonFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `client_ibfk_4` FOREIGN KEY (`defaultAddressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=16839 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16879 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 */ ; @@ -21886,7 +22075,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=4154 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4155 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21907,7 +22096,7 @@ CREATE TABLE `clientCredit` ( KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=84778 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=85110 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21925,22 +22114,6 @@ CREATE TABLE `clientCreditLimit` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `clientCredit__` --- - -DROP TABLE IF EXISTS `clientCredit__`; -/*!50001 DROP VIEW IF EXISTS `clientCredit__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `clientCredit__` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `workerFk`, - 1 AS `amount`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `clientDefaultCompany` -- @@ -22012,7 +22185,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) 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=238172 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=239932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22047,7 +22220,7 @@ CREATE TABLE `clientObservation` ( KEY `Id_Cliente` (`clientFk`), CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=78533 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=78725 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22158,7 +22331,7 @@ CREATE TABLE `clientSample` ( PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18485 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18542 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22493,6 +22666,63 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ochoa` int(10) unsigned NOT NULL, + `invoiceOutFk` int(11) DEFAULT '0', + `bookFk` int(11) DEFAULT '0', + `serialAFk` int(11) DEFAULT '0', + `serialEFk` int(11) DEFAULT '0', + `serialRFk` int(11) DEFAULT '0', + `serialCFk` int(11) DEFAULT '0', + `serialHFk` int(11) NOT NULL, + `serialPFk` int(11) DEFAULT '0', + `serialTFk` int(11) DEFAULT '0', + `inventoried` datetime DEFAULT NULL, + `serialMFk` int(11) DEFAULT '0', + `itemLog` int(11) DEFAULT '0', + `weekGoal` int(11) DEFAULT NULL, + `photosPath` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `cashBoxNumber` int(11) DEFAULT '0', + `redCode` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, + `TabletTime` datetime DEFAULT NULL, + `t0` int(11) NOT NULL DEFAULT '0', + `t1` int(11) NOT NULL DEFAULT '0', + `t2` int(11) NOT NULL DEFAULT '0', + `t3` int(11) NOT NULL DEFAULT '0', + `cc` double NOT NULL DEFAULT '0', + `palet` double NOT NULL DEFAULT '0', + `campaign` datetime NOT NULL, + `campaignLife` tinyint(3) unsigned NOT NULL, + `truckDays` tinyint(3) unsigned NOT NULL, + `transportCharges` double NOT NULL, + `escanerPath` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + `printedTurn` int(4) DEFAULT NULL, + `truckLength` int(11) DEFAULT '24', + `fuelConsumption` int(11) DEFAULT NULL, + `petrol` decimal(10,1) DEFAULT NULL, + `maintenance` decimal(10,1) DEFAULT NULL, + `hourPrice` decimal(10,1) DEFAULT NULL, + `meterPrice` decimal(10,1) DEFAULT NULL, + `kmPrice` decimal(10,1) DEFAULT NULL, + `routeOption` int(11) DEFAULT '1', + `dbproduccion` tinyint(1) NOT NULL DEFAULT '1', + `mdbServer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, + `fakeEmail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `defaultersMaxAmount` int(10) DEFAULT '200' COMMENT 'maxima deuda permitida a partir de la cual se bloquea a un usuario', + `ASIEN` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `fechainv_idx` (`inventoried`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `config__` +-- + +DROP TABLE IF EXISTS `config__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `config__` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mdbServer` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `fakeEmail` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -22551,7 +22781,7 @@ DROP TABLE IF EXISTS `country`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `country` ( - `Id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `country` varchar(25) COLLATE utf8_unicode_ci NOT NULL, `CEE` tinyint(1) NOT NULL DEFAULT '1', `code` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, @@ -22563,7 +22793,7 @@ CREATE TABLE `country` ( `hasDailyInvoice` tinyint(4) NOT NULL DEFAULT '0', `isUeeMember` tinyint(4) NOT NULL DEFAULT '0', `ibanLength` tinyint(4) DEFAULT NULL, - PRIMARY KEY (`Id`), + PRIMARY KEY (`id`), KEY `Id_Paisreal` (`politicalCountryFk`) ) ENGINE=InnoDB AUTO_INCREMENT=72 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -22810,7 +23040,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3264 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3268 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 */ ; @@ -22855,7 +23085,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=3125 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=3147 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 */ ; @@ -23051,7 +23281,7 @@ CREATE TABLE `device` ( PRIMARY KEY (`id`), KEY `device_fk1_idx` (`userFk`), CONSTRAINT `device_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=365 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=367 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23076,7 +23306,7 @@ CREATE TABLE `deviceProduction` ( KEY `departmentFgn` (`departmentFk`), CONSTRAINT `departmentFgn` FOREIGN KEY (`departmentFk`) REFERENCES `vn2008`.`department` (`department_id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `deviceProductionModelsFgn` FOREIGN KEY (`modelFk`) REFERENCES `deviceProductionModels` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=376 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23164,7 +23394,7 @@ CREATE TABLE `dms` ( UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), KEY `trabajador_id` (`workerFk`), KEY `warehouse_id` (`warehouseFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1379804 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1386776 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 */ ; @@ -23351,7 +23581,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`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 `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4294 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4307 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23392,7 +23622,7 @@ CREATE TABLE `duaIntrastat` ( KEY `duaIntrastat_fk2_idx` (`duaFk`), CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `intrastat` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7137 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7185 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23412,7 +23642,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=5253 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=5267 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 */; -- @@ -23437,7 +23667,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 `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=10040 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23573,7 +23803,7 @@ CREATE TABLE `entry` ( CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=181287 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=181977 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 */ ; @@ -23774,7 +24004,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=175066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=176820 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24021,7 +24251,7 @@ CREATE TABLE `expedition` ( KEY `index4` (`ticketFk`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3407728 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3420411 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 */ ; @@ -24299,7 +24529,7 @@ CREATE TABLE `greuge` ( KEY `Greuges_cliente_idx` (`clientFk`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3783801 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; +) ENGINE=InnoDB AUTO_INCREMENT=3807112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24338,38 +24568,6 @@ CREATE TABLE `greugeType` ( ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `greugeType__` --- - -DROP TABLE IF EXISTS `greugeType__`; -/*!50001 DROP VIEW IF EXISTS `greugeType__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `greugeType__` AS SELECT - 1 AS `id`, - 1 AS `name`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `greuge__` --- - -DROP TABLE IF EXISTS `greuge__`; -/*!50001 DROP VIEW IF EXISTS `greuge__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `greuge__` AS SELECT - 1 AS `id`, - 1 AS `clientFk`, - 1 AS `description`, - 1 AS `amount`, - 1 AS `shipped`, - 1 AS `created`, - 1 AS `greugeTypeFk`, - 1 AS `ticketFk`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `holiday` -- @@ -24399,14 +24597,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `holidayLegend__` +-- Temporary table structure for view `holidayLegend` -- -DROP TABLE IF EXISTS `holidayLegend__`; -/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; +DROP TABLE IF EXISTS `holidayLegend`; +/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `holidayLegend__` AS SELECT +/*!50001 CREATE VIEW `holidayLegend` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; @@ -24471,23 +24669,6 @@ SET character_set_client = utf8; 1 AS `name`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `ink__` --- - -DROP TABLE IF EXISTS `ink__`; -/*!50001 DROP VIEW IF EXISTS `ink__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `ink__` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `picture`, - 1 AS `showOrder`, - 1 AS `ball`, - 1 AS `isCargex`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `intrastat` -- @@ -24551,7 +24732,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26503 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=27119 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24772,7 +24953,7 @@ CREATE TABLE `invoiceInTaxBookingAccount` ( KEY `invoiceInTaxBookingAccount_fk3_idx` (`countryFk`), CONSTRAINT `invoiceInTaxBookingAccount_fk1` FOREIGN KEY (`taxAreaFk`) REFERENCES `taxArea` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInTaxBookingAccount_fk2` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE, - CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE + CONSTRAINT `invoiceInTaxBookingAccount_fk3` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -24829,7 +25010,7 @@ CREATE TABLE `invoiceOut` ( CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=521420 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=521491 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 */ ; @@ -24955,7 +25136,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=135589 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=135660 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 */; -- @@ -24998,7 +25179,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1176977 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1177056 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25104,7 +25285,7 @@ CREATE TABLE `item` ( CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=375197 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=376303 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 */ ; @@ -25231,23 +25412,9 @@ CREATE TABLE `itemBarcode` ( UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42554 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42918 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `itemBarcode__` --- - -DROP TABLE IF EXISTS `itemBarcode__`; -/*!50001 DROP VIEW IF EXISTS `itemBarcode__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemBarcode__` AS SELECT - 1 AS `id`, - 1 AS `itemFk`, - 1 AS `code`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `itemBotanical` -- @@ -25321,21 +25488,6 @@ SET character_set_client = utf8; 1 AS `ediBotanic`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `itemBotanical__` --- - -DROP TABLE IF EXISTS `itemBotanical__`; -/*!50001 DROP VIEW IF EXISTS `itemBotanical__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemBotanical__` AS SELECT - 1 AS `itemFk`, - 1 AS `botanical`, - 1 AS `genusFk`, - 1 AS `specieFk`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `itemCategory` -- @@ -25458,7 +25610,7 @@ CREATE TABLE `itemLog` ( KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=92669 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=98195 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25485,28 +25637,24 @@ CREATE TABLE `itemPlacement` ( CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=955168 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1159689 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemPlacementAfterUpdate` - AFTER UPDATE ON `itemPlacement` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`itemPlacement_AFTER_DELETE` AFTER DELETE ON `itemPlacement` FOR EACH ROW BEGIN - IF NEW.`code` = 0 THEN INSERT INTO vn2008.mail SET `to` = 'jgallego@verdnatura.es', `reply_to` = 'jgallego@verdnatura.es', `subject` = 'Nicho modificado', - `text` = CONCAT(account.myUserGetName(), ' ha modificado el nicho del item ', - NEW.itemFk, ' de ', OLD.`code`, ' a ', NEW.`code`); - END IF; + `text` = CONCAT(account.myUserGetName(), ' ha eliminado la linea de ', OLD.`itemFk`); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25539,7 +25687,7 @@ CREATE TABLE `itemPlacementSupply` ( 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, CONSTRAINT `itemPlacementSupply_fk4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=78764 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=80270 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 */; -- @@ -25658,7 +25806,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=136195 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=138716 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25775,7 +25923,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 DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=73775 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB AUTO_INCREMENT=75118 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 */; -- @@ -25847,7 +25995,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 `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=38275 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=41364 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25974,7 +26122,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1388702 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1398362 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 */ ; @@ -26115,11 +26263,10 @@ CREATE TABLE `itemTaxCountry` ( UNIQUE KEY `itemFk_UNIQUE` (`itemFk`,`countryFk`), KEY `taxClassFK_idx` (`taxClassFk`), KEY `countryFK_paises_idx` (`countryFk`), - KEY `itemFK_Article_idx` (`itemFk`), - CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=879400 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=887149 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 */; -- @@ -26194,7 +26341,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemType_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=282 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=284 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 */ ; @@ -26347,66 +26494,6 @@ CREATE TABLE `itemVerdecora` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona nuestros articulos con los de Verdecora'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `item__` --- - -DROP TABLE IF EXISTS `item__`; -/*!50001 DROP VIEW IF EXISTS `item__`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `item__` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `typeFk`, - 1 AS `size`, - 1 AS `inkFk`, - 1 AS `category`, - 1 AS `stems`, - 1 AS `originFk`, - 1 AS `description`, - 1 AS `producerFk`, - 1 AS `intrastatFk`, - 1 AS `isOnOffer`, - 1 AS `box`, - 1 AS `expenceFk`, - 1 AS `isBargain`, - 1 AS `comment`, - 1 AS `relevancy`, - 1 AS `image`, - 1 AS `generic`, - 1 AS `density`, - 1 AS `taxClassFk`, - 1 AS `minPrice`, - 1 AS `hasMinPrice`, - 1 AS `isActive`, - 1 AS `longName`, - 1 AS `subName`, - 1 AS `tag5`, - 1 AS `value5`, - 1 AS `tag6`, - 1 AS `value6`, - 1 AS `tag7`, - 1 AS `value7`, - 1 AS `tag8`, - 1 AS `value8`, - 1 AS `tag9`, - 1 AS `value9`, - 1 AS `tag10`, - 1 AS `value10`, - 1 AS `minimum`, - 1 AS `upToDown`, - 1 AS `compression`, - 1 AS `hasKgPrice`, - 1 AS `equivalent`, - 1 AS `isToPrint`, - 1 AS `isDeliveryNote`, - 1 AS `family`, - 1 AS `doPhoto`, - 1 AS `niche`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `labourTree` -- @@ -26504,7 +26591,7 @@ CREATE TABLE `mandate` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`mandateTypeFk`) REFERENCES `mandateType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17236 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=17277 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 */ ; @@ -26629,7 +26716,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 `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=367 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=369 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26650,7 +26737,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=2048871 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2054567 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26672,7 +26759,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2224271 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2230247 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26802,7 +26889,7 @@ CREATE TABLE `origin` ( KEY `warehouse_id` (`warehouseFk`), KEY `Id_Paises` (`countryFk`), CONSTRAINT `origin_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26902,7 +26989,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=2961 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27005,7 +27092,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=26778 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=26789 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 */ ; @@ -27608,7 +27695,7 @@ CREATE TABLE `producer` ( `isVisible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=14171 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14462 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27708,7 +27795,7 @@ CREATE TABLE `province` ( KEY `Paises_Id` (`countryFk`), KEY `warehouse_Id` (`warehouseFk`), KEY `provicne_zone_fk_idx` (`zoneFk`), - CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=209 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -27941,7 +28028,7 @@ CREATE TABLE `receipt` ( CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=608220 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=609571 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 */ ; @@ -28035,7 +28122,7 @@ CREATE TABLE `recovery` ( KEY `cliente_idx` (`clientFk`), CONSTRAINT `cliente333` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=316 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDB AUTO_INCREMENT=318 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28127,7 +28214,7 @@ CREATE TABLE `route` ( KEY `route_ibfk_2_idx` (`workerFk`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=59755 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=60062 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 */ ; @@ -28218,7 +28305,7 @@ CREATE TABLE `routeComplement` ( KEY `fgn_routeActionFk_idx` (`routeActionFk`), CONSTRAINT `fgn_routeActionFk` FOREIGN KEY (`routeActionFk`) REFERENCES `routeAction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgn_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1020 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28321,7 +28408,7 @@ CREATE TABLE `routeLog` ( KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=185459 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=194875 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28432,7 +28519,7 @@ CREATE TABLE `sale` ( KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26334522 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=26397790 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 */ ; @@ -28673,7 +28760,7 @@ CREATE TABLE `saleTracking` ( KEY `fgnStateFk_idx` (`stateFk`), KEY `saleTracking_idx5` (`created`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20832569 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20981803 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 */ ; @@ -28735,6 +28822,7 @@ SET character_set_client = utf8; 1 AS `shipped`, 1 AS `volume`, 1 AS `physicalWeight`, + 1 AS `weight`, 1 AS `physicalVolume`*/; SET character_set_client = @saved_cs_client; @@ -28799,7 +28887,7 @@ DROP TABLE IF EXISTS `sample`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `sample` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(20) CHARACTER SET utf8 NOT NULL, `description` varchar(105) COLLATE utf8_unicode_ci NOT NULL, `isVisible` tinyint(4) NOT NULL DEFAULT '1', `hasCompany` varchar(45) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', @@ -28864,7 +28952,7 @@ CREATE TABLE `sharingCart` ( KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2210 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2223 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 */ ; @@ -29073,7 +29161,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=154152 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=154883 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29262,7 +29350,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=842567 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=847019 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29321,11 +29409,11 @@ CREATE TABLE `supplier` ( KEY `province_id` (`provinceFk`), KEY `pay_dem_id` (`payDemFk`), KEY `codpos` (`postCode`,`postCode__`), - CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON UPDATE CASCADE, + CONSTRAINT `Id_Pais` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2946 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2953 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29350,7 +29438,7 @@ CREATE TABLE `supplierAccount` ( KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), KEY `fk_banco_prov_account_idx` (`bankFk`) -) ENGINE=InnoDB AUTO_INCREMENT=871 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=876 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29627,7 +29715,7 @@ CREATE TABLE `taxType` ( PRIMARY KEY (`id`), KEY `serie_id` (`serial`), KEY `Id_Pais` (`countryFk`), - CONSTRAINT `taxType_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `taxType_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29707,7 +29795,7 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2472973 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2481940 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 */ ; @@ -29982,7 +30070,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) 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=8018501 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8090850 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30019,7 +30107,7 @@ CREATE TABLE `ticketObservation` ( KEY `observation_type_id` (`observationTypeFk`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1501295 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1508239 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30074,7 +30162,7 @@ CREATE TABLE `ticketPackaging` ( CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=76679 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=77239 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 */ ; @@ -30137,7 +30225,7 @@ CREATE TABLE `ticketParking` ( KEY `ticketParking_fk1_idx` (`parkingFk`), CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8919 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +) ENGINE=InnoDB AUTO_INCREMENT=10892 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30203,7 +30291,7 @@ CREATE TABLE `ticketRequest` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=51780 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52095 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 */ ; @@ -30462,7 +30550,7 @@ CREATE TABLE `ticketWeekly` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`ticketFk`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2459705 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2477090 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30736,7 +30824,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 `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB AUTO_INCREMENT=437 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 */; -- @@ -30788,7 +30876,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn2008`.`Proveedores_cargueras` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=140526 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=142064 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 */ ; @@ -31045,7 +31133,7 @@ CREATE TABLE `vehicle` ( KEY `provinceFk_idx` (`warehouseFk`), CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `vehicle_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=450 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=451 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31097,7 +31185,7 @@ CREATE TABLE `warehouse` ( UNIQUE KEY `name_UNIQUE` (`name`), KEY `Id_Paises` (`countryFk`), KEY `isComparativeIdx` (`isComparative`), - CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`Id`) + CONSTRAINT `warehouse_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -31430,7 +31518,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `worker` (`userFk`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12770 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12892 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31495,7 +31583,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=60070840 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=61483385 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31534,7 +31622,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 `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15870 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16021 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31560,9 +31648,8 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `workerTeam` AS SELECT 1 AS `team`, - 1 AS `user`, 1 AS `id`, - 1 AS `Id_Trabajador`*/; + 1 AS `workerFk`*/; SET character_set_client = @saved_cs_client; -- @@ -31598,7 +31685,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8290721 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=8295889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32001,7 +32088,7 @@ CREATE TABLE `zoneGeo` ( KEY `name_idx` (`name`), KEY `parentFk` (`parentFk`), KEY `path` (`path`) -) ENGINE=InnoDB AUTO_INCREMENT=597459 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=597460 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 */ ; @@ -33002,6 +33089,200 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `client_getSalesPerson` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `client_getSalesPerson`(vClientFk INT, vDated DATE) RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo + * en cuenta la jerarquía de las tablas: 1º la de sharingclient, 2º la de + * sharingcart y tercero la de clientes. + * + * @param vClientFk El id del cliente + * @param vDated Fecha a comprobar + * @return El id del comercial para la fecha dada + **/ + DECLARE vSalesPersonFk INT DEFAULT NULL; + DECLARE vWorkerSubstituteFk INT DEFAULT NULL; + DECLARE vLoop BOOLEAN; + + -- Obtiene el comercial original y el de sharingclient + + SELECT c.salesPersonFk, s.workerFk + INTO vSalesPersonFk, vWorkerSubstituteFk + FROM client c + LEFT JOIN sharingClient s + ON c.id = s.clientFk + AND vDated BETWEEN s.started AND s.ended + WHERE c.id = vClientFk + ORDER BY s.id + LIMIT 1; + + -- Si no hay ninguno en sharingclient busca en sharingcart + + IF vWorkerSubstituteFk IS NOT NULL + THEN + SET vSalesPersonFk = vWorkerSubstituteFk; + ELSEIF vSalesPersonFk IS NOT NULL + THEN + DROP TEMPORARY TABLE IF EXISTS tmp.stack; + CREATE TEMPORARY TABLE tmp.stack + (INDEX (substitute)) + ENGINE = MEMORY + SELECT vSalesPersonFk substitute; + + l: LOOP + SELECT workerSubstitute INTO vWorkerSubstituteFk + FROM sharingCart + WHERE vDated BETWEEN started AND ended + AND workerFk = vSalesPersonFk + ORDER BY id + LIMIT 1; + + IF vWorkerSubstituteFk IS NULL THEN + LEAVE l; + END IF; + + SELECT COUNT(*) > 0 INTO vLoop + FROM tmp.stack WHERE substitute = vWorkerSubstituteFk; + + IF vLoop THEN + LEAVE l; + END IF; + + INSERT INTO tmp.stack SET + substitute = vWorkerSubstituteFk; + + SET vSalesPersonFk = vWorkerSubstituteFk; + END LOOP; + + DROP TEMPORARY TABLE tmp.stack; + END IF; + + RETURN vSalesPersonFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonByTicket` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `client_getSalesPersonByTicket`(vTicketFk INT) RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Dado un id ticket, devuelve su comercial. + * Para más información ir a client_getSalesPerson() + * + * @param vClientFk El id del cliente + * @param vDated Fecha a comprobar + * @return El id del comercial para la fecha dada + **/ + DECLARE vClientFk INT; + DECLARE vDated DATE; + + SELECT clientFk, shipped + INTO vClientFk, vDated + FROM ticket WHERE id = vTicketFk; + + RETURN client_getSalesPerson(vClientFk, vDated); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonCode` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `client_getSalesPersonCode`(vClientFk INT, vDated DATE) RETURNS varchar(3) CHARSET utf8 + DETERMINISTIC +BEGIN +/** + * Dado un id cliente y una fecha, devuelve su comercial. + * Para más información ir a client_getSalesPerson() + * + * @param vClientFk El id del cliente + * @param vDated Fecha a comprobar + * @return El código del comercial para la fecha dada + **/ + DECLARE vWorkerCode CHAR(3); + DECLARE vSalesPersonFk INT; + + SET vSalesPersonFk = client_getSalesPerson(vClientFk, vDated); + + SELECT code + INTO vWorkerCode + FROM worker + WHERE id = vSalesPersonFk; + + RETURN IFNULL(vWorkerCode, '---'); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `client_getSalesPersonCodeByTicket` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `client_getSalesPersonCodeByTicket`(vTicketFk INT) RETURNS varchar(3) CHARSET utf8 + DETERMINISTIC +BEGIN +/** + * Dado un id ticket, devuelve su comercial. + * Para más información ir a client_getSalesPerson() + * + * @param vClientFk El id del cliente + * @param vDated Fecha a comprobar + * @return El código del comercial para la fecha dada + **/ + DECLARE vClientFk INT; + DECLARE vDated DATE; + + SELECT clientFk, shipped + INTO vClientFk, vDated + FROM ticket WHERE id = vTicketFk; + + RETURN client_getSalesPersonCode(vClientFk, vDated); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `currentRate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -36921,9 +37202,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -36936,7 +37217,7 @@ BEGIN * @param vDate Fecha maxima de los registros * @return tmp.risk */ - DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 5, CURDATE()); + DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, -35, CURDATE()); DECLARE vEnded DATETIME; SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); @@ -37122,6 +37403,85 @@ 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 `clientGetDebt__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `clientGetDebt__`(vDate DATE) +BEGIN +/** + * Calcula el riesgo para los clientes activos + * + * @table tmp.clientGetDebt(clientFk) + * @param vDate Fecha maxima de los registros + * @return tmp.risk + */ + DECLARE vStarted DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(CURDATE()) - 5, CURDATE()); + DECLARE vEnded DATETIME; + + SET vEnded = TIMESTAMP(IFNULL(vDate, CURDATE()), '23:59:59'); + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT id ticketFk, c.clientFk + FROM ticket t + JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk + WHERE refFk IS NULL + AND shipped BETWEEN vStarted AND vEnded; + + CALL ticketGetTotal(); + + DROP TEMPORARY TABLE IF EXISTS tClientRisk; + CREATE TEMPORARY TABLE tClientRisk + ENGINE = MEMORY + SELECT cr.customer_id clientFk, SUM(cr.amount) amount + FROM bi.customer_risk cr + JOIN tmp.clientGetDebt c ON c.clientFk = cr.customer_id + GROUP BY cr.customer_id; + + INSERT INTO tClientRisk + SELECT c.clientFk, SUM(r.amountPaid) + FROM receipt r + JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk + WHERE r.payed > vEnded + GROUP BY c.clientFk; + + INSERT INTO tClientRisk + SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) + FROM hedera.tpvTransaction t + JOIN tmp.clientGetDebt c ON c.clientFk = t.clientFk + WHERE t.receiptFk IS NULL + AND t.status = 'ok' + GROUP BY t.clientFk; + + INSERT INTO tClientRisk + SELECT t.clientFk, total + FROM tmp.ticketTotal tt + JOIN tmp.ticket t ON t.ticketFk = tt.ticketFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.risk; + CREATE TEMPORARY TABLE tmp.risk + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT clientFk, SUM(amount) risk + FROM client c + JOIN tClientRisk cr ON cr.clientFk = c.id + WHERE c.isActive + GROUP BY c.id; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `clientGreugeSpray` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -39448,9 +39808,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -39462,7 +39822,6 @@ proc: BEGIN * @param vDate Fecha de los nuevos inventarios */ - DECLARE vDone BOOL; DECLARE vEntryFk INT; DECLARE vTravelFk INT; @@ -39497,7 +39856,8 @@ proc: BEGIN WHERE warehouseOutFk = 13 AND landed < vDate AND e.supplierFk = 4 - AND warehouseInFk = vWh; + AND warehouseInFk = vWh + AND NOT isRaid; -- Generamos travel, si no existe. SET vTravelFK = 0; @@ -39581,7 +39941,9 @@ proc: BEGIN JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk WHERE tr.warehouseInFk = vWh - AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday + AND tr.landed BETWEEN vDateLastInventory + AND vDateYesterday + AND NOT isRaid GROUP BY b.itemFk; SELECT vDateLastInventory , vDateYesterday; -- Traslados @@ -39593,7 +39955,9 @@ proc: BEGIN JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk WHERE tr.warehouseOutFk = vWh - AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday + AND tr.shipped BETWEEN vDateLastInventory + AND vDateYesterday + AND NOT isRaid GROUP BY b.itemFk ) sub ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.quantityOut; @@ -42989,7 +43353,7 @@ BEGIN iss.visible itemShelvingStock, IFNULL(v.visible,0) visible, b.isPickedOff, - vSectorFk as sectorFk + iss.sectorFk FROM vn.itemShelvingStock iss JOIN vn.item i on i.id = iss.itemFk LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iss.itemFk AND ip.warehouseFk = vWarehouseFk @@ -43002,7 +43366,8 @@ BEGIN WHERE saldo > 0 GROUP BY itemFk ) ips ON ips.itemFk = i.id - WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) ; + WHERE IFNULL(iss.sectorFk,0) IN (0, vSectorFk) + AND iss.sectorFk = vSectorFk; DROP TEMPORARY TABLE IF EXISTS tmp.itemOutTime; CREATE TEMPORARY TABLE tmp.itemOutTime @@ -56752,7 +57117,7 @@ CREATE TABLE `Cajas` ( KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `Cajas_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=741068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=743086 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 */ ; @@ -57005,7 +57370,7 @@ CREATE TABLE `Colas` ( KEY `Id_Trabajador` (`Id_Trabajador`), CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `vn`.`queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3267 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16828 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57426,7 +57791,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`entry` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3965007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3981946 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57444,7 +57809,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 `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58071,7 +58436,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=2879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2880 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58137,7 +58502,7 @@ CREATE TABLE `PreciosEspeciales` ( CONSTRAINT `sp_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE, CONSTRAINT `{01A99AF1-3D3F-4B15-AC0C-C7A834F319A3}` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `{EE4ADEF6-0AC6-401F-B7C4-D797972FC065}` FOREIGN KEY (`Id_Article`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=713 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=714 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58346,7 +58711,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1361 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1367 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58371,7 +58736,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58555,7 +58920,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) 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=370114 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=370266 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58573,7 +58938,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=36995 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=37005 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58667,7 +59032,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65226145 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65246637 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 */ ; @@ -58945,7 +59310,7 @@ CREATE TABLE `Vehiculos_consumo` ( CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `vn`.`vehicle` (`id`) ON UPDATE CASCADE, CONSTRAINT `fuelTypeFk` FOREIGN KEY (`fuelTypeFk`) REFERENCES `vn`.`fuelType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `proveedoresFk` FOREIGN KEY (`proveedoresFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=12835 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=12896 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 */; -- @@ -58980,131 +59345,82 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `XDiario` +-- Temporary table structure for view `XDiario` -- DROP TABLE IF EXISTS `XDiario`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `XDiario` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ASIEN` double DEFAULT NULL, - `FECHA` datetime DEFAULT NULL, - `SUBCTA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `CONTRA` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `CONCEPTO` varchar(50) CHARACTER SET utf8 DEFAULT NULL, - `EURODEBE` decimal(10,2) DEFAULT NULL, - `EUROHABER` decimal(10,2) DEFAULT NULL, - `BASEEURO` decimal(10,2) DEFAULT NULL, - `SERIE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `FACTURA` varchar(8) COLLATE utf8_unicode_ci DEFAULT '0', - `BASEIMPO` decimal(10,2) DEFAULT NULL, - `IVA` decimal(10,2) DEFAULT NULL, - `RECEQUIV` decimal(10,2) DEFAULT '0.00', - `DOCUMENTO` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `DEPARTA` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL, - `CLAVE` int(11) DEFAULT NULL, - `ESTADO` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `NCASADO` decimal(10,2) DEFAULT NULL, - `TCASADO` decimal(10,2) DEFAULT NULL, - `TRANS` decimal(10,2) DEFAULT NULL, - `CAMBIO` decimal(10,2) DEFAULT NULL, - `DEBEME` decimal(10,2) DEFAULT NULL, - `HABERME` decimal(10,2) DEFAULT NULL, - `PTAHABER` decimal(10,2) DEFAULT NULL, - `AUXILIAR` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `SUCURSAL` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, - `PTADEBE` decimal(10,2) DEFAULT NULL, - `CODDIVISA` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `IMPAUXME` decimal(10,2) DEFAULT NULL, - `MONEDAUSO` varchar(1) COLLATE utf8_unicode_ci DEFAULT '2', - `NOCONV` tinyint(1) NOT NULL DEFAULT '0', - `NUMEROINV` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOOPE` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `NFACTICK` tinyint(1) NOT NULL DEFAULT '1', - `TERIDNIF` tinyint(1) NOT NULL DEFAULT '2', - `TERNIF` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'I.F.', - `TERNOM` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'Nombre Importador', - `OPBIENES` tinyint(1) NOT NULL DEFAULT '1', - `TIPOFAC` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `TIPOIVA` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL, - `L340` tinyint(2) NOT NULL DEFAULT '0', - `enlazado` tinyint(1) NOT NULL DEFAULT '0', - `FECHA_EX` date DEFAULT NULL COMMENT 'FEcha de expedicion de la factura', - `LRECT349` tinyint(1) NOT NULL DEFAULT '0', - `empresa_id` smallint(5) unsigned NOT NULL DEFAULT '442', - `LDIFADUAN` tinyint(4) NOT NULL DEFAULT '0', - `METAL` tinyint(1) NOT NULL DEFAULT '0', - `METALIMP` decimal(10,2) NOT NULL DEFAULT '0.00', - `CLIENTE` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `METALEJE` varchar(4) COLLATE utf8_unicode_ci DEFAULT NULL, - `FECHA_OP` date DEFAULT NULL COMMENT 'FEcha de operacion', - `FACTURAEX` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Numero de factura del proveedor', - `TIPOCLAVE` int(3) DEFAULT NULL, - `TIPOEXENCI` int(3) DEFAULT NULL, - `TIPONOSUJE` int(3) DEFAULT NULL, - `TIPOFACT` int(3) DEFAULT NULL, - `TIPORECTIF` int(3) DEFAULT NULL, - `SERIE_RT` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL, - `FACTU_RT` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `BASEIMP_RT` decimal(10,2) DEFAULT NULL, - `BASEIMP_RF` decimal(10,2) DEFAULT NULL, - `RECTIFICA` int(1) NOT NULL DEFAULT '0', - `FECHA_RT` date DEFAULT NULL, - `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `FECREGCON` date DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `empresa_id` (`empresa_id`), - CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4050157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`XDiario_BEFORE_INSERT` BEFORE INSERT ON `XDiario` FOR EACH ROW -BEGIN -/* - IF NEW.EURODEBE < 0 THEN - - SET NEW.EUROHABER = - NEW.EURODEBE; - SET NEW.EURODEBE = NULL; - - END IF; - - IF NEW.EUROHABER < 0 THEN - - SET NEW.EURODEBE = - NEW.EUROHABER; - SET NEW.EUROHABER = NULL; - - END IF; - - IF NEW.DEBEME < 0 THEN - - SET NEW.HABERME = - NEW.DEBEME; - SET NEW.DEBEME = NULL; - - END IF; - - IF NEW.HABERME < 0 THEN - - SET NEW.DEBEME = - NEW.HABERME; - SET NEW.HABERME = NULL; - - END IF; - */ -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `XDiario`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `XDiario` AS SELECT + 1 AS `id`, + 1 AS `ASIEN`, + 1 AS `FECHA`, + 1 AS `SUBCTA`, + 1 AS `CONTRA`, + 1 AS `CONCEPTO`, + 1 AS `EURODEBE`, + 1 AS `EUROHABER`, + 1 AS `BASEEURO`, + 1 AS `SERIE`, + 1 AS `FACTURA`, + 1 AS `BASEIMPO`, + 1 AS `IVA`, + 1 AS `RECEQUIV`, + 1 AS `DOCUMENTO`, + 1 AS `DEPARTA`, + 1 AS `CLAVE`, + 1 AS `ESTADO`, + 1 AS `NCASADO`, + 1 AS `TCASADO`, + 1 AS `TRANS`, + 1 AS `CAMBIO`, + 1 AS `DEBEME`, + 1 AS `HABERME`, + 1 AS `PTAHABER`, + 1 AS `AUXILIAR`, + 1 AS `SUCURSAL`, + 1 AS `PTADEBE`, + 1 AS `CODDIVISA`, + 1 AS `IMPAUXME`, + 1 AS `MONEDAUSO`, + 1 AS `NOCONV`, + 1 AS `NUMEROINV`, + 1 AS `TIPOOPE`, + 1 AS `NFACTICK`, + 1 AS `TERIDNIF`, + 1 AS `TERNIF`, + 1 AS `TERNOM`, + 1 AS `OPBIENES`, + 1 AS `TIPOFAC`, + 1 AS `TIPOIVA`, + 1 AS `L340`, + 1 AS `enlazado`, + 1 AS `FECHA_EX`, + 1 AS `LRECT349`, + 1 AS `empresa_id`, + 1 AS `LDIFADUAN`, + 1 AS `METAL`, + 1 AS `METALIMP`, + 1 AS `CLIENTE`, + 1 AS `METALEJE`, + 1 AS `FECHA_OP`, + 1 AS `FACTURAEX`, + 1 AS `TIPOCLAVE`, + 1 AS `TIPOEXENCI`, + 1 AS `TIPONOSUJE`, + 1 AS `TIPOFACT`, + 1 AS `TIPORECTIF`, + 1 AS `SERIE_RT`, + 1 AS `FACTU_RT`, + 1 AS `BASEIMP_RT`, + 1 AS `BASEIMP_RF`, + 1 AS `RECTIFICA`, + 1 AS `FECHA_RT`, + 1 AS `created`, + 1 AS `updated`, + 1 AS `FECREGCON`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `accion_dits` @@ -59143,7 +59459,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 `vn`.`supplierAccount` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=37440 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=37876 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 */ ; @@ -59451,7 +59767,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`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 `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3722 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59530,7 +59846,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 `vn`.`supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3593 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3606 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 */ ; @@ -59696,7 +60012,7 @@ CREATE TABLE `awb_component` ( CONSTRAINT `awb_component_` FOREIGN KEY (`awb_component_type_id`) REFERENCES `awb_component_type` (`awb_component_type_id`) ON UPDATE CASCADE, CONSTRAINT `awb_role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=32465 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=32804 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59811,7 +60127,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 `vn`.`dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3174 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3187 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59958,7 +60274,7 @@ CREATE TABLE `botanic_export` ( `isProtectedZone` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`botanic_export_id`), KEY `Id_Paises` (`Id_Paises`), - CONSTRAINT `botanic_export_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `vn`.`country` (`Id`) + CONSTRAINT `botanic_export_ibfk_1` FOREIGN KEY (`Id_Paises`) REFERENCES `vn`.`country` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=340 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Especifica los generos y especies prohibidos en paises'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -60902,7 +61218,7 @@ CREATE TABLE `duaDismissed` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticketFk` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`,`ticketFk`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61525,7 +61841,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `vn`.`intrastat` (`id`) 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=84230 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=84537 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61810,7 +62126,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1928287 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1935466 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62042,7 +62358,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `vn`.`payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52505 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52643 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 */ ; @@ -62473,7 +62789,7 @@ CREATE TABLE `plantpassport_authority` ( PRIMARY KEY (`plantpassport_authority_id`), UNIQUE KEY `denomination_UNIQUE` (`denomination`), KEY `Pais_id_idx` (`Paises_Id`), - CONSTRAINT `Pais_id` FOREIGN KEY (`Paises_Id`) REFERENCES `vn`.`country` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `Pais_id` FOREIGN KEY (`Paises_Id`) REFERENCES `vn`.`country` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='entidades certificadoras'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -62538,7 +62854,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 `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64735 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64835 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 */ ; @@ -62718,7 +63034,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=88912 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=89106 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 */ ; @@ -62956,7 +63272,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`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 `vn`.`expence` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=165608 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=166766 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62979,7 +63295,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `vn`.`bank` (`id`) 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=163686 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=164779 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 */ ; @@ -63249,7 +63565,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=112178 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=112863 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 */; -- @@ -63291,7 +63607,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=1430269 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1440144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63491,82 +63807,59 @@ CREATE TABLE `tarifas` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `tblContadores` +-- Temporary table structure for view `tblContadores` -- DROP TABLE IF EXISTS `tblContadores`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tblContadores` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `ochoa` int(10) unsigned NOT NULL, - `nfactura` int(11) DEFAULT '0', - `nasiento` int(11) DEFAULT '0', - `serieA` int(11) DEFAULT '0', - `serieE` int(11) DEFAULT '0', - `serieR` int(11) DEFAULT '0', - `serieC` int(11) DEFAULT '0', - `SerieH` int(11) NOT NULL, - `serieP` int(11) DEFAULT '0', - `serieT` int(11) DEFAULT '0', - `FechaInventario` datetime DEFAULT NULL, - `serieM` int(11) DEFAULT '0', - `HistoricoArticulo` int(11) DEFAULT '0', - `week_goal` int(11) DEFAULT NULL, - `Rutafotos` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, - `numCaja` int(11) DEFAULT '0', - `CodigoRojo` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, - `Tablet_Hora` datetime DEFAULT NULL, - `t0` int(11) NOT NULL DEFAULT '0', - `t1` int(11) NOT NULL DEFAULT '0', - `t2` int(11) NOT NULL DEFAULT '0', - `t3` int(11) NOT NULL DEFAULT '0', - `cc` double NOT NULL DEFAULT '0', - `palet` double NOT NULL DEFAULT '0', - `campaign` datetime NOT NULL, - `campaign_life` tinyint(3) unsigned NOT NULL, - `truck_days` tinyint(3) unsigned NOT NULL, - `tasa_transporte` double NOT NULL, - `escaner_path` varchar(50) COLLATE utf8_unicode_ci NOT NULL, - `turnoimpreso` int(4) DEFAULT NULL, - `truck_length` int(11) DEFAULT '24', - `fuel_consumption` int(11) DEFAULT NULL, - `petrol` decimal(10,1) DEFAULT NULL, - `maintenance` decimal(10,1) DEFAULT NULL, - `hour_price` decimal(10,1) DEFAULT NULL, - `meter_price` decimal(10,1) DEFAULT NULL, - `km_price` decimal(10,1) DEFAULT NULL, - `route_option` int(11) DEFAULT '1', - `dbproduccion` tinyint(1) NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - KEY `fechainv_idx` (`FechaInventario`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`tblContadores_bi` BEFORE INSERT ON `tblContadores` FOR EACH ROW -BEGIN - DECLARE v_count INT; - - SELECT COUNT(*) INTO v_count FROM tblContadores; - - IF v_count > 0 THEN - SIGNAL SQLSTATE '45000' - SET MESSAGE_TEXT = 'ONLY_ONE_ROW_ALLOWED'; - END IF; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50001 DROP VIEW IF EXISTS `tblContadores`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `tblContadores` AS SELECT + 1 AS `id`, + 1 AS `ochoa`, + 1 AS `nfactura`, + 1 AS `nasiento`, + 1 AS `serieA`, + 1 AS `serieE`, + 1 AS `serieR`, + 1 AS `serieC`, + 1 AS `SerieH`, + 1 AS `serieP`, + 1 AS `serieT`, + 1 AS `FechaInventario`, + 1 AS `serieM`, + 1 AS `HistoricoArticulo`, + 1 AS `week_goal`, + 1 AS `Rutafotos`, + 1 AS `numCaja`, + 1 AS `CodigoRojo`, + 1 AS `Tablet_Hora`, + 1 AS `t0`, + 1 AS `t1`, + 1 AS `t2`, + 1 AS `t3`, + 1 AS `cc`, + 1 AS `palet`, + 1 AS `campaign`, + 1 AS `campaign_life`, + 1 AS `truck_days`, + 1 AS `tasa_transporte`, + 1 AS `escaner_path`, + 1 AS `turnoimpreso`, + 1 AS `truck_length`, + 1 AS `fuel_consumption`, + 1 AS `petrol`, + 1 AS `maintenance`, + 1 AS `hour_price`, + 1 AS `meter_price`, + 1 AS `km_price`, + 1 AS `route_option`, + 1 AS `dbproduccion`, + 1 AS `mdbServer`, + 1 AS `fakeEmail`, + 1 AS `defaultersMaxAmount`, + 1 AS `ASIEN`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `tblIVA` @@ -63830,7 +64123,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 `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=244897 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=246042 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63860,7 +64153,7 @@ CREATE TABLE `travel_pattern` ( CONSTRAINT `travel_pattern_ibfk_4` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_5` FOREIGN KEY (`warehouse_in`) REFERENCES `vn`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_pattern_ibfk_6` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -65088,7 +65381,7 @@ CREATE TABLE `workerTeam` ( KEY `user_idx` (`user`), KEY `team_idx` (`team`), CONSTRAINT `user_team` FOREIGN KEY (`user`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=242 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -67882,9 +68175,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -67942,7 +68235,7 @@ proc: BEGIN -- Inserta el visible - CALL inventario_multiple_inventarios (vWh, vDateTime); + CALL vn.inventoryMake (vDateTime, vWh); -- Inserta Last_buy_id @@ -72565,9 +72858,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -72605,8 +72898,8 @@ BEGIN 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_2(C.Id_Cubo, C.Id_Article)) / 1000000) / C.Packing,0),3) + ROUND((va.importe * A.density * vn.item_getVolume(C.Id_Article,C.Id_Cubo) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + ROUND(IFNULL(((AG.m3 * vn.item_getVolume(C.Id_Article,C.Id_Cubo)) / 1000000) / C.Packing,0),3) ), C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), C.Embalajefijo = @EF:= ROUND(IF (vIsWarehouseFloramondo,0,(CB.costeRetorno + IF(CB.Retornable != 0, 0, CB.Valor)) / C.packing),3), @@ -72627,9 +72920,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -72662,7 +72955,7 @@ BEGIN 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:= round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + SET C.Portefijo = @PF:= round((va.importe * A.density * vn.item_getVolume( C.Id_Article,C.Id_Cubo) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), C.Embalajefijo = @EF:= ROUND((CB.costeRetorno + IF(CB.Retornable != 0, 0, CB.Valor)) / C.Packing,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 @@ -72823,8 +73116,8 @@ BEGIN 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) + ROUND((va.importe * A.density * vn.item_getVolume(C.Id_Article, C.Id_Cubo) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + ROUND(IFNULL(((AG.m3 * @cm3:= vn.item_getVolume(C.Id_Article, C.Id_Cubo)) / 1000000) / C.Packing,0),3) ), C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), C.Embalajefijo = @EF:= IF(CB.Retornable != 0 OR vIsWarehouseFloramondo, 0, ROUND(IFNULL( CB.Valor / C.Packing ,0),3)), @@ -72906,9 +73199,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -72937,7 +73230,7 @@ BEGIN nz(Costefijo) + nz(Embalajefijo) + nz(Portefijo) + nz(Comisionfija), life, C.Packing, - (cm3_2(C.Id_Cubo, C.Id_Article) / 1000000) / C.Packing, + (vn.item_getVolume(C.Id_Article, C.Id_Cubo) / 1000000) / C.Packing, promo INTO idART , wh , datFEC , dbCOST , intLIFE, intPACK, m3value, intPromo FROM Compres C @@ -73545,7 +73838,7 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -73644,7 +73937,7 @@ proc: BEGIN c.`grouping`, c.caja, @cost := IFNULL(c.Costefijo, 0) + IFNULL(c.Comisionfija, 0) + IFNULL(c.Portefijo, 0), - @porte := ROUND((@cm3:= cm3_2(c.Id_Cubo, c.Id_Article)) * a.m3 / 1000000 / c.Packing, 3), + @porte := ROUND((@cm3:= vn.item_getVolume(C.Id_Article, C.Id_Cubo)) * a.m3 / 1000000 / c.Packing, 3), c.EmbalajeFijo, @comision := ROUND(c.Costefijo * e.comision / 100, 3), c.buy_edi_id @@ -73668,7 +73961,7 @@ DELIMITER ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET character_set_client = utf8mb4 */ ; /*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -73767,7 +74060,7 @@ proc: BEGIN c.`grouping`, c.caja, @cost := IFNULL(c.Costefijo, 0) + IFNULL(c.Comisionfija, 0) + IFNULL(c.Portefijo, 0), - @porte := ROUND((@cm3:= cm3_2(c.Id_Cubo, c.Id_Article)) * a.m3 / 1000000 / c.Packing, 3), + @porte := ROUND((@cm3:= vn.item_getVolume(c.Id_Article, c.Id_Cubo)) * a.m3 / 1000000 / c.Packing, 3), c.EmbalajeFijo, @comision := ROUND(c.Costefijo * e.comision / 100, 3), c.buy_edi_id @@ -74281,9 +74574,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -74403,11 +74696,11 @@ proc: BEGIN DELETE w.* FROM vn2008.workerTeam w - JOIN (SELECT id, team, user, COUNT(*) - 1 as duplicated + JOIN (SELECT id, team, workerFk, COUNT(*) - 1 as duplicated FROM vn.workerTeam - GROUP BY team,user + GROUP BY team,workerFk HAVING duplicated - ) d ON d.team = w.team AND d.user = w.user AND d.id != w.id; + ) d ON d.team = w.team AND d.workerFk = w.user AND d.id != w.id; -- CAP 29/10/2018 Mantenimiento tabla Movimientos_componentes @@ -84148,6 +84441,84 @@ CREATE DEFINER=`root`@`%` PROCEDURE `pay`(IN datFEC DATE , IN strCONCEPTO VARCHAR(40) , IN idEMP INT) BEGIN + + -- Registro en la tabla Cajas + INSERT INTO Cajas ( Concepto + , Serie + , Numero + , Salida + , Cajafecha + , Partida + , Id_Banco + , Id_Trabajador + ,empresa_id + ,conciliado) + + SELECT CONCAT('n/pago a ', Proveedor) + , 'R' + , idPROV + , dblIMPORTE + , datFEC + , 1 + , idCAJA + , account.myUserGetId() + , idEMP + , 1 + FROM Proveedores + WHERE Id_Proveedor = idPROV; + + -- Registro en la tabla pago + INSERT INTO pago(fecha + , id_proveedor + , importe + , id_moneda + , divisa + , id_banco + , pay_met_id + , g_bancarios + , concepte + , empresa_id) + + VALUES(datFEC + , idPROV + , dblIMPORTE + , idMONEDA + , IF(dblDIVISA = 0, NULL, dblDIVISA) + , idCAJA + , idPAYMET + , dblGASTOS + , strCONCEPTO + , idEMP); + + SELECT LAST_INSERT_ID() as pago_id; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `pay__` */; +/*!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 `pay__`(IN datFEC DATE + , IN idPROV INT + , IN dblIMPORTE DOUBLE + , IN idMONEDA INT + , IN dblDIVISA DOUBLE + , IN idCAJA INT + , IN idPAYMET INT + , IN dblGASTOS DOUBLE + , IN strCONCEPTO VARCHAR(40) + , IN idEMP INT) +BEGIN -- Registro en la tabla Cajas @@ -84655,7 +85026,7 @@ BEGIN LEFT JOIN vn.state st ON st.id = `stPrevious`.`stateFk` AND st.code = 'PREVIOUS_PREPARATION' JOIN cache.visible v ON M.Id_Article = v.item_id AND v.calc_id = vVisibleCache -- JOIN tmp.visible visible ON visible.itemFk = v.item_id AND visible.warehouseFk = vWarehouse - JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id AND iss.warehouseFk = vWarehouse -- WHERE v.visible - visible.visible < M.Cantidad WHERE (v.visible - iss.visible) < M.Cantidad AND M.OK = FALSE @@ -89604,9 +89975,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -89745,6 +90116,7 @@ BEGIN T.Id_Ticket, T.warehouse_id as wh, T.Fecha, + T.Alias, -- T.Vista, REPEAT(' ',50) as problem, @@ -91152,9 +91524,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -91185,7 +91557,7 @@ BEGIN land.`grouping`, land.caja, @cost := ROUND(IFNULL(land.Costefijo, 0) + IFNULL(land.Comisionfija, 0) + IFNULL(land.Portefijo, 0),3) Costefij, - @porte := ROUND((@cm3:= cm3_2(land.Id_Cubo, land.Id_Article)) * a.m3 / 1000000 / land.Packing,3) Porte, + @porte := ROUND((@cm3:= vn.item_getVolume(land.Id_Article,land.Id_Cubo)) * a.m3 / 1000000 / land.Packing,3) Porte, land.EmbalajeFijo AS Embalaje, @comision := ROUND(land.Costefijo * e2.comision / 100, 3) Comision, land.novincular,land.buy_edi_id @@ -91319,9 +91691,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -91361,7 +91733,7 @@ BEGIN C.Packing, C.`grouping`, C.caja, - @pf := ROUND(@cm3:=cm3_2(IFNULL(C.Id_Cubo,'--'), b.item_id) * AG.m3 / 1000000 / C.Packing ,3) AS Porte, + @pf := ROUND(@cm3:=vn.item_getVolume(b.item_id,IFNULL(C.Id_Cubo,'--')) * AG.m3 / 1000000 / C.Packing ,3) AS Porte, @cf := IFNULL(ROUND(C.Costefijo * E.comision / 100 ,3),0) AS Comision, @ef := ROUND(IF(CB.Retornable = FALSE,CB.Valor/ C.Packing,0) ,3) AS Embalaje, @cost := ROUND(IFNULL(C.Costefijo,0) + @cf + @ef + @pf,3), @@ -93480,7 +93852,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21463048 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21606889 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 */ ; @@ -93983,12 +94355,12 @@ USE `bs`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `m3Silla` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; +/*!50001 VIEW `m3Silla` AS select `m3__`.`fecha` AS `fecha`,`m3__`.`year` AS `year`,`m3__`.`month` AS `month`,`m3__`.`week` AS `week`,`m3__`.`day` AS `day`,`m3__`.`dayName` AS `dayName`,cast(sum(`m3__`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3__`.`euros`) as decimal(10,0)) AS `Euros` from `m3__` where (`m3__`.`warehouseFk` in (1,44)) group by `m3__`.`fecha` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -94689,6 +95061,24 @@ USE `util`; USE `vn`; +-- +-- Final view structure for view `XDiario__` +-- + +/*!50001 DROP VIEW IF EXISTS `XDiario__`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `XDiario__` AS select `d`.`id` AS `id`,`d`.`ASIEN` AS `ASIEN`,`d`.`FECHA` AS `FECHA`,`d`.`SUBCTA` AS `SUBCTA`,`d`.`CONTRA` AS `CONTRA`,`d`.`CONCEPTO` AS `CONCEPTO`,`d`.`EURODEBE` AS `EURODEBE`,`d`.`EUROHABER` AS `EUROHABER`,`d`.`BASEEURO` AS `BASEEURO`,`d`.`SERIE` AS `SERIE`,`d`.`FACTURA` AS `FACTURA`,`d`.`BASEIMPO` AS `BASEIMPO`,`d`.`IVA` AS `IVA`,`d`.`RECEQUIV` AS `RECEQUIV`,`d`.`DOCUMENTO` AS `DOCUMENTO`,`d`.`DEPARTA` AS `DEPARTA`,`d`.`CLAVE` AS `CLAVE`,`d`.`ESTADO` AS `ESTADO`,`d`.`NCASADO` AS `NCASADO`,`d`.`TCASADO` AS `TCASADO`,`d`.`TRANS` AS `TRANS`,`d`.`CAMBIO` AS `CAMBIO`,`d`.`DEBEME` AS `DEBEME`,`d`.`HABERME` AS `HABERME`,`d`.`PTAHABER` AS `PTAHABER`,`d`.`AUXILIAR` AS `AUXILIAR`,`d`.`SUCURSAL` AS `SUCURSAL`,`d`.`PTADEBE` AS `PTADEBE`,`d`.`CODDIVISA` AS `CODDIVISA`,`d`.`IMPAUXME` AS `IMPAUXME`,`d`.`MONEDAUSO` AS `MONEDAUSO`,`d`.`NOCONV` AS `NOCONV`,`d`.`NUMEROINV` AS `NUMEROINV`,`d`.`TIPOOPE` AS `TIPOOPE`,`d`.`NFACTICK` AS `NFACTICK`,`d`.`TERIDNIF` AS `TERIDNIF`,`d`.`TERNIF` AS `TERNIF`,`d`.`TERNOM` AS `TERNOM`,`d`.`OPBIENES` AS `OPBIENES`,`d`.`TIPOFAC` AS `TIPOFAC`,`d`.`TIPOIVA` AS `TIPOIVA`,`d`.`L340` AS `L340`,`d`.`enlazado` AS `enlazado`,`d`.`FECHA_EX` AS `FECHA_EX`,`d`.`LRECT349` AS `LRECT349`,`d`.`empresa_id` AS `empresa_id`,`d`.`LDIFADUAN` AS `LDIFADUAN`,`d`.`METAL` AS `METAL`,`d`.`METALIMP` AS `METALIMP`,`d`.`CLIENTE` AS `CLIENTE`,`d`.`METALEJE` AS `METALEJE`,`d`.`FECHA_OP` AS `FECHA_OP`,`d`.`FACTURAEX` AS `FACTURAEX`,`d`.`TIPOCLAVE` AS `TIPOCLAVE`,`d`.`TIPOEXENCI` AS `TIPOEXENCI`,`d`.`TIPONOSUJE` AS `TIPONOSUJE`,`d`.`TIPOFACT` AS `TIPOFACT`,`d`.`TIPORECTIF` AS `TIPORECTIF`,`d`.`SERIE_RT` AS `SERIE_RT`,`d`.`FACTU_RT` AS `FACTU_RT`,`d`.`BASEIMP_RT` AS `BASEIMP_RT`,`d`.`BASEIMP_RF` AS `BASEIMP_RF`,`d`.`RECTIFICA` AS `RECTIFICA`,`d`.`FECHA_RT` AS `FECHA_RT`,`d`.`created` AS `created`,`d`.`updated` AS `updated`,`d`.`FECREGCON` AS `FECREGCON` from `vn2008`.`XDiario` `d` */; +/*!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 `__taxClassCode` -- @@ -94761,24 +95151,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `addressObservation__` --- - -/*!50001 DROP VIEW IF EXISTS `addressObservation__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `addressObservation__` AS select `co`.`consignatarios_observation_id` AS `id`,`co`.`Id_Consigna` AS `addressFk`,`co`.`observation_type_id` AS `observationTypeFk`,`co`.`text` AS `description` from `vn2008`.`consignatarios_observation` `co` */; -/*!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 `address__` -- @@ -95175,24 +95547,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `clientCredit__` --- - -/*!50001 DROP VIEW IF EXISTS `clientCredit__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `clientCredit__` AS select `c`.`id` AS `id`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`amount` AS `amount`,`c`.`odbc_date` AS `created` from `vn2008`.`credit` `c` */; -/*!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 `clientDefaultCompany` -- @@ -96021,42 +96375,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `greugeType__` --- - -/*!50001 DROP VIEW IF EXISTS `greugeType__`*/; -/*!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 `greugeType__` AS select `gt`.`Greuges_type_id` AS `id`,`gt`.`name` AS `name` from `vn2008`.`Greuges_type` `gt` */; -/*!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 `greuge__` --- - -/*!50001 DROP VIEW IF EXISTS `greuge__`*/; -/*!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 `greuge__` AS select `g`.`Id` AS `id`,`g`.`Id_Cliente` AS `clientFk`,`g`.`Comentario` AS `description`,`g`.`Importe` AS `amount`,`g`.`Fecha` AS `shipped`,`g`.`odbc_date` AS `created`,`g`.`Greuges_type_id` AS `greugeTypeFk`,`g`.`Id_Ticket` AS `ticketFk` from `vn2008`.`Greuges` `g` */; -/*!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 `holiday` -- @@ -96094,10 +96412,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `holidayLegend__` +-- Final view structure for view `holidayLegend` -- -/*!50001 DROP VIEW IF EXISTS `holidayLegend__`*/; +/*!50001 DROP VIEW IF EXISTS `holidayLegend`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -96106,7 +96424,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `holidayLegend__` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; +/*!50001 VIEW `holidayLegend` AS select `cll`.`calendar_labour_legend_id` AS `id`,`cll`.`descripcion` AS `description` from `postgresql`.`calendar_labour_legend` `cll` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -96147,24 +96465,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `ink__` --- - -/*!50001 DROP VIEW IF EXISTS `ink__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ink__` AS select `c`.`Id_Tinta` AS `id`,`c`.`name` AS `name`,`c`.`Tinta` AS `picture`,`c`.`Orden` AS `showOrder`,`c`.`ball` AS `ball`,`c`.`cargex` AS `isCargex` from `vn2008`.`Tintas` `c` */; -/*!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 `intrastat__` -- @@ -96345,24 +96645,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `itemBarcode__` --- - -/*!50001 DROP VIEW IF EXISTS `itemBarcode__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemBarcode__` AS select `barcodes`.`id` AS `id`,`barcodes`.`Id_Article` AS `itemFk`,`barcodes`.`code` AS `code` from `vn2008`.`barcodes` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `itemBotanicalWithGenus` -- @@ -96381,24 +96663,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `itemBotanical__` --- - -/*!50001 DROP VIEW IF EXISTS `itemBotanical__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemBotanical__` AS select `ab`.`Id_Article` AS `itemFk`,`ab`.`botanical` AS `botanical`,`ab`.`genus_id` AS `genusFk`,`ab`.`specie_id` AS `specieFk` from `vn2008`.`Articles_botanical` `ab` */; -/*!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 `itemCategoryL10n` -- @@ -96592,7 +96856,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`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk` */; +/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,min(`ish`.`grouping`) AS `grouping`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk`,`ish`.`shelvingFk` AS `shelvingFk`,`p`.`code` AS `parkingCode`,`sh`.`parkingFk` AS `parkingFk`,`ish`.`id` AS `itemShelvingFk`,`ish`.`created` AS `created` from ((((`itemShelving` `ish` left join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) left join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) left join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where ((`ish`.`visible` <> 0) and `p`.`sectorFk`) group by `ish`.`itemFk`,`p`.`sectorFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -96705,24 +96969,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `item__` --- - -/*!50001 DROP VIEW IF EXISTS `item__`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `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`.`compression` AS `compression`,`t`.`hasKgPrice` AS `hasKgPrice`,`t`.`Equivalente` AS `equivalent`,`t`.`Imprimir` AS `isToPrint`,`t`.`Albaranero` AS `isDeliveryNote`,`t`.`Familia` AS `family`,`t`.`do_photo` AS `doPhoto`,`t`.`Nicho` AS `niche`,`t`.`odbc_date` AS `created` 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 */; - -- -- Final view structure for view `mail` -- @@ -97438,7 +97684,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `r`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume` from (((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; +/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round(((((`i`.`compression` * (greatest(`i`.`density`,167) / 167)) * `r`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros`,`t`.`routeFk` AS `routeFk`,`t`.`shipped` AS `shipped`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume`,((((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) * (greatest(`i`.`density`,167) / 167)) / 1000000) AS `physicalWeight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`density`) / 1000000) AS `weight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `physicalVolume` from (((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -98279,12 +98525,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTeam` AS select `w`.`team` AS `team`,`w`.`user` AS `user`,`w`.`id` AS `id`,`t`.`Id_Trabajador` AS `Id_Trabajador` from (`vn2008`.`workerTeam` `w` left join `vn2008`.`Trabajadores` `t` on((`t`.`user_id` = `w`.`user`))) */; +/*!50001 VIEW `workerTeam` AS select `w`.`team` AS `team`,`w`.`id` AS `id`,`w`.`user` AS `workerFk` from `vn2008`.`workerTeam` `w` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -98297,12 +98543,12 @@ USE `vn`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`Id_Trabajador` AS `workerFk`,`t`.`Id_Trabajador` AS `collegueFk` from (`vn`.`workerTeam` `w` join `vn`.`workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; +/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerFk`,`t`.`workerFk` AS `collegueFk` from (`vn`.`workerTeam` `w` join `vn`.`workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -98830,7 +99076,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `Paises` AS select `c`.`Id` AS `Id`,`c`.`country` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`politicalCountryFk` AS `Id_Paisreal`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice`,`c`.`nstGeoFk` AS `nst_geo_id`,`c`.`nstName` AS `nst_name` from `vn`.`country` `c` */; +/*!50001 VIEW `Paises` AS select `c`.`id` AS `Id`,`c`.`country` AS `Pais`,`c`.`CEE` AS `CEE`,`c`.`isUeeMember` AS `isUeeMember`,`c`.`code` AS `Codigo`,`c`.`currencyFk` AS `Id_Moneda`,`c`.`politicalCountryFk` AS `Id_Paisreal`,`c`.`geoFk` AS `geoFk`,`c`.`ibanLength` AS `ibanLength`,`c`.`hasDailyInvoice` AS `hasDailyInvoice`,`c`.`nstGeoFk` AS `nst_geo_id`,`c`.`nstName` AS `nst_name` from `vn`.`country` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -99087,6 +99333,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `XDiario` +-- + +/*!50001 DROP VIEW IF EXISTS `XDiario`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `XDiario` AS select `d`.`id` AS `id`,`d`.`ASIEN` AS `ASIEN`,`d`.`FECHA` AS `FECHA`,`d`.`SUBCTA` AS `SUBCTA`,`d`.`CONTRA` AS `CONTRA`,`d`.`CONCEPTO` AS `CONCEPTO`,`d`.`EURODEBE` AS `EURODEBE`,`d`.`EUROHABER` AS `EUROHABER`,`d`.`BASEEURO` AS `BASEEURO`,`d`.`SERIE` AS `SERIE`,`d`.`FACTURA` AS `FACTURA`,`d`.`BASEIMPO` AS `BASEIMPO`,`d`.`IVA` AS `IVA`,`d`.`RECEQUIV` AS `RECEQUIV`,`d`.`DOCUMENTO` AS `DOCUMENTO`,`d`.`DEPARTA` AS `DEPARTA`,`d`.`CLAVE` AS `CLAVE`,`d`.`ESTADO` AS `ESTADO`,`d`.`NCASADO` AS `NCASADO`,`d`.`TCASADO` AS `TCASADO`,`d`.`TRANS` AS `TRANS`,`d`.`CAMBIO` AS `CAMBIO`,`d`.`DEBEME` AS `DEBEME`,`d`.`HABERME` AS `HABERME`,`d`.`PTAHABER` AS `PTAHABER`,`d`.`AUXILIAR` AS `AUXILIAR`,`d`.`SUCURSAL` AS `SUCURSAL`,`d`.`PTADEBE` AS `PTADEBE`,`d`.`CODDIVISA` AS `CODDIVISA`,`d`.`IMPAUXME` AS `IMPAUXME`,`d`.`MONEDAUSO` AS `MONEDAUSO`,`d`.`NOCONV` AS `NOCONV`,`d`.`NUMEROINV` AS `NUMEROINV`,`d`.`TIPOOPE` AS `TIPOOPE`,`d`.`NFACTICK` AS `NFACTICK`,`d`.`TERIDNIF` AS `TERIDNIF`,`d`.`TERNIF` AS `TERNIF`,`d`.`TERNOM` AS `TERNOM`,`d`.`OPBIENES` AS `OPBIENES`,`d`.`TIPOFAC` AS `TIPOFAC`,`d`.`TIPOIVA` AS `TIPOIVA`,`d`.`L340` AS `L340`,`d`.`enlazado` AS `enlazado`,`d`.`FECHA_EX` AS `FECHA_EX`,`d`.`LRECT349` AS `LRECT349`,`d`.`empresa_id` AS `empresa_id`,`d`.`LDIFADUAN` AS `LDIFADUAN`,`d`.`METAL` AS `METAL`,`d`.`METALIMP` AS `METALIMP`,`d`.`CLIENTE` AS `CLIENTE`,`d`.`METALEJE` AS `METALEJE`,`d`.`FECHA_OP` AS `FECHA_OP`,`d`.`FACTURAEX` AS `FACTURAEX`,`d`.`TIPOCLAVE` AS `TIPOCLAVE`,`d`.`TIPOEXENCI` AS `TIPOEXENCI`,`d`.`TIPONOSUJE` AS `TIPONOSUJE`,`d`.`TIPOFACT` AS `TIPOFACT`,`d`.`TIPORECTIF` AS `TIPORECTIF`,`d`.`SERIE_RT` AS `SERIE_RT`,`d`.`FACTU_RT` AS `FACTU_RT`,`d`.`BASEIMP_RT` AS `BASEIMP_RT`,`d`.`BASEIMP_RF` AS `BASEIMP_RF`,`d`.`RECTIFICA` AS `RECTIFICA`,`d`.`FECHA_RT` AS `FECHA_RT`,`d`.`created` AS `created`,`d`.`updated` AS `updated`,`d`.`FECREGCON` AS `FECREGCON` from `vn`.`XDiario` `d` */; +/*!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 `agency` -- @@ -100473,6 +100737,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `tblContadores` +-- + +/*!50001 DROP VIEW IF EXISTS `tblContadores`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ +/*!50001 VIEW `tblContadores` AS select `c`.`id` AS `id`,`c`.`ochoa` AS `ochoa`,`c`.`invoiceOutFk` AS `nfactura`,`c`.`bookFk` AS `nasiento`,`c`.`serialAFk` AS `serieA`,`c`.`serialEFk` AS `serieE`,`c`.`serialRFk` AS `serieR`,`c`.`serialCFk` AS `serieC`,`c`.`serialHFk` AS `SerieH`,`c`.`serialPFk` AS `serieP`,`c`.`serialTFk` AS `serieT`,`c`.`inventoried` AS `FechaInventario`,`c`.`serialMFk` AS `serieM`,`c`.`itemLog` AS `HistoricoArticulo`,`c`.`weekGoal` AS `week_goal`,`c`.`photosPath` AS `Rutafotos`,`c`.`cashBoxNumber` AS `numCaja`,`c`.`redCode` AS `CodigoRojo`,`c`.`TabletTime` AS `Tablet_Hora`,`c`.`t0` AS `t0`,`c`.`t1` AS `t1`,`c`.`t2` AS `t2`,`c`.`t3` AS `t3`,`c`.`cc` AS `cc`,`c`.`palet` AS `palet`,`c`.`campaign` AS `campaign`,`c`.`campaignLife` AS `campaign_life`,`c`.`truckDays` AS `truck_days`,`c`.`transportCharges` AS `tasa_transporte`,`c`.`escanerPath` AS `escaner_path`,`c`.`printedTurn` AS `turnoimpreso`,`c`.`truckLength` AS `truck_length`,`c`.`fuelConsumption` AS `fuel_consumption`,`c`.`petrol` AS `petrol`,`c`.`maintenance` AS `maintenance`,`c`.`hourPrice` AS `hour_price`,`c`.`meterPrice` AS `meter_price`,`c`.`kmPrice` AS `km_price`,`c`.`routeOption` AS `route_option`,`c`.`dbproduccion` AS `dbproduccion`,`c`.`mdbServer` AS `mdbServer`,`c`.`fakeEmail` AS `fakeEmail`,`c`.`defaultersMaxAmount` AS `defaultersMaxAmount`,`c`.`ASIEN` AS `ASIEN` from `vn`.`config` `c` */; +/*!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 `ticketCreationData` -- @@ -101381,12 +101663,12 @@ USE `vn2008`; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 SET character_set_client = utf8mb4 */; +/*!50001 SET character_set_results = utf8mb4 */; +/*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`Id_Trabajador` AS `workerId`,`t`.`Id_Trabajador` AS `collegueId` from (`vn`.`workerTeam` `w` join `vn`.`workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; +/*!50001 VIEW `workerTeamCollegues` AS select distinct `w`.`workerFk` AS `workerId`,`t`.`workerFk` AS `collegueId` from (`vn`.`workerTeam` `w` join `vn`.`workerTeam` `t` on((`w`.`team` = `t`.`team`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -101424,4 +101706,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-12 9:11:50 +-- Dump completed on 2019-11-19 13:08:44 From c47f3137c13a5a8baa79c92243d96cc263a03f7d Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 19 Nov 2019 13:49:10 +0100 Subject: [PATCH 02/12] Delivery days fixes --- db/changes/10081-agency/00-zone_getEvents.sql | 6 +-- modules/agency/front/calendar/index.js | 42 ++++++++++--------- modules/agency/front/events/index.html | 2 +- modules/agency/front/events/index.js | 30 +++++-------- 4 files changed, 38 insertions(+), 42 deletions(-) diff --git a/db/changes/10081-agency/00-zone_getEvents.sql b/db/changes/10081-agency/00-zone_getEvents.sql index 6e47bad22..be50f602d 100644 --- a/db/changes/10081-agency/00-zone_getEvents.sql +++ b/db/changes/10081-agency/00-zone_getEvents.sql @@ -16,7 +16,7 @@ BEGIN * @param vPostCode The postcode or %NULL to use the province */ DECLARE vGeoFk INT; - + IF vPostCode IS NOT NULL THEN SELECT p.geoFk INTO vGeoFk FROM postCode p @@ -37,11 +37,11 @@ BEGIN WHERE z.agencyModeFk != vAgencyModeFk; END IF; - SELECT e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays + SELECT e.zoneFk, e.`type`, e.dated, e.`started`, e.`ended`, e.weekDays FROM tmp.zone t JOIN zoneEvent e ON e.zoneFk = t.id; - SELECT DISTINCT e.dated + SELECT e.zoneFk, e.dated FROM tmp.zone t JOIN zoneExclusion e ON e.zoneFk = t.id; diff --git a/modules/agency/front/calendar/index.js b/modules/agency/front/calendar/index.js index ec28fa134..88f16d334 100644 --- a/modules/agency/front/calendar/index.js +++ b/modules/agency/front/calendar/index.js @@ -62,12 +62,15 @@ class Controller extends Component { return date && new Date(date).setHours(0, 0, 0, 0); } - this.exclusionsMap = {}; + this.exclusions = {}; let exclusions = value.exclusions; if (exclusions) { - for (let exclusion of exclusions) - this.exclusionsMap[toStamp(exclusion.dated)] = exclusion; + for (let exclusion of exclusions) { + let stamp = toStamp(exclusion.dated); + if (!this.exclusions[stamp]) this.exclusions[stamp] = []; + this.exclusions[stamp].push(exclusion); + } } let events = value.events; @@ -98,6 +101,7 @@ class Controller extends Component { let stamp = day.getTime(); let wday = day.getDay(); let dayEvents = []; + let exclusions = this.exclusions[stamp] || []; if (this.events) { for (let event of this.events) { @@ -114,46 +118,46 @@ class Controller extends Component { break; } - if (match) + if (match && !exclusions.find(e => e.zoneFk == event.zoneFk)) dayEvents.push(event); } } - let exclusion = this.exclusionsMap[stamp]; - - if (dayEvents.length || exclusion) { - let dayData = {}; - if (dayEvents.length) dayData.events = dayEvents; - if (exclusion) dayData.exclusion = exclusion; - this.days[stamp] = dayData; - } + if (dayEvents.length) + this.days[stamp] = dayEvents; day.setDate(day.getDate() + 1); } } onSelection($days, $type, $weekday) { - let $data = []; + let $events = []; + let $exclusions = []; + for (let day of $days) { - let dayData = this.days[day.getTime()]; - if (dayData) $data.push(dayData); + let stamp = day.getTime(); + $events = $events.concat(this.days[stamp] || []); + $exclusions = $exclusions.concat(this.exclusions[stamp] || []); } this.emit('selection', { $days, $type, $weekday, - $data + $events, + $exclusions }); } hasEvents(day) { - return this.days[day.getTime()] != null; + let stamp = day.getTime(); + return this.days[stamp] || this.exclusions[stamp]; } getClass(day) { - let dayData = this.days[day.getTime()]; - return dayData && dayData.exclusion ? 'excluded' : ''; + let stamp = day.getTime(); + return this.exclusions[stamp] && !this.days[stamp] + ? 'excluded' : ''; } } Controller.$inject = ['$element', '$scope', 'vnWeekDays']; diff --git a/modules/agency/front/events/index.html b/modules/agency/front/events/index.html index 1b8c1e871..274d79997 100644 --- a/modules/agency/front/events/index.html +++ b/modules/agency/front/events/index.html @@ -1,7 +1,7 @@ diff --git a/modules/agency/front/events/index.js b/modules/agency/front/events/index.js index b6352802a..90f06c8d1 100644 --- a/modules/agency/front/events/index.js +++ b/modules/agency/front/events/index.js @@ -36,22 +36,14 @@ class Controller extends Section { : this.$t('Everyday'); } - onSelection(days, type, weekday, data) { + onSelection(days, type, weekday, events, exclusions) { + console.log(events, exclusions); if (this.editMode == 'include') { - let dayData = data[0] || {}; - let event = dayData.events && dayData.events[0]; - - if (event) - this.edit(event); + if (events.length) + this.edit(events[0]); else this.create(days, type, weekday); } else { - let exclusions = []; - for (let dayData of data) { - if (dayData.exclusion) - exclusions.push(dayData.exclusion.id); - } - if (exclusions.length) this.exclusionDelete(exclusions); else @@ -155,16 +147,16 @@ class Controller extends Section { .then(() => this.refresh()); } - exclusionDelete(ids) { - let promises = []; + exclusionDelete(exclusions) { + let reqs = []; - for (let id of ids) { - promises.push( - this.$http.delete(`${this.exclusionsPath}/${id}`) - ); + for (let exclusion of exclusions) { + if (!exclusion.id) continue; + let path = `${this.exclusionsPath}/${exclusion.id}`; + reqs.push(this.$http.delete(path)); } - this.$q.all(promises) + this.$q.all(reqs) .then(() => this.refresh()); } } From 43c1c34cf3e509167009693d5010ab10dd9cb8e4 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 19 Nov 2019 14:33:25 +0100 Subject: [PATCH 03/12] #1888 nightmarejs extension --- e2e/helpers/extensions.js | 10 ++++++++++ e2e/helpers/selectors.js | 3 ++- e2e/paths/02-client-module/03_edit_fiscal_data.spec.js | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 4d6285603..ed12439a9 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -428,6 +428,16 @@ let actions = { waitForSpinnerLoad: function() { return this.waitUntilNotPresent('vn-topbar vn-spinner'); + }, + + waitForWatcherData: function(selector) { + return this.wait(selector) + .wait(selector => { + const watcher = document.querySelector(selector); + let orgData = watcher.$ctrl.orgData; + return !angular.equals({}, orgData) && orgData != null; + }, selector) + .waitForSpinnerLoad(); } }; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7b5b583f6..1e73f3191 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -118,7 +118,8 @@ export default { addObservationButton: 'vn-client-address-edit div[name="observations"] vn-icon-button[icon="add_circle"]', saveButton: `button[type=submit]`, cancelCreateAddressButton: 'button[ui-sref="client.card.address.index"]', - cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button' + cancelEditAddressButton: 'vn-client-address-edit > form > vn-button-bar > vn-button > button', + watcher: 'vn-client-address-edit vn-watcher' }, clientWebAccess: { webAccessButton: 'vn-left-menu a[ui-sref="client.card.webAccess"]', diff --git a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js index 836ce8976..c28f0a8fe 100644 --- a/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/02-client-module/03_edit_fiscal_data.spec.js @@ -138,7 +138,7 @@ describe('Client Edit fiscalData path', () => { it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => { const result = await nightmare .waitToClick(selectors.clientAddresses.firstEditAddress) - .waitForSpinnerLoad() + .waitForWatcherData(selectors.clientAddresses.watcher) .checkboxState(selectors.clientAddresses.equalizationTaxCheckbox); expect(result).toBe('checked'); @@ -149,7 +149,7 @@ describe('Client Edit fiscalData path', () => { const result = await nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditAddress) - .waitForSpinnerLoad() + .waitForWatcherData(selectors.clientAddresses.watcher) .checkboxState(selectors.clientAddresses.equalizationTaxCheckbox); expect(result).toBe('checked'); From 59fddb5c552c2abc40508832570644a3023f0afc Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 19 Nov 2019 15:44:33 +0100 Subject: [PATCH 04/12] vnAgencyEvents: console.log removed --- modules/agency/front/events/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/agency/front/events/index.js b/modules/agency/front/events/index.js index 90f06c8d1..bea352d06 100644 --- a/modules/agency/front/events/index.js +++ b/modules/agency/front/events/index.js @@ -37,7 +37,6 @@ class Controller extends Section { } onSelection(days, type, weekday, events, exclusions) { - console.log(events, exclusions); if (this.editMode == 'include') { if (events.length) this.edit(events[0]); From 5bb7f7f14aafa1ddcd1354fe7b843c71e0f00e60 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 20 Nov 2019 11:14:11 +0100 Subject: [PATCH 05/12] deprecated getItemVisibleAvailable() #1887 --- .../00-getItemVisibleAvailable.sql | 17 +++++ .../00-itemGetVisibleAvailable.sql | 17 +++++ .../00-item_getVisibleAvailable.sql | 71 +++++++++++++++++++ modules/item/back/methods/item/getSummary.js | 2 +- .../back/methods/item/getVisibleAvailable.js | 2 +- modules/item/back/methods/item/regularize.js | 2 +- .../methods/item/specs/regularize.spec.js | 2 +- .../back/methods/ticket-request/confirm.js | 2 +- modules/ticket/back/methods/ticket/addSale.js | 2 +- 9 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 db/changes/10110-postCampaign/00-getItemVisibleAvailable.sql create mode 100644 db/changes/10110-postCampaign/00-itemGetVisibleAvailable.sql create mode 100644 db/changes/10110-postCampaign/00-item_getVisibleAvailable.sql diff --git a/db/changes/10110-postCampaign/00-getItemVisibleAvailable.sql b/db/changes/10110-postCampaign/00-getItemVisibleAvailable.sql new file mode 100644 index 000000000..21b827a75 --- /dev/null +++ b/db/changes/10110-postCampaign/00-getItemVisibleAvailable.sql @@ -0,0 +1,17 @@ +USE `vn`; +DROP procedure IF EXISTS `getItemVisibleAvailable`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `getItemVisibleAvailable`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) +BEGIN + -- DEPRECADO - UTILIZAR vn.item_getVisibleAvailable() - JSB - 2019-11-20 + CALL item_getVisibleAvailable(vItem, vDate, vWarehouse, vRefresh); +END$$ + +DELIMITER ; + diff --git a/db/changes/10110-postCampaign/00-itemGetVisibleAvailable.sql b/db/changes/10110-postCampaign/00-itemGetVisibleAvailable.sql new file mode 100644 index 000000000..4701e7124 --- /dev/null +++ b/db/changes/10110-postCampaign/00-itemGetVisibleAvailable.sql @@ -0,0 +1,17 @@ +USE `vn`; +DROP procedure IF EXISTS `itemGetVisibleAvailable`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `itemGetVisibleAvailable`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) +BEGIN + -- DEPRECADO - UTILIZAR vn.item_getVisibleAvailable() - JSB - 2019-11-20 + CALL item_getVisibleAvailable(vItem, vDate, vWarehouse, vRefresh); +END$$ + +DELIMITER ; + diff --git a/db/changes/10110-postCampaign/00-item_getVisibleAvailable.sql b/db/changes/10110-postCampaign/00-item_getVisibleAvailable.sql new file mode 100644 index 000000000..e6b6df2f9 --- /dev/null +++ b/db/changes/10110-postCampaign/00-item_getVisibleAvailable.sql @@ -0,0 +1,71 @@ + +USE `vn`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` PROCEDURE `item_getVisibleAvailable`( + vItem INT, + vDate DATE, + vWarehouse TINYINT, + vRefresh BOOL) +BEGIN + DECLARE vVisibleCalc INT; + DECLARE vAvailableCalc INT; + DECLARE vVisibleAltillo INT; + + CALL cache.available_refresh(vAvailableCalc, FALSE /*vRefresh*/ , vWarehouse, vDate); + CALL cache.visible_refresh(vVisibleCalc, FALSE,vWarehouse); + + SELECT visible INTO vVisibleAltillo + FROM vn.itemShelvingStock + WHERE itemFk = vItem + AND warehouseFk = vWarehouse; + + IF vRefresh THEN + + DROP TEMPORARY TABLE IF EXISTS vn2008.tmp_item; + CREATE TEMPORARY TABLE vn2008.tmp_item + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT vItem item_id, 0 stock, 0 visible; + + SELECT i.id, i.longName, i.box, i.typeFk, + i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8, + ip.code, ip.reserve, + vi.visible - IFNULL(vVisibleAltillo,0) AS visible, + av.available + FROM vn.item i + LEFT JOIN vn.itemPlacement ip + ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse + LEFT JOIN vn2008.tmp_item v + ON v.item_id = i.id + LEFT JOIN cache.available av + ON av.calc_id = vAvailableCalc AND av.item_id = i.id + LEFT JOIN cache.visible vi + ON vi.calc_id = vVisibleCalc AND vi.item_id = i.id + LEFT JOIN cache.stock st + ON st.warehouse_id = vWarehouse AND st.item_id = i.id + WHERE (vItem IS NULL OR i.id = vItem); + + ELSE + + SELECT i.id, i.longName, i.box, i.typeFk, + i.tag5,i.value5,i.tag6,i.value6,i.tag7,i.value7,i.tag8,i.value8, + ip.code, ip.reserve, + v.visible - IFNULL(vVisibleAltillo,0) AS visible, + av.available + FROM vn.item i + LEFT JOIN vn.itemPlacement ip + ON i.id = ip.itemFk AND ip.warehouseFk = vWarehouse + LEFT JOIN cache.visible v + ON v.item_id = i.id AND v.calc_id = vVisibleCalc + LEFT JOIN cache.available av + ON av.item_id = i.id AND av.calc_id = vAvailableCalc + WHERE (vItem IS NULL OR i.id = vItem); + + END IF; + +END$$ + +DELIMITER ; +; diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 51fed3753..749e1212f 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -103,7 +103,7 @@ module.exports = Self => { // Visible Avaible let query = ` - CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; + CALL vn.item_getVisibleAvailable(?,curdate(),?,?)`; let options = [summary.item.id, summary.item.itemType().warehouseFk, false]; [res] = await Self.rawSql(query, options); diff --git a/modules/item/back/methods/item/getVisibleAvailable.js b/modules/item/back/methods/item/getVisibleAvailable.js index b35ca5fb7..7f0855740 100644 --- a/modules/item/back/methods/item/getVisibleAvailable.js +++ b/modules/item/back/methods/item/getVisibleAvailable.js @@ -24,7 +24,7 @@ module.exports = Self => { Self.getVisibleAvailable = async(id, warehouseFk) => { let query = ` - CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; + CALL vn.item_getVisibleAvailable(?,curdate(),?,?)`; let options = [id, warehouseFk, false]; [res] = await Self.rawSql(query, options); diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js index b9aa0d85f..b9c646086 100644 --- a/modules/item/back/methods/item/regularize.js +++ b/modules/item/back/methods/item/regularize.js @@ -65,7 +65,7 @@ module.exports = Self => { let query = ` - CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; + CALL vn.item_getVisibleAvailable(?,curdate(),?,?)`; let params = [itemFk, warehouseFk, true]; let [res] = await Self.rawSql(query, params, options); diff --git a/modules/item/back/methods/item/specs/regularize.spec.js b/modules/item/back/methods/item/specs/regularize.spec.js index e0ea4d874..a5d7c1c95 100644 --- a/modules/item/back/methods/item/specs/regularize.spec.js +++ b/modules/item/back/methods/item/specs/regularize.spec.js @@ -16,7 +16,7 @@ describe('regularize()', () => { let ctx = {req: {accessToken: {userId: 18}}}; - let query = `CALL vn.getItemVisibleAvailable(?,curdate(),?,?)`; + let query = `CALL vn.item_getVisibleAvailable(?,curdate(),?,?)`; let options = [itemFk, warehouseFk, true]; diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 53fb2527c..72c41737a 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -46,7 +46,7 @@ module.exports = Self => { include: {relation: 'ticket'} }, options); - let [[stock]] = await Self.rawSql(`CALL vn.getItemVisibleAvailable(?,?,?,?)`, [ + let [[stock]] = await Self.rawSql(`CALL vn.item_getVisibleAvailable(?,?,?,?)`, [ ctx.args.itemFk, request.ticket().shipped, request.ticket().warehouseFk, diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 5eb06cf78..bb833709e 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -43,7 +43,7 @@ module.exports = Self => { const ticket = await models.Ticket.findById(id); const shouldRefresh = false; - const [[stock]] = await Self.rawSql(`CALL vn.itemGetVisibleAvailable(?, ?, ?, ?)`, [ + const [[stock]] = await Self.rawSql(`CALL vn.item_getVisibleAvailable(?, ?, ?, ?)`, [ itemId, ticket.shipped, ticket.warehouseFk, From 37618efb581862e78964e5f6f32f7aa943a8b5d9 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 20 Nov 2019 11:37:13 +0100 Subject: [PATCH 06/12] changed userPhone fkeys --- db/changes/10100-allSaints/01-userPhone.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/changes/10100-allSaints/01-userPhone.sql b/db/changes/10100-allSaints/01-userPhone.sql index 99690b0b6..54dfbeb26 100644 --- a/db/changes/10100-allSaints/01-userPhone.sql +++ b/db/changes/10100-allSaints/01-userPhone.sql @@ -2,9 +2,9 @@ CREATE TABLE `vn`.`userPhone` ( `id` INT NOT NULL AUTO_INCREMENT, `userFk` INT(10) UNSIGNED NOT NULL, `typeFk` VARCHAR(45) NOT NULL, - `phone` VARCHAR(15) NOT NULL, + `phone` VARCHAR(25) NOT NULL, PRIMARY KEY (`id`), - UNIQUE INDEX `UserFK_Phone` (`userFk` ASC, `phone` ASC)); + UNIQUE INDEX `UserFk_Phone` (`userFk` ASC, `typeFk` ASC, `phone` ASC)); ALTER TABLE `vn`.`userPhone` From a1784470cc8e9bb0c020865a60c113c7040c1cb4 Mon Sep 17 00:00:00 2001 From: Bernat Date: Wed, 20 Nov 2019 12:42:10 +0100 Subject: [PATCH 07/12] update scheme db --- .../10110-postCampaign/00-bionicConfig.sql | 13 +++ .../01-bionicCalcReverse.sql | 92 +++++++++++++++++++ .../reports/driver-route/driver-route.js | 2 +- 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 db/changes/10110-postCampaign/00-bionicConfig.sql create mode 100644 db/changes/10110-postCampaign/01-bionicCalcReverse.sql diff --git a/db/changes/10110-postCampaign/00-bionicConfig.sql b/db/changes/10110-postCampaign/00-bionicConfig.sql new file mode 100644 index 000000000..559eeaf11 --- /dev/null +++ b/db/changes/10110-postCampaign/00-bionicConfig.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS `vn`.`bionicConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `generalInflationCoeficient` double(10,2) NOT NULL, + `minimumDensityVolumetricWeight` double(10,2) NOT NULL, + `verdnaturaVolumeBox` int(11) NOT NULL, + `itemCarryBox` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + + +INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) + VALUES + (1.30, 167.00, 138000, 71); diff --git a/db/changes/10110-postCampaign/01-bionicCalcReverse.sql b/db/changes/10110-postCampaign/01-bionicCalcReverse.sql new file mode 100644 index 000000000..e3f6b1387 --- /dev/null +++ b/db/changes/10110-postCampaign/01-bionicCalcReverse.sql @@ -0,0 +1,92 @@ +DROP function IF EXISTS `vn`.`bionicCalcReverse`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` FUNCTION `vn`.`bionicCalcReverse`(vWarehouse INT, + vMargin DECIMAL(10,3), + vRetailedPrice DECIMAL(10,3), + vM3 DECIMAL(10,3), + vAddress INT, + vAgencyMode INT) RETURNS decimal(10,3) + DETERMINISTIC +BEGIN + DECLARE vGeneralInflationCoeficient INT; + DECLARE vVerdnaturaVolumeBox BIGINT; + DECLARE vClientFk INT; + DECLARE vComponentRecovery VARCHAR(50) DEFAULT 'debtCollection'; + DECLARE vComponentMana VARCHAR(50) DEFAULT 'autoMana'; + DECLARE vComponentPort VARCHAR(50) DEFAULT 'delivery'; + DECLARE vComponentMargin VARCHAR(50) DEFAULT 'margin'; + DECLARE vComponentCost VARCHAR(50) DEFAULT 'purchaseValue'; + DECLARE vComponentCostValue DECIMAL(10,2); + DECLARE vItem INT DEFAULT 98; + DECLARE vItemCarryBox INT; + + SELECT generalInflationCoeFicient, verdnaturaVolumeBox, itemCarryBox + INTO vGeneralInflationCoeficient, vVerdnaturaVolumeBox, vItemCarryBox + FROM bionicConfig; + + SELECT clientFk INTO vClientFk FROM address WHERE id = vAddress; + + -- Creamos la tabla tmp.bionicComponent + DROP TEMPORARY TABLE IF EXISTS tmp.bionicComponent; + CREATE TEMPORARY TABLE tmp.bionicComponent( + `warehouseFk` smallint(5) unsigned NOT NULL, + `itemFk` int(11) NOT NULL, + `componentFk` int(10) unsigned NOT NULL, + `value` decimal(10,4) NOT NULL, + UNIQUE KEY `itemWarehouseComponent` (`itemFk`,`warehouseFk`,`componentFk`) USING HASH, + KEY `itemWarehouse` (`itemFk`,`warehouseFk`) USING BTREE + ) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + + -- Margin + INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) + SELECT vWarehouse, vItem, id, vMargin + FROM component + WHERE code = vComponentMargin; + + -- Recobro + INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) + SELECT vWarehouse, vItem, c.id, ROUND(LEAST(cr.recobro,0.25), 3) + FROM bi.claims_ratio cr + JOIN component c ON c.code = vComponentRecovery + WHERE cr.Id_Cliente = vClientFk AND cr.recobro > 0.009; + + -- Componente de maná automático, en función del maná acumulado por el comercial. + INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) + SELECT vWarehouse, vItem, co.id, ROUND(ms.prices_modifier_rate, 3) + FROM client c + JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador + JOIN component co ON co.code = vComponentMana + WHERE ms.prices_modifier_activated AND c.id = vClientFk LIMIT 1; + + -- Reparto + INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) + SELECT vWarehouse, vItem, co.id, vGeneralInflationCoeficient + * ROUND( + vM3 + * az.price + * az.inflation + / vVerdnaturaVolumeBox, 4 + ) + FROM agencyMode ag + JOIN address a ON a.id = vAddress AND ag.id = vAgencyMode + JOIN agencyProvince ap ON ap.agencyFk = ag.agencyFk + AND ap.warehouseFk = vWarehouse AND ap.provinceFk = a.provinceFk + JOIN agencyModeZone az ON az.agencyModeFk = vAgencyMode + AND az.zone = ap.zone AND az.itemFk = 71 AND az.warehouseFk = vWarehouse + JOIN component co ON co.code = vComponentPort; + + -- Coste + SELECT vRetailedPrice - SUM(`value`) INTO vComponentCostValue + FROM tmp.bionicComponent; + + INSERT INTO tmp.bionicComponent (warehouseFk, itemFk, componentFk, `value`) + SELECT vWarehouse, vItem, id,vComponentCostValue + FROM component + WHERE code = vComponentCost; + + RETURN vComponentCostValue; +END$$ + +DELIMITER ; + diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index 908f49370..498666cc6 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -59,7 +59,7 @@ module.exports = { LEFT JOIN ticket t ON t.routeFk = r.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker w ON w.id = vn2008.Averiguar_ComercialCliente_Id(t.clientFk, CURDATE()) + LEFT JOIN worker w ON w.id = client_getSalesPerson(t.clientFk, CURDATE()) LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = 3 LEFT JOIN province p ON a.provinceFk = p.id From 6929e3d4972b650d3546b83273f88e58319c6fb5 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Wed, 20 Nov 2019 14:22:44 +0100 Subject: [PATCH 08/12] #1889 absences() unit test fixed + refactor --- .../back/methods/worker-calendar/absences.js | 6 +- .../worker-calendar/specs/absences.spec.js | 186 +++++++++--------- 2 files changed, 96 insertions(+), 96 deletions(-) diff --git a/modules/worker/back/methods/worker-calendar/absences.js b/modules/worker/back/methods/worker-calendar/absences.js index 541f95ff5..2cef07ec5 100644 --- a/modules/worker/back/methods/worker-calendar/absences.js +++ b/modules/worker/back/methods/worker-calendar/absences.js @@ -134,11 +134,11 @@ module.exports = Self => { }); if (currentContract) { - const maxDays = currentContract.holidays().days; - calendar.totalHolidays = maxDays; + const maxHolidays = currentContract.holidays().days; + calendar.totalHolidays = maxHolidays; if (workedDays < 365) - calendar.totalHolidays = Math.round(2 * maxDays * (workedDays + 1) / 365) / 2; + calendar.totalHolidays = Math.round(2 * maxHolidays * (workedDays) / 365) / 2; } return [calendar, absences, holidays]; diff --git a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js index 0a5e92e1f..6cc204e28 100644 --- a/modules/worker/back/methods/worker-calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/worker-calendar/specs/absences.spec.js @@ -1,20 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Worker absences()', () => { - afterAll(async done => { - const hiredWorker = await app.models.WorkerLabour.findById(106); - - const endedDate = new Date(); - endedDate.setFullYear(endedDate.getFullYear() + 1); - endedDate.setHours(0, 0, 0, 0); - endedDate.setMonth(0); - endedDate.setDate(1); - - await hiredWorker.updateAttributes({ended: endedDate}); - done(); - }); - - it('should get the absence calendar for the given dates then evaluate the type of absences', async() => { + it('should get the absence calendar for a full year contract', async() => { let ctx = {req: {accessToken: {userId: 106}}}; let workerFk = 106; @@ -43,16 +30,11 @@ describe('Worker absences()', () => { expect(sixthType).toEqual('Holidays'); }); - it(`should see he/she has 26.5`, async() => { + it('should get the absence calendar for a permanent contract', async() => { let workerFk = 106; - const firedWorker = await app.models.WorkerLabour.findById(workerFk); - - const endedDate = new Date(); - endedDate.setDate(endedDate.getDate() + 1); - endedDate.setMonth(endedDate.getMonth() + 1); - endedDate.setHours(0, 0, 0, 0); - - await firedWorker.updateAttributes({ended: endedDate}); + let worker = await app.models.WorkerLabour.findById(workerFk); + let endedDate = worker.ended; + await worker.updateAttributes({ended: null}); let ctx = {req: {accessToken: {userId: 9}}}; @@ -71,76 +53,6 @@ describe('Worker absences()', () => { let calendar = result[0]; let absences = result[1]; - expect(calendar.totalHolidays).toEqual(26.5); - expect(calendar.holidaysEnjoyed).toEqual(5); - - let firstType = absences[0].absenceType().name; - let sixthType = absences[5].absenceType().name; - - expect(firstType).toEqual('Leave of absence'); - expect(sixthType).toEqual('Holidays'); - }); - - it(`should see he/she has 26.5`, async() => { - const firedWorker = await app.models.WorkerLabour.findById(106); - - const endedDate = new Date(); - endedDate.setDate(endedDate.getDate() + 1); - endedDate.setMonth(endedDate.getMonth() + 1); - endedDate.setHours(0, 0, 0, 0); - - await firedWorker.updateAttributes({ended: endedDate}); - - let ctx = {req: {accessToken: {userId: 106}}}; - let workerFk = 106; - - const started = new Date(); - started.setHours(0, 0, 0, 0); - started.setMonth(0); - started.setDate(1); - - const monthIndex = 11; - const ended = new Date(); - ended.setHours(0, 0, 0, 0); - ended.setMonth(monthIndex + 1); - ended.setDate(0); - - let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended); - let calendar = result[0]; - let absences = result[1]; - - expect(calendar.totalHolidays).toEqual(26.5); - expect(calendar.holidaysEnjoyed).toEqual(5); - - let firstType = absences[0].absenceType().name; - let sixthType = absences[5].absenceType().name; - - expect(firstType).toEqual('Leave of absence'); - expect(sixthType).toEqual('Holidays'); - }); - - it(`should see he/she has 27.5`, async() => { - let ctx = {req: {accessToken: {userId: 106}}}; - let workerFk = 106; - - const firedWorker = await app.models.WorkerLabour.findById(106); - await firedWorker.updateAttributes({ended: null}); - - const started = new Date(); - started.setHours(0, 0, 0, 0); - started.setMonth(0); - started.setDate(1); - - const monthIndex = 11; - const ended = new Date(); - ended.setHours(0, 0, 0, 0); - ended.setMonth(monthIndex + 1); - ended.setDate(0); - - let result = await app.models.WorkerCalendar.absences(ctx, workerFk, started, ended); - let calendar = result[0]; - let absences = result[1]; - expect(calendar.totalHolidays).toEqual(27.5); expect(calendar.holidaysEnjoyed).toEqual(5); @@ -149,5 +61,93 @@ describe('Worker absences()', () => { expect(firstType).toEqual('Leave of absence'); expect(sixthType).toEqual('Holidays'); + + // restores the contract end date + await worker.updateAttributes({ended: endedDate}); + }); + + it('should give the same holidays as worked days since the holidays amount matches the amount of days in a year', async() => { + const today = new Date(); + + // getting how many days in a year + const yearStart = new Date(); + yearStart.setHours(0, 0, 0, 0); + yearStart.setMonth(0); + yearStart.setDate(1); + + const yearEnd = new Date(); + yearEnd.setHours(23, 59, 59, 59); + yearEnd.setMonth(11); + yearEnd.setDate(31); + const startedTime = yearStart.getTime(); + const endedTime = yearEnd.getTime(); + const dayTimestamp = 1000 * 60 * 60 * 24; + + const daysInYear = Math.floor((endedTime - startedTime) / dayTimestamp); + + // sets the holidays per year to the amount of days in the current year + let holidaysConfig = await app.models.WorkCenterHoliday.findOne({ + where: { + workCenterFk: 1, + year: today.getFullYear() + }}); + + let originalHolidaysValue = holidaysConfig.days; + + await app.models.WorkCenterHoliday.updateAll( + { + workCenterFk: 1, + year: today.getFullYear() + }, + { + days: daysInYear + } + ); + // normal test begins + const contract = await app.models.WorkerLabour.findById(106); + const contractStartDate = contract.started; + + const startingContract = new Date(); + startingContract.setHours(0, 0, 0, 0); + startingContract.setMonth(today.getMonth()); + startingContract.setDate(1); + + await contract.updateAttributes({started: startingContract}); + + let ctx = {req: {accessToken: {userId: 106}}}; + let workerFk = 106; + + let result = await app.models.WorkerCalendar.absences(ctx, workerFk, yearStart, yearEnd); + let calendar = result[0]; + let absences = result[1]; + + let remainingDays = 0; + for (let i = today.getMonth(); i < 12; i++) { + today.setMonth(i + 1); + today.setDate(0); + + remainingDays += today.getDate(); + } + + expect(calendar.totalHolidays).toEqual(remainingDays); + expect(calendar.holidaysEnjoyed).toEqual(5); + + let firstType = absences[0].absenceType().name; + let sixthType = absences[5].absenceType().name; + + expect(firstType).toEqual('Leave of absence'); + expect(sixthType).toEqual('Holidays'); + + // resets the holidays per year with originalHolidaysValue and the contract starting date + await app.models.WorkCenterHoliday.updateAll( + { + workCenterFk: 1, + year: today.getFullYear() + }, + { + days: originalHolidaysValue + } + ); + await contract.updateAttributes({started: contractStartDate}); }); }); From 525e1157810a828b0ce3debaa714782550db2d98 Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 21 Nov 2019 07:24:31 +0100 Subject: [PATCH 09/12] #1711 Eliminar referencias al esquema vn2008 --- .../10110-postCampaign/00-bionicConfig.sql | 13 - .../00-buyNotifyPassport.sql | 34 + .../10110-postCampaign/00-clientGetMana.sql | 74 + .../10110-postCampaign/01-buyAfterUpsert.sql | 59 + db/dump/fixtures.sql | 19 +- db/dump/structure.sql | 2989 ++++------------- 6 files changed, 808 insertions(+), 2380 deletions(-) delete mode 100644 db/changes/10110-postCampaign/00-bionicConfig.sql create mode 100644 db/changes/10110-postCampaign/00-buyNotifyPassport.sql create mode 100644 db/changes/10110-postCampaign/00-clientGetMana.sql create mode 100644 db/changes/10110-postCampaign/01-buyAfterUpsert.sql diff --git a/db/changes/10110-postCampaign/00-bionicConfig.sql b/db/changes/10110-postCampaign/00-bionicConfig.sql deleted file mode 100644 index 559eeaf11..000000000 --- a/db/changes/10110-postCampaign/00-bionicConfig.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE IF NOT EXISTS `vn`.`bionicConfig` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `generalInflationCoeficient` double(10,2) NOT NULL, - `minimumDensityVolumetricWeight` double(10,2) NOT NULL, - `verdnaturaVolumeBox` int(11) NOT NULL, - `itemCarryBox` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - -INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) - VALUES - (1.30, 167.00, 138000, 71); diff --git a/db/changes/10110-postCampaign/00-buyNotifyPassport.sql b/db/changes/10110-postCampaign/00-buyNotifyPassport.sql new file mode 100644 index 000000000..d8b35ade3 --- /dev/null +++ b/db/changes/10110-postCampaign/00-buyNotifyPassport.sql @@ -0,0 +1,34 @@ +DROP procedure IF EXISTS `vn`.`buy_notifyPassport`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`buy_notifyPassport`( + IN vBuyFk INT, + IN vItemFk INT, + IN vStickers SMALLINT, + IN vPacking SMALLINT +) +BEGIN + INSERT INTO vn.mail(`subject`,`body`,`sender`) + SELECT 'Solicitar pasaporte', + CONCAT( + 'Etiquetas: ', IFNULL(vStickers, 0), + ', Packing: ', IFNULL(vPacking, 0), + ', Nombre: ', IFNULL(i.`name`, 0), + ', buy_edi: ', IFNULL(e.id, 0), + ', Nombre botánico: ', IFNULL(g.latin_genus_name, ''), ' ', IFNULL(s.latin_species_name, ''), + ', Productor: ',IFNULL(es.company_name, IFNULL(p.`name`, '')) + ) + ,'ekt@verdnatura.es' + FROM item i + LEFT JOIN itemBotanical ib ON ib.itemFk = i.id + LEFT JOIN edi.genus g ON g.genus_id = ib.genusFk + LEFT JOIN edi.specie s ON IFNULL(s.specie_id, ib.specieFk) = ib.specieFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN buy b ON b.id = vBuyFk + LEFT JOIN edi.ekt e ON b.ektFk = e.id + LEFT JOIN edi.supplier es ON es.supplier_id = e.pro + WHERE i.id = vItemFk; +END$$ + +DELIMITER ; + diff --git a/db/changes/10110-postCampaign/00-clientGetMana.sql b/db/changes/10110-postCampaign/00-clientGetMana.sql new file mode 100644 index 000000000..7666d0c1c --- /dev/null +++ b/db/changes/10110-postCampaign/00-clientGetMana.sql @@ -0,0 +1,74 @@ +DROP function IF EXISTS `vn`.`clientGetMana`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` FUNCTION `vn`.`clientGetMana`(vClient INT) RETURNS decimal(10,2) + DETERMINISTIC +BEGIN +/** + * Devuelve el maná del cliente. + * + * @param vClient Id del cliente + * @return Maná del cliente + */ + DECLARE vMana DECIMAL(10,2); + DECLARE vFromDated DATE; + DECLARE vHasMana BOOLEAN; + DECLARE vManaComponent INT; + DECLARE vAutoManaComponent INT; + DECLARE vManaBank INT DEFAULT 66; + + SELECT id INTO vManaComponent FROM component WHERE code = 'mana'; + SELECT id INTO vAutoManaComponent FROM component WHERE code = 'autoMana'; + + SELECT COUNT(*) INTO vHasMana + FROM `client` c + WHERE c.id = vClient AND c.typeFk = 'normal'; + + IF NOT vHasMana THEN + RETURN 0; + END IF; + + SELECT max(dated) INTO vFromDated + FROM clientManaCache; + + SELECT sum(mana) INTO vMana + FROM + ( + SELECT mana + FROM clientManaCache + WHERE clientFk = vClient + AND dated = vFromDated + UNION ALL + SELECT s.quantity * value + FROM ticket t + JOIN address a ON a.id = t.addressFk + JOIN sale s on s.ticketFk = t.id + JOIN saleComponent sc on sc.saleFk = s.id + WHERE sc.componentFk IN (vManaComponent, vAutoManaComponent) + AND t.shipped > vFromDated + AND t.shipped < TIMESTAMPADD(DAY,1,CURDATE()) + AND a.clientFk = vClient + UNION ALL + SELECT - amountPaid + FROM receipt r + JOIN `client` c ON c.id = r.clientFk + WHERE r.bankFk = vManaBank + AND r.payed > vFromDated + AND r.payed <= CURDATE() + AND c.id = vClient + UNION ALL + SELECT g.Importe + FROM vn2008.Greuges g + JOIN vn2008.Clientes c using(Id_Cliente) + WHERE g.Greuges_type_id = 3 -- Maná + AND g.Fecha > vFromDated + AND g.Fecha <= CURDATE() + AND c.Id_Cliente = vClient + ) sub; + + RETURN IFNULL(vMana,0); + +END$$ + +DELIMITER ; + diff --git a/db/changes/10110-postCampaign/01-buyAfterUpsert.sql b/db/changes/10110-postCampaign/01-buyAfterUpsert.sql new file mode 100644 index 000000000..2e3b80752 --- /dev/null +++ b/db/changes/10110-postCampaign/01-buyAfterUpsert.sql @@ -0,0 +1,59 @@ + +DROP procedure IF EXISTS `vn`.`buy_afterUpsert`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) +BEGIN +/** + * Triggered actions when a buy is updated or inserted. + * + * @param vSelf The buy reference + */ + DECLARE vEntryFk INT; + DECLARE vItemFk INT; + DECLARE vStickers INT; + DECLARE vPacking INT; + DECLARE vWarehouse INT; + DECLARE vWarehouseOut INT; + DECLARE vIsMerchandise BOOL; + DECLARE vIsFeedStock BOOL; + + SELECT entryFk, itemFk, stickers, packing + INTO vEntryFk, vItemFk, vStickers, vPacking + FROM buy + WHERE id = vSelf; + + SELECT t.warehouseInFk, t.warehouseOutFk + INTO vWarehouse, vWarehouseOut + FROM entry e + JOIN travel t ON t.id = e.travelFk + WHERE e.id = vEntryFk; + + SELECT k.merchandise INTO vIsMerchandise + FROM itemCategory k + JOIN itemType it ON it.categoryFk = k.id + JOIN item i ON i.typeFk = it.id + WHERE i.id = vItemFk; + IF vIsMerchandise THEN + REPLACE bi.rotacion SET + Id_Article = vItemFk, + warehouse_id = vWarehouse, + cm3 = buy_getUnitVolume(vSelf); + END IF; + + SELECT isFeedStock INTO vIsFeedStock + FROM warehouse WHERE id = vWarehouseOut AND id <> 13; + + IF vIsFeedStock AND vn2008.has_notify_passport(vItemFk, vSelf) THEN + CALL vn.buy_notifyPassport(vSelf, vItemFk, vStickers, vPacking); + INSERT IGNORE INTO producer(`name`) + SELECT es.company_name + FROM buy b + JOIN edi.ekt be ON be.id = b.ektFk + JOIN edi.supplier es ON es.supplier_id = be.pro + WHERE b.id = 1; + END IF; +END$$ + +DELIMITER ; + diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 21413d329..c9dbd8a8a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -10,6 +10,11 @@ INSERT INTO `account`.`mailConfig` (`id`, `domain`) VALUES ('1', 'verdnatura.es'); +INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVolumetricWeight`, `verdnaturaVolumeBox`, `itemCarryBox`) + VALUES + (1.30, 167.00, 138000, 71); + + INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`) SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'es' FROM `account`.`role`; @@ -562,14 +567,14 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, VALUES (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(CURDATE(),INTERVAL -1 MONTH)); -INSERT INTO `vn`.`greugeType`(`id`, `name`) +INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) VALUES - (1, 'Diff'), - (2, 'Recover'), - (3, 'Manna'), - (4, 'Reclaim'), - (5, 'Heritage'), - (6, 'Miscellaneous'); + (1, 'Diff', 'diff'), + (2, 'Recover', 'recover'), + (3, 'Mana', 'mana'), + (4, 'Reclaim', 'reclaim'), + (5, 'Heritage', 'heritage'), + (6, 'Miscellaneous', 'miscellaneous'); INSERT INTO `vn`.`greuge`(`id`, `clientFk`, `description`, `amount`, `shipped`, `created`, `greugeTypeFk`, `ticketFk`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index e3484d410..cb75fc2db 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -175,7 +175,7 @@ CREATE TABLE `mailAlias` ( `isPublic` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `alias` (`alias`) -) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; +) ENGINE=InnoDB AUTO_INCREMENT=83 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mail aliases'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -365,7 +365,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=16879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=16888 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 */ ; @@ -1977,7 +1977,7 @@ CREATE TABLE `analisis_ventas` ( `Importe` double NOT NULL, PRIMARY KEY (`id`), KEY `Año` (`Año`,`Semana`) -) ENGINE=InnoDB AUTO_INCREMENT=112778678 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=113827238 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2458,7 +2458,7 @@ CREATE TABLE `rutasBoard` ( KEY `rutasBoard_ix1` (`year`), KEY `rutasBoard_ix2` (`month`), KEY `rutasBoard_ix3` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=198546 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=202638 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5396,6 +5396,29 @@ SET character_set_client = utf8; 1 AS `lastYearWeekSales`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `m3` +-- + +DROP TABLE IF EXISTS `m3`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `m3` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `fecha` date NOT NULL, + `provinceFk` smallint(5) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', + `m3` decimal(10,2) DEFAULT NULL, + `year` int(11) DEFAULT NULL, + `month` int(11) DEFAULT NULL, + `week` int(11) DEFAULT NULL, + `day` int(11) DEFAULT NULL, + `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, + `euros` decimal(10,2) DEFAULT '0.00', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=370910 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Temporary table structure for view `m3Silla` -- @@ -5415,29 +5438,6 @@ SET character_set_client = utf8; 1 AS `Euros`*/; SET character_set_client = @saved_cs_client; --- --- Table structure for table `m3__` --- - -DROP TABLE IF EXISTS `m3__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `m3__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` date NOT NULL, - `provinceFk` smallint(5) unsigned DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '0', - `m3` decimal(10,2) DEFAULT NULL, - `year` int(11) DEFAULT NULL, - `month` int(11) DEFAULT NULL, - `week` int(11) DEFAULT NULL, - `day` int(11) DEFAULT NULL, - `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, - `euros` decimal(10,2) DEFAULT '0.00', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=368864 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `m3analisis` -- @@ -5688,7 +5688,7 @@ CREATE TABLE `payMethodClient` ( KEY `FkDateClientPayMethod` (`dated`,`clientFk`), CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn`.`payMethod` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5829757 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=5862523 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5763,7 +5763,7 @@ CREATE TABLE `productivity` ( `m3PCA` double NOT NULL DEFAULT '0', `m3Artificial` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=61099748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=61353576 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -7016,7 +7016,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `m3Add__` */; +/*!50003 DROP PROCEDURE IF EXISTS `m3Add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -7026,7 +7026,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `m3Add__`() +CREATE DEFINER=`root`@`%` PROCEDURE `m3Add`() BEGIN DECLARE datSTART DATE; @@ -8918,7 +8918,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=436254 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=437035 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8986,7 +8986,7 @@ CREATE TABLE `prod_graphic_source` ( `alert_level` int(11) NOT NULL DEFAULT '0', `Agencia` varchar(45) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2234381 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2240007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10033,7 +10033,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=24314205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24393221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10091,7 +10091,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1111068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1112531 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10112,7 +10112,7 @@ CREATE TABLE `exchange` ( KEY `buy_edi_id` (`ektFk`), CONSTRAINT `exchange_ibfk_1` FOREIGN KEY (`mailFk`) REFERENCES `mail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `exchange_ibfk_2` FOREIGN KEY (`ektFk`) REFERENCES `ekt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=651748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=653193 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10374,7 +10374,7 @@ CREATE TABLE `mail` ( UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`senderFk`) REFERENCES `mailSender` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=681655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=683079 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10630,7 +10630,7 @@ CREATE TABLE `supplyResponse` ( PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' -) ENGINE=InnoDB AUTO_INCREMENT=8917792 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8947741 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11327,7 +11327,7 @@ CREATE TABLE `image` ( PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=171273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=171831 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12008,7 +12008,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2244750 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2247959 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 */ ; @@ -12127,7 +12127,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13453850 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13471735 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 */ ; @@ -12551,7 +12551,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) 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=372339 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=372874 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12586,7 +12586,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgentFk`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgentFk`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2005986 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2008312 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12606,7 +12606,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agentFk`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agentFk`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4478440 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4484736 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12631,7 +12631,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccessFk`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visitFk`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccessFk`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2652592 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2655432 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12651,7 +12651,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`userFk`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`accessFk`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3922066 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3927228 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16389,7 +16389,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDB AUTO_INCREMENT=315692 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=316007 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17490,7 +17490,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=73578 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=73581 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -18209,7 +18209,7 @@ CREATE TABLE `outbound` ( KEY `warehouseFk` (`warehouseFk`,`itemFk`,`dated`), KEY `expired` (`expired`), KEY `isSync` (`isSync`) -) ENGINE=InnoDB AUTO_INCREMENT=4273151 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; ALTER DATABASE `stock` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -20180,7 +20180,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4053991 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4055070 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 */ ; @@ -20357,23 +20357,6 @@ SET character_set_client = utf8; 1 AS `code`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `accounting` --- - -DROP TABLE IF EXISTS `accounting`; -/*!50001 DROP VIEW IF EXISTS `accounting`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `accounting` AS SELECT - 1 AS `id`, - 1 AS `bank`, - 1 AS `account`, - 1 AS `accountingTypeFk`, - 1 AS `entityFk`, - 1 AS `isActive`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `accountingType` -- @@ -20388,6 +20371,23 @@ CREATE TABLE `accountingType` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='descripcio dels valors de la columna "cash" de la taula vn2008.Bancios'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `accounting__` +-- + +DROP TABLE IF EXISTS `accounting__`; +/*!50001 DROP VIEW IF EXISTS `accounting__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `accounting__` AS SELECT + 1 AS `id`, + 1 AS `bank`, + 1 AS `account`, + 1 AS `accountingTypeFk`, + 1 AS `entityFk`, + 1 AS `isActive`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `activeContrat` -- @@ -20460,7 +20460,7 @@ CREATE TABLE `address` ( CONSTRAINT `address_ibfk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `address_ibfk_3` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `address_ibfk_4` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=29594 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=29607 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 */ ; @@ -20580,7 +20580,7 @@ CREATE TABLE `addressObservation` ( KEY `addressObservationFgn_idx` (`observationTypeFk`), CONSTRAINT `addressFgn` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4196 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; +) ENGINE=InnoDB AUTO_INCREMENT=4198 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20684,7 +20684,7 @@ CREATE TABLE `agencyMode` ( PRIMARY KEY (`id`), KEY `Agencias` (`name`), KEY `Vista` (`deliveryMethodFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1236 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20980,6 +20980,23 @@ SET character_set_client = utf8; 1 AS `currencyFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `bionicConfig` +-- + +DROP TABLE IF EXISTS `bionicConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bionicConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `generalInflationCoeficient` double(10,2) NOT NULL, + `minimumDensityVolumetricWeight` double(10,2) NOT NULL, + `verdnaturaVolumeBox` int(11) NOT NULL, + `itemCarryBox` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `bookingPlanner` -- @@ -21102,7 +21119,7 @@ CREATE TABLE `buy` ( CONSTRAINT `buy_ibfk_3` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=352192921 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=352686632 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 */ ; @@ -21412,7 +21429,7 @@ CREATE TABLE `claim` ( CONSTRAINT `claim_ibfk_3` FOREIGN KEY (`claimStateFk`) REFERENCES `claimState` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_4` FOREIGN KEY (`claimDepartmentFk`) REFERENCES `vn2008`.`cl_dep` (`id`) ON UPDATE CASCADE, CONSTRAINT `claim_ibfk_5` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=71448 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +) ENGINE=InnoDB AUTO_INCREMENT=71547 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21434,7 +21451,7 @@ CREATE TABLE `claimBeginning` ( KEY `cl_main_id` (`claimFk`), CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimBeginning_ibfk_8` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=156853 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=157005 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 */ ; @@ -21544,7 +21561,7 @@ CREATE TABLE `claimDevelopment` ( CONSTRAINT `claimDevelopment_ibfk_7` FOREIGN KEY (`claimReasonFk`) REFERENCES `claimReason` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_8` FOREIGN KEY (`claimResultFk`) REFERENCES `claimResult` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimDevelopment_ibfk_9` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=61379 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=61439 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21605,7 +21622,7 @@ CREATE TABLE `claimEnd` ( CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=119692 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +) ENGINE=InnoDB AUTO_INCREMENT=119821 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21649,7 +21666,7 @@ CREATE TABLE `claimLog` ( KEY `userFk` (`userFk`), CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `claimUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6455 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6658 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21927,7 +21944,7 @@ CREATE TABLE `client` ( CONSTRAINT `client_ibfk_5` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientTypeFk`) REFERENCES `clientType` (`id`) ON UPDATE CASCADE, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=16879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16888 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 */ ; @@ -22096,7 +22113,7 @@ CREATE TABLE `clientCredit` ( KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=85110 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=85166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22185,7 +22202,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) 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=239932 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=240238 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22220,7 +22237,7 @@ CREATE TABLE `clientObservation` ( KEY `Id_Cliente` (`clientFk`), CONSTRAINT `clientObservation_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientObservation_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=78725 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=78785 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -22331,7 +22348,7 @@ CREATE TABLE `clientSample` ( PRIMARY KEY (`id`), KEY `empresa_id` (`companyFk`), CONSTRAINT `clientSample_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18542 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18548 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23040,7 +23057,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3268 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3269 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 */ ; @@ -23085,7 +23102,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=3147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=3152 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 */ ; @@ -23394,7 +23411,7 @@ CREATE TABLE `dms` ( UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), KEY `trabajador_id` (`workerFk`), KEY `warehouse_id` (`warehouseFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1386776 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1388177 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 */ ; @@ -23581,7 +23598,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`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 `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4307 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4311 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23642,7 +23659,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=5267 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=5268 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 */; -- @@ -23667,7 +23684,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 `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=10147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=10154 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23803,7 +23820,7 @@ CREATE TABLE `entry` ( CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=181977 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=182103 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 */ ; @@ -24004,7 +24021,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=176820 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=177180 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24251,7 +24268,7 @@ CREATE TABLE `expedition` ( KEY `index4` (`ticketFk`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3420411 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3424451 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 */ ; @@ -24529,7 +24546,7 @@ CREATE TABLE `greuge` ( KEY `Greuges_cliente_idx` (`clientFk`), CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `greuges_type_fk` FOREIGN KEY (`greugeTypeFk`) REFERENCES `greugeType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3807112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; +) ENGINE=InnoDB AUTO_INCREMENT=3810881 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=COMPACT; /*!40101 SET character_set_client = @saved_cs_client */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -24564,6 +24581,7 @@ DROP TABLE IF EXISTS `greugeType`; CREATE TABLE `greugeType` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `code` varchar(45) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -24732,7 +24750,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=27119 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=27230 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25010,7 +25028,7 @@ CREATE TABLE `invoiceOut` ( CONSTRAINT `invoiceOut_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=521491 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=521528 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 */ ; @@ -25136,7 +25154,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `expence` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=135660 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=135697 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 */; -- @@ -25179,7 +25197,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `invoiceOut` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1177056 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1177113 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25285,7 +25303,7 @@ CREATE TABLE `item` ( CONSTRAINT `item_ibfk_5` FOREIGN KEY (`typeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `item_ibfk_6` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=376303 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=376585 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 */ ; @@ -25412,7 +25430,7 @@ CREATE TABLE `itemBarcode` ( UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42918 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42923 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25610,7 +25628,7 @@ CREATE TABLE `itemLog` ( KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=98195 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=99157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25637,7 +25655,7 @@ CREATE TABLE `itemPlacement` ( CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1159689 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1160906 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 */ ; @@ -25687,7 +25705,7 @@ CREATE TABLE `itemPlacementSupply` ( 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, CONSTRAINT `itemPlacementSupply_fk4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80270 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=80804 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 */; -- @@ -25806,7 +25824,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=138716 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=139217 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -25923,7 +25941,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 DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=75118 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB AUTO_INCREMENT=75648 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 */; -- @@ -25995,7 +26013,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 `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=41364 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=42087 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -26122,7 +26140,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1398362 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1400544 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 */ ; @@ -26266,7 +26284,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `taxClass` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=887149 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=888991 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 */; -- @@ -26341,7 +26359,7 @@ CREATE TABLE `itemType` ( CONSTRAINT `itemType_ibfk_1` FOREIGN KEY (`categoryFk`) REFERENCES `itemCategory` (`id`) ON UPDATE CASCADE, CONSTRAINT `itemType_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=284 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=285 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 */ ; @@ -26390,22 +26408,6 @@ CREATE TABLE `itemTypeI18n` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `itemTypeI18nFr` --- - -DROP TABLE IF EXISTS `itemTypeI18nFr`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `itemTypeI18nFr` ( - `id` int(11) NOT NULL, - `code` text COLLATE utf8_unicode_ci, - `es` text COLLATE utf8_unicode_ci, - `fr` text COLLATE utf8_unicode_ci, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `itemTypeL10n` -- @@ -26591,7 +26593,7 @@ CREATE TABLE `mandate` ( CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`mandateTypeFk`) REFERENCES `mandateType` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17277 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=17280 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 */ ; @@ -26737,7 +26739,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=2054567 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2056489 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26759,7 +26761,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2230247 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2232309 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26989,7 +26991,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=3144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3224 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27092,7 +27094,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=26789 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=27698 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 */ ; @@ -27695,7 +27697,7 @@ CREATE TABLE `producer` ( `isVisible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=14462 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14545 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27798,7 +27800,7 @@ CREATE TABLE `province` ( CONSTRAINT `province_ibfk_1` FOREIGN KEY (`countryFk`) REFERENCES `country` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn2008`.`zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=209 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=216 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 */ ; @@ -28028,7 +28030,7 @@ CREATE TABLE `receipt` ( CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=609571 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=609864 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 */ ; @@ -28214,7 +28216,7 @@ CREATE TABLE `route` ( KEY `route_ibfk_2_idx` (`workerFk`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=60062 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=60130 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 */ ; @@ -28305,7 +28307,7 @@ CREATE TABLE `routeComplement` ( KEY `fgn_routeActionFk_idx` (`routeActionFk`), CONSTRAINT `fgn_routeActionFk` FOREIGN KEY (`routeActionFk`) REFERENCES `routeAction` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgn_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1051 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1057 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28408,7 +28410,7 @@ CREATE TABLE `routeLog` ( KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=194875 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=197166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28519,7 +28521,7 @@ CREATE TABLE `sale` ( KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26397790 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=26414808 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 */ ; @@ -28760,7 +28762,7 @@ CREATE TABLE `saleTracking` ( KEY `fgnStateFk_idx` (`stateFk`), KEY `saleTracking_idx5` (`created`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=20981803 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21026302 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 */ ; @@ -28930,7 +28932,7 @@ CREATE TABLE `sector` ( UNIQUE KEY `code_UNIQUE` (`code`), KEY `sector_fk1_idx` (`warehouseFk`), CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28952,7 +28954,7 @@ CREATE TABLE `sharingCart` ( KEY `Suplent` (`workerSubstitute`), CONSTRAINT `Suplent_key` FOREIGN KEY (`workerSubstitute`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2223 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2226 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 */ ; @@ -29161,7 +29163,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=154883 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=155196 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29350,7 +29352,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=847019 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=847937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29413,7 +29415,7 @@ CREATE TABLE `supplier` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`payDemFk`) REFERENCES `payDem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2953 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2956 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29438,7 +29440,7 @@ CREATE TABLE `supplierAccount` ( KEY `fk_proveedores_proveedores_account_idx` (`supplierFk`), KEY `fk_Proveedores_account_entity1_idx` (`bankEntityFk`), KEY `fk_banco_prov_account_idx` (`bankFk`) -) ENGINE=InnoDB AUTO_INCREMENT=876 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=878 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29795,7 +29797,7 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2481940 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2484593 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 */ ; @@ -30070,7 +30072,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) 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=8090850 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8112788 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30107,7 +30109,7 @@ CREATE TABLE `ticketObservation` ( KEY `observation_type_id` (`observationTypeFk`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1508239 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1509900 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30162,7 +30164,7 @@ CREATE TABLE `ticketPackaging` ( CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `packaging` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=77239 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=77383 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 */ ; @@ -30225,7 +30227,7 @@ CREATE TABLE `ticketParking` ( KEY `ticketParking_fk1_idx` (`parkingFk`), CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=10892 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +) ENGINE=InnoDB AUTO_INCREMENT=11492 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30291,7 +30293,7 @@ CREATE TABLE `ticketRequest` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52095 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52123 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 */ ; @@ -30550,7 +30552,7 @@ CREATE TABLE `ticketWeekly` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`ticketFk`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2477090 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2481744 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30695,7 +30697,7 @@ CREATE TABLE `town` ( KEY `name_idx` (`name`), KEY `townProvinceFk` (`provinceFk`), CONSTRAINT `townProvinceFk` FOREIGN KEY (`provinceFk`) REFERENCES `province` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=241171 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=241176 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 */ ; @@ -30876,7 +30878,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_4` FOREIGN KEY (`cargoSupplierFk`) REFERENCES `vn2008`.`Proveedores_cargueras` (`Id_Proveedor`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=142064 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=142120 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 */ ; @@ -31518,7 +31520,7 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `worker` (`userFk`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `dms` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12892 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12895 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31583,7 +31585,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=61483385 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=61848937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31622,7 +31624,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 `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16021 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16022 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31685,7 +31687,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8295889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=8297369 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32046,7 +32048,7 @@ CREATE TABLE `zone` ( KEY `zone_name_idx` (`name`), CONSTRAINT `fk_zone_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=458 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=460 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -32088,7 +32090,7 @@ CREATE TABLE `zoneGeo` ( KEY `name_idx` (`name`), KEY `parentFk` (`parentFk`), KEY `path` (`path`) -) ENGINE=InnoDB AUTO_INCREMENT=597460 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=597478 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 */ ; @@ -32737,9 +32739,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -32788,10 +32790,10 @@ BEGIN SELECT SUM(total) amount FROM tmp.ticketTotal UNION ALL - SELECT SUM(Entregado) - FROM vn2008.Recibos - WHERE Id_Cliente = vClient - AND Fechacobro > vDateEnd + SELECT SUM(amountPaid) + FROM receipt + WHERE clientFk = vClient + AND payed > vDateEnd UNION ALL SELECT SUM(amount) FROM bi.customer_risk r @@ -35212,6 +35214,71 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP FUNCTION IF EXISTS `workerTimeControl_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `workerTimeControl_add`( vUserFk INT, vWarehouseFk INT, vTimed DATETIME, vIsManual BOOL) RETURNS int(11) + DETERMINISTIC +BEGIN + DECLARE vDirection VARCHAR(6); + DECLARE vLastIn DATETIME; + DECLARE vDayStayMax INT; + DECLARE vHasDirectionOut INT; + + SELECT dayStayMax INTO vDayStayMax + FROM vn.workerTimeControlParams; + + SELECT vn.timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; + + IF vDirection = 'out' THEN + + SELECT MAX(timed) INTO vLastIn + FROM vn.workerTimeControl + WHERE userFk = vUserFk + AND direction = 'in' + AND timed < vTimed; + + UPDATE vn.workerTimeControl wtc + SET wtc.direction = 'middle' + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vLastIn AND vTimed; + + ELSE IF vDirection = 'in' THEN + + SELECT COUNT(*) INTO vHasDirectionOut + FROM vn.workerTimeControl wtc + WHERE userFk = vUserFk + AND direction = 'out' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + UPDATE vn.workerTimeControl wtc + SET wtc.direction = IF (vHasDirectionOut,'middle','out') + WHERE userFk = vUserFk + AND direction = 'in' + AND timed BETWEEN vTimed AND TIMESTAMPADD(SECOND, 50400, vTimed); + + END IF; + END IF; + + INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) + VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); + + +RETURN LAST_INSERT_ID(); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP FUNCTION IF EXISTS `zoneGeo_new` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -36450,9 +36517,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -36472,7 +36539,6 @@ proc: BEGIN * packing, grouping, groupingMode, buyFk, typeFk) * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) */ - DECLARE vClientFk INT; DECLARE vGeneralInflationCoefficient INT DEFAULT 1; DECLARE vMinimumDensityWeight INT DEFAULT 167; @@ -36509,7 +36575,7 @@ proc: BEGIN IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, IFNULL(pf.rate3, 0) AS minPrice, IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) grouping, + IFNULL(pf.`grouping`, b.`grouping`) `grouping`, ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, tl.buyFk, i.typeFk, @@ -36654,7 +36720,7 @@ proc: BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) grouping, + IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc @@ -36664,12 +36730,12 @@ proc: BEGIN AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) GROUP BY tcs.warehouseFk, tcs.itemFk; - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 2 rate, - tcc.packing grouping, + tcc.packing `grouping`, SUM(tcs.sumCost) price, SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc @@ -36679,12 +36745,12 @@ proc: BEGIN AND tcc.packing > 0 AND tcc.available >= tcc.packing) GROUP BY tcs.warehouseFk, tcs.itemFk; - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 3 rate, - tcc.available grouping, + tcc.available `grouping`, SUM(tcs.sumCost) price, SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc @@ -36712,268 +36778,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `catalog_componentCalculate__` */; -/*!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 `catalog_componentCalculate__`( - vZoneFk INT, - vAddressFk INT, - vShipped DATE) -proc: BEGIN -/** - * Calcula los componentes de los articulos de tmp.ticketLot - * - * @param vZoneFk para calcular el transporte - * @param vAgencyModeFk Id del modo de agencia - * @param tmp.ticketLot (warehouseFk,available,itemFk,buyFk) - * - * @return tmp.ticketComponent(itemFk, warehouseFk, available, rate2, rate3, minPrice, - * packing, grouping, groupingMode, buyFk, typeFk) - * @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, grouping, price) - */ - - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) grouping, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, i.typeFk - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, z.warehouseFk - FROM priceFixed pf - JOIN zone z ON z.warehouseFk = pf.warehouseFk OR pf.warehouseFk = 0 - WHERE vShipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, - tcb.itemFk, - cr.id, - GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN componentRate cr - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL((z.price - z.bonus) - * 1/*amz.inflation*/ , 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN zone z ON z.id = vZoneFk - JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - HAVING cost <> 0; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN componentRate cr ON cr.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE cr.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate - FROM tmp.ticketComponent tc - JOIN componentRate cr ON cr.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) grouping, - CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing grouping, - SUM(tcs.sumCost) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available grouping, - SUM(tcs.sumCost) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `clean` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -43492,6 +43296,7 @@ DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingSaleAdd`(vItemShelvingFk INT, saleFk INT, vQuantity INT) BEGIN +IF saleFk <> 0 THEN INSERT INTO vn.itemShelvingSale( itemShelvingFk, saleFk, quantity, @@ -43500,7 +43305,10 @@ BEGIN saleFk, vQuantity, getUser()); - +ELSE + UPDATE vn.itemShelving SET quantity = (quantity - vQuantity), available = (available - vQuantity), visible = (visible - vQuantity) + WHERE id = vItemShelvingFk; +END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -45194,6 +45002,54 @@ BEGIN VALUES(saleFk,valueFk,getWorker(),encajando); +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 `parking_add` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `parking_add`(vFromColumn INT, vToColumn INT, vFromRow INT, vToRow INT, vSectorFk INT) +BEGIN + + DECLARE vColumn INT; + DECLARE vRow INT; + DECLARE vMaxId INT; + + SET vColumn = vFromColumn; + SET vRow = vFromRow; + + SELECT MAX(id) INTO vMaxId + FROM vn.parking; + + WHILE vColumn <= vToColumn DO + + WHILE vRow <= vToRow DO + + INSERT IGNORE INTO vn.parking(`column`, `row`, sectorFk, `code`) + VALUES (vColumn, vRow, vSectorFk, CONCAT(LPAD(vColumn,3,'0'),'-',LPAD(vRow, 2,'0'))); + + SET vRow = vRow + 1; + + END WHILE; + + SET vRow = vFromRow; + + SET vColumn = vColumn + 1; + + END WHILE; + + SELECT * FROM vn.parking WHERE id > vMaxId; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -49028,9 +48884,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -49040,7 +48896,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculate`( proc: BEGIN -- OBSOLETO usar catalog_componentCalculate /** - * Calcula los componentes de un ticket + * Calcula los componentes de un ticket * * @param vAddressFk Id del consignatario * @param vAgencyModeFk Id del modo de agencia @@ -49087,7 +48943,7 @@ proc: BEGIN IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, IFNULL(pf.rate3, 0) AS minPrice, IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) grouping, + IFNULL(pf.`grouping`, b.`grouping`) `grouping`, ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, tl.buyFk, i.typeFk, @@ -49234,7 +49090,7 @@ proc: BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) grouping, + IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, CAST(SUM(tcs.sumCost) / weightGrouping AS DECIMAL(10,2)) priceKg FROM tmp.ticketComponentCalculate tcc @@ -49244,12 +49100,12 @@ proc: BEGIN AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) GROUP BY tcs.warehouseFk, tcs.itemFk; - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 2 rate, - tcc.packing grouping, + tcc.packing `grouping`, SUM(tcs.sumCost) price, SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc @@ -49259,12 +49115,12 @@ proc: BEGIN AND tcc.packing > 0 AND tcc.available >= tcc.packing) GROUP BY tcs.warehouseFk, tcs.itemFk; - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 3 rate, - tcc.available grouping, + tcc.available `grouping`, SUM(tcs.sumCost) price, SUM(tcs.sumCost) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc @@ -49292,317 +49148,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `ticketComponentCalculateKK` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticketComponentCalculateKK`(IN `vAddressFk` INT, IN `vAgencyModeFk` INT) -proc: BEGIN -/** - * Calcula los componentes de un ticket - * - * @param vAddressFk Id del consignatario - * @param vAgencyModeFk Id del modo de agencia - * @return tmp.ticketComponent, tmp.ticketComponentPrice - */ - DECLARE vClientFk INT; - DECLARE vGeneralInflationCoefficient INT DEFAULT 1; - DECLARE vMinimumDensityWeight INT DEFAULT 167; - DECLARE vBoxFreightItem INT DEFAULT 71; - DECLARE vBoxVolume BIGINT; -- DEFAULT 138000; - DECLARE vSpecialPriceComponent INT DEFAULT 10; - DECLARE vExtraFreightComponent INT DEFAULT 14; - DECLARE vDeliveryComponent INT DEFAULT 15; - DECLARE vRecoveryComponent INT DEFAULT 17; - DECLARE vSellByPacketComponent INT DEFAULT 22; - DECLARE vBuyValueComponent INT DEFAULT 28; - DECLARE vMarginComponent INT DEFAULT 29; - DECLARE vDiscountLastItemComponent INT DEFAULT 32; - DECLARE vExtraBaggedComponent INT DEFAULT 38; - DECLARE vManaAutoComponent INT DEFAULT 39; - DECLARE vFreightBonusComponent INT DEFAULT 41; - - - SELECT volume INTO vBoxVolume - FROM vn.packaging - WHERE id = '94'; - - SELECT clientFk INTO vClientFK - FROM address - WHERE id = vAddressFk; - - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCalculate; - CREATE TEMPORARY TABLE tmp.ticketComponentCalculate - (PRIMARY KEY (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT - tl.itemFk, tl.warehouseFk, tl.available, - IF((@rate2 := IFNULL(pf.rate2, b.price2)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate2) * 1.0 rate2, - IF((@rate3 := IFNULL(pf.rate3, b.price3)) < i.minPrice AND i.hasMinPrice, i.minPrice, @rate3) * 1.0 rate3, - IFNULL(pf.rate3, 0) AS minPrice, - IFNULL(pf.packing, b.packing) packing, - IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, i.typeFk - FROM tmp.ticketLot tl - JOIN buy b ON b.id = tl.buyFk - JOIN item i ON i.id = tl.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemCategory ic ON ic.id = it.categoryFk - LEFT JOIN specialPrice sp ON sp.itemFk = i.id AND sp.clientFk = vClientFk - LEFT JOIN ( - SELECT * FROM ( - SELECT pf.itemFk, pf.`grouping`, pf.packing, pf.box, pf.rate2, pf.rate3, aho.warehouseFk - FROM priceFixed pf - JOIN tmp.agencyHourGetShipped aho ON pf.warehouseFk = aho.warehouseFk OR pf.warehouseFk = 0 - WHERE aho.shipped BETWEEN pf.started AND pf.ended ORDER BY pf.itemFk, pf.warehouseFk DESC - ) tpf - GROUP BY tpf.itemFk, tpf.warehouseFk - ) pf ON pf.itemFk = tl.itemFk AND pf.warehouseFk = tl.warehouseFk - WHERE b.buyingValue + b.freightValue + b.packageValue + b.comissionValue > 0.01 AND ic.display <> 0; - - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent; - CREATE TEMPORARY TABLE tmp.ticketComponent ( - `warehouseFk` INT UNSIGNED NOT NULL, - `itemFk` INT NOT NULL, - `componentFk` INT UNSIGNED NOT NULL, - `cost` DECIMAL(10,4) NOT NULL, - INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC), - UNIQUE INDEX `itemWarehouseComponent` (`itemFk` ASC, `warehouseFk` ASC, `componentFk` ASC)); - - - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vBuyValueComponent, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - INSERT INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost) - SELECT - tcc.warehouseFk, - tcc.itemFk, - vMarginComponent, - tcc.rate3 - b.buyingValue - b.freightValue - b.packageValue - b.comissionValue - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentBase; - CREATE TEMPORARY TABLE tmp.ticketComponentBase ENGINE = MEMORY - SELECT tc.itemFk, ROUND(SUM(tc.cost), 4) AS base, tc.warehouseFk - FROM tmp.ticketComponent tc - GROUP BY tc.itemFk, warehouseFk; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vRecoveryComponent, ROUND(tcb.base * LEAST(cr.recobro, 0.25), 3) - FROM tmp.ticketComponentBase tcb - JOIN bi.claims_ratio cr ON cr.Id_Cliente = vClientFk - WHERE cr.recobro > 0.009; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vManaAutoComponent, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM tmp.ticketComponentBase tcb - JOIN `client` c on c.id = vClientFk - JOIN bs.mana_spellers ms ON c.salesPersonFk = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - HAVING manaAuto <> 0; - - INSERT INTO tmp.ticketComponent - SELECT - tcb.warehouseFk, - tcb.itemFk, - cr.id, - GREATEST(IFNULL(ROUND(tcb.base * cr.tax, 4), 0), tcc.minPrice - tcc.rate3) - FROM tmp.ticketComponentBase tcb - JOIN componentRate cr - JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE cr.id = vDiscountLastItemComponent AND cr.tax <> 0 AND tcc.minPrice < tcc.rate3 AND sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, tcc.itemFk, vSellByPacketComponent, tcc.rate2 - tcc.rate3 - FROM tmp.ticketComponentCalculate tcc - JOIN buy b ON b.id = tcc.buyFk - LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk - WHERE sp.value IS NULL; - - INSERT INTO tmp.ticketComponent - SELECT - tcc.warehouseFK, - tcc.itemFk, - vDeliveryComponent, - vGeneralInflationCoefficient - * ROUND(( - i.compression - * r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * IFNULL(amz.price - * amz.inflation, 50)) / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN agencyMode am ON am.id = vAgencyModeFk - JOIN `address` a ON a.id = vAddressFk - JOIN agencyProvince ap ON ap.agencyFk = am.agencyFk - AND ap.warehouseFk = tcc.warehouseFk AND ap.provinceFk = a.provinceFk - JOIN agencyModeZone amz ON amz.agencyModeFk = vAgencyModeFk - AND amz.zone = ap.zone AND amz.itemFk = 71 AND amz.warehouseFk = tcc.warehouseFk - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - HAVING cost <> 0; - - INSERT INTO tmp.ticketComponent - SELECT - tcc.warehouseFk, - tcc.itemFk, - vFreightBonusComponent, - vGeneralInflationCoefficient - * ROUND( - r.cm3 - * IF(am.deliveryMethodFk = 1, (GREATEST(i.density, vMinimumDensityWeight) / vMinimumDensityWeight), 1) - * awb.bonus - * amz.inflation / vBoxVolume, 4 - ) cost - FROM tmp.ticketComponentCalculate tcc - JOIN item i ON i.id = tcc.itemFk - JOIN agencyMode am ON am.id = vAgencyModeFk - JOIN `address` a ON a.id = vAddressFk - JOIN agencyProvince ap ON ap.agencyFk = a.id - AND ap.warehouseFk = tcc.warehouseFk AND ap.provinceFk = a.provinceFk - JOIN agencyModeZone amz ON amz.agencyModeFk = vAgencyModeFk - AND amz.zone = ap.zone AND amz.itemFk = vBoxFreightItem AND amz.warehouseFk = tcc.warehouseFk - JOIN agencyWeekDayBonus awb ON awb.warehouseFk = amz.warehouseFk AND awb.zone = amz.zone AND am.id = awb.agencyFk - LEFT JOIN bi.rotacion r ON r.warehouse_id = tcc.warehouseFk - AND r.Id_Article = tcc.itemFk - JOIN tmp.agencyHourGetShipped aho ON aho.warehouseFk = awb.warehouseFk - AND WEEKDAY(aho.landed) = awb.weekDay - HAVING cost <> 0 - LIMIT 1; - - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = vAddressFk) THEN - INSERT INTO tmp.ticketComponent - SELECT tcc.warehouseFk, b.itemFk, vExtraBaggedComponent, ap.packagingValue cost - FROM tmp.ticketComponentCalculate tcc - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = vAddressFk; - END IF; - - INSERT INTO tmp.ticketComponent - SELECT tcb.warehouseFk, tcb.itemFk, vExtraFreightComponent, tcb.base * (IFNULL(pe.percentage,pp.percentage)/100) - FROM tmp.ticketComponentBase tcb - JOIN tmp.agencyHourGetShipped aho ON aho.warehouseFk = tcb.warehouseFk - LEFT JOIN preparationPercentage pp ON pp.weekDay = WEEKDAY(aho.shipped) - AND tcb.warehouseFk = IFNULL(pp.warehouseFk, tcb.warehouseFk) - LEFT JOIN preparationException pe ON pe.exceptionDay = aho.shipped - AND tcb.warehouseFk = IFNULL(pe.warehouseFk, tcb.warehouseFk) - WHERE IFNULL(pe.percentage, pp.percentage); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentCopy; - CREATE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY - SELECT * FROM tmp.ticketComponent; - - INSERT INTO tmp.ticketComponent - SELECT - tcc.warehouseFk, - tcc.itemFk, - vSpecialPriceComponent, - sp.value - SUM(tcc.cost) sumCost - FROM tmp.ticketComponentCopy tcc - JOIN componentRate cr ON cr.id = tcc.componentFk - JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk - WHERE cr.classRate IS NULL - GROUP BY tcc.itemFk, tcc.warehouseFk - HAVING ABS(sumCost) > 0.001; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentSum; - CREATE TEMPORARY TABLE tmp.ticketComponentSum - (INDEX (itemFk, warehouseFk)) - ENGINE = MEMORY - SELECT SUM(cost) sumCost, tc.itemFk, tc.warehouseFk, cr.classRate - FROM tmp.ticketComponent tc - JOIN componentRate cr ON cr.id = tc.componentFk - GROUP BY tc.itemFk, tc.warehouseFk, cr.classRate; - - select 1; - - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentRate; - CREATE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY - SELECT - tcc.warehouseFk, - tcc.itemFk, - 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, - SUM(tcs.sumCost) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 2 rate, - tcc.packing `grouping`, - SUM(tcs.sumCost) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE tcc.available IS NULL OR (IFNULL(tcs.classRate, 2) = 2 - AND tcc.packing > 0 AND tcc.available >= tcc.packing) - GROUP BY tcs.warehouseFk, tcs.itemFk; - - INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price) - SELECT - tcc.warehouseFk, - tcc.itemFk, - 3 rate, - tcc.available `grouping`, - SUM(tcs.sumCost) price - FROM tmp.ticketComponentCalculate tcc - JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk - AND tcs.warehouseFk = tcc.warehouseFk - WHERE IFNULL(tcs.classRate, 3) = 3 - GROUP BY tcs.warehouseFk, tcs.itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponentPrice; - -select 2; - - CREATE TEMPORARY TABLE tmp.ticketComponentPrice ENGINE = MEMORY - SELECT * FROM ( - SELECT * FROM tmp.ticketComponentRate ORDER BY price - ) t - GROUP BY itemFk, warehouseFk, `grouping`; - - DROP TEMPORARY TABLE - tmp.ticketComponentCalculate, - tmp.ticketComponentSum, - tmp.ticketComponentBase, - tmp.ticketComponentRate, - tmp.ticketComponentCopy; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticketComponentMakeUpdate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -54402,6 +53947,26 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) +BEGIN + SELECT vn.workerTimeControl_add(vUserFk,vWarehouseFk,vTimed,vIsManual); + CALL vn.workerTimeControlSOWP(vUserFk, vTimed); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add__`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) BEGIN DECLARE vDirection VARCHAR(6); @@ -54455,51 +54020,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_add__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerTimeControl_add__`(IN vUserFk INT, IN vWarehouseFk INT, IN vTimed DATETIME, IN vIsManual BOOL) -BEGIN - - DECLARE vDirection VARCHAR(6); - DECLARE vLastIn DATETIME; - - - SELECT vn.timeWorkerControl_getDirection(vUserFk,vTimed) INTO vDirection; - - IF vDirection = 'out' THEN - - SELECT MAX(timed) INTO vLastIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction = 'in' - AND timed < vTimed; - - UPDATE vn.workerTimeControl wtc - SET wtc.direction = 'middle' - WHERE userFk = vUserFk - AND direction = 'out' - AND timed BETWEEN vLastIn AND vTimed; - - END IF; - - INSERT INTO workerTimeControl(userFk, timed, warehouseFk, direction, manual) - VALUES(vUserFk, vTimed, vWarehouseFk, vDirection, vIsManual); - - CALL vn.workerTimeControlSOWP(vUserFk, vTimed); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -57117,7 +56637,7 @@ CREATE TABLE `Cajas` ( KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `Cajas_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=743086 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=743475 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 */ ; @@ -57370,7 +56890,7 @@ CREATE TABLE `Colas` ( KEY `Id_Trabajador` (`Id_Trabajador`), CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `vn`.`queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16828 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21582 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57567,7 +57087,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2761 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2762 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 */ ; @@ -57791,7 +57311,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`entry` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3981946 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3986463 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57809,7 +57329,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 `vn`.`entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58736,7 +58256,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=252 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58920,7 +58440,7 @@ CREATE TABLE `Split_lines` ( KEY `Id_Compra` (`Id_Compra`), CONSTRAINT `Id_Compra` FOREIGN KEY (`Id_Compra`) REFERENCES `vn`.`buy` (`id`) 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=370266 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=370625 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58938,7 +58458,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=37005 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=37014 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59032,7 +58552,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65246637 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65253509 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 */ ; @@ -59310,7 +58830,7 @@ CREATE TABLE `Vehiculos_consumo` ( CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `vn`.`vehicle` (`id`) ON UPDATE CASCADE, CONSTRAINT `fuelTypeFk` FOREIGN KEY (`fuelTypeFk`) REFERENCES `vn`.`fuelType` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `proveedoresFk` FOREIGN KEY (`proveedoresFk`) REFERENCES `vn`.`supplier` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=12896 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=12909 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 */; -- @@ -59459,7 +58979,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 `vn`.`supplierAccount` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=37876 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=37944 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 */ ; @@ -59767,7 +59287,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `vn`.`company` (`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 `vn`.`warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3745 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -59846,7 +59366,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 `vn`.`supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3606 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3610 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 */ ; @@ -60012,7 +59532,7 @@ CREATE TABLE `awb_component` ( CONSTRAINT `awb_component_` FOREIGN KEY (`awb_component_type_id`) REFERENCES `awb_component_type` (`awb_component_type_id`) ON UPDATE CASCADE, CONSTRAINT `awb_role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=32804 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=32915 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -60127,7 +59647,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 `vn`.`dms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3187 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3191 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -61841,7 +61361,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `vn`.`intrastat` (`id`) 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=84537 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=84827 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62126,7 +61646,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1935466 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1938221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62358,7 +61878,7 @@ CREATE TABLE `pago` ( CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `vn`.`payMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `vn`.`supplier` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52643 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52653 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 */ ; @@ -62854,7 +62374,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 `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64835 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64846 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 */ ; @@ -63034,7 +62554,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=89106 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=89245 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 */ ; @@ -63272,7 +62792,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `vn`.`taxCode` (`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 `vn`.`expence` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=166766 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=167139 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -63295,7 +62815,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `vn`.`bank` (`id`) 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=164779 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=165073 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 */ ; @@ -63565,7 +63085,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=112863 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=113055 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 */; -- @@ -63607,7 +63127,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=1440144 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1443192 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -64123,7 +63643,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 `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=246042 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=246368 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -65553,15 +65073,16 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `Averiguar_ComercialCliente`(v_customer INT, v_date DATE) RETURNS varchar(3) CHARSET utf8 DETERMINISTIC BEGIN +-- DEPRECATED USE vn.client_getSalesPersonCode /** * Dado un id cliente y una fecha, devuelve su comercial. * Para más información ir a Averiguar_ComercialCliente_Id() @@ -65591,15 +65112,17 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `Averiguar_ComercialCliente_Id`(v_customer INT, v_date DATE) RETURNS int(11) DETERMINISTIC BEGIN + + -- DEPRECATED USE vn.client_getSalesPerson /** * Dado un id cliente y una fecha, devuelve su comercial para ese dia, teniendo * en cuenta la jerarquía de las tablas: 1º la de sharingclient, 2º la de @@ -65677,15 +65200,16 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `Averiguar_ComercialCliente_IdTicket`(v_ticket INT) RETURNS varchar(3) CHARSET utf8 DETERMINISTIC BEGIN +-- DEPRECATED USE vn.client_getSalesPersonCodeByTicket /** * Dado un id ticket, devuelve su comercial. * Para más información ir a Averiguar_ComercialCliente_Id() @@ -65712,15 +65236,16 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`%` FUNCTION `Averiguar_ComercialCliente_IdTicket_Id`(v_ticket INT) RETURNS int(11) DETERMINISTIC BEGIN +-- DEPRECATED USE vn.client_getSalesPersonByTicket /** * Dado un id ticket, devuelve su comercial. * Para más información ir a Averiguar_ComercialCliente_Id() @@ -70253,592 +69778,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `bionic_calc_componentTestKk` */; -/*!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 `bionic_calc_componentTestKk`(IN `v_consigna` INT, IN `v_agencia` INT) -proc: BEGIN - - DECLARE v_customer INT; - DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.3; - DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; - DECLARE VOLUMEN_CAJA_VERDNATURA BIGINT DEFAULT 138000; - -- DECLARE vValorEmbolsado DOUBLE DEFAULT 0.04; - - SELECT Id_Cliente INTO v_customer FROM Consignatarios WHERE Id_Consigna = v_consigna; - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS t_bionic_temp; - CREATE TEMPORARY TABLE t_bionic_temp - (PRIMARY KEY (item_id,warehouse_id)) - ENGINE = MEMORY - SELECT - b.item_id, b.warehouse_id,available, - IF((@rate2 := IFNULL(pf.rate_2,c.Tarifa2)) < a.PVP AND a.`Min`, a.PVP, @rate2) * 1.0 rate_2, - IF((@rate3 := IFNULL(pf.rate_3,c.Tarifa3)) < a.PVP AND a.`Min`, a.PVP, @rate3) * 1.0 rate_3, - ifnull(pf.rate_3,0) AS min_price, - IFNULL(pf.Packing,c.Packing) packing, - IFNULL(pf.`grouping`,c.`grouping`) `grouping`, - ABS(IFNULL(pf.caja,c.caja)) box, - b.buy_id, a.tipo_id - FROM tmp.bionic_lot b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - JOIN vn2008.Articles a ON b.item_id = a.Id_Article - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = t.reino_id - LEFT JOIN vn2008.PreciosEspeciales p ON a.Id_Article = p.Id_Article AND p.Id_Cliente = v_customer - LEFT JOIN ( - SELECT * FROM ( - SELECT p.item_id, p.`grouping`, p.Packing,p.caja, p.rate_2, p.rate_3, ah.warehouseFk AS warehouse_id - FROM vn2008.price_fixed p - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = p.warehouse_id OR p.warehouse_id = 0 - WHERE ah.shipped BETWEEN p.date_start AND p.date_end ORDER BY p.item_id, p.warehouse_id DESC - ) t - GROUP BY item_id, warehouse_id - ) pf ON pf.item_id = b.item_id AND pf.warehouse_id = b.warehouse_id - -- descartamos articulos con coste menor de 0.01 - WHERE Costefijo + Portefijo + Embalajefijo + Comisionfija > 0.01 AND r.display <> 0; - - -- Creamos la tabla tmp.bionic_component - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component; - CREATE TEMPORARY TABLE tmp.bionic_component LIKE - template_bionic_component; - - -- Componentes del precio, valores absolutos - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 29, rate_3 - Costefijo - Portefijo - Embalajefijo - Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 28, Costefijo + Portefijo + Embalajefijo + Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - -- Ahora los valores en funcion de la base - - DROP TEMPORARY TABLE IF EXISTS t_components_base; - - CREATE TEMPORARY TABLE t_components_base - SELECT bc.item_id, ROUND(SUM(cost), 4) AS base, bc.warehouse_id - FROM tmp.bionic_component bc - GROUP BY bc.item_id,warehouse_id; - - -- La ratio se calcula teniendo en cuenta el valor de las reclamaciones y el saldo de greuge - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 17, ROUND(base * LEAST(recobro,0.25), 3) - FROM t_components_base cb - JOIN bi.claims_ratio ON Id_Cliente = v_customer - WHERE recobro > 0.009; - - -- PAK 2016-08-31 Componente de maná automático, en función del maná acumulado por el comercial. - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 39, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM t_components_base cb - JOIN Clientes c on c.Id_Cliente = v_customer - JOIN bs.mana_spellers ms ON c.Id_Trabajador = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - AND c.Id_Trabajador != 196 -- Ruben Espinosa - HAVING manaAuto <> 0 ; - - -/* - -- Vendedor variable - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, Id_Componente, IFNULL(ROUND(base * tax,4), 0) - FROM t_components_base cb - JOIN bi.tarifa_componentes - WHERE tarifa_componentes_series_id = 2 and IFNULL(tax, 0) > 0; - */ - - --- ******* Inicio Bloque para componentes con tarifa_class diferente de NULL - -- Descuento por ultimas unidades - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, b.item_id, Id_Componente, GREATEST(IFNULL(ROUND(base * tax,4), 0), b.min_price - b.rate_3) - FROM t_components_base cb - JOIN bi.tarifa_componentes - JOIN t_bionic_temp b ON b.item_id = cb.item_id AND b.warehouse_id = cb.warehouse_id - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE Id_Componente = 32 AND tax <> 0 AND b.min_price < b.rate_3 AND PrecioEspecial IS NULL; - - -- Incremento por paquete suelto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 22, rate_2 - rate_3 - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE PrecioEspecial IS NULL; - --- ******* Fin Bloque para componentes con tarifa_class diferente de NULL - - -- Reparto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 15 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * IFNULL(az.price - * az.inflacion ,50) - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - HAVING cost <> 0; - --- Reparto bonificado - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 41 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * awb.bonus - * az.inflacion - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - JOIN vn2008.agency_weekday_bonus awb ON awb.warehouse_id = az.warehouse_id AND awb.zona = az.zona AND a.agency_id = awb.agency_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = awb.warehouse_id AND weekday(ah.landed) = awb.weekDay - HAVING cost <> 0 - LIMIT 1; - --- PAK 12-05-2015 - -- EMBOLSADO - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = v_consigna) THEN - - -- IF v_consigna IN (13690, 3402, 5661, 4233) THEN - - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 38, ap.packagingValue cost - FROM t_bionic_temp b - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = v_consigna; - - END IF; - - -- JGF 14-08-2015 - -- Modificacion de precio por dia de preparacion del pedido - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, cb.item_id, 14, cb.base * (IFNULL(pe.percentage,pp.percentage)/100) - FROM t_components_base cb - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = cb.warehouse_id - LEFT JOIN vn2008.preparation_percentage pp ON pp.week_day = weekday(ah.shipped) AND cb.warehouse_id = IFNULL(pp.warehouse_id,cb.warehouse_id) - LEFT JOIN vn2008.preparation_exception pe ON pe.exception_day = ah.shipped AND cb.warehouse_id = IFNULL(pe.warehouse_id,cb.warehouse_id) - WHERE IFNULL(pe.percentage,pp.percentage); - - -- Creamos la tabla tmp.bionic_component_copy por que mysql no puede reabrir una tabla temporal - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component_copy; - CREATE TEMPORARY TABLE tmp.bionic_component_copy - SELECT * FROM tmp.bionic_component; - - -- JGF 19-01-2016 - -- Precios especiales - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 10, pe.PrecioEspecial - SUM(cost) sum_cost - FROM tmp.bionic_component_copy b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE t.tarifa_class IS NULL - GROUP BY b.item_id, b.warehouse_id - HAVING ABS(sum_cost) > 0.001; - - -- Lotes - DROP TEMPORARY TABLE IF EXISTS t_component_sum; - CREATE TEMPORARY TABLE t_component_sum - (INDEX (item_id, warehouse_id)) - ENGINE = MEMORY - SELECT SUM(cost) sum_cost, b.item_id, b.warehouse_id, t.tarifa_class - FROM tmp.bionic_component b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - GROUP BY b.item_id, b.warehouse_id, t.tarifa_class; - - -- ***** Inicia Modifica t_bionic_rate las diferentes tarifas - -- Tarifa por unidad minima - DROP TEMPORARY TABLE IF EXISTS t_bionic_rate; - CREATE TEMPORARY TABLE t_bionic_rate - ENGINE = MEMORY - SELECT b.warehouse_id, item_id, 1 rate, - IF(box = 1, `grouping`, 1) `grouping`, SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,1) = 1 AND box < 2 AND (packing > `grouping` or box = 0) - GROUP BY warehouse_id, item_id; - - -- Tarifa por caja - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 2 rate, packing `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE available IS NULL OR (IFNULL(cs.tarifa_class,2) = 2 AND packing > 0 AND available >= packing) - GROUP BY warehouse_id, item_id; - - -- Tarifa para toda la cantidad disponible - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 3 rate, available `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,3) = 3 - GROUP BY warehouse_id, item_id; - - -- ***** Fin Modifica t_bionic_rate las diferentes tarifas - - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_price; - CREATE TEMPORARY TABLE tmp.bionic_price - LIKE template_bionic_price; - - INSERT INTO tmp.bionic_price (warehouse_id, item_id, rate, `grouping`, price) - SELECT * FROM ( - SELECT * FROM t_bionic_rate ORDER BY price - ) t - GROUP BY item_id, warehouse_id, `grouping`; - - - DROP TEMPORARY TABLE IF EXISTS tmp.travel_tree; - CREATE TEMPORARY TABLE tmp.travel_tree - ENGINE = MEMORY - SELECT * FROM tmp.agencyHourGetShipped; - - -- Limpieza - - DROP TEMPORARY TABLE tmp.agencyHourGetShipped; - DROP TEMPORARY TABLE t_bionic_temp; - DROP TEMPORARY TABLE t_component_sum; - DROP TEMPORARY TABLE t_components_base; - DROP TEMPORARY TABLE t_bionic_rate; - DROP TEMPORARY TABLE tmp.bionic_component_copy; -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 `bionic_calc_component__` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `bionic_calc_component__`(IN `v_consigna` INT, IN `v_agencia` INT) -proc: BEGIN - - DECLARE v_customer INT; - DECLARE COEFICIENTE_DE_INFLACION_GENERAL INT DEFAULT 1.0; - DECLARE DENSIDAD_MINIMA_PESO_VOLUMETRICO INT DEFAULT 167; - DECLARE VOLUMEN_CAJA_VERDNATURA BIGINT; -- DEFAULT 138000; - -- DECLARE vValorEmbolsado DOUBLE DEFAULT 0.04; - - CALL util.THROW('OBSOLETO'); - - SELECT Volumen INTO VOLUMEN_CAJA_VERDNATURA - FROM Cubos - WHERE Id_Cubo = '94'; - - SELECT Id_Cliente INTO v_customer FROM Consignatarios WHERE Id_Consigna = v_consigna; - SET @rate2 := 0; - SET @rate3 := 0; - - DROP TEMPORARY TABLE IF EXISTS t_bionic_temp; - CREATE TEMPORARY TABLE t_bionic_temp - (PRIMARY KEY (item_id,warehouse_id)) - ENGINE = MEMORY - SELECT - b.item_id, b.warehouse_id,available, - IF((@rate2 := IFNULL(pf.rate_2,c.Tarifa2)) < a.PVP AND a.`Min`, a.PVP, @rate2) * 1.0 rate_2, - IF((@rate3 := IFNULL(pf.rate_3,c.Tarifa3)) < a.PVP AND a.`Min`, a.PVP, @rate3) * 1.0 rate_3, - ifnull(pf.rate_3,0) AS min_price, - IFNULL(pf.Packing,c.Packing) packing, - IFNULL(pf.`grouping`,c.`grouping`) `grouping`, - ABS(IFNULL(pf.caja,c.caja)) box, - b.buy_id, a.tipo_id - FROM tmp.bionic_lot b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - JOIN vn2008.Articles a ON b.item_id = a.Id_Article - JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = t.reino_id - LEFT JOIN vn2008.PreciosEspeciales p ON a.Id_Article = p.Id_Article AND p.Id_Cliente = v_customer - LEFT JOIN ( - SELECT * FROM ( - SELECT p.item_id, p.`grouping`, p.Packing, p.caja, p.rate_2, p.rate_3, zgs.warehouseFk AS warehouse_id - FROM vn2008.price_fixed p - JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = p.warehouse_id OR p.warehouse_id = 0 - WHERE zgs.shipped BETWEEN p.date_start AND p.date_end ORDER BY p.item_id, p.warehouse_id DESC - ) t - GROUP BY item_id, warehouse_id - ) pf ON pf.item_id = b.item_id AND pf.warehouse_id = b.warehouse_id - -- descartamos articulos con coste menor de 0.01 - WHERE Costefijo + Portefijo + Embalajefijo + Comisionfija > 0.01 AND r.display <> 0; - - -- Creamos la tabla tmp.bionic_component - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component; - CREATE TEMPORARY TABLE tmp.bionic_component LIKE - template_bionic_component; - - -- Componentes del precio, valores absolutos - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 29, rate_3 - Costefijo - Portefijo - Embalajefijo - Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - INSERT INTO tmp.bionic_component ( warehouse_id, item_id, component_id, cost) - SELECT b.warehouse_id, b.item_id, 28, Costefijo + Portefijo + Embalajefijo + Comisionfija - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra; - - -- Ahora los valores en funcion de la base - - DROP TEMPORARY TABLE IF EXISTS t_components_base; - - CREATE TEMPORARY TABLE t_components_base - SELECT bc.item_id, ROUND(SUM(cost), 4) AS base, bc.warehouse_id - FROM tmp.bionic_component bc - GROUP BY bc.item_id,warehouse_id; - - -- La ratio se calcula teniendo en cuenta el valor de las reclamaciones y el saldo de greuge - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 17, ROUND(base * LEAST(recobro,0.25), 3) - FROM t_components_base cb - JOIN bi.claims_ratio ON Id_Cliente = v_customer - WHERE recobro > 0.009; - - -- PAK 2016-08-31 Componente de maná automático, en función del maná acumulado por el comercial. - - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, 39, ROUND(base * (0.01 + prices_modifier_rate), 3) as manaAuto - FROM t_components_base cb - JOIN Clientes c on c.Id_Cliente = v_customer - JOIN bs.mana_spellers ms ON c.Id_Trabajador = ms.Id_Trabajador - WHERE ms.prices_modifier_activated - AND c.Id_Trabajador != 196 -- Ruben Espinosa - HAVING manaAuto <> 0 ; - - -/* - -- Vendedor variable - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, item_id, Id_Componente, IFNULL(ROUND(base * tax,4), 0) - FROM t_components_base cb - JOIN bi.tarifa_componentes - WHERE tarifa_componentes_series_id = 2 and IFNULL(tax, 0) > 0; - */ - - --- ******* Inicio Bloque para componentes con tarifa_class diferente de NULL - -- Descuento por ultimas unidades - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, b.item_id, Id_Componente, GREATEST(IFNULL(ROUND(base * tax,4), 0), b.min_price - b.rate_3) - FROM t_components_base cb - JOIN bi.tarifa_componentes - JOIN t_bionic_temp b ON b.item_id = cb.item_id AND b.warehouse_id = cb.warehouse_id - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE Id_Componente = 32 AND tax <> 0 AND b.min_price < b.rate_3 AND PrecioEspecial IS NULL; - - -- Incremento por paquete suelto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 22, rate_2 - rate_3 - FROM t_bionic_temp b - JOIN vn2008.Compres c ON b.buy_id = c.Id_Compra - LEFT JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE PrecioEspecial IS NULL; - --- ******* Fin Bloque para componentes con tarifa_class diferente de NULL - - -- Reparto - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 15 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - * IFNULL(az.price - * az.inflacion ,50) - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - HAVING cost <> 0; - --- Reparto bonificado - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id - , b.item_id - , 41 - , COEFICIENTE_DE_INFLACION_GENERAL - * ROUND( - r.cm3 - * art.compression - * IF(a.Vista = 1, (GREATEST(art.density,DENSIDAD_MINIMA_PESO_VOLUMETRICO) / DENSIDAD_MINIMA_PESO_VOLUMETRICO ) , 1) - -- * awb.bonus - * az.inflacion - / VOLUMEN_CAJA_VERDNATURA, 4 - ) cost - FROM t_bionic_temp b - JOIN vn2008.Articles art ON art.Id_Article = b.item_id - JOIN vn2008.Agencias a ON a.Id_Agencia = v_agencia - JOIN vn2008.Consignatarios c ON c.Id_Consigna = v_consigna - JOIN vn2008.Agencias_province ap ON ap.agency_id = a.agency_id AND ap.warehouse_id = b.warehouse_id AND ap.province_id = c.province_id - JOIN vn2008.Agencias_zonas az ON az.Id_Agencia = v_agencia AND az.zona = ap.zona AND az.Id_Article = 71 AND az.warehouse_id = b.warehouse_id - -- JOIN vn2008.agency_weekday_bonus awb ON awb.warehouse_id = az.warehouse_id AND awb.zona = az.zona AND a.agency_id = awb.agency_id - LEFT JOIN bi.rotacion r ON r.warehouse_id = b.warehouse_id AND r.Id_Article = b.item_id - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = awb.warehouse_id AND weekday(ah.landed) = awb.weekDay - HAVING cost <> 0 - LIMIT 1; - --- PAK 12-05-2015 - -- EMBOLSADO - IF (SELECT COUNT(*) FROM vn.addressForPackaging WHERE addressFk = v_consigna) THEN - - -- IF v_consigna IN (13690, 3402, 5661, 4233) THEN - - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 38, ap.packagingValue cost - FROM t_bionic_temp b - JOIN vn.addressForPackaging ap - WHERE ap.addressFk = v_consigna; - - END IF; - - -- JGF 14-08-2015 - -- Modificacion de precio por dia de preparacion del pedido - INSERT INTO tmp.bionic_component - SELECT cb.warehouse_id, cb.item_id, 14, cb.base * (IFNULL(pe.percentage,pp.percentage)/100) - FROM t_components_base cb - JOIN tmp.agencyHourGetShipped ah ON ah.warehouseFk = cb.warehouse_id - LEFT JOIN vn2008.preparation_percentage pp ON pp.week_day = weekday(ah.shipped) AND cb.warehouse_id = IFNULL(pp.warehouse_id,cb.warehouse_id) - LEFT JOIN vn2008.preparation_exception pe ON pe.exception_day = ah.shipped AND cb.warehouse_id = IFNULL(pe.warehouse_id,cb.warehouse_id) - WHERE IFNULL(pe.percentage,pp.percentage); - - -- Creamos la tabla tmp.bionic_component_copy por que mysql no puede reabrir una tabla temporal - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_component_copy; - CREATE TEMPORARY TABLE tmp.bionic_component_copy - SELECT * FROM tmp.bionic_component; - - -- JGF 19-01-2016 - -- Precios especiales - INSERT INTO tmp.bionic_component - SELECT b.warehouse_id, b.item_id, 10, pe.PrecioEspecial - SUM(cost) sum_cost - FROM tmp.bionic_component_copy b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - JOIN PreciosEspeciales pe ON pe.Id_Cliente = v_customer AND pe.Id_Article = b.item_id - WHERE t.tarifa_class IS NULL - GROUP BY b.item_id, b.warehouse_id - HAVING ABS(sum_cost) > 0.001; - - -- Lotes - DROP TEMPORARY TABLE IF EXISTS t_component_sum; - CREATE TEMPORARY TABLE t_component_sum - (INDEX (item_id, warehouse_id)) - ENGINE = MEMORY - SELECT SUM(cost) sum_cost, b.item_id, b.warehouse_id, t.tarifa_class - FROM tmp.bionic_component b - JOIN bi.tarifa_componentes t ON b.component_id = t.Id_Componente - GROUP BY b.item_id, b.warehouse_id, t.tarifa_class; - - -- ***** Inicia Modifica t_bionic_rate las diferentes tarifas - -- Tarifa por unidad minima - DROP TEMPORARY TABLE IF EXISTS t_bionic_rate; - CREATE TEMPORARY TABLE t_bionic_rate - ENGINE = MEMORY - SELECT b.warehouse_id, item_id, 1 rate, - IF(box = 1, `grouping`, 1) `grouping`, SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,1) = 1 AND box < 2 AND (packing > `grouping` or box = 0) - GROUP BY warehouse_id, item_id; - - -- Tarifa por caja - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 2 rate, packing `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE available IS NULL OR (IFNULL(cs.tarifa_class,2) = 2 AND packing > 0 AND available >= packing) - GROUP BY warehouse_id, item_id; - - -- Tarifa para toda la cantidad disponible - INSERT INTO t_bionic_rate (warehouse_id, item_id, rate, `grouping`, price) - SELECT b.warehouse_id, item_id, 3 rate, available `grouping`, - SUM(sum_cost) price - FROM t_bionic_temp b - JOIN t_component_sum cs USING(item_id, warehouse_id) - WHERE IFNULL(cs.tarifa_class,3) = 3 - GROUP BY warehouse_id, item_id; - - -- ***** Fin Modifica t_bionic_rate las diferentes tarifas - - DROP TEMPORARY TABLE IF EXISTS tmp.bionic_price; - CREATE TEMPORARY TABLE tmp.bionic_price - LIKE template_bionic_price; - - INSERT INTO tmp.bionic_price (warehouse_id, item_id, rate, `grouping`, price) - SELECT * FROM ( - SELECT * FROM t_bionic_rate ORDER BY price - ) t - GROUP BY item_id, warehouse_id, `grouping`; - - - DROP TEMPORARY TABLE IF EXISTS tmp.travel_tree; - CREATE TEMPORARY TABLE tmp.travel_tree - ENGINE = MEMORY - SELECT * FROM tmp.agencyHourGetShipped; - - -- Limpieza - - DROP TEMPORARY TABLE tmp.agencyHourGetShipped; - DROP TEMPORARY TABLE t_bionic_temp; - DROP TEMPORARY TABLE t_component_sum; - DROP TEMPORARY TABLE t_components_base; - DROP TEMPORARY TABLE t_bionic_rate; - DROP TEMPORARY TABLE tmp.bionic_component_copy; -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 `bionic_calc_dateKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -74078,122 +73017,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `buy_transferKk` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `buy_transferKk`(IN `v_buy` INT, IN `v_fv_entry` INT, IN `v_pca_entry` INT) -proc: BEGIN -/** - * Traslada la cantidad restante de una compra de Holanda - * al almacén de Silla. - **/ - DECLARE v_wh INT; - DECLARE v_entry INT; - DECLARE v_fv INT; - DECLARE v_amount INT; - DECLARE v_item INT; - DECLARE v_holland_wh INT DEFAULT 7; - - -- Comprueba que es mercancía que llega al almacén de Holanda - - SELECT t.warehouse_id, IF(tp.warehouseFk=1,1,0) AS v_fv INTO v_wh,v_fv - FROM Compres c - JOIN Entradas e ON c.Id_Entrada = e.Id_Entrada - JOIN travel t ON t.id = e.travel_id - JOIN Articles a ON a.Id_Article = c.Id_Article - JOIN Tipos tp ON tp.tipo_id = a.tipo_id - WHERE c.Id_Compra = v_buy; - - IF v_wh != v_holland_wh THEN - LEAVE proc; - END IF; - - -- Calcula a que almacén de Silla debe transladar la mercancía - - SET v_entry = IF(v_fv, v_fv_entry, v_pca_entry); - SET v_entry = COALESCE(v_entry, v_pca_entry, v_fv_entry); - - IF v_entry IS NULL THEN - LEAVE proc; - END IF; - - -- Calcula la cantidad a trasladar - - SELECT Id_Article INTO v_item - FROM Compres WHERE Id_Compra = v_buy; - - SELECT IFNULL(SUM(amount), 0) INTO v_amount - FROM ( - SELECT SUM(c.Cantidad) amount - 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.landing = CURDATE() - AND t.warehouse_id = v_holland_wh - UNION ALL - SELECT -SUM(c.Cantidad) - 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 = v_holland_wh - UNION ALL - SELECT -SUM(Cantidad) - FROM Movimientos m - JOIN Tickets t ON t.Id_Ticket = m.Id_Ticket - WHERE m.Id_Article = v_item - AND t.Fecha = CURDATE() - AND t.warehouse_id = v_holland_wh - ) t; - - IF v_amount <= 0 THEN - LEAVE proc; - END IF; - - -- Crea la nueva línea de compra con el translado - - INSERT INTO Compres ( - Id_Article, Etiquetas, Cantidad, Id_Entrada, - Id_Cubo, Packing, `grouping`, caja, Costefijo, Portefijo, - Embalajefijo, Comisionfija, novincular, buy_edi_id) - SELECT - c.Id_Article, - v_amount DIV c.Packing, - v_amount, - v_entry, - c.Id_Cubo, - c.Packing, - c.`grouping`, - c.caja, - @cost := IFNULL(c.Costefijo, 0) + IFNULL(c.Comisionfija, 0) + IFNULL(c.Portefijo, 0), - @porte := ROUND((@cm3:= cm3_2(c.Id_Cubo, c.Id_Article)) * a.m3 / 1000000 / c.Packing, 3), - c.EmbalajeFijo, - @comision := ROUND(c.Costefijo * e.comision / 100, 3), - c.novincular, - c.buy_edi_id - FROM Compres c - JOIN Cubos cu ON cu.Id_Cubo = c.Id_Cubo - JOIN Entradas e ON e.Id_Entrada = v_entry - JOIN travel t ON t.id = e.travel_id - JOIN Agencias a ON t.agency_id = a.Id_Agencia - WHERE c.Id_Compra = v_buy; - - CALL buy_tarifas (LAST_INSERT_ID()); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `cacheReset` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -78687,158 +77510,6 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `F5__` */; -/*!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 `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 */ ; -/*!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 `Facturas_Saltos` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -81690,9 +80361,9 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; @@ -81821,7 +80492,7 @@ BEGIN END IF; -- Mercancia en transito - INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) + /*INSERT INTO inv(warehouseFk, Id_Article, cantidad, Almacen) SELECT tr.warehouse_id, C.Id_Article, C.Cantidad, CONCAT(wOut.`name`,' - ', wIn.`name`) FROM Compres C JOIN Articles A USING(Id_Article) @@ -81830,12 +80501,14 @@ BEGIN JOIN Tipos t USING(tipo_id) JOIN warehouse wIn ON wIn.id = tr.warehouse_id JOIN warehouse wOut ON wOut.id = tr.warehouse_id_out - WHERE vInventoried >= shipment AND vInventoried < landing + JOIN recibida r on r.id = E.recibida_id + WHERE vDated >= shipment AND vDated < landing AND NOT redada AND wIn.valuatedInventory AND t.inventory - ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad); - + AND r.dateOperation <=vDated + ON DUPLICATE KEY UPDATE inv.cantidad = inv.cantidad + (C.Cantidad);*/ + CALL vn.buyUltimate(NULL,vDateDayEnd); UPDATE inv i @@ -81850,28 +80523,30 @@ BEGIN IF vIsDetailed THEN SELECT inv.warehouseFk, a.Id_Article, a.Article, a.Medida, inv.Cantidad, tp.Id_Tipo, - tp.reino_id, inv.coste, cast(inv.total as decimal(10,2)) total, an.nicho, Almacen + tp.reino_id, inv.coste, cast(inv.total as decimal(10,2)) total, Almacen FROM inv JOIN warehouse w on w.id = warehouseFk JOIN Articles a ON a.Id_Article = inv.Id_Article JOIN Tipos tp ON tp.tipo_id = a.tipo_id - JOIN Articles_nicho an ON an.Id_Article = a.Id_Article AND an.warehouse_id = w.id WHERE w.valuatedInventory and inv.total > 0 order by inv.total desc; ELSE - SELECT i.Almacen, r.reino as Reino, cast(i.total as decimal) as Euros, tr.Codigotrabajador as Comprador, - A.Id_Article + SELECT i.Almacen, r.reino as Reino, cast(i.total as decimal(10,2)) as Euros, tr.Codigotrabajador as Comprador,A.Id_Article FROM inv i + JOIN warehouse w on w.id = warehouseFk JOIN Articles A USING(Id_Article) JOIN Tipos t USING(tipo_id) LEFT JOIN Trabajadores tr ON tr.Id_trabajador = t.Id_trabajador - JOIN reinos r ON r.id = t.reino_id; + JOIN reinos r ON r.id = t.reino_id + WHERE w.valuatedInventory + AND i.total > 0; END IF; DROP TEMPORARY TABLE tmp.buyUltimate; + DROP TEMPORARY TABLE inv; end ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -88227,60 +86902,6 @@ JOIN ) t ON t.Id_Ruta = rm.Id_Ruta SET rm.bultos = t.bultos; -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 `salePreparingList__` */; -/*!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 `salePreparingList__`(IN idT BIGINT) -BEGIN - - SELECT t.clientFk, - t.shipped, - a.nickname, - s.ticketFk, - s.itemFk, - s.quantity, - s.concept, - s.reserved, - s.id saleFk, - i.size, - i.inkFk, - i.stems, - i.image, - i.subName, - b.`grouping`, - ip.code as placement, - lpad(ifnull(cooler_path_detail_id, ip.code),5,'0') as path, - stPrevious.isChecked as isPrevious, - stPrepared.isChecked as isPrepared, - stControled.isChecked as isControled - - FROM vn.ticket t - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.sale s ON s.ticketFk = t.id - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.itemPlacement ip ON i.id = ip.itemFk AND i.warehouseFk = t.warehouseFk - LEFT JOIN vn2008.cooler_path_detail cpd on left(ip.code,3) = cpd.pasillo - LEFT JOIN bi.Last_buy_id lb ON lb.Id_Article = i.id AND lb.warehouse_id = t.warehouseFk - LEFT JOIN vn.buy b ON b.id = lb.Id_Compra - LEFT JOIN vn.saleTracking stPrepared ON stPrepared.saleFk = s.id AND stPrepared.stateFk = 8 - LEFT JOIN vn.saleTracking stControled ON stControled.saleFk = s.id AND stControled.stateFk = 14 - LEFT JOIN vn.saleTracking stPrevious ON stPrevious.saleFk = s.id AND stPrevious.stateFk = 26 - - WHERE t.id = idT - GROUP BY s.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -90068,6 +88689,249 @@ BEGIN DROP TEMPORARY TABLE ticketToShow; END IF; + IF (SELECT COUNT(*) FROM ticketRange) THEN + + -- Generamos varias auxiliares (ya podian los de mysql haber solucionado esto) + + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + CREATE TEMPORARY TABLE tmp.client_list + (INDEX (Id_Cliente)) + ENGINE = MEMORY + SELECT DISTINCT Id_Cliente FROM ticketRange; + + DROP TEMPORARY TABLE IF EXISTS cr5; + CREATE TEMPORARY TABLE cr5 + (INDEX (Id_Cliente)) + ENGINE = MEMORY + SELECT Id_Cliente FROM tmp.client_list; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket; + CREATE TEMPORARY TABLE tmp.ticket + ENGINE = MEMORY + SELECT t.Id_Ticket ticketFk + FROM Tickets t + STRAIGHT_JOIN tmp.client_list c ON t.Id_Cliente = c.Id_Cliente + WHERE Fecha BETWEEN dateStart AND maxDate + AND Factura IS NULL; + + CALL vn.ticketGetTotal; + + -- Generamos otra tabla temporal con los Tickets_iva + + DROP TEMPORARY TABLE IF EXISTS tt3; + CREATE TEMPORARY TABLE tt3 + ENGINE = MEMORY + SELECT t.ticketFk, tt.total, tr.* + FROM tmp.ticket t + LEFT JOIN tmp.ticketTotal tt ON t.ticketFk = tt.ticketFk + JOIN ticketRange tr ON tr.Id_Ticket = t.ticketFk; + + -- Generamos la lista de tickets y sus datos + + DROP TEMPORARY TABLE IF EXISTS Radartest; + CREATE TEMPORARY TABLE Radartest + SELECT IF(C.Id_Trabajador = worker, 1, 0) as Propio, + Credito, + CAST(Riesgo AS DECIMAL (10,2)) Riesgo, + -- Greuge, + T.Id_Ticket, + T.warehouse_id as wh, + DATE(T.Fecha) Fecha, + IF (TIME_FORMAT(T.Fecha, '%H:%i')='00:00', '23:59', TIME_FORMAT(T.Fecha, '%H:%i'))Hora, + T.Alias, + -- T.Vista, + REPEAT(' ',50) as problem, + T.Agencia Tipo, + -- C.Id_Trabajador, + T.workerId AS Id_Trabajador, + T.Solucion, + T.Localizacion, + IFNULL(state,'LIBRE') as Estado, + alertLevel, + alertCode, + CAST(T.Importe AS DECIMAL (10,2)) Importe, + C.Descuento, + C.calidad, + C.Id_Cliente, + p.`name` provincia, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute + FROM Clientes C + JOIN ( + SELECT T.* , A.Vista, A.Agencia, s.`name` as state, alertLevel, + s.`code` AS alertCode, tt3.Id_Trabajador AS workerId, + tt3.total as Importe, + 0 AS inacabable + -- (-1 < ifnull(order_id,-1)) as isbionic + FROM Tickets T + LEFT JOIN vn.ticketState ts on ts.ticket = T.Id_Ticket + LEFT JOIN vn2008.state s on s.id = ts.state + JOIN tt3 ON tt3.ticketFk = T.Id_Ticket + JOIN Agencias A ON A.Id_Agencia = T.Id_Agencia + -- WHERE T.Etiquetasemitidas = FALSE + GROUP BY T.Id_Ticket + ) AS T ON T.Id_Cliente = C.Id_Cliente + LEFT JOIN Consignatarios co ON co.Id_Consigna = T.Id_Consigna + LEFT JOIN province p ON p.province_id = co.province_id + LEFT JOIN vn.zone z ON z.id = T.zoneFk + LEFT JOIN ( + SELECT TOTAL.Id_Cliente, ROUND(SUM(amount),2) as Riesgo + FROM ( + SELECT cl.Id_Cliente, amount + FROM bi.customer_risk cr + JOIN tmp.client_list cl ON cr.customer_id = cl.Id_Cliente + UNION ALL + SELECT t.Id_Cliente, tt.total + FROM tmp.ticketTotal tt + JOIN Tickets t ON t.Id_Ticket = tt.ticketFk + JOIN cr5 C ON C.Id_Cliente = t.Id_Cliente + WHERE t.Fecha BETWEEN dateStart AND maxDate + AND t.Factura is null + ) as TOTAL GROUP BY TOTAL.Id_Cliente + ) AS Peligros ON Peligros.Id_Cliente = C.Id_Cliente; + + -- Actualizamos el Riesgo con los tickets futuros + + SET @cliente:= 0; + SET @riesgo := 0; + + UPDATE Radartest + SET Riesgo = IF(@cliente <> @cliente:= Id_Cliente, + -Importe + @riesgo:= - Riesgo + Importe, + -Importe + @riesgo:= @riesgo + Importe + ) + ORDER BY Id_Cliente, Fecha DESC; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; + + CREATE TEMPORARY TABLE tmp.ticket_list + SELECT Id_Ticket, Id_Cliente FROM Radartest; + + CALL prepare_client_list; + CALL production_buffer_problems; + + UPDATE Radartest r + JOIN ( + SELECT Id_Ticket, GROUP_CONCAT(problem) problem + FROM tmp.buffer_problems + GROUP BY Id_Ticket + ) p on p.Id_Ticket = r.Id_Ticket + SET r.problem = p.problem; + + SELECT R.*, Riesgo + Credito as Risk , CodigoTrabajador + FROM Radartest R + JOIN vn2008.Trabajadores trab on R.Id_Trabajador=trab.Id_Trabajador; + + DROP TEMPORARY TABLE tmp.client_list; + DROP TEMPORARY TABLE cr5; + DROP TEMPORARY TABLE tmp.ticket; + END IF; + + DROP TEMPORARY TABLE ticketRange; + DROP TEMPORARY TABLE subordinate; +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 `ticketRadar__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticketRadar__`(IN `today` DATETIME, IN `worker` INT, IN `scopeDays` SMALLINT, vCategoryFk INT) + NO SQL +BEGIN + DECLARE yesterday DATETIME; + DECLARE maxDate DATETIME; + DECLARE dateStart DATE; + + SET dateStart = TIMESTAMPADD(MONTH, -2, CURDATE()); + SELECT TIMESTAMPADD(DAY, -1, today) INTO yesterday; + + -- Lo quitamos despues de campaña + SELECT TIMESTAMP(TIMESTAMPADD(DAY, scopeDays, yesterday),'23:59:59') INTO maxDate; + -- SELECT TIMESTAMP(TIMESTAMPADD(DAY, 14, yesterday),'23:59:59') INTO maxDate; + -- Creamos una tabla con los Comerciales de los que se mostraran los tickets + + CALL subordinate(worker, TRUE); + + -- Se genera una tabla con los tickets representados + + DROP TEMPORARY TABLE IF EXISTS ticketRange; + CREATE TEMPORARY TABLE ticketRange + (INDEX (Id_Ticket)) + ENGINE = MEMORY + SELECT T.Id_Ticket, T.Id_Cliente, C.Id_Trabajador + FROM Tickets T + LEFT JOIN vn.ticketState tls on tls.ticket = T.Id_Ticket + JOIN Clientes C on C.Id_Cliente = T.Id_Cliente + JOIN subordinate s1 ON C.Id_Trabajador = s1.Id_Trabajador + WHERE Fecha >= yesterday + AND Fecha <= maxDate AND T.Factura Is NULL + AND IFNULL(tls.alertLevel,0) < 3; + + INSERT INTO ticketRange + SELECT Id_Ticket, s.Id_Cliente, s.Id_Trabajador + FROM sharingclient s + JOIN Tickets T USING(Id_Cliente) + LEFT JOIN vn.ticketState tls on tls.ticket = T.Id_Ticket + JOIN subordinate s2 ON s.Id_Trabajador = s2.Id_Trabajador + WHERE maxDate >= datSTART + AND datEND >= yesterday + AND date(Fecha) >= IF(yesterday > datSTART, yesterday, datSTART) + AND date(Fecha) <= IF(datEND > maxDate, maxDate, datEND) + AND IFNULL(tls.alertLevel,0) < 3; + + INSERT INTO ticketRange + SELECT Id_Ticket, C.Id_Cliente, s.Id_Suplente + FROM Clientes C + JOIN Tickets T USING(Id_Cliente) + LEFT JOIN vn.ticketState tls on tls.ticket = T.Id_Ticket + JOIN sharingcart s ON s.Id_Trabajador = C.Id_Trabajador + JOIN subordinate su on su.Id_Trabajador = Id_Suplente + WHERE maxDate >= datSTART + AND datEND >= yesterday + AND date(Fecha) >= IF(yesterday > datSTART, yesterday, datSTART) + AND date(Fecha) <= IF(datEND > maxDate, maxDate, datEND) + AND IFNULL(tls.alertLevel,0) < 3; + + INSERT INTO ticketRange + SELECT Id_Ticket, C.Id_Cliente, C.Id_Trabajador + FROM Clientes C + JOIN Tickets T USING(Id_Cliente) + LEFT JOIN vn.ticketState tls on tls.ticket = T.Id_Ticket + JOIN workerTeamCollegues w ON w.collegueId = C.Id_Trabajador + WHERE Fecha >= yesterday + AND Fecha <= maxDate AND T.Factura Is NULL + AND IFNULL(tls.alertLevel,0) < 3 + AND w.workerId = worker; + + IF vCategoryFk THEN + DROP TEMPORARY TABLE IF EXISTS ticketToShow; + CREATE TEMPORARY TABLE ticketToShow + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT DISTINCT s.ticketFk + FROM ticketRange tr + JOIN vn.sale s ON s.ticketFk = tr.Id_Ticket + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + WHERE it.categoryFk = vCategoryFk; + + DELETE tr.* FROM ticketRange tr + LEFT JOIN ticketToShow ttr ON tr.Id_Ticket = ttr.ticketFk + WHERE ttr.ticketFk IS NULL; + + DROP TEMPORARY TABLE ticketToShow; + END IF; + IF (SELECT COUNT(*) FROM ticketRange) THEN -- Generamos varias auxiliares (ya podian los de mysql haber solucionado esto) @@ -91092,214 +89956,6 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; DROP TEMPORARY TABLE tblTARIFAS; -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 `trasladoKk` */; -/*!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 `trasladoKk`(IN i_entrada INTEGER) -BEGIN - DECLARE dateShipment DATE; - DECLARE dateLanding DATE; - DECLARE warehouseShipment INTEGER; - DECLARE warehouseLanding INTEGER; - DECLARE v_calc_available INTEGER; - DECLARE v_calc_visible INTEGER; - - SELECT shipment, landing, warehouse_id_out, warehouse_id - INTO dateShipment, dateLanding, warehouseShipment, warehouseLanding - FROM travel t JOIN Entradas e ON t.id = e.travel_id - WHERE Id_Entrada = i_entrada; - - CALL buy_tarifas_table(i_entrada); - - -- Traslado en almacen origen - - DROP TEMPORARY TABLE IF EXISTS buy_edi_temp; - - CREATE TEMPORARY TABLE buy_edi_temp - (KEY (Id_Article)) ENGINE = MEMORY - - SELECT * - FROM (SELECT c.Id_Article, c.Id_Compra - FROM Compres c INNER JOIN Entradas e USING(Id_Entrada) - INNER JOIN travel t ON t.id = e.travel_id - WHERE t.landing BETWEEN date_inv() AND dateShipment - AND c.Novincular = FALSE - AND c.Tarifa2 >= 0 - ORDER BY (warehouseShipment = t.warehouse_id) DESC, t.landing DESC) t - GROUP BY Id_Article; - - IF dateShipment >= CURDATE() THEN - - CALL availableTraslate(warehouseShipment, dateShipment,NULL); - CALL `cache`.visible_refresh(v_calc_visible,TRUE,warehouseShipment); - DROP TEMPORARY TABLE IF EXISTS tmp_item; - CREATE TEMPORARY TABLE tmp_item (UNIQUE INDEX i USING HASH (item_id)) ENGINE = MEMORY - SELECT item_id, visible,0 available FROM `cache`.visible WHERE calc_id = v_calc_visible; - INSERT INTO tmp_item(item_id, available) - SELECT a.item_id, a.available FROM availableTraslate a - ON DUPLICATE KEY UPDATE available = a.available; - ELSE - CALL item_stock(warehouseShipment, dateShipment,NULL); - END IF; - - DROP TEMPORARY TABLE IF EXISTS Traslados; - CREATE TEMPORARY TABLE Traslados ENGINE MEMORY - SELECT tp.Id_Tipo AS Tipo, - - tp.reino_id, - - ar.tipo_id, - - ar.Id_Article AS article_id, - - ar.Article, - - ar.Medida, - - ar.Categoria, - - ar.Color, - - Origen.abreviatura as Origen, - - CE.Cantidad, - - ar.Tallos, - - CAST(AIM.visible AS DECIMAL(10,0)) as vis1, - - CAST(AIM.available AS DECIMAL(10,0)) as dis1, - - 0 as vis2, - - 0 as dis2, - - IFNULL(CE.`grouping`,C.`grouping`) as `grouping`, - - IFNULL(CE.Packing,C.Packing) as Packing, - - IFNULL(CE.caja,C.caja) as caja, - - IFNULL(C.Productor, P2.Alias) AS Productor, - - C.Id_Cubo, - - 1 Tinta, - - CE.Id_Compra, - - CE.Etiquetas, - - C.buy_edi_id, - - tp.Id_Trabajador, - - CB.Volumen, - - CB.x, CB.y, CB.z, - - IFNULL(C.Costefijo,0) Costefijo, - - IFNULL(C.Comisionfija,0) Comisionfija, - - IFNULL(C.Portefijo,0) Portefijo, - - A.m3, - - E.comision, - - CB.Retornable, - - IFNULL(CEB.Valor,CB.Valor) Valor, - - t3, t2, tp.promo, - - C.`grouping` groupingOrigin, - - C.Packing PackingOrigin, - - C.Id_Compra CompraOrigin, - - CB.costeRetorno - - FROM Articles ar - LEFT JOIN tmp_item AIM ON AIM.item_id = ar.Id_Article - LEFT JOIN Tipos tp ON tp.tipo_id = ar.tipo_id - LEFT JOIN Origen ON Origen.id = ar.id_origen - LEFT JOIN buy_edi_temp lb ON lb.Id_Article = ar.Id_Article - LEFT JOIN Compres C ON C.Id_Compra = lb.Id_Compra - LEFT JOIN Cubos CB ON CB.Id_Cubo = C.Id_Cubo - LEFT JOIN Entradas E2 ON E2.Id_Entrada = C.Id_Entrada - LEFT JOIN Proveedores P2 ON P2.Id_Proveedor = E2.Id_Proveedor - LEFT JOIN Entradas E ON E.Id_Entrada = i_entrada - LEFT JOIN travel TR ON TR.id = E.travel_id - LEFT JOIN Agencias A ON A.Id_Agencia = TR.agency_id - LEFT JOIN Compres CE ON CE.Id_Article = ar.Id_Article AND CE.Id_Entrada = i_entrada - LEFT JOIN Cubos CEB ON CEB.Id_Cubo = CE.Id_Cubo - LEFT JOIN tblTARIFAS ON TRUE - WHERE tp.reino_id <> 6 AND tp.reino_id <> 8 - AND E.Redada = FALSE; - - CREATE INDEX tindex USING HASH ON Traslados (article_id); - --- Inventario en el warehouse destino - IF dateShipment >= CURDATE() THEN - - CALL cache.visible_refresh(v_calc_visible, TRUE, warehouseLanding); - CALL availableTraslate(warehouseLanding, dateLanding,warehouseShipment); - - UPDATE Traslados t - LEFT JOIN availableTraslate a ON t.article_id = a.item_id - LEFT JOIN `cache`.visible v ON v.calc_id = v_calc_visible AND t.article_id = v.item_id - SET vis2 = v.visible, dis2 = a.available; - - END IF; --- --------------------------------------------- - - SELECT t.*, - - Cantidad - MOD(Cantidad , `grouping`) as Subcantidad, - - MOD(Cantidad , `grouping`) as Soll, - - ROUND((IF(Volumen > 0,Volumen,x * y * IF(z = 0, Medida + 10, z))) / Packing,0) as cm3, - - Costefijo + Comisionfija + Portefijo AS Cost, - - @porte := ROUND((IF(Volumen > 0,Volumen,x * y * IF(z = 0, Medida + 10, z))) * m3 / 1000000 / Packing ,3) AS Porte, - - @comision := ROUND((Costefijo + Comisionfija + Portefijo) * comision / 100 ,3) AS Comision, - - ROUND(@embalaje := (costeRetorno + IF(Retornable != 0, 0, Valor)) / packing ,3) AS Embalaje, - - @coste := IFNULL((Costefijo + Comisionfija + Portefijo),0) + IFNULL(@embalaje,0) + IFNULL(@porte,0) + IFNULL(@comision,0) AS Coste, - - @t3 := ROUND(@coste / ( (100 - t3 - t.promo)/100),2) AS Tarifa3, - - ROUND(@t3 * (1 + ((t2 - t3)/100)),2) AS Tarifa2, - - 0 selected - - FROM Traslados t - WHERE vis1 <> 0 OR dis1 <> 0 OR vis2 <> 0 OR dis2 <> 0 - ORDER BY tipo_id, Article, Medida, Categoria, Origen; - - DROP TEMPORARY TABLE IF EXISTS Traslados; - DROP TEMPORARY TABLE IF EXISTS tmp_item; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -91589,98 +90245,6 @@ BEGIN END IF; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `traslado_label__` */; -/*!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 `traslado_label__`(IN intArticle INTEGER,IN i_entrada_FV INTEGER, IN i_entrada_PCA INTEGER) -BEGIN - -DECLARE intEntrada INTEGER; -DECLARE i_FV INTEGER; - -SELECT FV INTO i_FV -FROM Articles a -JOIN Tipos tp ON tp.tipo_id = a.tipo_id -WHERE a.Id_Article = intArticle; - -SET intEntrada = IF(i_FV, i_entrada_FV,i_entrada_PCA); - -SET intEntrada = IF(intEntrada = 0, i_entrada_PCA + i_entrada_FV, intEntrada); - - - IF intEntrada > 0 THEN - - CALL buy_tarifas_table(intEntrada); - - INSERT INTO Compres (Id_Article, Etiquetas, Cantidad, Id_Entrada, Id_Cubo, Packing,`grouping`,caja, - Costefijo, Portefijo, Embalajefijo, Comisionfija, novincular,buy_edi_id) - SELECT - land.Id_Article, - land.Etiquetas - IFNULL(ship.Etiquetas,0) - (IFNULL(Ventas,0) / land.Packing), - land.Cantidad - IFNULL(ship.Cantidad,0) - IFNULL(Ventas,0), - intEntrada, - land.Id_Cubo, - land.Packing, - land.`grouping`, - land.caja, - @cost := ROUND(IFNULL(land.Costefijo, 0) + IFNULL(land.Comisionfija, 0) + IFNULL(land.Portefijo, 0), - 3) Costefij, - @porte := ROUND((@cm3:= cm3_2(land.Id_Cubo, land.Id_Article)) * a.m3 / 1000000 / land.Packing, - 3) Porte, - land.EmbalajeFijo AS Embalaje, - @comision := ROUND(land.Costefijo * e2.comision / 100, 3) Comision, - land.novincular,land.buy_edi_id - FROM ( - select c_land.Id_Cubo,c_land.Packing,c_land.`grouping`,c_land.Costefijo,c_land.Comisionfija,c_land.Portefijo,c_land.caja,SUM(c_land.Etiquetas) Etiquetas,c_land.EmbalajeFijo, - c_land.novincular,c_land.buy_edi_id,c_land.Id_Article,SUM(c_land.Cantidad) Cantidad - from - -- Entradas que llegan a vnh - Compres c_land - JOIN - Entradas e_land ON c_land.Id_Entrada = e_land.Id_Entrada AND c_land.Id_Article = intArticle - JOIN - travel t_land ON t_land.id = e_land.travel_id - JOIN - Cubos cu ON cu.Id_Cubo = c_land.Id_Cubo - WHERE - -- Entradas que llegan a vnh - (t_land.warehouse_id = 7 AND t_land.landing = CURDATE()) - ) land - LEFT JOIN -- Entradas que salen de vnh - (SELECT SUM(c_ship.Etiquetas) Etiquetas,c_ship.Packing,SUM(c_ship.Cantidad) Cantidad - FROM Compres c_ship - LEFT JOIN Entradas e_ship ON c_ship.Id_Entrada = e_ship.Id_Entrada AND c_ship.Id_Article = intArticle - LEFT JOIN travel t_ship ON t_ship.id = e_ship.travel_id - WHERE t_ship.warehouse_id_out = 7 AND t_ship.shipment = CURDATE() - -- Entrada destino - ) ship ON TRUE - JOIN Entradas e2 ON e2.Id_Entrada = intEntrada - JOIN travel t ON t.id = e2.travel_id - JOIN Agencias a ON t.agency_id = a.Id_Agencia - -- Ventas ese dia en VNH - LEFT JOIN - (SELECT sum(Cantidad) as Ventas - FROM Movimientos m - JOIN Tickets t on t.Id_Ticket = m.Id_Ticket - WHERE t.Fecha = CURDATE() AND m.Id_Article = intArticle AND t.warehouse_id = 7) v on true - GROUP BY land.Id_Article; - CALL buy_tarifas(LAST_INSERT_ID()); - - END IF; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -91758,301 +90322,6 @@ BEGIN DROP TEMPORARY TABLE t_item_last_buy; DROP TEMPORARY TABLE tblTARIFAS; -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 `traslado_ticket__` */; -/*!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 `traslado_ticket__`(IN i_entrada INTEGER, IN i_ticket INTEGER) -BEGIN - - DECLARE intWarehouse INT; - DECLARE datTicket DATE; - - SELECT warehouse_id, Fecha INTO intWarehouse,datTicket FROM Tickets WHERE Id_Ticket = i_ticket; - - CALL buy_tarifas_table(i_entrada); - - CALL item_last_buy_(intWarehouse,datTicket); - - - INSERT INTO Compres( Id_Article, - Cantidad, - Novincular, - Id_Entrada, - Id_Cubo, - Packing, - `grouping`, - caja, - Portefijo, - Comisionfija, - Embalajefijo, - Costefijo, - Productor, - Tarifa2, - Tarifa3 - ) - - SELECT M.Id_Article, - IF(T.Id_Cliente IN (1625, 1118, 400), -1, 1) * M.Cantidad, - - IF(T.Id_Cliente IN (1625, 1118, 400), TRUE, FALSE), - i_entrada, - IFNULL(C.Id_Cubo,'--'), - C.Packing, - C.`grouping`, - C.caja, - @pf := ROUND(@cm3:=cm3_2(IFNULL(C.Id_Cubo,'--'), b.item_id) * AG.m3 / 1000000 / C.Packing ,3) AS Porte, - @cf := IFNULL(ROUND(C.Costefijo * E.comision / 100 ,3),0) AS Comision, - @ef := ROUND(IF(CB.Retornable = FALSE,CB.Valor/ C.Packing,0) ,3) AS Embalaje, - @cost := ROUND(IFNULL(C.Costefijo,0) + @cf + @ef + @pf,3), - C.Productor, - @t3 := ROUND(@cost / ((100 - TC.t3)/100),2) Tarifa3, - @t2 := IF(@cost / ((100 - TC.t2)/100) <= @t3,@t3+0.01,@cost / ((100 - TC.t2)/100)) Tarifa2 - - FROM Movimientos M - LEFT JOIN Tickets T USING(Id_Ticket) - LEFT JOIN t_item_last_buy b ON M.Id_Article = b.item_id AND T.warehouse_id = b.warehouse_id - LEFT JOIN Compres C ON C.Id_Compra = b.buy_id - LEFT JOIN Cubos CB ON CB.Id_Cubo = C.Id_Cubo - LEFT JOIN Entradas E ON E.Id_Entrada = i_entrada - LEFT JOIN travel TR ON TR.id = E.travel_id - LEFT JOIN Agencias AG ON AG.Id_Agencia = TR.agency_id - LEFT JOIN Proveedores P ON P.Id_Proveedor = E.Id_Proveedor - JOIN tblTARIFAS TC - LEFT JOIN tblContadores ON TRUE - JOIN (SELECT m3 as ZEL_PORT FROM Agencias WHERE Id_Agencia = 618) Z - WHERE M.Id_Ticket = i_ticket; - - - DROP TEMPORARY TABLE t_item_last_buy; - - -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 `traslado__` */; -/*!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 `traslado__`(IN i_entrada INTEGER) -BEGIN --- Lo esta probando JFP 2018-12-13 - DECLARE dateShipment DATE; - DECLARE dateLanding DATE; - DECLARE warehouseShipment INTEGER; - DECLARE warehouseLanding INTEGER; - DECLARE v_calc_visible INTEGER; - DECLARE vInventoryDate DATE; - - SET vInventoryDate := date_inv(); - SELECT shipment, landing, warehouse_id_out, warehouse_id - INTO dateShipment, dateLanding, warehouseShipment, warehouseLanding - FROM travel t JOIN Entradas e ON t.id = e.travel_id - WHERE Id_Entrada = i_entrada; - - CALL buy_tarifas_table(i_entrada); - - -- Traslado en almacen origen - - DROP TEMPORARY TABLE IF EXISTS buy_edi_temp; - CREATE TEMPORARY TABLE buy_edi_temp - (KEY (Id_Article), INDEX(Id_Compra)) ENGINE = MEMORY - SELECT * - FROM (SELECT c.Id_Article, c.Id_Compra - FROM Compres c INNER JOIN Entradas e USING(Id_Entrada) - INNER JOIN travel t ON t.id = e.travel_id - WHERE t.landing BETWEEN vInventoryDate AND dateShipment - AND c.Novincular = FALSE - AND c.Tarifa2 >= 0 - ORDER BY (warehouseShipment = t.warehouse_id) DESC, t.landing DESC) t - GROUP BY Id_Article; - - CALL vn.buyUltimateFromInterval(warehouseLanding,vInventoryDate,dateLanding); - - IF dateShipment >= CURDATE() THEN - - CALL availableTraslate(warehouseShipment, dateShipment,NULL); - CALL `cache`.visible_refresh(v_calc_visible,TRUE,warehouseShipment); - - DROP TEMPORARY TABLE IF EXISTS tmp_item; - CREATE TEMPORARY TABLE tmp_item (UNIQUE INDEX i USING HASH (item_id)) ENGINE = MEMORY - SELECT item_id, visible,0 available FROM `cache`.visible WHERE calc_id = v_calc_visible; - INSERT INTO tmp_item(item_id, available) - SELECT a.item_id, a.available FROM availableTraslate a - ON DUPLICATE KEY UPDATE available = a.available; - ELSE - CALL item_stock(warehouseShipment, dateShipment,NULL); - END IF; - - DROP TEMPORARY TABLE IF EXISTS Traslados; - CREATE TEMPORARY TABLE Traslados ENGINE MEMORY - SELECT tp.Id_Tipo AS Tipo, - - tp.reino_id, - - ar.tipo_id, - - ar.Id_Article AS article_id, - - ar.Article, - - ar.Medida, - - ar.Categoria, - - ar.Color, - - Origen.abreviatura as Origen, - - CE.Cantidad, - - ar.Tallos, - - CAST(AIM.visible AS DECIMAL(10,0)) as vis1, - - CAST(AIM.available AS DECIMAL(10,0)) as dis1, - - 0 as vis2, - - 0 as dis2, - - COALESCE(/*cl.`grouping`, */CE.`grouping`, C.`grouping`) as `grouping`, - - COALESCE(/*cl.Packing, */CE.Packing, C.Packing) as Packing, - - COALESCE(cl.caja, CE.caja, C.caja) as caja, - - IFNULL(C.Productor, P2.Alias) AS Productor, - - C.Id_Cubo, - - 1 Tinta, - - CE.Id_Compra, - - CE.Etiquetas, - - C.buy_edi_id, - - tp.Id_Trabajador, - - CB.Volumen, - - CB.x, CB.y, CB.z, - - IFNULL(C.Costefijo,0) Costefijo, - - IFNULL(C.Comisionfija,0) Comisionfija, - - IFNULL(C.Portefijo,0) Portefijo, - - A.m3, - - E.comision, - - CB.Retornable, - - IFNULL(CEB.Valor,CB.Valor) Valor, - - t3, t2, tp.promo, - - C.`grouping` groupingOrigin, - - C.Packing PackingOrigin, - - C.Id_Compra CompraOrigin, - - CB.costeRetorno - - FROM Articles ar - LEFT JOIN tmp_item AIM ON AIM.item_id = ar.Id_Article - LEFT JOIN Tipos tp ON tp.tipo_id = ar.tipo_id - LEFT JOIN Origen ON Origen.id = ar.id_origen - LEFT JOIN buy_edi_temp lb ON lb.Id_Article = ar.Id_Article - LEFT JOIN Compres C ON C.Id_Compra = lb.Id_Compra - LEFT JOIN Cubos CB ON CB.Id_Cubo = C.Id_Cubo - LEFT JOIN Entradas E2 ON E2.Id_Entrada = C.Id_Entrada - LEFT JOIN Proveedores P2 ON P2.Id_Proveedor = E2.Id_Proveedor - LEFT JOIN Entradas E ON E.Id_Entrada = i_entrada - LEFT JOIN travel TR ON TR.id = E.travel_id - LEFT JOIN Agencias A ON A.Id_Agencia = TR.agency_id - LEFT JOIN Compres CE ON CE.Id_Article = ar.Id_Article AND CE.Id_Entrada = i_entrada - LEFT JOIN Cubos CEB ON CEB.Id_Cubo = CE.Id_Cubo - LEFT JOIN tblTARIFAS ON TRUE - LEFT JOIN tmp.buyUltimateFromInterval bufi ON bufi.itemFk = ar.Id_Article - LEFT JOIN Compres cl ON cl.Id_Compra = bufi.buyFk - WHERE tp.reino_id <> 6 AND tp.reino_id <> 8 - AND E.Redada = FALSE; - - CREATE INDEX tindex USING HASH ON Traslados (article_id); - --- Inventario en el warehouse destino - IF dateShipment >= CURDATE() THEN - - CALL cache.visible_refresh(v_calc_visible, TRUE, warehouseLanding); - CALL availableTraslate(warehouseLanding, dateLanding,warehouseShipment); - - UPDATE Traslados t - LEFT JOIN availableTraslate a ON t.article_id = a.item_id - LEFT JOIN `cache`.visible v ON v.calc_id = v_calc_visible AND t.article_id = v.item_id - SET vis2 = v.visible, dis2 = a.available; - - END IF; --- --------------------------------------------- - - SELECT t.*, - - Cantidad - MOD(Cantidad , `grouping`) as Subcantidad, - - MOD(Cantidad , `grouping`) as Soll, - - ROUND((IF(Volumen > 0,Volumen,x * y * IF(z = 0, Medida + 10, z))) / Packing,0) as cm3, - - Costefijo + Comisionfija + Portefijo AS Cost, - - @porte := ROUND((IF(Volumen > 0,Volumen,x * y * IF(z = 0, Medida + 10, z))) * m3 / 1000000 / Packing ,3) AS Porte, - - @comision := ROUND((Costefijo + Comisionfija + Portefijo) * comision / 100 ,3) AS Comision, - - ROUND(@embalaje := (costeRetorno + IF(Retornable != 0, 0, Valor)) / packing ,3) AS Embalaje, - - @coste := IFNULL((Costefijo + Comisionfija + Portefijo),0) + IFNULL(@embalaje,0) + IFNULL(@porte,0) + IFNULL(@comision,0) AS Coste, - - @t3 := ROUND(@coste / ( (100 - t3 - t.promo)/100),2) AS Tarifa3, - - ROUND(@t3 * (1 + ((t2 - t3)/100)),2) AS Tarifa2, - - 0 selected - - FROM Traslados t - WHERE vis1 <> 0 OR dis1 <> 0 OR vis2 <> 0 OR dis2 <> 0 - ORDER BY tipo_id, Article, Medida, Categoria, Origen; - - DROP TEMPORARY TABLE IF EXISTS Traslados; - DROP TEMPORARY TABLE IF EXISTS tmp_item; - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -93852,7 +92121,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21606889 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21652202 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 */ ; @@ -94360,7 +92629,7 @@ USE `bs`; /*!50001 SET collation_connection = utf8mb4_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `m3Silla` AS select `m3__`.`fecha` AS `fecha`,`m3__`.`year` AS `year`,`m3__`.`month` AS `month`,`m3__`.`week` AS `week`,`m3__`.`day` AS `day`,`m3__`.`dayName` AS `dayName`,cast(sum(`m3__`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3__`.`euros`) as decimal(10,0)) AS `Euros` from `m3__` where (`m3__`.`warehouseFk` in (1,44)) group by `m3__`.`fecha` */; +/*!50001 VIEW `m3Silla` AS select `m3`.`fecha` AS `fecha`,`m3`.`year` AS `year`,`m3`.`month` AS `month`,`m3`.`week` AS `week`,`m3`.`day` AS `day`,`m3`.`dayName` AS `dayName`,cast(sum(`m3`.`m3`) as decimal(10,0)) AS `Volumen`,cast(sum(`m3`.`euros`) as decimal(10,0)) AS `Euros` from `m3` where (`m3`.`warehouseFk` in (1,44)) group by `m3`.`fecha` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -95134,10 +93403,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `accounting` +-- Final view structure for view `accounting__` -- -/*!50001 DROP VIEW IF EXISTS `accounting`*/; +/*!50001 DROP VIEW IF EXISTS `accounting__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -95146,7 +93415,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `accounting` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `accountingTypeFk`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive` from `vn2008`.`Bancos` `b` */; +/*!50001 VIEW `accounting__` AS select `b`.`Id_Banco` AS `id`,`b`.`Banco` AS `bank`,`b`.`Cuenta` AS `account`,`b`.`cash` AS `accountingTypeFk`,`b`.`entity_id` AS `entityFk`,`b`.`activo` AS `isActive` from `vn2008`.`Bancos` `b` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -101706,4 +99975,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-19 13:08:44 +-- Dump completed on 2019-11-21 7:08:17 From d1dfa126c0048694b0adea8fa3971bbbab1a3bb7 Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 21 Nov 2019 09:08:43 +0100 Subject: [PATCH 10/12] #1711 Eliminar referencias al esquema vn2008 --- .../worker/back/methods/device/checkUuid.js | 61 ------------------- .../methods/device/specs/checkUuid.spec.js | 11 ---- modules/worker/back/models/device.js | 2 - 3 files changed, 74 deletions(-) delete mode 100644 modules/worker/back/methods/device/checkUuid.js delete mode 100644 modules/worker/back/methods/device/specs/checkUuid.spec.js diff --git a/modules/worker/back/methods/device/checkUuid.js b/modules/worker/back/methods/device/checkUuid.js deleted file mode 100644 index 73c6cb57c..000000000 --- a/modules/worker/back/methods/device/checkUuid.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -Author : Enrique Blasco BLanquer -Date: 27 de mayo de 2019 -*/ -module.exports = Self => { - Self.remoteMethodCtx('checkUuid', { - description: 'Check UUID from user', - accessType: 'WRITE', - accepts: [{ - arg: 'data', - type: 'object', - required: true, - description: 'uuid,model', - http: {source: 'body'} - }], - returns: [{ - type: 'Object', - root: true - }], - http: { - path: `/checkUuid`, - verb: 'POST' - } - }); - - Self.checkUuid = async(ctx, data) => { - const myUserId = ctx.req.accessToken.userId; - // 1 Check is a registered user with a uuid - let deviceUser = await Self.findOne({where: {userFk: myUserId, sn: data.uuid}}); - - if (deviceUser != null) - return {'state': true, 'mng': ''}; - else { - // 2 If it does not exist it can be for two reasons: - // 2.1 It is the first time that the application enters so we have to register a new user associated with the user - // 2.2 Has the user associated with a different uuid, so we deny access. - - let device = await Self.findOne({where: {userFk: myUserId}}); - if (device != null) { - // The device is already registered by another user, access is denied - return {'state': false, 'mng': 'Ya estas regisgtrado en otro dispositivo, contacta con los dioses de informática.'}; - } else { - // Check that the device is free - let aDevice = await Self.findOne({where: {sn: data.uuid}}); - if (aDevice != null) - return {'state': false, 'mng': 'El dispositivo esta siendo usado por otro usuario'}; - else { - // It's the first time you access the application, insert - /* await Self.rawSql('INSERT INTO vn2008.device (sn, model) VALUES (?,?);', [data.uuid, data.model]);*/ - await Self.create({ - sn: data.uuid, - model: data.model, - userFk: myUserId - }); - - return {'state': true, 'mng': 'Nuevo dispositivo registrado'}; - } - } - } - }; -}; diff --git a/modules/worker/back/methods/device/specs/checkUuid.spec.js b/modules/worker/back/methods/device/specs/checkUuid.spec.js deleted file mode 100644 index c2784809c..000000000 --- a/modules/worker/back/methods/device/specs/checkUuid.spec.js +++ /dev/null @@ -1,11 +0,0 @@ -const app = require('vn-loopback/server/server'); - -describe('device checkUuid()', () => { - it('should return an state equal to false', async() => { - let ctx = {req: {accessToken: {userId: 9}}}; - let data = {'uuid': '123', 'model': 'ihpne kike molon'}; - let result = await app.models.Device.checkUuid(ctx, data); - - expect(result.name).toBeFalsy(); - }); -}); diff --git a/modules/worker/back/models/device.js b/modules/worker/back/models/device.js index ada0ba33b..cda7a958f 100644 --- a/modules/worker/back/models/device.js +++ b/modules/worker/back/models/device.js @@ -1,8 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - require('../methods/device/checkUuid')(Self); - Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(``); From 0473f1de821b28339b0b587f5cba25dbb720178e Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 21 Nov 2019 09:09:17 +0100 Subject: [PATCH 11/12] #1711 Eliminar referencias al esquema vn2008 --- .../10110-postCampaign/00-clientGetMana.sql | 25 +-- .../10110-postCampaign/01-notifyPassport.sql | 16 ++ db/dump/structure.sql | 145 +++++++++--------- 3 files changed, 102 insertions(+), 84 deletions(-) create mode 100644 db/changes/10110-postCampaign/01-notifyPassport.sql diff --git a/db/changes/10110-postCampaign/00-clientGetMana.sql b/db/changes/10110-postCampaign/00-clientGetMana.sql index 7666d0c1c..df1b2adbc 100644 --- a/db/changes/10110-postCampaign/00-clientGetMana.sql +++ b/db/changes/10110-postCampaign/00-clientGetMana.sql @@ -5,18 +5,21 @@ CREATE DEFINER=`root`@`%` FUNCTION `vn`.`clientGetMana`(vClient INT) RETURNS dec DETERMINISTIC BEGIN /** - * Devuelve el maná del cliente. + * Devuelve el mana del cliente. * * @param vClient Id del cliente - * @return Maná del cliente + * @return Mana del cliente */ DECLARE vMana DECIMAL(10,2); DECLARE vFromDated DATE; DECLARE vHasMana BOOLEAN; DECLARE vManaComponent INT; DECLARE vAutoManaComponent INT; - DECLARE vManaBank INT DEFAULT 66; + DECLARE vManaBank INT; + DECLARE vManaGreugeType INT; + SELECT id INTO vManaGreugeType FROM greugeType WHERE code = 'mana'; + SELECT id INTO vManaBank FROM bank WHERE code = 'mana'; SELECT id INTO vManaComponent FROM component WHERE code = 'mana'; SELECT id INTO vAutoManaComponent FROM component WHERE code = 'autoMana'; @@ -57,17 +60,15 @@ BEGIN AND r.payed <= CURDATE() AND c.id = vClient UNION ALL - SELECT g.Importe - FROM vn2008.Greuges g - JOIN vn2008.Clientes c using(Id_Cliente) - WHERE g.Greuges_type_id = 3 -- Maná - AND g.Fecha > vFromDated - AND g.Fecha <= CURDATE() - AND c.Id_Cliente = vClient + SELECT g.amount + FROM greuge g + JOIN client c ON c.id = g.clientFk + WHERE g.greugeTypeFk = vManaGreugeType + AND g.shipped > vFromDated + AND g.shipped <= CURDATE() + AND c.id = vClient ) sub; - RETURN IFNULL(vMana,0); - END$$ DELIMITER ; diff --git a/db/changes/10110-postCampaign/01-notifyPassport.sql b/db/changes/10110-postCampaign/01-notifyPassport.sql new file mode 100644 index 000000000..c3f066936 --- /dev/null +++ b/db/changes/10110-postCampaign/01-notifyPassport.sql @@ -0,0 +1,16 @@ +DROP procedure IF EXISTS `vn2008`.`notify_passport`; + +DELIMITER $$ +CREATE DEFINER=`root`@`%` PROCEDURE `vn2008`.`notify_passport`( + IN vItemFk INT, + IN vStickers SMALLINT, + IN vPacking SMALLINT, + IN vBuyFk INT +) +BEGIN + -- DPRECATED use vn.buy_notifyPassport + CALL vn.buy_notifyPassport(vBuyFk, vItemFk, vStickers, vPacking); +END$$ + +DELIMITER ; + diff --git a/db/dump/structure.sql b/db/dump/structure.sql index cb75fc2db..cda45dec7 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -8918,7 +8918,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=437035 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=437042 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10033,7 +10033,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=24393221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=24393824 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10091,7 +10091,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1112531 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1112639 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10112,7 +10112,7 @@ CREATE TABLE `exchange` ( KEY `buy_edi_id` (`ektFk`), CONSTRAINT `exchange_ibfk_1` FOREIGN KEY (`mailFk`) REFERENCES `mail` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `exchange_ibfk_2` FOREIGN KEY (`ektFk`) REFERENCES `ekt` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=653193 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=653301 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10374,7 +10374,7 @@ CREATE TABLE `mail` ( UNIQUE KEY `mail_id` (`messageId`), KEY `sender_id` (`senderFk`), CONSTRAINT `mail_ibfk_2` FOREIGN KEY (`senderFk`) REFERENCES `mailSender` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=683079 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=683172 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10630,7 +10630,7 @@ CREATE TABLE `supplyResponse` ( PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`), KEY `IX_TransNumber` (`TransactionNumber`) COMMENT 'Agregado por Ernesto 11.6.2019\nSe ejecutaba 1 consulta por segundo desde MAIL y consumia un 20% de CPU de todo el servidor !!!!!\nCPU usada es mas estable que Indice en SendererID, cpu vs espacio que ocupa?\n' -) ENGINE=InnoDB AUTO_INCREMENT=8947741 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8947858 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11327,7 +11327,7 @@ CREATE TABLE `image` ( PRIMARY KEY (`id`), UNIQUE KEY `collection` (`collectionFk`,`name`), CONSTRAINT `image_ibfk_1` FOREIGN KEY (`collectionFk`) REFERENCES `imageCollection` (`name`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=171831 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=171862 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12008,7 +12008,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn`.`address` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn`.`deliveryMethod` (`id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn`.`agencyMode` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2247959 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2247972 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 */ ; @@ -12127,7 +12127,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=13471735 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13471768 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 */ ; @@ -12551,7 +12551,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn`.`receipt` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) 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=372874 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=372875 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12586,7 +12586,7 @@ CREATE TABLE `visit` ( PRIMARY KEY (`id`), KEY `firstAgent` (`firstAgentFk`), CONSTRAINT `visit_ibfk_1` FOREIGN KEY (`firstAgentFk`) REFERENCES `visitAgent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2008312 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2008351 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12606,7 +12606,7 @@ CREATE TABLE `visitAccess` ( KEY `visit_access_idx_agent` (`agentFk`), KEY `stamp` (`stamp`), CONSTRAINT `visitAccess_ibfk_1` FOREIGN KEY (`agentFk`) REFERENCES `visitAgent` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4484736 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4484795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12631,7 +12631,7 @@ CREATE TABLE `visitAgent` ( KEY `firstAccess` (`firstAccessFk`), CONSTRAINT `visitAgent_ibfk_1` FOREIGN KEY (`visitFk`) REFERENCES `visit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `visitAgent_ibfk_2` FOREIGN KEY (`firstAccessFk`) REFERENCES `visitAccess` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2655432 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2655475 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12651,7 +12651,7 @@ CREATE TABLE `visitUser` ( KEY `date_time` (`stamp`), KEY `user_id` (`userFk`), CONSTRAINT `visitUser_ibfk_1` FOREIGN KEY (`accessFk`) REFERENCES `visitAccess` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3927228 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3927275 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20180,7 +20180,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4055070 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4055076 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 */ ; @@ -20933,6 +20933,7 @@ CREATE TABLE `bank` ( `entityFk` int(10) unsigned NOT NULL, `isActive` tinyint(4) NOT NULL DEFAULT '1', `currencyFk` tinyint(3) unsigned DEFAULT '1', + `code` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `BancosBanco` (`bank`), KEY `fk_Bancos_entity1_idx` (`entityFk`), @@ -21119,7 +21120,7 @@ CREATE TABLE `buy` ( CONSTRAINT `buy_ibfk_3` FOREIGN KEY (`containerFk`) REFERENCES `vn2008`.`container` (`container_id`) ON UPDATE CASCADE, CONSTRAINT `buy_id` FOREIGN KEY (`entryFk`) REFERENCES `entry` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `buy_itemfk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=352686632 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=352686690 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 */ ; @@ -22113,7 +22114,7 @@ CREATE TABLE `clientCredit` ( KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=85166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=85167 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22202,7 +22203,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `client` (`id`) 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=240238 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=240239 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23411,7 +23412,7 @@ CREATE TABLE `dms` ( UNIQUE KEY `emp_id` (`companyFk`,`hardCopyNumber`,`warehouseFk`), KEY `trabajador_id` (`workerFk`), KEY `warehouse_id` (`warehouseFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1388177 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1388197 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 */ ; @@ -23820,7 +23821,7 @@ CREATE TABLE `entry` ( CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=182103 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=182107 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 */ ; @@ -24021,7 +24022,7 @@ CREATE TABLE `entryLog` ( KEY `entryLog_ibfk_2` (`userFk`), CONSTRAINT `entryLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `entryLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=177180 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=177189 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25430,7 +25431,7 @@ CREATE TABLE `itemBarcode` ( UNIQUE KEY `Id_Article_2` (`itemFk`,`code`), KEY `Id_Article` (`itemFk`), CONSTRAINT `itemBarcode_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42923 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=42930 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25628,7 +25629,7 @@ CREATE TABLE `itemLog` ( KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemLogUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=99157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=99171 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25655,7 +25656,7 @@ CREATE TABLE `itemPlacement` ( CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacement_fk3` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1160906 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1160939 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 */ ; @@ -25705,7 +25706,7 @@ CREATE TABLE `itemPlacementSupply` ( 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, CONSTRAINT `itemPlacementSupply_fk4` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80804 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=80805 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 */; -- @@ -26013,7 +26014,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 `sale` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=42087 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=42119 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 */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -26140,7 +26141,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1400544 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1400546 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 */ ; @@ -26739,7 +26740,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=2056489 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2056575 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26761,7 +26762,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2232309 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2232395 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26991,7 +26992,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=3224 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3231 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27697,7 +27698,7 @@ CREATE TABLE `producer` ( `isVisible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=14545 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=14549 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28030,7 +28031,7 @@ CREATE TABLE `receipt` ( CONSTRAINT `receipt_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `receipt_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=609864 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=609865 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 */ ; @@ -28216,7 +28217,7 @@ CREATE TABLE `route` ( KEY `route_ibfk_2_idx` (`workerFk`), CONSTRAINT `route_ibfk_1` FOREIGN KEY (`gestdocFk`) REFERENCES `dms` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `route_ibfk_2` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=60130 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=60147 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 */ ; @@ -28410,7 +28411,7 @@ CREATE TABLE `routeLog` ( KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `route` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `routeLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=197166 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=197397 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -28521,7 +28522,7 @@ CREATE TABLE `sale` ( KEY `itemFk_ticketFk` (`itemFk`,`ticketFk`), CONSTRAINT `movement_ticket_id` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `sale_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=26414808 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=26414860 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 */ ; @@ -28762,7 +28763,7 @@ CREATE TABLE `saleTracking` ( KEY `fgnStateFk_idx` (`stateFk`), KEY `saleTracking_idx5` (`created`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21026302 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21026634 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 */ ; @@ -29163,7 +29164,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=155196 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=155221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29352,7 +29353,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=847937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=848177 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -29797,7 +29798,7 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2484593 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2484620 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 */ ; @@ -30072,7 +30073,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `ticket` (`id`) 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=8112788 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8113130 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30109,7 +30110,7 @@ CREATE TABLE `ticketObservation` ( KEY `observation_type_id` (`observationTypeFk`), CONSTRAINT `ticketObservation_ibfk_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketObservation_ibfk_2` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1509900 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=1509914 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30227,7 +30228,7 @@ CREATE TABLE `ticketParking` ( KEY `ticketParking_fk1_idx` (`parkingFk`), CONSTRAINT `ticketParking_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON UPDATE CASCADE, CONSTRAINT `ticketParking_fk2` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11492 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; +) ENGINE=InnoDB AUTO_INCREMENT=11497 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Almacena los distintos lugares donde puede estar aparcado cada uno de los prepedidos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -30293,7 +30294,7 @@ CREATE TABLE `ticketRequest` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `worker` (`id`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=52123 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52125 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 */ ; @@ -31687,7 +31688,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=8297369 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=8297378 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56637,7 +56638,7 @@ CREATE TABLE `Cajas` ( KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `vn`.`bank` (`id`) ON UPDATE CASCADE, CONSTRAINT `Cajas_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=743475 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=743478 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 */ ; @@ -56890,7 +56891,7 @@ CREATE TABLE `Colas` ( KEY `Id_Trabajador` (`Id_Trabajador`), CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `vn`.`queuePriority` (`id`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21582 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21605 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57311,7 +57312,7 @@ CREATE TABLE `Entradas_dits` ( CONSTRAINT `Entradas_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`entry` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3986463 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3986582 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58552,7 +58553,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) 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 `vn`.`worker` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=65253509 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65253575 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 */ ; @@ -61646,7 +61647,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1938221 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1938230 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -62374,7 +62375,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 `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64846 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64851 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 */ ; @@ -63643,7 +63644,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 `vn`.`worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=246368 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=246370 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -79693,7 +79694,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `inventario_multiple_inventarios` */; +/*!50003 DROP PROCEDURE IF EXISTS `inventario_multiple_inventariosKk` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -79703,7 +79704,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_inventarios`(wh SMALLINT, date_ticket DATETIME) +CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_inventariosKk`(wh SMALLINT, date_ticket DATETIME) BEGIN DECLARE date_order DATETIME; DECLARE date_end DATETIME DEFAULT CURDATE(); @@ -79714,8 +79715,16 @@ BEGIN ALTER TABLE article_inventory ADD visible FLOAT(7,2) NOT NULL; - SELECT FechaInventario, TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59') - INTO date_start, date_end + -- Campaña + + SELECT + IF(@camp := DATEDIFF(campaign, date_ticket) BETWEEN 0 AND campaign_life , + TIMESTAMPADD(DAY, -campaign_life, campaign) , + FechaInventario), + IF(@camp BETWEEN 0 AND campaign_life, + TIMESTAMP(campaign, '23:59:59'), + TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59')) + INTO date_start, date_end FROM tblContadores; SET date_order = TIMESTAMP(DATE(date_ticket), '00:00:00'); @@ -79752,17 +79761,17 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP PROCEDURE IF EXISTS `inventario_multiple_inventariosKk` */; +/*!50003 DROP PROCEDURE IF EXISTS `inventario_multiple_inventarios__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_inventariosKk`(wh SMALLINT, date_ticket DATETIME) +CREATE DEFINER=`root`@`%` PROCEDURE `inventario_multiple_inventarios__`(wh SMALLINT, date_ticket DATETIME) BEGIN DECLARE date_order DATETIME; DECLARE date_end DATETIME DEFAULT CURDATE(); @@ -79773,16 +79782,8 @@ BEGIN ALTER TABLE article_inventory ADD visible FLOAT(7,2) NOT NULL; - -- Campaña - - SELECT - IF(@camp := DATEDIFF(campaign, date_ticket) BETWEEN 0 AND campaign_life , - TIMESTAMPADD(DAY, -campaign_life, campaign) , - FechaInventario), - IF(@camp BETWEEN 0 AND campaign_life, - TIMESTAMP(campaign, '23:59:59'), - TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59')) - INTO date_start, date_end + SELECT FechaInventario, TIMESTAMP(TIMESTAMPADD(DAY, 15, date_ticket),'23:59:59') + INTO date_start, date_end FROM tblContadores; SET date_order = TIMESTAMP(DATE(date_ticket), '00:00:00'); @@ -92121,7 +92122,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn`.`ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=21652202 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=21652681 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 */ ; @@ -99975,4 +99976,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-11-21 7:08:17 +-- Dump completed on 2019-11-21 7:34:03 From 5f28d39bbf02702916124fd8a1841f9b5450dc8b Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 21 Nov 2019 09:33:08 +0100 Subject: [PATCH 12/12] dynamic header & footer texts by company #1336 --- db/dump/fixtures.sql | 2 +- .../components/email-footer/email-footer.html | 6 +-- .../components/email-footer/email-footer.js | 3 +- .../components/email-footer/locale/en.yml | 17 +++++++ .../components/email-footer/locale/es.yml | 31 +++++++------ .../components/email-footer/locale/fr.yml | 31 +++++++------ .../components/email-footer/locale/pt.yml | 17 +++++++ .../components/email-header/email-header.js | 3 +- .../components/report-footer/locale/en.yml | 8 ++++ .../components/report-footer/locale/es.yml | 2 - .../components/report-footer/locale/fr.yml | 2 - .../components/report-footer/locale/pt.yml | 2 - .../report-footer/report-footer.html | 2 +- .../components/report-footer/report-footer.js | 16 ++++++- .../components/report-header/locale/en.yml | 2 + .../components/report-header/locale/es.yml | 5 +-- .../components/report-header/locale/fr.yml | 2 + .../components/report-header/locale/pt.yml | 5 +-- .../report-header/report-header.html | 9 +++- .../components/report-header/report-header.js | 44 ++++++++++++++++++- print/core/database.js | 23 +++++++++- print/core/mixins/user-locale.js | 6 ++- .../claim-pickup-order.html | 10 +---- .../email/client-welcome/client-welcome.html | 10 +---- .../delivery-note-link.html | 10 +---- .../email/delivery-note/delivery-note.html | 10 +---- .../email/driver-route/driver-route.html | 10 +---- .../letter-debtor-nd/letter-debtor-nd.html | 11 +---- .../letter-debtor-st/letter-debtor-st.html | 11 +---- .../email/payment-update/payment-update.html | 10 +---- .../email/printer-setup/printer-setup.html | 10 +---- .../templates/email/sepa-core/sepa-core.html | 10 +---- .../claim-pickup-order.html | 8 +--- .../reports/delivery-note/delivery-note.html | 9 ++-- .../reports/delivery-note/delivery-note.js | 3 +- .../reports/delivery-note/locale/en.yml | 26 +++++++++++ .../reports/delivery-note/locale/fr.yml | 14 +++--- .../reports/driver-route/driver-route.html | 10 ++--- .../reports/letter-debtor/letter-debtor.html | 8 +--- print/templates/reports/receipt/receipt.html | 8 +--- .../reports/sepa-core/sepa-core.html | 8 +--- 41 files changed, 246 insertions(+), 188 deletions(-) create mode 100644 print/core/components/email-footer/locale/en.yml create mode 100644 print/core/components/email-footer/locale/pt.yml create mode 100644 print/core/components/report-footer/locale/en.yml create mode 100644 print/core/components/report-header/locale/en.yml create mode 100644 print/core/components/report-header/locale/fr.yml create mode 100644 print/templates/reports/delivery-note/locale/en.yml diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 21413d329..cf760e25a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -31,7 +31,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`password`,`role`,`active`,`email`,`lang`) VALUES (101, 'BruceWayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es'), - (102, 'PetterParker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'es'), + (102, 'PetterParker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en'), (103, 'ClarkKent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr'), (104, 'TonyStark', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'TonyStark@mydomain.com', 'es'), (105, 'MaxEisenhardt', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt'), diff --git a/print/core/components/email-footer/email-footer.html b/print/core/components/email-footer/email-footer.html index b60125c5d..a033ec633 100644 --- a/print/core/components/email-footer/email-footer.html +++ b/print/core/components/email-footer/email-footer.html @@ -39,9 +39,9 @@
-

{{$t('privacy.fiscalAddress')}}

-

{{$t('privacy.disclaimer')}}

-

{{$t('privacy.law')}}

+

{{$t('fiscalAddress')}}

+

{{$t('disclaimer')}}

+

{{$t('privacy')}}

\ No newline at end of file diff --git a/print/core/components/email-footer/email-footer.js b/print/core/components/email-footer/email-footer.js index 527c8121a..d21ad348e 100755 --- a/print/core/components/email-footer/email-footer.js +++ b/print/core/components/email-footer/email-footer.js @@ -1,4 +1,3 @@ module.exports = { - name: 'email-footer', - props: ['isPreview', 'locale'] + name: 'email-footer' }; diff --git a/print/core/components/email-footer/locale/en.yml b/print/core/components/email-footer/locale/en.yml new file mode 100644 index 000000000..ccc0832e8 --- /dev/null +++ b/print/core/components/email-footer/locale/en.yml @@ -0,0 +1,17 @@ +buttons: + webAcccess: Visit our website + info: Help us to improve +fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es +disclaimer: '- NOTICE - This message is private and confidential, and should be used + exclusively by the person receiving it. If you have received this message by mistake, + please notify the sender and delete that message and any attached documents that it may contain. + Verdnatura Levante SL does not waive confidentiality or any privilege due to erroneous + transmission or malfunction. Likewise, it is not responsible for the changes, alterations, + errors or omissions that could be made to the message once sent.' +privacy: 'In compliance with the provisions of Organic Law 15/1999, on the + Protection of Personal Data, we inform you that the personal data you provide + will be included in automated files of VERDNATURA LEVANTE SL, being able at all + times to exercise the rights of access, rectification, cancellation and opposition, + communicating it in writing to the registered office of the entity. + The purpose of the file is administrative management, accounting, and billing.' diff --git a/print/core/components/email-footer/locale/es.yml b/print/core/components/email-footer/locale/es.yml index 592a46737..7f4b13045 100644 --- a/print/core/components/email-footer/locale/es.yml +++ b/print/core/components/email-footer/locale/es.yml @@ -1,19 +1,18 @@ buttons: webAcccess: Visita nuestra Web info: Ayúdanos a mejorar -privacy: - fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla - · www.verdnatura.es · clientes@verdnatura.es - disclaimer: '- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado - exclusivamente por la persona destinataria del mismo. Si has recibido este mensaje - por error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier - documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la - confidencialidad ni a ningún privilegio por causa de transmisión errónea o mal - funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, - errores u omisiones que pudieran hacerse al mensaje una vez enviado.' - law: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de - Datos de Carácter Personal, te comunicamos que los datos personales que facilites - se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en - todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, - comunicándolo por escrito al domicilio social de la entidad. La finalidad del - fichero es la gestión administrativa, contabilidad, y facturación. +fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es +disclaimer: '- AVISO - Este mensaje es privado y confidencial, y debe ser utilizado + exclusivamente por la persona destinataria del mismo. Si has recibido este mensaje + por error, te rogamos lo comuniques al remitente y borres dicho mensaje y cualquier + documento adjunto que pudiera contener. Verdnatura Levante SL no renuncia a la + confidencialidad ni a ningún privilegio por causa de transmisión errónea o mal + funcionamiento. Igualmente no se hace responsable de los cambios, alteraciones, + errores u omisiones que pudieran hacerse al mensaje una vez enviado.' +privacy: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de + Datos de Carácter Personal, te comunicamos que los datos personales que facilites + se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en + todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, + comunicándolo por escrito al domicilio social de la entidad. La finalidad del + fichero es la gestión administrativa, contabilidad, y facturación. diff --git a/print/core/components/email-footer/locale/fr.yml b/print/core/components/email-footer/locale/fr.yml index c3eb5c3ff..d93f9769e 100644 --- a/print/core/components/email-footer/locale/fr.yml +++ b/print/core/components/email-footer/locale/fr.yml @@ -1,19 +1,18 @@ buttons: webAcccess: Visitez notre site web info: Aidez-nous à améliorer -privacy: - fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla - · www.verdnatura.es · clientes@verdnatura.es - disclaimer: "- AVIS - Ce message est privé et confidentiel et doit être utilisé - exclusivement par le destinataire. Si vous avez reçu ce message par erreur, - veuillez en informer l'expéditeur et supprimer ce message ainsi que tous les - documents joints qu'il pourrait contenir. Verdnatura Levante SL ne renonce pas à la - confidentialité ni aux privilèges résultant d'une transmission erronée ou d'un dysfonctionnement. - De même, il n'est pas responsable des modifications, altérations, erreurs ou - omissions qui pourraient être apportées au message une fois envoyé." - law: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de - Datos de Carácter Personal, te comunicamos que los datos personales que facilites - se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L.,pudiendo en - todo momento ejercitar los derechos de acceso, rectificación, cancelación y oposición, - comunicándolo porescrito al domicilio social de la entidad. La finalidad del fichero - es la gestión administrativa, contabilidad, y facturación. +fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es +disclaimer: "- AVIS - Ce message est privé et confidentiel et doit être utilisé + exclusivement par le destinataire. Si vous avez reçu ce message par erreur, + veuillez en informer l'expéditeur et supprimer ce message ainsi que tous les + documents joints qu'il pourrait contenir. Verdnatura Levante SL ne renonce pas à la + confidentialité ni aux privilèges résultant d'une transmission erronée ou d'un dysfonctionnement. + De même, il n'est pas responsable des modifications, altérations, erreurs ou + omissions qui pourraient être apportées au message une fois envoyé." +privacy: Conformément aux dispositions de la loi organique 15/1999 sur la protection + des données personnelles, nous vous informons que les données personnelles que + vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous + pouvez à tout moment, exercer les droits d'accès, de rectification, d'annulation + et d'opposition, en communiquant par écrit au siège social de la société. Le dossier + a pour objet la gestion administrative, la comptabilité et la facturation. diff --git a/print/core/components/email-footer/locale/pt.yml b/print/core/components/email-footer/locale/pt.yml new file mode 100644 index 000000000..d7267dbaf --- /dev/null +++ b/print/core/components/email-footer/locale/pt.yml @@ -0,0 +1,17 @@ +buttons: + webAcccess: Visite o nosso site + info: Ajude-nos a melhorar +fiscalAddress: VERDNATURA LEVANTE SL, B97367486 Avda. Espioca, 100, 46460 Silla + · www.verdnatura.es · clientes@verdnatura.es +disclaimer: '- AVISO - Esta mensagem é privada e confidencial e deve ser usada exclusivamente + pela pessoa que a recebe. Se você recebeu esta mensagem por engano, notifique o remetente e + exclua essa mensagem e todos os documentos anexos que ela possa conter. + A Verdnatura Levante SL não renuncia à confidencialidade ou a qualquer privilégio devido a + transmissão ou mau funcionamento incorretos. Da mesma forma, não se responsabiliza pelas alterações, + alterações, erros ou omissões que possam ser feitos na mensagem após o envio.' +privacy: Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados + de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão + nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento + exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando + por escrito ao domicílio social da entidade. A finalidade do ficheiro é a gestão + administrativa, contabilidade e facturação. diff --git a/print/core/components/email-header/email-header.js b/print/core/components/email-header/email-header.js index 257770cad..0f5a6845d 100755 --- a/print/core/components/email-header/email-header.js +++ b/print/core/components/email-header/email-header.js @@ -1,4 +1,3 @@ module.exports = { - name: 'email-header', - props: ['locale'] + name: 'email-header' }; diff --git a/print/core/components/report-footer/locale/en.yml b/print/core/components/report-footer/locale/en.yml new file mode 100644 index 000000000..404c7e7a4 --- /dev/null +++ b/print/core/components/report-footer/locale/en.yml @@ -0,0 +1,8 @@ +numPages: Page {{page}} of {{pages}} +law: + privacy: 'In compliance with the provisions of Organic Law 15/1999, on the + Protection of Personal Data, we inform you that the personal data you provide + will be included in automated files of VERDNATURA LEVANTE SL, being able at all + times to exercise the rights of access, rectification, cancellation and opposition, + communicating it in writing to the registered office of the entity. + The purpose of the file is administrative management, accounting, and billing.' diff --git a/print/core/components/report-footer/locale/es.yml b/print/core/components/report-footer/locale/es.yml index 8c54b796f..39dae8b58 100644 --- a/print/core/components/report-footer/locale/es.yml +++ b/print/core/components/report-footer/locale/es.yml @@ -1,7 +1,5 @@ numPages: Página {{page}} de {{pages}} law: - phytosanitary: 'VERDNATURA LEVANTE SL - Pasaporte Fitosanitario R.P. Generalitat - Valenciana - Nº Comerciante: ES17462130' privacy: En cumplimiento de lo dispuesto en la Ley Orgánica 15/1999, de Protección de Datos de Carácter Personal, le comunicamos que los datos personales que facilite se incluirán en ficheros automatizados de VERDNATURA LEVANTE S.L., pudiendo en diff --git a/print/core/components/report-footer/locale/fr.yml b/print/core/components/report-footer/locale/fr.yml index e35f9fb7f..8f2543640 100644 --- a/print/core/components/report-footer/locale/fr.yml +++ b/print/core/components/report-footer/locale/fr.yml @@ -1,7 +1,5 @@ numPages: Page {{page}} de {{pages}} law: - phytosanitary: 'VERDNATURA LEVANTE SL - Passeport Phytosanitaire R.P. Generalitat - Valenciana - Numéro d''opérateur: ES17462130' privacy: Conformément aux dispositions de la loi organique 15/1999 sur la protection des données personnelles, nous vous informons que les données personnelles que vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous diff --git a/print/core/components/report-footer/locale/pt.yml b/print/core/components/report-footer/locale/pt.yml index 8494c1ed5..8b4987bb7 100644 --- a/print/core/components/report-footer/locale/pt.yml +++ b/print/core/components/report-footer/locale/pt.yml @@ -1,7 +1,5 @@ numPages: Página {{page}} de {{pages}} law: - phytosanitary: 'VERDNATURA LEVANTE S.L - Passaporte Fitossanitário R.P. Generalitat - Valenciana - Nº Comerciante: ES17462130' privacy: Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento diff --git a/print/core/components/report-footer/report-footer.html b/print/core/components/report-footer/report-footer.html index a87c36109..4e0b7e327 100644 --- a/print/core/components/report-footer/report-footer.html +++ b/print/core/components/report-footer/report-footer.html @@ -4,6 +4,6 @@
{{centerText}}
{{$t('numPages')}}
-

{{$t('law.phytosanitary')}}

+

{{phytosanitary}}

diff --git a/print/core/components/report-footer/report-footer.js b/print/core/components/report-footer/report-footer.js index df1dca665..749170a0a 100755 --- a/print/core/components/report-footer/report-footer.js +++ b/print/core/components/report-footer/report-footer.js @@ -1,4 +1,18 @@ +const db = require('../../database'); + module.exports = { name: 'report-footer', - props: ['leftText', 'centerText', 'locale', 'showPhytosanitary'] + async serverPrefetch() { + const companyCode = this.companyCode || 'VNL'; + + this.phytosanitary = await this.getPhytosanitary(companyCode); + }, + methods: { + getPhytosanitary(code) { + return db.findValue(` + SELECT phytosanitary FROM company c + WHERE c.code = :code`, {code}); + } + }, + props: ['companyCode', 'showPhytosanitary', 'leftText', 'centerText'] }; diff --git a/print/core/components/report-header/locale/en.yml b/print/core/components/report-header/locale/en.yml new file mode 100644 index 000000000..334f50ce9 --- /dev/null +++ b/print/core/components/report-header/locale/en.yml @@ -0,0 +1,2 @@ +company: + contactData: www.verdnatura.es - clientes@verdnatura.es \ No newline at end of file diff --git a/print/core/components/report-header/locale/es.yml b/print/core/components/report-header/locale/es.yml index 51552c24c..fe4222eb0 100644 --- a/print/core/components/report-header/locale/es.yml +++ b/print/core/components/report-header/locale/es.yml @@ -1,5 +1,2 @@ company: - fiscalAddress: VERDNATURA LEVANTE S.L., B97367486 Avda. Espioca, 100, 46460 Silla - - www.verdnatura.es - clientes@verdnatura.es - registry: 'CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, - Folio 160, Sección 8, Hoja V 102076' + contactData: www.verdnatura.es - clientes@verdnatura.es diff --git a/print/core/components/report-header/locale/fr.yml b/print/core/components/report-header/locale/fr.yml new file mode 100644 index 000000000..fe4222eb0 --- /dev/null +++ b/print/core/components/report-header/locale/fr.yml @@ -0,0 +1,2 @@ +company: + contactData: www.verdnatura.es - clientes@verdnatura.es diff --git a/print/core/components/report-header/locale/pt.yml b/print/core/components/report-header/locale/pt.yml index 51552c24c..4e138c69c 100644 --- a/print/core/components/report-header/locale/pt.yml +++ b/print/core/components/report-header/locale/pt.yml @@ -1,5 +1,2 @@ company: - fiscalAddress: VERDNATURA LEVANTE S.L., B97367486 Avda. Espioca, 100, 46460 Silla - - www.verdnatura.es - clientes@verdnatura.es - registry: 'CIF: B97367486 Registro Mercantil de Valencia, Tomo 8041, Libro 5334, - Folio 160, Sección 8, Hoja V 102076' + contactData: · www.verdnatura.es · clientes@verdnatura.es \ No newline at end of file diff --git a/print/core/components/report-header/report-header.html b/print/core/components/report-header/report-header.html index 6cfe65870..2667f14ed 100644 --- a/print/core/components/report-header/report-header.html +++ b/print/core/components/report-header/report-header.html @@ -1,5 +1,10 @@
Verdnatura -
{{$t('company.fiscalAddress')}}
-
{{$t('company.registry')}}
+
+ {{companyName}}. {{company.street}}. + {{company.postCode}} {{company.city}}. + ☎ {{companyPhone}} + · {{$t('company.contactData')}} +
+
CIF: {{fiscalAddress.nif}} {{fiscalAddress.register}}
diff --git a/print/core/components/report-header/report-header.js b/print/core/components/report-header/report-header.js index d86080f9e..9d501d3ba 100755 --- a/print/core/components/report-header/report-header.js +++ b/print/core/components/report-header/report-header.js @@ -1,4 +1,46 @@ +const db = require('../../database'); + module.exports = { name: 'report-header', - props: ['isPreview', 'locale'] + async serverPrefetch() { + const companyCode = this.companyCode || 'VNL'; + + this.company = await this.getCompany(companyCode); + this.fiscalAddress = await this.getFiscalAddress(companyCode); + }, + computed: { + companyName() { + if (!this.company.name) return; + + return this.company.name.toUpperCase(); + }, + companyPhone() { + if (!this.company.phone) return; + + let phone = this.company.phone; + + if (phone.length >= 13) { + const prefix = parseInt(phone.substr(0, 4)); + const number = phone.substr(5, phone.length); + return `+${prefix} ${number}`; + } else + return phone; + } + }, + methods: { + getCompany(code) { + return db.findOne(` + SELECT s.name, s.street, s.postCode, s.city, s.phone + FROM company c + JOIN supplier s ON s.id = c.id + WHERE c.code = :code`, {code}); + }, + getFiscalAddress(code) { + return db.findOne(` + SELECT nif, register FROM company c + JOIN supplier s ON s.id = c.id + WHERE c.code = :code`, {code}); + } + }, + props: ['companyCode'] }; diff --git a/print/core/database.js b/print/core/database.js index 553fe3265..a2e6e9573 100644 --- a/print/core/database.js +++ b/print/core/database.js @@ -15,15 +15,34 @@ module.exports = { * @param {String} query - The raw SQL query * @param {Object} params - Parameterized values * - * @return {Object} - Result + * @return {Object} - Result promise */ rawSql(query, params) { return this.pool.query(query, params).then(([rows]) => { return rows; }); }, + /** + * Returns the first row from a given raw sql + * @param {String} query - The raw SQL query + * @param {Object} params - Parameterized values + * + * @return {Object} - Result promise + */ findOne(query, params) { - return this.rawSql(query, params).then(([rows]) => rows); + return this.rawSql(query, params).then(([row]) => row); + }, + /** + * Returns the first property from a given raw sql + * @param {String} query - The raw SQL query + * @param {Object} params - Parameterized values + * + * @return {Object} - Result promise + */ + findValue(query, params) { + return this.findOne(query, params).then(row => { + return Object.values(row)[0]; + }); }, findFromDef() { diff --git a/print/core/mixins/user-locale.js b/print/core/mixins/user-locale.js index bb688b7bf..f8001aefc 100644 --- a/print/core/mixins/user-locale.js +++ b/print/core/mixins/user-locale.js @@ -1,5 +1,7 @@ const Vue = require('vue'); const db = require('../database'); +const config = require('../config'); +const fallbackLocale = config.i18n.fallbackLocale; const userLocale = { async serverPrefetch() { if (this.clientId) @@ -13,7 +15,9 @@ const userLocale = { return db.findOne(` SELECT lang FROM account.user WHERE id = ?`, [clientId]).then(rows => { - return rows.lang; + if (rows) + return rows.lang; + else return fallbackLocale; }); } }, diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html index 039f5761a..b00338467 100644 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html @@ -17,10 +17,7 @@
- - +
@@ -34,10 +31,7 @@
- - +
diff --git a/print/templates/email/client-welcome/client-welcome.html b/print/templates/email/client-welcome/client-welcome.html index dc5c5e572..c5f203621 100644 --- a/print/templates/email/client-welcome/client-welcome.html +++ b/print/templates/email/client-welcome/client-welcome.html @@ -17,10 +17,7 @@
- - +
@@ -80,10 +77,7 @@
- - +
diff --git a/print/templates/email/delivery-note-link/delivery-note-link.html b/print/templates/email/delivery-note-link/delivery-note-link.html index 2be79a118..28dbc7922 100644 --- a/print/templates/email/delivery-note-link/delivery-note-link.html +++ b/print/templates/email/delivery-note-link/delivery-note-link.html @@ -22,10 +22,7 @@
- - +
@@ -57,10 +54,7 @@
- - +
diff --git a/print/templates/email/delivery-note/delivery-note.html b/print/templates/email/delivery-note/delivery-note.html index dcc7f0d56..0ee59a26f 100644 --- a/print/templates/email/delivery-note/delivery-note.html +++ b/print/templates/email/delivery-note/delivery-note.html @@ -17,10 +17,7 @@
- - +
@@ -37,10 +34,7 @@
- - +
diff --git a/print/templates/email/driver-route/driver-route.html b/print/templates/email/driver-route/driver-route.html index 40635bab1..b9d0aeab5 100644 --- a/print/templates/email/driver-route/driver-route.html +++ b/print/templates/email/driver-route/driver-route.html @@ -17,10 +17,7 @@
- - +
@@ -33,10 +30,7 @@
- - +
diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.html b/print/templates/email/letter-debtor-nd/letter-debtor-nd.html index 5299ab5be..c7a6faebc 100644 --- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.html +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.html @@ -17,10 +17,7 @@
- - +
@@ -69,7 +66,6 @@ @@ -77,10 +73,7 @@
- - +
diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.html b/print/templates/email/letter-debtor-st/letter-debtor-st.html index 40c1b76b1..d277d363a 100644 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.html +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.html @@ -17,10 +17,7 @@
- - +
@@ -52,7 +49,6 @@ @@ -60,10 +56,7 @@
- - +
diff --git a/print/templates/email/payment-update/payment-update.html b/print/templates/email/payment-update/payment-update.html index 49bdc4e1b..6bba77308 100644 --- a/print/templates/email/payment-update/payment-update.html +++ b/print/templates/email/payment-update/payment-update.html @@ -17,10 +17,7 @@
- - +
@@ -54,10 +51,7 @@
- - +
diff --git a/print/templates/email/printer-setup/printer-setup.html b/print/templates/email/printer-setup/printer-setup.html index e6b66cd98..12dcf4877 100644 --- a/print/templates/email/printer-setup/printer-setup.html +++ b/print/templates/email/printer-setup/printer-setup.html @@ -17,10 +17,7 @@
- - +
@@ -77,10 +74,7 @@
- - +
diff --git a/print/templates/email/sepa-core/sepa-core.html b/print/templates/email/sepa-core/sepa-core.html index 0fc09cc9c..b71c8e10f 100644 --- a/print/templates/email/sepa-core/sepa-core.html +++ b/print/templates/email/sepa-core/sepa-core.html @@ -17,10 +17,7 @@
- - +
@@ -45,10 +42,7 @@
- - +
diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 860d17b08..9c6b0fa4e 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -8,10 +8,7 @@
- - +
@@ -93,8 +90,7 @@ + v-bind="$props"> diff --git a/print/templates/reports/delivery-note/delivery-note.html b/print/templates/reports/delivery-note/delivery-note.html index 3908133cc..812ef0715 100644 --- a/print/templates/reports/delivery-note/delivery-note.html +++ b/print/templates/reports/delivery-note/delivery-note.html @@ -8,9 +8,8 @@
- +
@@ -238,11 +237,11 @@
+ v-bind="$props">
diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js index ece7521e9..f22d7694a 100755 --- a/print/templates/reports/delivery-note/delivery-note.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -57,8 +57,9 @@ module.exports = { `SELECT t.id, t.shipped, - t.companyFk + c.code companyCode FROM ticket t + JOIN company c ON c.id = t.companyFk WHERE t.id = ?`, [ticketId]); }, fetchAddress(ticketId) { diff --git a/print/templates/reports/delivery-note/locale/en.yml b/print/templates/reports/delivery-note/locale/en.yml new file mode 100644 index 000000000..8810a7595 --- /dev/null +++ b/print/templates/reports/delivery-note/locale/en.yml @@ -0,0 +1,26 @@ +title: Delivery note +ticketId: Delivery note +clientId: Client +deliveryAddress: Delivery address +fiscalData: Fiscal data +saleLines: Line items +date: Date +reference: Ref. +quantity: Qty. +concept: Concept +price: PSP/u +discount: Disc. +vat: VAT +amount: Amount +type: Type +taxBase: Tax base +tax: Tax +fee: Fee +total: Total +subtotal: Subtotal +taxBreakdown: Tax breakdown +packagings: Buckets and packaging +services: Services +vatType: VAT Type +digitalSignature: Digital signature +ticket: Delivery note {0} \ No newline at end of file diff --git a/print/templates/reports/delivery-note/locale/fr.yml b/print/templates/reports/delivery-note/locale/fr.yml index 98b1264b1..4dc7d4ff9 100644 --- a/print/templates/reports/delivery-note/locale/fr.yml +++ b/print/templates/reports/delivery-note/locale/fr.yml @@ -1,10 +1,10 @@ -title: Bon de livraison -ticketId: Bon de livraison -clientId: Client -deliveryAddress: Addresse de livraison +title: Albarán +ticketId: Albarán +clientId: Cliente +deliveryAddress: Dirección de entrega fiscalData: Datos fiscales saleLines: Líneas de pedido -date: Date +date: Fecha reference: Ref. quantity: Cant. concept: Concepto @@ -18,8 +18,8 @@ tax: Tasa fee: Cuota total: Total subtotal: Subtotal -taxBreakdown: Répartition de la taxe -packagings: Seaux et emballages +taxBreakdown: Desglose impositivo +packagings: Cubos y embalajes services: Servicios vatType: Tipo de IVA digitalSignature: Firma digital diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 453c4eab5..bfeba3b8a 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -8,10 +8,7 @@
- - +
@@ -159,10 +156,9 @@
- + v-bind="$props">
diff --git a/print/templates/reports/letter-debtor/letter-debtor.html b/print/templates/reports/letter-debtor/letter-debtor.html index 23fc4daed..93e59bba1 100644 --- a/print/templates/reports/letter-debtor/letter-debtor.html +++ b/print/templates/reports/letter-debtor/letter-debtor.html @@ -8,10 +8,7 @@
- - +
@@ -91,8 +88,7 @@ + v-bind="$props"> diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index ffcc4ffb1..5538b7c3f 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -8,10 +8,7 @@
- - +
@@ -44,8 +41,7 @@ + v-bind="$props"> diff --git a/print/templates/reports/sepa-core/sepa-core.html b/print/templates/reports/sepa-core/sepa-core.html index 69bf2651b..720f70058 100644 --- a/print/templates/reports/sepa-core/sepa-core.html +++ b/print/templates/reports/sepa-core/sepa-core.html @@ -8,10 +8,7 @@
- - +
@@ -174,8 +171,7 @@ + v-bind="$props">