From cbbce91defde38bb080313f39872e5e27fc80ea1 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 17 Sep 2019 13:52:29 +0200 Subject: [PATCH] #1693 export structure, data and fix back test --- db/changes/10080-september/00-articles.sql | 54 - .../10080-september/00-saleComponent.sql | 2 + db/dump/dumpedFixtures.sql | 124 +- db/dump/fixtures.sql | 43 +- db/dump/structure.sql | 7219 ++++++++++++----- db/export-data.sh | 9 +- modules/item/back/methods/item/getSummary.js | 2 +- .../order/specs/getTotalVolume.spec.js | 2 +- .../methods/sale/specs/updatePrice.spec.js | 4 +- .../ticket/specs/getTotalVolume.spec.js | 2 +- 10 files changed, 5396 insertions(+), 2065 deletions(-) delete mode 100644 db/changes/10080-september/00-articles.sql create mode 100644 db/changes/10080-september/00-saleComponent.sql diff --git a/db/changes/10080-september/00-articles.sql b/db/changes/10080-september/00-articles.sql deleted file mode 100644 index a608908ae..000000000 --- a/db/changes/10080-september/00-articles.sql +++ /dev/null @@ -1,54 +0,0 @@ -ALTER TABLE `vn2008`.`Articles` -ADD COLUMN `hasKgPrice` TINYINT(1) NOT NULL DEFAULT '0' AFTER `upToDown`; - -CREATE - OR REPLACE ALGORITHM = UNDEFINED - DEFINER = `root`@`%` - SQL SECURITY DEFINER -VIEW `vn`.`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` - - FROM - `vn2008`.`Articles` `t`; diff --git a/db/changes/10080-september/00-saleComponent.sql b/db/changes/10080-september/00-saleComponent.sql new file mode 100644 index 000000000..ebb8b7176 --- /dev/null +++ b/db/changes/10080-september/00-saleComponent.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn2008`.`Movimientos_componentes` +CHANGE COLUMN `Valor` `Valor` DECIMAL(10,4) NOT NULL ; diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 621912e83..6a2c13f67 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -36,7 +36,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:06 +-- Dump completed on 2019-09-16 13:23:24 USE `account`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -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),(5,19),(52,19),(65,19),(17,20),(30,20),(19,21),(22,21),(39,21),(30,22),(5,33),(34,33),(15,35),(52,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),(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),(52,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),(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,19),(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,19),(39,21),(39,33),(39,39),(39,53),(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,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,19),(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,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,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),(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,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,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,7 +94,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:06 +-- Dump completed on 2019-09-16 13:23:24 USE `salix`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -142,7 +142,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:06 +-- Dump completed on 2019-09-16 13:23:24 USE `vn`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -177,7 +177,7 @@ UNLOCK TABLES; LOCK TABLES `bookingPlanner` WRITE; /*!40000 ALTER TABLE `bookingPlanner` DISABLE KEYS */; -INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',1,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',2,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',3,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',2,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',4,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',5,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',2,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',5,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',1,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',3,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',1,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',2,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',3,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',1,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',2,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',3,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',2,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',5,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',1,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',3,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',1,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',2,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',3,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',1,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',2,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',1,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',3,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',1,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',2,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',3,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',1,0,30); +INSERT INTO `bookingPlanner` VALUES (5,'2017-06-30 22:00:00','4770000002','WORLD',1,4,1),(6,'2017-06-30 22:00:00','4770000010','NATIONAL',2,1,1),(8,'2017-06-30 22:00:00','4770000021','NATIONAL',3,2,1),(9,'2017-06-30 22:00:00','4770000101','EQU',3,1,1),(11,'2017-06-30 22:00:00','4770000110','EQU',2,1,1),(12,'2017-06-30 22:00:00','4770000215','EQU',4,2,1),(13,'2017-06-30 22:00:00','4770000521','EQU',5,2,1),(15,'2017-06-30 22:00:00','4771000000','CEE',2,1,1),(16,'2017-06-30 22:00:00','4771000001','CEE',5,3,1),(19,'2017-07-05 11:54:58','4770000020','NATIONAL',1,4,1),(20,'2017-07-05 12:09:24','4771000000','CEE',3,2,1),(21,'2017-07-05 12:09:24','4771000000','CEE',1,4,1),(22,'2017-07-05 12:12:14','4770000002','WORLD',2,1,1),(23,'2017-07-05 12:12:14','4770000002','WORLD',3,2,1),(24,'2017-07-06 08:07:21','4770000002','WORLD',1,4,5),(25,'2017-07-06 08:07:21','HolandaRED','NATIONAL',2,1,5),(27,'2017-07-06 08:07:21','HolandaGEN','NATIONAL',3,2,5),(32,'2017-07-06 08:07:21','4771000000','CEE',2,1,5),(33,'2017-07-06 08:07:21','4771000001','CEE',5,3,5),(34,'2017-07-06 08:07:21','4770000020','NATIONAL',1,4,5),(35,'2017-07-06 08:07:21','4771000000','CEE',3,2,5),(36,'2017-07-06 08:07:21','4771000000','CEE',1,4,5),(37,'2017-07-06 08:07:21','4770000002','WORLD',2,1,5),(38,'2017-07-06 08:07:21','4770000002','WORLD',3,2,5),(70,'2017-07-06 08:08:48','4770000002','WORLD',1,4,30),(71,'2017-07-06 08:08:48','IGIC reduc','NATIONAL',2,1,30),(72,'2017-07-06 08:08:48','4770000020','NATIONAL',1,4,30),(73,'2017-07-06 08:08:48','IGIC gener','NATIONAL',3,2,30),(78,'2017-07-06 08:08:48','4770000020','NATIONAL',1,4,30),(79,'2017-07-06 08:08:48','4770000002','WORLD',2,1,30),(80,'2017-07-06 08:08:48','4770000002','WORLD',3,2,30),(81,'2017-07-05 22:00:00','IGIC cero','NATIONAL',1,5,30),(82,'2019-01-01 11:51:56','4770000504','EQU',10,5,1),(83,'2019-09-11 10:54:03','4770000405','EQU',11,5,1),(84,'2019-09-11 10:58:17','4770000004','NATIONAL',9,5,1); /*!40000 ALTER TABLE `bookingPlanner` ENABLE KEYS */; UNLOCK TABLES; @@ -217,7 +217,7 @@ UNLOCK TABLES; LOCK TABLES `pgc` WRITE; /*!40000 ALTER TABLE `pgc` DISABLE KEYS */; -INSERT INTO `pgc` VALUES ('4722000000',0.00,'Importación Exento ',1,0,0,1),('4722000010',10.00,'Importación Reducido ',1,0,0,1),('4722000021',21.00,'Importación General ',1,0,0,1),('4770000001',8.00,'Reducido',1,1,1,1),('4770000002',0.00,'Extra-Community supply',3,1,0,2),('4770000010',10.00,'Reducido',1,1,1,1),('4770000020',0.00,'Exento',7,1,1,1),('4770000021',21.00,'General',1,1,1,1),('4770000101',10.00,'Reducido ',1,1,1,1),('4770000108',8.00,'Reducido',1,1,1,1),('4770000110',1.40,'Rec. Eq. Reducido',1,0,0,1),('4770000215',21.00,'General',1,1,1,1),('4770000521',5.20,'Rec. Eq. General',1,0,0,1),('4770000701',1.00,'Rec. Eq. Reducido',1,0,0,1),('4771000000',0.00,'Intra-Community supply',6,1,1,1),('4771000001',0.00,'Intra-Community services',7,1,1,1),('HolandaGEN',21.00,'General',1,0,0,1),('HolandaRED',9.00,'Reducido',1,0,0,1),('IGIC cero',0.00,'Cero',1,0,0,1),('IGIC gener',6.50,'General',1,0,0,1),('IGIC reduc',3.00,'Reducido',1,0,0,1); +INSERT INTO `pgc` VALUES ('4722000000',0.00,'Importación Exento ',1,0,0,1),('4722000010',10.00,'Importación Reducido ',1,0,0,1),('4722000021',21.00,'Importación General ',1,0,0,1),('4770000001',8.00,'Reducido',1,1,1,1),('4770000002',0.00,'Extra-Community supply',3,1,0,2),('4770000004',4.00,'Super reducido',1,1,1,1),('4770000010',10.00,'Reducido',1,1,1,1),('4770000020',0.00,'Exento',7,1,1,1),('4770000021',21.00,'General',1,1,1,1),('4770000101',10.00,'Reducido ',1,1,1,1),('4770000108',8.00,'Reducido',1,1,1,1),('4770000110',1.40,'Rec. Eq. Reducido',1,0,0,1),('4770000215',21.00,'General',1,1,1,1),('4770000405',0.50,'Rec. Eq. Super Reducido',1,0,0,1),('4770000504',4.00,'Super reducido',1,1,1,1),('4770000521',5.20,'Rec. Eq. General',1,0,0,1),('4770000701',1.00,'Rec. Eq. Reducido',1,0,0,1),('4771000000',0.00,'Intra-Community supply',6,1,1,1),('4771000001',0.00,'Intra-Community services',7,1,1,1),('HolandaGEN',21.00,'General',1,0,0,1),('HolandaRED',9.00,'Reducido',1,0,0,1),('IGIC cero',0.00,'Cero',1,0,0,1),('IGIC gener',6.50,'General',1,0,0,1),('IGIC reduc',3.00,'Reducido',1,0,0,1); /*!40000 ALTER TABLE `pgc` ENABLE KEYS */; UNLOCK TABLES; @@ -227,9 +227,49 @@ UNLOCK TABLES; LOCK TABLES `tag` WRITE; /*!40000 ALTER TABLE `tag` DISABLE KEYS */; -INSERT INTO `tag` VALUES (1,'Color',0,0,'ink',NULL,NULL),(2,'Forma',1,0,NULL,NULL,NULL),(3,'Material',1,0,NULL,NULL,NULL),(4,'Longitud',1,1,NULL,'mm',NULL),(5,'Diámetro',1,1,NULL,'mm',NULL),(6,'Perímetro',1,1,NULL,'mm',NULL),(7,'Ancho de la base',1,1,NULL,'mm',NULL),(8,'Altura',1,1,NULL,'mm',NULL),(9,'Volumen',1,1,NULL,'ml',NULL),(10,'Densidad',1,1,NULL,NULL,NULL),(11,'Calidad',1,0,NULL,NULL,NULL),(12,'Textura',1,0,NULL,NULL,NULL),(13,'Material del mango',1,0,NULL,NULL,NULL),(14,'Compra mínima',1,0,NULL,NULL,NULL),(15,'Nº pétalos',1,1,NULL,NULL,NULL),(16,'Ancho',1,1,NULL,'mm',NULL),(17,'Alto',1,1,NULL,'mm',NULL),(18,'Profundidad',1,1,NULL,'mm',NULL),(19,'Largo',1,1,NULL,'mm',NULL),(20,'Ancho superior',1,1,NULL,'mm',NULL),(21,'Ancho inferior',1,1,NULL,'mm',NULL),(22,'Gramaje',1,0,NULL,'g',NULL),(23,'Tallos',1,1,NULL,NULL,NULL),(24,'Estado',0,0,NULL,NULL,NULL),(25,'Color principal',0,0,NULL,NULL,NULL),(26,'Color secundario',0,0,NULL,NULL,NULL),(27,'Longitud(cm)',1,1,NULL,'cm',NULL),(28,'Diámetro base',1,1,'','mm',NULL),(29,'Colección',1,0,NULL,NULL,NULL),(30,'Uds / caja',1,1,NULL,NULL,NULL),(31,'Contenido',1,0,NULL,NULL,NULL),(32,'Peso',1,1,NULL,'g',NULL),(33,'Grosor',1,1,NULL,'mm',NULL),(34,'Marca',1,0,NULL,NULL,NULL),(35,'Origen',0,0,'origin',NULL,NULL),(36,'Proveedor',1,0,NULL,NULL,NULL),(37,'Productor',0,0,'producer',NULL,NULL),(38,'Duración',1,1,NULL,'s',NULL),(39,'Flor',1,0,NULL,NULL,NULL),(40,'Soporte',1,0,NULL,NULL,NULL),(41,'Tamaño flor',1,0,NULL,NULL,NULL),(42,'Apertura',1,0,NULL,NULL,NULL),(43,'Tallo',0,0,NULL,NULL,NULL),(44,'Nº hojas',1,1,NULL,NULL,NULL),(45,'Dimensiones',1,0,NULL,NULL,NULL),(46,'Diámetro boca',1,1,NULL,'mm',NULL),(47,'Nº flores',1,1,NULL,NULL,NULL),(48,'Uds / paquete',1,1,NULL,NULL,NULL),(49,'Maceta',1,0,NULL,NULL,NULL),(50,'Textura flor',1,0,NULL,NULL,NULL),(51,'Textura hoja',1,0,NULL,NULL,NULL),(52,'Tipo de IVA',1,0,NULL,NULL,NULL),(53,'Tronco',1,0,NULL,NULL,NULL),(54,'Hoja',1,0,NULL,NULL,NULL),(55,'Formato',1,0,NULL,NULL,NULL),(56,'Genero',1,0,NULL,NULL,NULL),(57,'Especie',1,0,NULL,NULL,NULL),(58,'Variedad',1,0,NULL,NULL,NULL),(59,'Medida grande',1,0,NULL,NULL,NULL),(60,'Medida mediano',1,0,NULL,NULL,NULL),(61,'Medida pequeño',1,0,NULL,NULL,NULL),(62,'Medida pequeño',1,0,NULL,NULL,NULL),(63,'Recipiente interior',1,0,NULL,NULL,NULL),(64,'Material secundario',1,0,NULL,NULL,NULL),(65,'Colores',1,0,NULL,NULL,NULL),(66,'Referencia',1,0,NULL,NULL,NULL),(67,'Categoria',1,0,NULL,NULL,NULL),(68,'Amb',0,0,NULL,NULL,NULL),(69,'Anchura',1,1,NULL,'cm',NULL),(70,'Hueco interior',-1,0,NULL,NULL,NULL),(71,'Tamaño',1,0,NULL,NULL,NULL),(72,'Color botón',1,0,NULL,NULL,NULL),(73,'Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'Obtentor',1,0,NULL,NULL,NULL),(75,'Longitud del brote',1,0,NULL,NULL,NULL),(76,'Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'Madera de',1,0,NULL,NULL,NULL),(78,'Unidad de venta',1,0,NULL,NULL,NULL),(79,'Temporal',1,0,NULL,NULL,NULL),(80,'Gramaje/tallo',1,1,NULL,'g',NULL),(81,'Peso/paquete',1,1,NULL,'g',NULL),(82,'Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'Nº planchas',1,1,NULL,NULL,NULL),(84,'Nº páginas',1,1,NULL,NULL,NULL),(85,'Editorial',1,0,NULL,NULL,NULL),(86,'Idioma',1,0,NULL,NULL,NULL),(87,'Fecha publicación',1,0,NULL,NULL,NULL),(88,'Cubierta',1,0,NULL,NULL,NULL),(89,'Encuadernación',1,0,NULL,NULL,NULL),(90,'Autor',1,0,NULL,NULL,NULL),(91,'Envoltorio',1,0,NULL,NULL,NULL),(92,'Nombre temporal',1,0,NULL,NULL,NULL),(93,'Modelo',1,0,NULL,NULL,NULL),(94,'Producto',1,0,NULL,NULL,NULL),(95,'Título',1,0,NULL,NULL,NULL),(96,'Tomo',1,0,NULL,NULL,NULL),(97,'Articulo',1,0,NULL,NULL,NULL),(98,'Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'Edad',1,0,NULL,NULL,NULL),(100,'Agotado',1,0,NULL,NULL,NULL),(101,'Altura con asa',1,0,NULL,NULL,NULL),(102,'Nº tallos',1,1,NULL,NULL,NULL),(103,'Cultivo',1,0,NULL,NULL,NULL),(104,'Sabor',1,0,NULL,NULL,NULL),(105,'Talla',1,0,NULL,NULL,NULL); +INSERT INTO `tag` VALUES (1,'Color',0,0,'ink',NULL,NULL),(2,'Forma',1,0,NULL,NULL,NULL),(3,'Material',1,0,NULL,NULL,NULL),(4,'Longitud',1,1,NULL,'mm',NULL),(5,'Diámetro',1,1,NULL,'mm',NULL),(6,'Perímetro',1,1,NULL,'mm',NULL),(7,'Ancho de la base',1,1,NULL,'mm',NULL),(8,'Altura',1,1,NULL,'mm',NULL),(9,'Volumen',1,1,NULL,'ml',NULL),(10,'Densidad',1,1,NULL,NULL,NULL),(11,'Calidad',1,0,NULL,NULL,NULL),(12,'Textura',1,0,NULL,NULL,NULL),(13,'Material del mango',1,0,NULL,NULL,NULL),(14,'Compra mínima',1,0,NULL,NULL,NULL),(15,'Nº pétalos',1,1,NULL,NULL,NULL),(16,'Ancho',1,1,NULL,'mm',NULL),(17,'Alto',1,1,NULL,'mm',NULL),(18,'Profundidad',1,1,NULL,'mm',NULL),(19,'Largo',1,1,NULL,'mm',NULL),(20,'Ancho superior',1,1,NULL,'mm',NULL),(21,'Ancho inferior',1,1,NULL,'mm',NULL),(22,'Gramaje',1,0,NULL,'g',NULL),(23,'Tallos',1,1,NULL,NULL,NULL),(24,'Estado',0,0,NULL,NULL,NULL),(25,'Color principal',0,0,NULL,NULL,NULL),(26,'Color secundario',0,0,NULL,NULL,NULL),(27,'Longitud(cm)',1,1,NULL,'cm',NULL),(28,'Diámetro base',1,1,'','mm',NULL),(29,'Colección',1,0,NULL,NULL,NULL),(30,'Uds / caja',1,1,NULL,NULL,NULL),(31,'Contenido',1,0,NULL,NULL,NULL),(32,'Peso',1,1,NULL,'g',NULL),(33,'Grosor',1,1,NULL,'mm',NULL),(34,'Marca',1,0,NULL,NULL,NULL),(35,'Origen',0,0,'origin',NULL,NULL),(36,'Proveedor',1,0,NULL,NULL,NULL),(37,'Productor',0,0,'producer',NULL,NULL),(38,'Duración',1,1,NULL,'s',NULL),(39,'Flor',1,0,NULL,NULL,NULL),(40,'Soporte',1,0,NULL,NULL,NULL),(41,'Tamaño flor',1,0,NULL,NULL,NULL),(42,'Apertura',1,0,NULL,NULL,NULL),(43,'Tallo',0,0,NULL,NULL,NULL),(44,'Nº hojas',1,1,NULL,NULL,NULL),(45,'Dimensiones',1,0,NULL,NULL,NULL),(46,'Diámetro boca',1,1,NULL,'mm',NULL),(47,'Nº flores',1,1,NULL,NULL,NULL),(48,'Uds / paquete',1,1,NULL,NULL,NULL),(49,'Maceta',1,0,NULL,NULL,NULL),(50,'Textura flor',1,0,NULL,NULL,NULL),(51,'Textura hoja',1,0,NULL,NULL,NULL),(52,'Tipo de IVA',1,0,NULL,NULL,NULL),(53,'Tronco',1,0,NULL,NULL,NULL),(54,'Hoja',1,0,NULL,NULL,NULL),(55,'Formato',1,0,NULL,NULL,NULL),(56,'Genero',1,0,NULL,NULL,NULL),(57,'Especie',1,0,NULL,NULL,NULL),(58,'Variedad',1,0,NULL,NULL,NULL),(59,'Medida grande',1,0,NULL,NULL,NULL),(60,'Medida mediano',1,0,NULL,NULL,NULL),(61,'Medida pequeño',1,0,NULL,NULL,NULL),(62,'Medida pequeño',1,0,NULL,NULL,NULL),(63,'Recipiente interior',1,0,NULL,NULL,NULL),(64,'Material secundario',1,0,NULL,NULL,NULL),(65,'Colores',1,0,NULL,NULL,NULL),(66,'Referencia',1,0,NULL,NULL,NULL),(67,'Categoria',1,0,NULL,NULL,NULL),(68,'Amb',0,0,NULL,NULL,NULL),(69,'Anchura',1,1,NULL,'cm',NULL),(70,'Hueco interior',-1,0,NULL,NULL,NULL),(71,'Tamaño',1,0,NULL,NULL,NULL),(72,'Color botón',1,0,NULL,NULL,NULL),(73,'Tamaño minimo del botón',1,0,NULL,NULL,NULL),(74,'Obtentor',1,0,NULL,NULL,NULL),(75,'Longitud del brote',1,0,NULL,NULL,NULL),(76,'Tallos / u.v.',1,0,NULL,NULL,NULL),(77,'Madera de',1,0,NULL,NULL,NULL),(78,'Unidad de venta',1,0,NULL,NULL,NULL),(79,'Temporal',1,0,NULL,NULL,NULL),(80,'Gramaje/tallo',1,1,NULL,'g',NULL),(81,'Peso/paquete',1,1,NULL,'g',NULL),(82,'Flexibilidad del tallo',1,0,NULL,NULL,NULL),(83,'Nº planchas',1,1,NULL,NULL,NULL),(84,'Nº páginas',1,1,NULL,NULL,NULL),(85,'Editorial',1,0,NULL,NULL,NULL),(86,'Idioma',1,0,NULL,NULL,NULL),(87,'Fecha publicación',1,0,NULL,NULL,NULL),(88,'Cubierta',1,0,NULL,NULL,NULL),(89,'Encuadernación',1,0,NULL,NULL,NULL),(90,'Autor',1,0,NULL,NULL,NULL),(91,'Envoltorio',1,0,NULL,NULL,NULL),(92,'Nombre temporal',1,0,NULL,NULL,NULL),(93,'Modelo',1,0,NULL,NULL,NULL),(94,'Producto',1,0,NULL,NULL,NULL),(95,'Título',1,0,NULL,NULL,NULL),(96,'Tomo',1,0,NULL,NULL,NULL),(97,'Articulo',1,0,NULL,NULL,NULL),(98,'Metodo de cultivo',1,0,NULL,NULL,NULL),(99,'Edad',1,0,NULL,NULL,NULL),(100,'Agotado',1,0,NULL,NULL,NULL),(101,'Altura con asa',1,0,NULL,NULL,NULL),(102,'Nº tallos',1,1,NULL,NULL,NULL),(103,'Cultivo',1,0,NULL,NULL,NULL),(104,'Sabor',1,0,NULL,NULL,NULL),(105,'Talla',1,0,NULL,NULL,NULL),(106,'Calibre',1,1,NULL,NULL,NULL),(107,'Dulzura',1,1,NULL,'bx',NULL),(108,'Piezas',1,0,NULL,NULL,NULL); /*!40000 ALTER TABLE `tag` ENABLE KEYS */; UNLOCK TABLES; + +-- +-- Dumping data for table `claimResponsible` +-- + +LOCK TABLES `claimResponsible` WRITE; +/*!40000 ALTER TABLE `claimResponsible` DISABLE KEYS */; +INSERT INTO `claimResponsible` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0); +/*!40000 ALTER TABLE `claimResponsible` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `claimReason` +-- + +LOCK TABLES `claimReason` WRITE; +/*!40000 ALTER TABLE `claimReason` DISABLE KEYS */; +INSERT INTO `claimReason` VALUES (1,'Prisas'),(2,'Novato'),(3,'Exceso de confianza'),(4,'Exceso de celo'),(5,'Indiferencia'),(6,'Extraviado o Hurto'),(7,'Incompetencia'),(8,'Ubicación erronea'),(9,'Dat.Inctos/Pak.conf'),(10,'Datos duplicados'),(11,'Fallo stock'),(12,'Innovación'),(13,'Distracción'),(15,'Portes indebidos'),(16,'Baja calidad'),(17,'Defectuoso'),(19,'Endiñado'),(20,'Calor'),(21,'Frio'),(22,'Cambiado'),(24,'Cansancio'),(25,'Mal etiquetado'),(26,'Cantidad malentendido'),(30,'No revisado'),(34,'Error fotografia'),(40,'Fallo Personal VN'),(41,'Fallo Personal Cliente'),(42,'Otros'),(43,'Precio alto'),(44,'Abuso de confianza'),(45,'Retraso Agencia'),(46,'Delicado'); +/*!40000 ALTER TABLE `claimReason` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `claimRedelivery` +-- + +LOCK TABLES `claimRedelivery` WRITE; +/*!40000 ALTER TABLE `claimRedelivery` DISABLE KEYS */; +INSERT INTO `claimRedelivery` VALUES (1,'Cliente'),(2,'No dev./No especif.'),(3,'Reparto'),(4,'Agencia'); +/*!40000 ALTER TABLE `claimRedelivery` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `claimResult` +-- + +LOCK TABLES `claimResult` WRITE; +/*!40000 ALTER TABLE `claimResult` DISABLE KEYS */; +INSERT INTO `claimResult` VALUES (1,'Otros daños'),(2,'Roces'),(3,'Humedad'),(4,'Deshidratacion'),(5,'Error identidad'),(6,'Incompleto (Faltas)'),(7,'Error packing'),(8,'Error color'),(9,'Error medida'),(10,'Error origen'),(11,'Envejecido'),(12,'Venta Perdida'),(13,'Duplicacion'),(14,'Rechazado'),(15,'Rotura'),(16,'Deterioro/Estropeado'),(17,'Podrido'),(18,'Baboso'),(19,'Cocido'),(20,'Congelado'),(21,'Machacado'),(22,'Error precio'),(23,'Manchado'),(24,'No entregado'),(25,'Cobro indebido'),(26,'Decepcion/Esperaba mas'),(27,'Otros'); +/*!40000 ALTER TABLE `claimResult` ENABLE KEYS */; +UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -240,7 +280,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:07 +-- Dump completed on 2019-09-16 13:23:25 USE `vn2008`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -289,46 +329,6 @@ INSERT INTO `businessReasonEnd` VALUES (1,'Baja voluntaria'),(2,'No supera PP em /*!40000 ALTER TABLE `businessReasonEnd` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `cl_con` --- - -LOCK TABLES `cl_con` WRITE; -/*!40000 ALTER TABLE `cl_con` DISABLE KEYS */; -INSERT INTO `cl_con` VALUES (1,'Otros daños'),(2,'Roces'),(3,'Humedad'),(4,'Deshidratacion'),(5,'Error identidad'),(6,'Incompleto (Faltas)'),(7,'Error packing'),(8,'Error color'),(9,'Error medida'),(10,'Error origen'),(11,'Envejecido'),(12,'Venta Perdida'),(13,'Duplicacion'),(14,'Rechazado'),(15,'Rotura'),(16,'Deterioro/Estropeado'),(17,'Podrido'),(18,'Baboso'),(19,'Cocido'),(20,'Congelado'),(21,'Machacado'),(22,'Error precio'),(23,'Manchado'),(24,'No entregado'),(25,'Cobro indebido'),(26,'Decepcion/Esperaba mas'),(27,'Otros'); -/*!40000 ALTER TABLE `cl_con` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `cl_res` --- - -LOCK TABLES `cl_res` WRITE; -/*!40000 ALTER TABLE `cl_res` DISABLE KEYS */; -INSERT INTO `cl_res` VALUES (1,'Compradores',0),(2,'Proveedor',0),(3,'Entradores',0),(4,'Camareros',0),(6,'Sacadores',0),(7,'Revisadores',0),(8,'Calidad general',0),(9,'Encajadores',0),(11,'Comerciales',1),(12,'Clientes',1),(13,'Administración',0),(14,'Agencia',0),(15,'Repartidores',0),(16,'Informatica',0),(17,'Transp.origen',0),(18,'Confeccion',0),(19,'OTROS',0),(21,'Gerencia',0),(22,'Paletizadores',0); -/*!40000 ALTER TABLE `cl_res` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `cl_dev` --- - -LOCK TABLES `cl_dev` WRITE; -/*!40000 ALTER TABLE `cl_dev` DISABLE KEYS */; -INSERT INTO `cl_dev` VALUES (1,'Cliente'),(2,'No dev./No especif.'),(3,'Reparto'),(4,'Agencia'); -/*!40000 ALTER TABLE `cl_dev` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `cl_mot` --- - -LOCK TABLES `cl_mot` WRITE; -/*!40000 ALTER TABLE `cl_mot` DISABLE KEYS */; -INSERT INTO `cl_mot` VALUES (1,'Prisas'),(2,'Novato'),(3,'Exceso de confianza'),(4,'Exceso de celo'),(5,'Indiferencia'),(6,'Extraviado o Hurto'),(7,'Incompetencia'),(8,'Ubicación erronea'),(9,'Dat.Inctos/Pak.conf'),(10,'Datos duplicados'),(11,'Fallo stock'),(12,'Innovación'),(13,'Distracción'),(15,'Portes indebidos'),(16,'Baja calidad'),(17,'Defectuoso'),(19,'Endiñado'),(20,'Calor'),(21,'Frio'),(22,'Cambiado'),(24,'Cansancio'),(25,'Mal etiquetado'),(26,'Cantidad malentendido'),(30,'No revisado'),(34,'Error fotografia'),(40,'Fallo Personal VN'),(41,'Fallo Personal Cliente'),(42,'Otros'),(43,'Precio alto'),(44,'Abuso de confianza'),(45,'Retraso Agencia'),(46,'Delicado'); -/*!40000 ALTER TABLE `cl_mot` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `container` -- @@ -375,27 +375,17 @@ UNLOCK TABLES; LOCK TABLES `iva_group_codigo` WRITE; /*!40000 ALTER TABLE `iva_group_codigo` DISABLE KEYS */; -INSERT INTO `iva_group_codigo` VALUES (1,'2012-09-01',21),(0,'2000-01-01',27),(1,'2000-01-01',27),(2,'2000-01-01',28),(3,'2000-01-01',28),(4,'2000-01-01',42),(1,'2016-01-01',63),(2,'2016-01-01',64),(1,'2015-01-01',67),(2,'2000-01-01',88),(0,'2000-01-01',89),(1,'2000-01-01',89),(3,'2000-01-01',105),(0,'2014-01-01',108),(1,'2014-01-01',108),(2,'2014-01-01',108),(3,'2014-01-01',108),(0,'2016-01-01',109),(3,'2016-01-01',109),(4,'2014-01-01',111),(0,'2019-01-01',122),(1,'2019-01-01',122),(2,'2019-01-01',122),(3,'2019-01-01',122); +INSERT INTO `iva_group_codigo` VALUES (1,'2012-09-01',21),(1,'2000-01-01',27),(5,'2000-01-01',27),(2,'2000-01-01',28),(3,'2000-01-01',28),(4,'2000-01-01',42),(1,'2016-01-01',63),(2,'2016-01-01',64),(1,'2015-01-01',67),(2,'2000-01-01',88),(1,'2000-01-01',89),(5,'2000-01-01',89),(3,'2000-01-01',105),(1,'2014-01-01',108),(2,'2014-01-01',108),(3,'2014-01-01',108),(5,'2014-01-01',108),(3,'2016-01-01',109),(5,'2016-01-01',109),(4,'2014-01-01',111),(1,'2019-01-01',122),(2,'2019-01-01',122),(3,'2019-01-01',122),(5,'2019-01-01',122); /*!40000 ALTER TABLE `iva_group_codigo` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `Monedas` --- - -LOCK TABLES `Monedas` WRITE; -/*!40000 ALTER TABLE `Monedas` DISABLE KEYS */; -INSERT INTO `Monedas` VALUES (1,'EUR','Euro',1),(2,'USD','Dollar USA',1.4),(3,'GBP','Libra',1),(4,'JPY','Yen Japones',1); -/*!40000 ALTER TABLE `Monedas` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `state` -- LOCK TABLES `state` WRITE; /*!40000 ALTER TABLE `state` DISABLE KEYS */; -INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL),(2,'Libre',1,0,'FREE',NULL),(3,'OK',3,0,'OK',3),(4,'Impreso',4,1,'PRINTED',2),(5,'Preparación',5,1,'ON_PREPARATION',7),(6,'En Revisión',7,1,'ON_CHECKING',NULL),(7,'Sin Acabar',2,0,'NOT_READY',NULL),(8,'Revisado',8,1,'CHECKED',NULL),(9,'Encajando',9,1,'PACKING',NULL),(10,'Encajado',10,2,'PACKED',NULL),(11,'Facturado',0,0,'INVOICED',NULL),(12,'Bloqueado',0,0,'BLOCKED',NULL),(13,'En Reparto',11,3,'ON_DELIVERY',NULL),(14,'Preparado',6,1,'PREPARED',NULL),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL),(16,'Entregado',13,3,'DELIVERED',NULL),(17,'Eliminado',14,3,'ERASED',NULL),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL),(21,'Retornado',4,1,'PRINTED_BACK',6),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL),(23,'URGENTE',2,0,'LAST_CALL',NULL),(24,'Encadenado',3,0,'CHAINED',4),(25,'Embarcando',3,0,'BOARDING',5),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7); +INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0),(2,'Libre',1,0,'FREE',NULL,2,0),(3,'OK',3,0,'OK',3,28,1),(4,'Impreso',4,1,'PRINTED',2,29,1),(5,'Preparación',5,1,'ON_PREPARATION',7,5,0),(6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0),(7,'Sin Acabar',2,0,'NOT_READY',NULL,7,0),(8,'Revisado',8,1,'CHECKED',NULL,8,0),(9,'Encajando',9,1,'PACKING',NULL,9,0),(10,'Encajado',10,2,'PACKED',NULL,10,0),(11,'Facturado',0,0,'INVOICED',NULL,11,0),(12,'Bloqueado',0,0,'BLOCKED',NULL,12,0),(13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0),(14,'Preparado',6,1,'PREPARED',NULL,14,0),(15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0),(16,'Entregado',13,3,'DELIVERED',NULL,16,0),(17,'Eliminado',14,3,'ERASED',NULL,17,0),(20,'Asignado',4,1,'PICKER_DESIGNED',NULL,20,1),(21,'Retornado',4,1,'PRINTED_BACK',6,21,1),(22,'¿Fecha?',2,0,'WRONG_DATE',NULL,22,0),(23,'URGENTE',2,0,'LAST_CALL',NULL,23,1),(24,'Encadenado',3,0,'CHAINED',4,24,0),(25,'Embarcando',3,0,'BOARDING',5,25,0),(26,'Prep Previa',5,1,'PREVIOUS_PREPARATION',1,26,0),(27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0),(28,'OK Previa',3,1,'OK PREVIOUS',3,28,1),(29,'Impreso Previa',4,1,'PRINTED PREVIOUS',2,29,1); /*!40000 ALTER TABLE `state` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -408,7 +398,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:07 +-- Dump completed on 2019-09-16 13:23:25 USE `bi`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -456,7 +446,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:07 +-- Dump completed on 2019-09-16 13:23:25 USE `cache`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -494,7 +484,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:07 +-- Dump completed on 2019-09-16 13:23:26 USE `hedera`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -562,7 +552,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:08 +-- Dump completed on 2019-09-16 13:23:26 USE `postgresql`; -- MySQL dump 10.13 Distrib 5.7.27, for Linux (x86_64) -- @@ -637,7 +627,7 @@ UNLOCK TABLES; LOCK TABLES `workcenter` WRITE; /*!40000 ALTER TABLE `workcenter` DISABLE KEYS */; -INSERT INTO `workcenter` VALUES (1,'Silla',20,952,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20007,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2847,5),(6,'Vilassar',88,88016,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,2,NULL); +INSERT INTO `workcenter` VALUES (1,'Silla',20,966,1),(2,'Mercaflor',19,NULL,NULL),(3,'Marjales',26,20007,NULL),(4,'VNH',NULL,NULL,3),(5,'Madrid',28,2848,5),(6,'Vilassar',88,88016,2),(7,'Tenerife',NULL,NULL,10),(8,'Silla-Agrario',26,2,NULL); /*!40000 ALTER TABLE `workcenter` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -650,4 +640,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:52:08 +-- Dump completed on 2019-09-16 13:23:26 diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 57af97ddb..f390ba904 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,5 +1,6 @@ ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1; +ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES @@ -76,6 +77,13 @@ INSERT INTO `vn`.`accountingType`(`id`, `description`) (4, 'Stolen Money'), (5, 'Miscellaneous'); +INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) + VALUES + (1, 'EUR', 'Euro', 1), + (2, 'USD', 'Dollar USA', 1.4), + (3, 'GBP', 'Libra', 1), + (4, 'JPY', 'Yen Japones', 1); + INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) VALUES (1, 'Pay on receipt', '0000000000', 4, 0, 1, 1), @@ -675,7 +683,7 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 1.69, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (5, 1, 2, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (6, 1, 3, 'Ranged weapon longbow 2m', 1, 110.33, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.43, 0, 0, 0, CURDATE()), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.44, 0, 0, 0, CURDATE()), (8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 1.79, 0, 0, 0, CURDATE()), (9, 1, 16, 'Ranged weapon longbow 2m', 1, 103.49, 0, 0, 0, CURDATE()), (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, CURDATE()), @@ -729,7 +737,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (6, 28, 50), (6, 29, 49.4), (6, 39, 0.994), - (7, 15, 0.0114), + (7, 15, 0.0199), (7, 17, 0.35), (7, 28, 5), (7, 29, 2), @@ -1067,10 +1075,10 @@ INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`package (1, 1, 1, 50, 5000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH)), (2, 2, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, DATE_ADD(CURDATE(), INTERVAL -1 MONTH)), (3, 3, 1, 50, 100, 4, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (4, 2, 2, 5, 450, 1, 1, 0.000, 0.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 0.000, 0.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0.00, NULL, 0, 1, 0, CURDATE()), (5, 3, 3, 55, 500, 5, 1, 0.000, 0.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0.00, NULL, 0, 1, 0, CURDATE()), (6, 4, 8, 50, 1000, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), - (7, 4, 9, 20, 1000, 1, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0.00, NULL, 0, 1, 0, CURDATE()), (8, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), (9, 4, 4, 1.25, 1000, 3, 1, 0.000, 0.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0.00, NULL, 0, 1, 0, CURDATE()), (10, 5, 1, 50, 10, 4, 1, 0.000, 0.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0.00, NULL, 0, 1, 0, CURDATE()), @@ -1545,51 +1553,42 @@ INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubs VALUES (1, 18, DATE_ADD(CURDATE(), INTERVAL -5 DAY), DATE_ADD(CURDATE(), INTERVAL +15 DAY), 19, DATE_ADD(CURDATE(), INTERVAL -5 DAY)); -INSERT INTO `vn`.`zoneGeo`(`id`, `name`, `lft`, `rgt`, `depth`, `sons`) - VALUES - (1, 'Origin', 1, 16, 0, 5), - (2, 'España', 2, 9, 1, 3), - (6, 'Valencia', 3, 8, 2, 2), - (7, 'Silla', 4, 7, 3, 1), - (8, '46460', 5, 6, 4, 0), - (3, 'Francia', 10, 11, 1, 0), - (4, 'Holanda', 12, 13, 1, 0), - (5, 'Portugal', 14, 15, 1, 0); +CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, columns: path,lft,rgt,depth,sons INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) VALUES (1, 3, 0), (1, 4, 0), (1, 5, 0), - (1, 2, 1), + (1, 1, 1), (2, 3, 0), (2, 4, 0), (2, 5, 0), - (2, 2, 1), + (2, 1, 1), (3, 3, 0), (3, 4, 0), (3, 5, 0), - (3, 2, 1), + (3, 1, 1), (4, 3, 0), (4, 4, 0), (4, 5, 0), - (4, 2, 1), + (4, 1, 1), (5, 3, 1), (5, 4, 0), (5, 5, 1), - (5, 2, 1), + (5, 1, 1), (6, 3, 1), (6, 4, 0), (6, 5, 1), - (6, 2, 1), + (6, 1, 1), (7, 3, 0), (7, 4, 0), (7, 5, 0), - (7, 2, 1), + (7, 1, 1), (8, 3, 0), (8, 4, 0), (8, 5, 0), - (8, 2, 1); + (8, 1, 1); INSERT INTO `vn`.`zoneCalendar`(`zoneFk`, `delivered`) VALUES diff --git a/db/dump/structure.sql b/db/dump/structure.sql index cbf5af21b..16dc74449 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -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=16256 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global users'; +) ENGINE=InnoDB AUTO_INCREMENT=16332 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 */ ; @@ -1923,7 +1923,7 @@ CREATE TABLE `XDiario_ALL` ( KEY `Cuenta` (`SUBCTA`), KEY `empresa` (`empresa_id`), KEY `Fecha` (`Fecha`) -) ENGINE=InnoDB AUTO_INCREMENT=5215770 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7691296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -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=78389700 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=82661609 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -2428,31 +2428,6 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; --- --- Temporary table structure for view `rutas` --- - -DROP TABLE IF EXISTS `rutas`; -/*!50001 DROP VIEW IF EXISTS `rutas`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `rutas` AS SELECT - 1 AS `year`, - 1 AS `month`, - 1 AS `warehouse_id`, - 1 AS `Id_Ruta`, - 1 AS `Id_Agencia`, - 1 AS `km`, - 1 AS `Dia`, - 1 AS `Fecha`, - 1 AS `cost`, - 1 AS `Bultos`, - 1 AS `Matricula`, - 1 AS `Tipo`, - 1 AS `isVolumetric`, - 1 AS `ticketFk`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `rutasBoard` -- @@ -2483,7 +2458,7 @@ CREATE TABLE `rutasBoard` ( KEY `rutasBoard_ix1` (`year`), KEY `rutasBoard_ix2` (`month`), KEY `rutasBoard_ix3` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=158558 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=170826 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4556,9 +4531,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 ;; @@ -4569,7 +4544,15 @@ CREATE DEFINER=`root`@`%` PROCEDURE `rotacion_update_manual`( vEndDate DATE ) BEGIN + DECLARE vDays INT DEFAULT DATEDIFF(vEndDate, vStartDate); + DECLARE vLastEventFinished DATETIME; + + DROP TEMPORARY TABLE IF EXISTS timing; + CREATE TEMPORARY TABLE timing + SELECT 'Starting Procedure' AS evento, now() as finished, 0 as seconds; + + SELECT now() INTO vLastEventFinished; REPLACE bi.rotacion(Id_Article, warehouse_id, total, rotacion) SELECT Id_Article, warehouse_id, Total, ROUND((SUM(Saldo_Ponderado) / Total), 2) AS rotacion @@ -4664,22 +4647,39 @@ BEGIN ) sub3 USING(Id_Article, warehouse_id) GROUP BY Id_Article, warehouse_id; + INSERT INTO timing + SELECT 'Replace' AS evento, now() as finished, TIMEDIFF(now(),vLastEventFinished) as seconds; + + SELECT MAX(finished) FROM timing INTO vLastEventFinished; + -- Añadimos el volumen por unidad de venta -- FIXME: Optimizar la consulta de actualización - CALL vn2008.item_last_buy_(NULL, vStartDate); + -- CALL vn2008.item_last_buy_(NULL, vStartDate); + CALL cache.last_buy_refresh(FALSE); + INSERT INTO timing + SELECT 'last_buy_refresh' AS evento, now() as finished, TIMEDIFF(now(),vLastEventFinished) as seconds; + + SELECT MAX(finished) FROM timing INTO vLastEventFinished; + UPDATE bi.rotacion r - JOIN vn2008.t_item_last_buy b ON r.Id_Article = b.item_id AND r.warehouse_id = b.warehouse_id - JOIN vn2008.Compres ON Id_Compra = b.buy_id - JOIN vn2008.Articles a ON a.Id_Article = Compres.Id_Article + JOIN cache.last_buy b ON r.Id_Article = b.item_id AND r.warehouse_id = b.warehouse_id + JOIN vn2008.Compres c ON c.Id_Compra = b.buy_id + JOIN vn.packaging p ON p.id = c.Id_Cubo + JOIN vn2008.Articles a ON a.Id_Article = c.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id JOIN vn2008.reinos re ON re.id = tp.reino_id - SET cm3 = a.compression * vn.item_getVolume(r.Id_Article, Id_Cubo) / Packing + SET cm3 = a.compression * IF(p.volume > 0, p.volume, p.width * p.depth * IF(p.height, p.height, a.medida + 10)) / c.packing WHERE re.mercancia = TRUE AND r.Id_Article BETWEEN vItemFrom AND vItemTo; - DROP TEMPORARY TABLE vn2008.t_item_last_buy; + INSERT INTO timing + SELECT 'update volume' AS evento, now() as finished, TIMEDIFF(now(),vLastEventFinished) as seconds; + + SELECT MAX(finished) FROM timing INTO vLastEventFinished; + + -- DROP TEMPORARY TABLE vn2008.t_item_last_buy; -- Añadimos el coste de almacenamiento y manipulacion @@ -4711,27 +4711,38 @@ BEGIN SET auxiliar = IF(rotacion < 0, 0, ROUND(rotacion * cm3 * Coste_Auxiliar / Operacion, 4)), almacenaje = IF(rotacion < 0, 0, ROUND(rotacion * cm3 * Coste_Operativo / Operacion, 4)), manipulacion = IF(rotacion < 0, 0, ROUND(rotacion * cm3 * Coste_Manipulacion / Operacion, 4)) - WHERE Id_Article BETWEEN vItemFrom AND vItemTo; - + WHERE Id_Article BETWEEN vItemFrom AND vItemTo; + + INSERT INTO timing + SELECT 'update almacenamiento' AS evento, now() as finished, TIMEDIFF(now(),vLastEventFinished) as seconds; + + SELECT MAX(finished) FROM timing INTO vLastEventFinished; + -- Añadimos todos los productos de los que no tenemos histórico -- con la media de su familia como valor por defecto - INSERT INTO bi.rotacion(Id_Article, warehouse_id, rotacion, cm3, almacenaje, manipulacion, auxiliar, mermas) - SELECT a.Id_Article, warehouse_id, rotacion_m, cm3_m, alm_m, man_m, aux_m, merm_m + INSERT INTO bi.rotacion(Id_Article, warehouse_id, cm3) + SELECT a.Id_Article, warehouse_id,cm3_m FROM vn2008.Articles a JOIN ( - SELECT tipo_id, warehouse_id, Id_Tipo, AVG(rotacion) rotacion_m, - AVG(cm3) cm3_m, AVG(almacenaje) alm_m, AVG(manipulacion) man_m, - AVG(auxiliar) aux_m, AVG(mermas) merm_m - FROM bi.rotacion - JOIN vn2008.Articles a USING(Id_Article) - JOIN vn2008.Tipos tp USING(tipo_id) + SELECT tp.tipo_id, warehouse_id,AVG(cm3) cm3_m + FROM bi.rotacion rt + JOIN vn2008.Articles a ON a.Id_Article = rt.Id_Article + JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id WHERE r.mercancia = TRUE GROUP BY tipo_id, warehouse_id - ) sub USING(tipo_id) + ) sub ON sub.tipo_id = a.tipo_id WHERE a.Id_Article BETWEEN vItemFrom AND vItemTo ON DUPLICATE KEY UPDATE rotacion = rotacion; + + INSERT INTO timing + SELECT 'historico' AS evento, now() as finished, TIMEDIFF(now(),vLastEventFinished) as seconds; + + SELECT MAX(finished) FROM timing INTO vLastEventFinished; + + SELECT * FROM timing; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -5300,7 +5311,7 @@ CREATE TABLE `m3` ( `dayName` varchar(12) COLLATE utf8_unicode_ci DEFAULT NULL, `euros` decimal(10,2) DEFAULT '0.00', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=293616 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=305719 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5572,7 +5583,7 @@ CREATE TABLE `payMethodClient` ( KEY `FkDateClientPayMethod` (`dated`,`clientFk`), CONSTRAINT `FkClientPayMethod` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `FkPayMethodClient` FOREIGN KEY (`payMethodFk`) REFERENCES `vn2008`.`pay_met` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4623627 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +) ENGINE=InnoDB AUTO_INCREMENT=4816062 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5646,7 +5657,7 @@ CREATE TABLE `productivity` ( `m3FV` double NOT NULL DEFAULT '0', `m3PCA` double NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=50700917 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=52223278 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -5818,7 +5829,7 @@ CREATE TABLE `ventas` ( CONSTRAINT `clientes_bs_ventas` FOREIGN KEY (`Id_Cliente`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `empresa_bs_ventas` FOREIGN KEY (`empresa_id`) REFERENCES `vn2008`.`empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `mov_to_mov` FOREIGN KEY (`Id_Movimiento`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `tip_to_tip` FOREIGN KEY (`tipo_id`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `tip_to_tip` FOREIGN KEY (`tipo_id`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -8697,7 +8708,7 @@ CREATE TABLE `cache_calc` ( KEY `cache_id` (`cache_id`), KEY `cacheName` (`cacheName`), KEY `expires` (`expires`) -) ENGINE=InnoDB AUTO_INCREMENT=392735 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=400709 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -8765,7 +8776,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=1432717 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1523534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9812,7 +9823,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=21696516 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22072628 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9870,7 +9881,7 @@ CREATE TABLE `ekt` ( KEY `barcode` (`barcode`), KEY `fec` (`fec`), KEY `putOrderFk` (`putOrderFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1029206 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1044352 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -9891,7 +9902,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=574594 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=586884 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10153,7 +10164,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=604854 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=617032 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -10409,7 +10420,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=7658751 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7851941 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11071,7 +11082,7 @@ CREATE TABLE `config` ( `testDomain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The address for beta website', `productionDomain` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The address for production website', `pdfsDir` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Directory where PDFs are allocated', - `dmsDir` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `dmsDir` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Directory where documents are allocated', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Global configuration parameters'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -11106,7 +11117,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=152789 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=155534 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -11787,7 +11798,7 @@ CREATE TABLE `order` ( CONSTRAINT `order_ibfk_5` FOREIGN KEY (`address_id`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_8` FOREIGN KEY (`delivery_method_id`) REFERENCES `vn2008`.`Vistas` (`vista_id`) ON UPDATE CASCADE, CONSTRAINT `order_ibfk_9` FOREIGN KEY (`agency_id`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2088530 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2114679 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 */ ; @@ -11903,7 +11914,7 @@ CREATE TABLE `orderRow` ( KEY `warehouse_shipment` (`warehouseFk`,`shipment`), CONSTRAINT `orderRow_ibfk_2` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `orderRow_ibfk_3` FOREIGN KEY (`orderFk`) REFERENCES `order` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12595636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12741800 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 */ ; @@ -12121,7 +12132,7 @@ CREATE TABLE `shelfConfig` ( KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), KEY `warehouse_id` (`warehouse`), - CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `shelfConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, CONSTRAINT `shelfConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; @@ -12327,7 +12338,7 @@ CREATE TABLE `tpvTransaction` ( CONSTRAINT `receipt_id` FOREIGN KEY (`receiptFk`) REFERENCES `vn2008`.`Recibos` (`Id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tpvTransaction_ibfk_2` FOREIGN KEY (`merchantFk`) REFERENCES `tpvMerchant` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=343934 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; +) ENGINE=InnoDB AUTO_INCREMENT=348669 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Transactions realized through the virtual TPV'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12362,7 +12373,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=1906174 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1922127 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12382,7 +12393,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=4203145 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4245996 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12407,7 +12418,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=2532038 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2550495 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12427,7 +12438,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=3688946 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3724600 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -12891,106 +12902,106 @@ CREATE DEFINER=`root`@`%` PROCEDURE `item_getVisible`( vDate DATE, vType INT, vPrefix VARCHAR(255)) -BEGIN -/** - * Gets visible items of the specified type at specified date. - * - * @param vWarehouse The warehouse id - * @param vDate The visible date - * @param vType The type id - * @param vPrefix The article prefix to filter or %NULL for all - * @return tmp.itemVisible Visible items - */ - DECLARE vPrefixLen SMALLINT; - DECLARE vFilter VARCHAR(255) DEFAULT NULL; - DECLARE vDateInv DATE DEFAULT vn2008.date_inv(); - - SET vPrefixLen = IFNULL(LENGTH(vPrefix), 0) + 1; - - IF vPrefixLen > 1 THEN - SET vFilter = CONCAT(vPrefix, '%'); - END IF; - - DROP TEMPORARY TABLE IF EXISTS filter; - CREATE TEMPORARY TABLE filter - (INDEX (itemFk)) - ENGINE = MEMORY - SELECT id itemFk FROM vn.item - WHERE typeFk = vType - AND (vFilter IS NULL OR `name` LIKE vFilter); - - DROP TEMPORARY TABLE IF EXISTS currentStock; - CREATE TEMPORARY TABLE currentStock - (INDEX (itemFk)) - ENGINE = MEMORY - SELECT itemFk, SUM(quantity) quantity - FROM ( - SELECT b.itemFk, b.quantity - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDateInv AND vDate - AND t.warehouseInFk = vWarehouse - AND NOT e.isRaid - UNION ALL - SELECT b.itemFk, -b.quantity - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDateInv AND CURDATE() - AND t.warehouseOutFk = vWarehouse - AND NOT e.isRaid - AND t.isDelivered - UNION ALL - SELECT m.itemFk, -m.quantity - FROM vn.sale m - JOIN vn.ticket t ON t.id = m.ticketFk - JOIN vn.ticketState s ON s.ticket = t.id - WHERE t.shipped BETWEEN vDateInv AND CURDATE() - AND t.warehouseFk = vWarehouse - AND s.alertLevel = 3 - ) t - GROUP BY itemFk - HAVING quantity > 0; - - DROP TEMPORARY TABLE IF EXISTS tmp; - CREATE TEMPORARY TABLE tmp - (INDEX (itemFk)) - ENGINE = MEMORY - SELECT * - FROM ( - SELECT b.itemFk, b.packageFk, b.packing - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDateInv AND vDate - AND NOT b.isIgnored - AND b.price2 >= 0 - AND b.packageFk IS NOT NULL - ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC - ) t GROUP BY itemFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.itemVisible; - CREATE TEMPORARY TABLE tmp.itemVisible - ENGINE = MEMORY - SELECT i.id Id_Article, - SUBSTRING(i.`name`, vPrefixLen) Article, - t.packing, p.id Id_Cubo, - IF(p.depth > 0, p.depth, 0) z, p.width x, p.height y, - CEIL(s.quantity / t.packing) etiquetas - FROM vn.item i - JOIN filter f ON f.itemFk = i.id - JOIN currentStock s ON s.itemFk = i.id - LEFT JOIN tmp t ON t.itemFk = i.id - LEFT JOIN vn.packaging p ON p.id = t.packageFk - WHERE CEIL(s.quantity / t.packing) > 0 - -- FIXME: Column Cubos.box not included in view vn.packaging - /* AND p.box */; - - DROP TEMPORARY TABLE - filter, - currentStock, - tmp; +BEGIN +/** + * Gets visible items of the specified type at specified date. + * + * @param vWarehouse The warehouse id + * @param vDate The visible date + * @param vType The type id + * @param vPrefix The article prefix to filter or %NULL for all + * @return tmp.itemVisible Visible items + */ + DECLARE vPrefixLen SMALLINT; + DECLARE vFilter VARCHAR(255) DEFAULT NULL; + DECLARE vDateInv DATE DEFAULT vn2008.date_inv(); + + SET vPrefixLen = IFNULL(LENGTH(vPrefix), 0) + 1; + + IF vPrefixLen > 1 THEN + SET vFilter = CONCAT(vPrefix, '%'); + END IF; + + DROP TEMPORARY TABLE IF EXISTS filter; + CREATE TEMPORARY TABLE filter + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT id itemFk FROM vn.item + WHERE typeFk = vType + AND (vFilter IS NULL OR `name` LIKE vFilter); + + DROP TEMPORARY TABLE IF EXISTS currentStock; + CREATE TEMPORARY TABLE currentStock + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT itemFk, SUM(quantity) quantity + FROM ( + SELECT b.itemFk, b.quantity + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDateInv AND vDate + AND t.warehouseInFk = vWarehouse + AND NOT e.isRaid + UNION ALL + SELECT b.itemFk, -b.quantity + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.shipped BETWEEN vDateInv AND CURDATE() + AND t.warehouseOutFk = vWarehouse + AND NOT e.isRaid + AND t.isDelivered + UNION ALL + SELECT m.itemFk, -m.quantity + FROM vn.sale m + JOIN vn.ticket t ON t.id = m.ticketFk + JOIN vn.ticketState s ON s.ticket = t.id + WHERE t.shipped BETWEEN vDateInv AND CURDATE() + AND t.warehouseFk = vWarehouse + AND s.alertLevel = 3 + ) t + GROUP BY itemFk + HAVING quantity > 0; + + DROP TEMPORARY TABLE IF EXISTS tmp; + CREATE TEMPORARY TABLE tmp + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT * + FROM ( + SELECT b.itemFk, b.packageFk, b.packing + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vDateInv AND vDate + AND NOT b.isIgnored + AND b.price2 >= 0 + AND b.packageFk IS NOT NULL + ORDER BY t.warehouseInFk = vWarehouse DESC, t.landed DESC + ) t GROUP BY itemFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemVisible; + CREATE TEMPORARY TABLE tmp.itemVisible + ENGINE = MEMORY + SELECT i.id Id_Article, + SUBSTRING(i.`name`, vPrefixLen) Article, + t.packing, p.id Id_Cubo, + IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, + CEIL(s.quantity / t.packing) etiquetas + FROM vn.item i + JOIN filter f ON f.itemFk = i.id + JOIN currentStock s ON s.itemFk = i.id + LEFT JOIN tmp t ON t.itemFk = i.id + LEFT JOIN vn.packaging p ON p.id = t.packageFk + WHERE CEIL(s.quantity / t.packing) > 0 + -- FIXME: Column Cubos.box not included in view vn.packaging + /* AND p.box */; + + DROP TEMPORARY TABLE + filter, + currentStock, + tmp; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -15906,7 +15917,7 @@ CREATE TABLE `cdr` ( KEY `dstchannel` (`dst_channel`), KEY `disposition` (`disposition`), KEY `src` (`src`) -) ENGINE=InnoDB AUTO_INCREMENT=295174 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=298064 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16690,7 +16701,7 @@ CREATE TABLE `address` ( KEY `address_address_type_id_idx` (`address_type_id`), KEY `address_town_id_idx` (`town_id`), CONSTRAINT `address_ibfk_1` FOREIGN KEY (`address_type_id`) REFERENCES `address_type` (`address_type_id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `address_ibfk_2` FOREIGN KEY (`town_id`) REFERENCES `town` (`town_id`) ON DELETE NO ACTION ON UPDATE CASCADE + CONSTRAINT `address_ibfk_2` FOREIGN KEY (`town_id`) REFERENCES `townKk` (`town_id`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=846 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -16737,7 +16748,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=852 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=865 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -16792,7 +16803,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=2743 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2762 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17006,7 +17017,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=70110 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=70134 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17040,7 +17051,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=2120 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2144 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17076,7 +17087,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=1041 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1063 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17156,7 +17167,7 @@ CREATE TABLE `person` ( UNIQUE KEY `nis_UNIQUE` (`nis`), KEY `index1` (`person_id`,`name`,`nickname`,`firstname`), KEY `person_worker` (`id_trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=1088 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1100 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17207,7 +17218,7 @@ CREATE TABLE `profile` ( KEY `profile_person_id_idx` (`person_id`), KEY `profile_profile_type_id_idx` (`profile_type_id`), CONSTRAINT `person_fk` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=972 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=983 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17243,7 +17254,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=1195 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1221 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -17279,20 +17290,20 @@ CREATE TABLE `province` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `town` +-- Table structure for table `townKk` -- -DROP TABLE IF EXISTS `town`; +DROP TABLE IF EXISTS `townKk`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `town` ( +CREATE TABLE `townKk` ( `town_id` int(11) NOT NULL AUTO_INCREMENT, `province_id` int(11) NOT NULL, `name` varchar(30) NOT NULL, `postal_code` varchar(8) NOT NULL, PRIMARY KEY (`town_id`), KEY `town_province_id_idx` (`province_id`), - CONSTRAINT `town_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE CASCADE + CONSTRAINT `townKk_ibfk_1` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=3673 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -17503,7 +17514,7 @@ CREATE TABLE `userConfigView` ( `configuration` text COLLATE utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `uniqueUser_TableCode` (`userFk`,`tableCode`) -) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19532,6 +19543,77 @@ SET character_set_client = utf8; 1 AS `created`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `__itemCategory` +-- + +DROP TABLE IF EXISTS `__itemCategory`; +/*!50001 DROP VIEW IF EXISTS `__itemCategory`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `__itemCategory` AS SELECT + 1 AS `id`, + 1 AS `name`, + 1 AS `display`, + 1 AS `color`, + 1 AS `icon`, + 1 AS `merchandise`, + 1 AS `order`, + 1 AS `shortLife`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `__itemType` +-- + +DROP TABLE IF EXISTS `__itemType`; +/*!50001 DROP VIEW IF EXISTS `__itemType`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `__itemType` AS SELECT + 1 AS `id`, + 1 AS `code`, + 1 AS `name`, + 1 AS `order`, + 1 AS `categoryFk`, + 1 AS `workerFk`, + 1 AS `warehouseFk`, + 1 AS `life`, + 1 AS `isPackaging`, + 1 AS `density`, + 1 AS `roleCodeFk`, + 1 AS `f11`, + 1 AS `isInventory`, + 1 AS `created`, + 1 AS `father`, + 1 AS `transaction`, + 1 AS `making`, + 1 AS `location`, + 1 AS `temperature`, + 1 AS `promo`, + 1 AS `isBox`, + 1 AS `CYM`, + 1 AS `maneuver`, + 1 AS `target`, + 1 AS `topMargin`, + 1 AS `profit`, + 1 AS `isFV`, + 1 AS `hasComponents`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `__observationType` +-- + +DROP TABLE IF EXISTS `__observationType`; +/*!50001 DROP VIEW IF EXISTS `__observationType`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `__observationType` AS SELECT + 1 AS `id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `absenceType` -- @@ -19667,8 +19749,8 @@ CREATE TABLE `addressObservation` ( UNIQUE KEY `Id_Consigna` (`addressFk`,`observationTypeFk`), KEY `addressObservationFgn_idx` (`observationTypeFk`), CONSTRAINT `addressFgn` FOREIGN KEY (`addressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `vn2008`.`observation_type` (`observation_type_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4044 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; + CONSTRAINT `addressObservationFgn` FOREIGN KEY (`observationTypeFk`) REFERENCES `observationType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4058 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Observaciones de los consignatarios'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19844,7 +19926,7 @@ CREATE TABLE `autoRadioLogCall` ( PRIMARY KEY (`id`), KEY `ticket_idx` (`ticketFk`), CONSTRAINT `ticket` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=1225 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1265 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -19917,14 +19999,33 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `bankEntity` +-- Table structure for table `bankEntity` -- DROP TABLE IF EXISTS `bankEntity`; -/*!50001 DROP VIEW IF EXISTS `bankEntity`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bankEntity` ( + `countryFk` mediumint(8) unsigned NOT NULL DEFAULT '1', + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `bic` varchar(11) CHARACTER SET utf8 DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `bic_UNIQUE` (`bic`), + KEY `fg_entity1_idx` (`countryFk`), + CONSTRAINT `fg_entity1` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=30044 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `bankEntity__` +-- + +DROP TABLE IF EXISTS `bankEntity__`; +/*!50001 DROP VIEW IF EXISTS `bankEntity__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `bankEntity` AS SELECT +/*!50001 CREATE VIEW `bankEntity__` AS SELECT 1 AS `id`, 1 AS `countryFk`, 1 AS `name`, @@ -19953,9 +20054,9 @@ CREATE TABLE `bookingPlanner` ( KEY `bookingPlannerTaxArea` (`taxAreaFk`), 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 `vn2008`.`iva_group` (`iva_group_id`) ON DELETE CASCADE, + CONSTRAINT `bookingPlanner_ibfk_2` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `bookingPlanner_ibfk_3` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20039,7 +20140,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 `vn2008`.`Articles` (`Id_Article`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=333384070 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=336356382 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 */ ; @@ -20304,64 +20405,178 @@ CREATE TABLE `chain` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `claim` +-- Table structure for table `claim` -- DROP TABLE IF EXISTS `claim`; -/*!50001 DROP VIEW IF EXISTS `claim`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `claim` AS SELECT - 1 AS `id`, - 1 AS `ticketCreated`, - 1 AS `claimStateFk`, - 1 AS `observation`, - 1 AS `clientFk`, - 1 AS `workerFk`, - 1 AS `responsibility`, - 1 AS `isChargedToMana`, - 1 AS `ticketFk`, - 1 AS `created`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claim` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `ticketCreated` date NOT NULL, + `claimDepartmentFk` tinyint(3) unsigned DEFAULT NULL, + `claimStateFk` int(10) unsigned NOT NULL DEFAULT '1', + `observation` text COLLATE utf8_unicode_ci, + `clientFk` int(11) NOT NULL, + `workerFk` int(11) NOT NULL, + `responsibility` int(1) unsigned NOT NULL DEFAULT '3', + `isChargedToMana` tinyint(1) NOT NULL DEFAULT '0', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `ticketFk` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `cl_dep_id` (`claimDepartmentFk`), + KEY `cl_est_id` (`claimStateFk`), + KEY `Id_Cliente` (`clientFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `cl_main_ticketFk_idx` (`ticketFk`), + CONSTRAINT `cl_main_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON UPDATE CASCADE, + 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 `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=67884 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `claimBeginning` +-- Table structure for table `claimBeginning` -- DROP TABLE IF EXISTS `claimBeginning`; -/*!50001 DROP VIEW IF EXISTS `claimBeginning`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimBeginning` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `claimFk` int(10) unsigned NOT NULL, + `saleFk` int(11) DEFAULT NULL, + `claimComplaintFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimRequestFk` int(1) unsigned NOT NULL DEFAULT '1', + `quantity` double DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `Id_Movimiento` (`saleFk`), + KEY `cl_main_id` (`claimFk`), + CONSTRAINT `claimBeginning_ibfk_7` FOREIGN KEY (`saleFk`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) 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=150836 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 */ ; +/*!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 `vn`.`claimBeginning_afterInsert` + AFTER INSERT ON `claimBeginning` + FOR EACH ROW +BEGIN + DECLARE vTicket INT; + + SELECT ticketFk INTO vTicket + FROM sale + WHERE id = NEW.saleFk; + + UPDATE claim + SET ticketFk = vTicket + WHERE id = NEW.claimFk; +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 `claimBeginning__` +-- + +DROP TABLE IF EXISTS `claimBeginning__`; +/*!50001 DROP VIEW IF EXISTS `claimBeginning__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimBeginning` AS SELECT +/*!50001 CREATE VIEW `claimBeginning__` AS SELECT 1 AS `id`, 1 AS `claimFk`, 1 AS `saleFk`, - 1 AS `quantity`*/; + 1 AS `quantity`, + 1 AS `claimComplaintFk`, + 1 AS `claimRequestFk`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimDestination` +-- Table structure for table `claimDestination` -- DROP TABLE IF EXISTS `claimDestination`; -/*!50001 DROP VIEW IF EXISTS `claimDestination`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimDestination` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `addressFk` int(10) DEFAULT NULL COMMENT 'Indica el consignatario para el ticket que regulariza el inventario', + PRIMARY KEY (`id`), + KEY `clSolAddressFk_idx` (`addressFk`), + CONSTRAINT `clSolAddressFk` FOREIGN KEY (`addressFk`) REFERENCES `vn2008`.`Consignatarios` (`id_consigna`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Solucion ofrecida a la reclamación'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimDestination__` +-- + +DROP TABLE IF EXISTS `claimDestination__`; +/*!50001 DROP VIEW IF EXISTS `claimDestination__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimDestination` AS SELECT +/*!50001 CREATE VIEW `claimDestination__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `addressFk`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimDevelopment` +-- Table structure for table `claimDevelopment` -- DROP TABLE IF EXISTS `claimDevelopment`; -/*!50001 DROP VIEW IF EXISTS `claimDevelopment`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimDevelopment` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `claimFk` int(10) unsigned NOT NULL, + `claimResponsibleFk` int(10) unsigned NOT NULL DEFAULT '1', + `workerFk` int(11) NOT NULL DEFAULT '20', + `claimReasonFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimResultFk` int(10) unsigned NOT NULL DEFAULT '1', + `claimRedeliveryFk` tinyint(3) unsigned NOT NULL DEFAULT '1', + `claimDestinationFk` tinyint(3) unsigned NOT NULL DEFAULT '2', + PRIMARY KEY (`id`), + KEY `cl_main_id` (`claimFk`), + KEY `cl_res_id` (`claimResponsibleFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `cl_mot_id` (`claimReasonFk`), + KEY `cl_con_id` (`claimResultFk`), + KEY `cl_dev` (`claimRedeliveryFk`), + KEY `cl_sol` (`claimDestinationFk`), + CONSTRAINT `claimDevelopment_ibfk_10` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `claimDevelopment_ibfk_11` FOREIGN KEY (`claimRedeliveryFk`) REFERENCES `claimRedelivery` (`id`) ON UPDATE CASCADE, + CONSTRAINT `claimDevelopment_ibfk_12` FOREIGN KEY (`claimDestinationFk`) REFERENCES `claimDestination` (`id`) ON UPDATE CASCADE, + CONSTRAINT `claimDevelopment_ibfk_6` FOREIGN KEY (`claimResponsibleFk`) REFERENCES `claimResponsible` (`id`) ON UPDATE CASCADE, + 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 `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=59053 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimDevelopment__` +-- + +DROP TABLE IF EXISTS `claimDevelopment__`; +/*!50001 DROP VIEW IF EXISTS `claimDevelopment__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimDevelopment` AS SELECT +/*!50001 CREATE VIEW `claimDevelopment__` AS SELECT 1 AS `id`, 1 AS `claimFk`, 1 AS `claimResponsibleFk`, @@ -20373,19 +20588,62 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimEnd` +-- Table structure for table `claimDms` +-- + +DROP TABLE IF EXISTS `claimDms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimDms` ( + `claimFk` int(10) unsigned NOT NULL, + `dmsFk` int(11) NOT NULL, + PRIMARY KEY (`claimFk`,`dmsFk`), + KEY `dmsFk_idx` (`dmsFk`), + CONSTRAINT `claimFk` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `dmsFk` FOREIGN KEY (`dmsFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `claimEnd` -- DROP TABLE IF EXISTS `claimEnd`; -/*!50001 DROP VIEW IF EXISTS `claimEnd`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimEnd` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `saleFk` int(11) DEFAULT NULL, + `claimFk` int(10) unsigned NOT NULL, + `workerFk` int(11) NOT NULL DEFAULT '20', + `claimDestinationFk` tinyint(4) DEFAULT NULL, + `isGreuge` tinyint(4) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `cl_main_id` (`claimFk`), + KEY `Id_Trabajador` (`workerFk`), + KEY `Id_Movimiento` (`saleFk`), + KEY `cl_sol_id` (`claimDestinationFk`), + CONSTRAINT `claimEnd_ibfk_1` FOREIGN KEY (`saleFk`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `claimEnd_ibfk_3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + CONSTRAINT `claimEnd_ibfk_4` FOREIGN KEY (`claimFk`) REFERENCES `claim` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=114742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimEnd__` +-- + +DROP TABLE IF EXISTS `claimEnd__`; +/*!50001 DROP VIEW IF EXISTS `claimEnd__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimEnd` AS SELECT +/*!50001 CREATE VIEW `claimEnd__` AS SELECT 1 AS `id`, 1 AS `saleFk`, 1 AS `claimFk`, 1 AS `workerFk`, - 1 AS `claimDestinationFk`*/; + 1 AS `claimDestinationFk`, + 1 AS `isGreuge`*/; SET character_set_client = @saved_cs_client; -- @@ -20410,7 +20668,7 @@ CREATE TABLE `claimLog` ( PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), - CONSTRAINT `claimOriginFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + 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 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -20433,72 +20691,168 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimReason` +-- Table structure for table `claimReason` -- DROP TABLE IF EXISTS `claimReason`; -/*!50001 DROP VIEW IF EXISTS `claimReason`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimReason` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Motivos de las fallos'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimReason__` +-- + +DROP TABLE IF EXISTS `claimReason__`; +/*!50001 DROP VIEW IF EXISTS `claimReason__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimReason` AS SELECT +/*!50001 CREATE VIEW `claimReason__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimRedelivery` +-- Table structure for table `claimRedelivery` -- DROP TABLE IF EXISTS `claimRedelivery`; -/*!50001 DROP VIEW IF EXISTS `claimRedelivery`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimRedelivery` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Método por el cual el cliente nos devuelve la mercancía'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimRedelivery__` +-- + +DROP TABLE IF EXISTS `claimRedelivery__`; +/*!50001 DROP VIEW IF EXISTS `claimRedelivery__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimRedelivery` AS SELECT +/*!50001 CREATE VIEW `claimRedelivery__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimResponsible` +-- Table structure for table `claimResponsible` -- DROP TABLE IF EXISTS `claimResponsible`; -/*!50001 DROP VIEW IF EXISTS `claimResponsible`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimResponsible` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `responsability` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'if=1 >sensib >culpa', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Responsables de las causas'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimResponsible__` +-- + +DROP TABLE IF EXISTS `claimResponsible__`; +/*!50001 DROP VIEW IF EXISTS `claimResponsible__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimResponsible` AS SELECT +/*!50001 CREATE VIEW `claimResponsible__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `responsability`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimResult` +-- Table structure for table `claimResult` -- DROP TABLE IF EXISTS `claimResult`; -/*!50001 DROP VIEW IF EXISTS `claimResult`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimResult` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Consecuencias de los motivos'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimResult__` +-- + +DROP TABLE IF EXISTS `claimResult__`; +/*!50001 DROP VIEW IF EXISTS `claimResult__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimResult` AS SELECT +/*!50001 CREATE VIEW `claimResult__` AS SELECT 1 AS `id`, 1 AS `description`*/; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `claimState` +-- Table structure for table `claimState` -- DROP TABLE IF EXISTS `claimState`; -/*!50001 DROP VIEW IF EXISTS `claimState`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `claimState` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + `roleFk` int(10) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + KEY `roleFgn_idx` (`roleFk`), + CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Estados posibles de las reclamaciones'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `claimState__` +-- + +DROP TABLE IF EXISTS `claimState__`; +/*!50001 DROP VIEW IF EXISTS `claimState__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `claimState` AS SELECT +/*!50001 CREATE VIEW `claimState__` AS SELECT 1 AS `id`, 1 AS `description`, 1 AS `roleFk`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `claim__` +-- + +DROP TABLE IF EXISTS `claim__`; +/*!50001 DROP VIEW IF EXISTS `claim__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `claim__` AS SELECT + 1 AS `id`, + 1 AS `ticketCreated`, + 1 AS `claimStateFk`, + 1 AS `observation`, + 1 AS `clientFk`, + 1 AS `workerFk`, + 1 AS `responsibility`, + 1 AS `isChargedToMana`, + 1 AS `ticketFk`, + 1 AS `created`, + 1 AS `claimDepartmentFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `client` -- @@ -20590,7 +20944,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=4138 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4142 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20611,7 +20965,7 @@ CREATE TABLE `clientCredit` ( KEY `credit_ClienteFk` (`clientFk`), CONSTRAINT `credit_ClienteFk` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `workers_fk` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80922 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=81334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20682,7 +21036,7 @@ CREATE TABLE `clientLog` ( KEY `userFk` (`userFk`), CONSTRAINT `clientLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `clientLog_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=223630 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=225760 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -20967,19 +21321,6 @@ CREATE TABLE `contactChannel` ( ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Canal por el que nos ha conocido un cliente y se ha dado de'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Temporary table structure for view `contactChannelkk` --- - -DROP TABLE IF EXISTS `contactChannelkk`; -/*!50001 DROP VIEW IF EXISTS `contactChannelkk`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `contactChannelkk` AS SELECT - 1 AS `id`, - 1 AS `name`*/; -SET character_set_client = @saved_cs_client; - -- -- Temporary table structure for view `coolerPath` -- @@ -21170,7 +21511,7 @@ CREATE TABLE `creditClassification` ( KEY `creditClassifClientFk_idx` (`client`), KEY `creditClassifdateEnd_idx` (`dateEnd`), CONSTRAINT `creditClassifClientFk` FOREIGN KEY (`client`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3194 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3205 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 */ ; @@ -21215,7 +21556,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=2894 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; +) ENGINE=InnoDB AUTO_INCREMENT=2931 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 */ ; @@ -21242,17 +21583,35 @@ DELIMITER ; ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; -- --- Temporary table structure for view `currency` +-- Table structure for table `currency` -- DROP TABLE IF EXISTS `currency`; -/*!50001 DROP VIEW IF EXISTS `currency`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `currency` ( + `id` tinyint(3) unsigned NOT NULL, + `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `ratio` double NOT NULL DEFAULT '1', + PRIMARY KEY (`id`), + UNIQUE KEY `Moneda_UNIQUE` (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `currency__` +-- + +DROP TABLE IF EXISTS `currency__`; +/*!50001 DROP VIEW IF EXISTS `currency__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `currency` AS SELECT +/*!50001 CREATE VIEW `currency__` AS SELECT 1 AS `id`, 1 AS `code`, - 1 AS `name`*/; + 1 AS `name`, + 1 AS `ratio`*/; SET character_set_client = @saved_cs_client; -- @@ -21375,9 +21734,53 @@ 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=249 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=261 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `deviceProduction` +-- + +DROP TABLE IF EXISTS `deviceProduction`; +/*!50001 DROP VIEW IF EXISTS `deviceProduction`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `deviceProduction` AS SELECT + 1 AS `id`, + 1 AS `imei`, + 1 AS `macWifi`, + 1 AS `serialNumber`, + 1 AS `departmentFk`, + 1 AS `modelFk`, + 1 AS `isOutOfService`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `deviceProductionModels` +-- + +DROP TABLE IF EXISTS `deviceProductionModels`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `deviceProductionModels` ( + `code` varchar(50) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `deviceProductionUser` +-- + +DROP TABLE IF EXISTS `deviceProductionUser`; +/*!50001 DROP VIEW IF EXISTS `deviceProductionUser`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `deviceProductionUser` AS SELECT + 1 AS `deviceProductionFk`, + 1 AS `userFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `dms` -- @@ -21465,7 +21868,7 @@ CREATE TABLE `dua` ( CONSTRAINT `dua_fk1` FOREIGN KEY (`gestdocFk`) REFERENCES `vn2008`.`gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `dua_fk2` FOREIGN KEY (`awbFk`) REFERENCES `vn2008`.`awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `dua_fk4` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=4086 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4129 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21506,7 +21909,7 @@ CREATE TABLE `duaIntrastat` ( KEY `duaIntrastat_fk2_idx` (`duaFk`), CONSTRAINT `duaIntrastat_fk1` FOREIGN KEY (`intrastatFk`) REFERENCES `vn2008`.`Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `duaIntrastat_fk2` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6586 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=6684 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21526,7 +21929,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=5007 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=5045 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 */; -- @@ -21551,7 +21954,7 @@ CREATE TABLE `duaTax` ( CONSTRAINT `duaTax_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `duaTax_fk2` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `duaTax_fk3` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7919 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8346 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -21687,7 +22090,7 @@ CREATE TABLE `entry` ( CONSTRAINT `entry_ibfk_1` FOREIGN KEY (`supplierFk`) REFERENCES `vn2008`.`Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_6` FOREIGN KEY (`travelFk`) REFERENCES `travel` (`id`) ON UPDATE CASCADE, CONSTRAINT `entry_ibfk_7` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=175669 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='InnoDB free: 88064 kB; (`Id_Proveedor`) REFER `vn2008/Provee'; +) ENGINE=InnoDB AUTO_INCREMENT=176725 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 */ ; @@ -21888,7 +22291,24 @@ 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=158063 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=162003 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `entrySplit` +-- + +DROP TABLE IF EXISTS `entrySplit`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `entrySplit` ( + `receivedFk` int(11) NOT NULL, + `delayedFk` int(11) NOT NULL, + PRIMARY KEY (`receivedFk`,`delayedFk`), + KEY `entrySplit_fk2_idx` (`delayedFk`), + CONSTRAINT `entrySplit_fk1` FOREIGN KEY (`receivedFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `entrySplit_fk2` FOREIGN KEY (`delayedFk`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22232,14 +22652,88 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `greuge` +-- Table structure for table `greuge` -- DROP TABLE IF EXISTS `greuge`; -/*!50001 DROP VIEW IF EXISTS `greuge`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `greuge` ( + `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `clientFk` int(10) unsigned NOT NULL, + `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `amount` decimal(10,2) NOT NULL, + `shipped` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `greugeTypeFk` int(11) DEFAULT NULL, + `ticketFk` int(11) DEFAULT NULL, + PRIMARY KEY (`Id`), + KEY `greuges_type_fk_idx` (`greugeTypeFk`), + KEY `Id_Ticket_Greuge_Ticket_idx` (`ticketFk`), + KEY `Greuges_cliente_idx` (`clientFk`), + CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) 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=3650147 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 */ ; +/*!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 `vn`.`greuge_beforeUpdate` BEFORE UPDATE ON `greuge` FOR EACH ROW +BEGIN + DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,CURDATE()); + + IF NEW.shipped > vMaxDate THEN + SET NEW.shipped = vMaxDate; + 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 */ ; + +-- +-- Table structure for table `greugeType` +-- + +DROP TABLE IF EXISTS `greugeType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `greugeType` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` 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 */; + +-- +-- 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 `greuge` AS SELECT +/*!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`, @@ -22250,19 +22744,6 @@ SET character_set_client = utf8; 1 AS `ticketFk`*/; 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 `holiday` -- @@ -22405,7 +22886,7 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18557 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19742 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22676,7 +23157,7 @@ CREATE TABLE `invoiceOutExpence` ( KEY `invoiceOutExpence_FK_2_idx` (`expenceFk`), CONSTRAINT `invoiceOutExpence_FK_1` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutExpence_FK_2` FOREIGN KEY (`expenceFk`) REFERENCES `vn2008`.`Gastos` (`Id_Gasto`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=126786 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=126986 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 */; -- @@ -22719,7 +23200,7 @@ CREATE TABLE `invoiceOutTax` ( KEY `pgcFk` (`pgcFk`), CONSTRAINT `invoiceOutFk` FOREIGN KEY (`invoiceOutFk`) REFERENCES `vn2008`.`Facturas` (`factura_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceOutTax_ibfk_1` FOREIGN KEY (`pgcFk`) REFERENCES `pgc` (`code`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1144052 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1144269 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22771,7 +23252,8 @@ SET character_set_client = utf8; 1 AS `value10`, 1 AS `minimum`, 1 AS `upToDown`, - 1 AS `compression`*/; + 1 AS `compression`, + 1 AS `hasKgPrice`*/; SET character_set_client = @saved_cs_client; -- @@ -22817,23 +23299,25 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemCategory` +-- Table structure for table `itemCategory` -- DROP TABLE IF EXISTS `itemCategory`; -/*!50001 DROP VIEW IF EXISTS `itemCategory`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemCategory` AS SELECT - 1 AS `id`, - 1 AS `name`, - 1 AS `display`, - 1 AS `color`, - 1 AS `icon`, - 1 AS `merchandise`, - 1 AS `order`, - 1 AS `shortLife`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemCategory` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + `order` int(10) unsigned DEFAULT NULL, + `display` tinyint(4) NOT NULL DEFAULT '1', + `color` char(6) COLLATE utf8_unicode_ci DEFAULT NULL, + `shortLife` int(11) NOT NULL DEFAULT '0' COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', + `merchandise` tinyint(1) NOT NULL DEFAULT '1', + `icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `reino_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `itemCategoryI18n` @@ -22917,7 +23401,7 @@ CREATE TABLE `itemLog` ( KEY `itemLogUserFk_idx` (`userFk`), CONSTRAINT `itemLogItemFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) 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=58559 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=65272 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -22960,7 +23444,7 @@ CREATE TABLE `itemPlacementSupply` ( CONSTRAINT `itemPlacementSupply_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemPlacementSupply_fk3` FOREIGN KEY (`repoUserFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=48601 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de nichos de picking que hay que reponer'; +) ENGINE=InnoDB AUTO_INCREMENT=53941 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 */; -- @@ -22972,6 +23456,32 @@ DROP TABLE IF EXISTS `itemPlacementSupplyList`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `itemPlacementSupplyList` AS SELECT + 1 AS `id`, + 1 AS `itemFk`, + 1 AS `quantity`, + 1 AS `priority`, + 1 AS `created`, + 1 AS `userFk`, + 1 AS `repoUserFk`, + 1 AS `saldo`, + 1 AS `longName`, + 1 AS `subName`, + 1 AS `size`, + 1 AS `workerCode`, + 1 AS `repoCode`, + 1 AS `parking`, + 1 AS `sectorFk`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `itemPlacementSupplyList__` +-- + +DROP TABLE IF EXISTS `itemPlacementSupplyList__`; +/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemPlacementSupplyList__` AS SELECT 1 AS `id`, 1 AS `itemFk`, 1 AS `quantity`, @@ -23032,7 +23542,7 @@ CREATE TABLE `itemShelving` ( CONSTRAINT `itemShelving_fk1` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk2` FOREIGN KEY (`shelvingFk`) REFERENCES `shelving` (`code`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelving_fk3` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=107600 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=111723 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 */; -- @@ -23063,37 +23573,8 @@ SET character_set_client = utf8; 1 AS `shipped`, 1 AS `grouping`, 1 AS `packing`, - 1 AS `hour`*/; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `itemShelvingAvailableKk` --- - -DROP TABLE IF EXISTS `itemShelvingAvailableKk`; -/*!50001 DROP VIEW IF EXISTS `itemShelvingAvailableKk`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemShelvingAvailableKk` AS SELECT - 1 AS `saleFk`, - 1 AS `Modificado`, - 1 AS `ticketFk`, - 1 AS `isPicked`, - 1 AS `itemFk`, - 1 AS `quantity`, - 1 AS `concept`, - 1 AS `size`, - 1 AS `Estado`, - 1 AS `sectorProdPriority`, - 1 AS `available`, - 1 AS `sectorFk`, - 1 AS `matricula`, - 1 AS `parking`, - 1 AS `itemShelving`, - 1 AS `Agency`, - 1 AS `shipped`, - 1 AS `grouping`, - 1 AS `packing`*/; + 1 AS `hour`, + 1 AS `isPreviousPreparable`*/; SET character_set_client = @saved_cs_client; -- @@ -23137,7 +23618,7 @@ CREATE TABLE `itemShelvingPlacementSupply` ( KEY `itemShelvingPlacementSupply_fk3_idx` (`userFk`), CONSTRAINT `itemShelvingPlacementSupply_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingPlacementSupply_fk2` FOREIGN KEY (`itemPlacementSupplyFk`) REFERENCES `itemPlacementSupply` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=45648 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Detalle de los itemShelving afectados por las ordenes de reposicion de nicho'; +) ENGINE=InnoDB AUTO_INCREMENT=50804 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 */; -- @@ -23184,9 +23665,25 @@ CREATE TABLE `itemShelvingSale` ( CONSTRAINT `itemShelvingSale_fk1` FOREIGN KEY (`itemShelvingFk`) REFERENCES `itemShelving` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk2` FOREIGN KEY (`saleFk`) REFERENCES `vn2008`.`Movimientos` (`Id_Movimiento`) ON UPDATE CASCADE, CONSTRAINT `itemShelvingSale_fk3` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18470 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=20927 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 */; +-- +-- Temporary table structure for view `itemShelvingSaleSum` +-- + +DROP TABLE IF EXISTS `itemShelvingSaleSum`; +/*!50001 DROP VIEW IF EXISTS `itemShelvingSaleSum`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `itemShelvingSaleSum` AS SELECT + 1 AS `id`, + 1 AS `itemShelvingFk`, + 1 AS `saleFk`, + 1 AS `quantity`, + 1 AS `created`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `itemShelvingStock` -- @@ -23201,7 +23698,9 @@ SET character_set_client = utf8; 1 AS `packing`, 1 AS `sector`, 1 AS `visibleOriginal`, - 1 AS `removed`*/; + 1 AS `removed`, + 1 AS `sectorFk`, + 1 AS `warehouseFk`*/; SET character_set_client = @saved_cs_client; -- @@ -23219,14 +23718,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemShelvingStock_beta` +-- Temporary table structure for view `itemShelvingStock__` -- -DROP TABLE IF EXISTS `itemShelvingStock_beta`; -/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_beta`*/; +DROP TABLE IF EXISTS `itemShelvingStock__`; +/*!50001 DROP VIEW IF EXISTS `itemShelvingStock__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemShelvingStock_beta` AS SELECT +/*!50001 CREATE VIEW `itemShelvingStock__` AS SELECT 1 AS `itemFk`, 1 AS `visible`, 1 AS `packing`, @@ -23235,20 +23734,6 @@ SET character_set_client = utf8; 1 AS `removed`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `itemShelvingStock_old` --- - -DROP TABLE IF EXISTS `itemShelvingStock_old`; -/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_old`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemShelvingStock_old` AS SELECT - 1 AS `itemFk`, - 1 AS `visible`, - 1 AS `packing`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `itemTag` -- @@ -23271,7 +23756,7 @@ CREATE TABLE `itemTag` ( KEY `itemFk_2` (`itemFk`,`tagFk`,`intValue`), CONSTRAINT `itemTagItemFk` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `itemTagTagFk` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1294187 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1307755 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 */ ; @@ -23416,7 +23901,7 @@ CREATE TABLE `itemTaxCountry` ( CONSTRAINT `countryFK_paises` FOREIGN KEY (`countryFk`) REFERENCES `vn2008`.`Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `itemFK_Article` FOREIGN KEY (`itemFk`) REFERENCES `vn2008`.`Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `taxClassFK_Iva_Group` FOREIGN KEY (`taxClassFk`) REFERENCES `vn2008`.`iva_group` (`iva_group_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=810273 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Define la clase de iva por artículo y pais'; +) ENGINE=InnoDB AUTO_INCREMENT=820488 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 */; -- @@ -23443,25 +23928,87 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `itemType` +-- Table structure for table `itemType` -- DROP TABLE IF EXISTS `itemType`; -/*!50001 DROP VIEW IF EXISTS `itemType`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `itemType` AS SELECT - 1 AS `id`, - 1 AS `code`, - 1 AS `name`, - 1 AS `categoryFk`, - 1 AS `life`, - 1 AS `workerFk`, - 1 AS `warehouseFk`, - 1 AS `isPackaging`, - 1 AS `density`, - 1 AS `order`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemType` ( + `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, + `code` varchar(3) COLLATE utf8_unicode_ci NOT NULL, + `name` varchar(30) COLLATE utf8_unicode_ci NOT NULL, + `order` int(11) DEFAULT '0', + `temperature` tinyint(1) unsigned NOT NULL DEFAULT '0', + `categoryFk` int(10) unsigned NOT NULL, + `workerFk` int(11) NOT NULL, + `isInventory` tinyint(4) NOT NULL DEFAULT '1', + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `f11` tinyint(4) NOT NULL DEFAULT '0', + `father` smallint(5) DEFAULT NULL, + `transaction` tinyint(4) NOT NULL DEFAULT '0', + `making` int(10) unsigned DEFAULT NULL, + `location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, + `life` smallint(5) unsigned DEFAULT NULL, + `maneuver` double NOT NULL DEFAULT '0.21', + `target` double NOT NULL DEFAULT '0.15', + `topMargin` double NOT NULL DEFAULT '0.3', + `profit` double NOT NULL DEFAULT '0.02', + `isFV` tinyint(3) DEFAULT '1', + `density` double NOT NULL DEFAULT '167' COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', + `promo` double NOT NULL DEFAULT '0', + `isBox` tinyint(4) NOT NULL DEFAULT '0', + `CYM` int(11) NOT NULL DEFAULT '0', + `isPackaging` tinyint(1) NOT NULL DEFAULT '0', + `hasComponents` tinyint(1) NOT NULL DEFAULT '1', + `roleCodeFk` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', + PRIMARY KEY (`code`), + UNIQUE KEY `tipo_id_UNIQUE` (`id`), + UNIQUE KEY `Tipo_UNIQUE` (`name`,`categoryFk`), + KEY `Trabajador` (`workerFk`), + KEY `reino_id` (`categoryFk`), + KEY `Tipos_fk3_idx` (`making`), + KEY `tipos_fk4_idx` (`roleCodeFk`), + KEY `warehouseFk5_idx` (`warehouseFk`), + CONSTRAINT `Tipos_fk3` FOREIGN KEY (`making`) REFERENCES `confectionType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `Trabajador` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, + 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 `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=280 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 */ ; +/*!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 `vn`.`itemType_beforeUpdate` BEFORE UPDATE ON `itemType` FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN + /* + Jgallego 12-08-2019 + + DECLARE strCOD VARCHAR(40); + + SELECT CodigoRojo INTO strCOD FROM tblContadores LIMIT 1; + IF strCOD <> 'tipos' + THEN + SET NEW.maneuver = OLD.maneuver ; + SET NEW.target = OLD.target ; + SET NEW.top_margin = OLD.top_margin ; + SET NEW.profit = OLD.profit ; + 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 */ ; -- -- Table structure for table `itemTypeI18n` @@ -23508,7 +24055,7 @@ CREATE TABLE `itemTypeTag` ( KEY `itemTypeTagTipo_idx` (`itemTypeFk`), KEY `itemTypeTagTag_idx` (`tagFk`), CONSTRAINT `itemTypeTagTag` FOREIGN KEY (`tagFk`) REFERENCES `tag` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, - CONSTRAINT `itemTypeTagTipos` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE NO ACTION ON UPDATE NO ACTION + CONSTRAINT `itemTypeTagTipos` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -23603,14 +24150,90 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `mandate` +-- Table structure for table `mandate` -- DROP TABLE IF EXISTS `mandate`; -/*!50001 DROP VIEW IF EXISTS `mandate`*/; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mandate` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `companyFk` smallint(5) unsigned NOT NULL, + `code` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, + `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `finished` timestamp NULL DEFAULT NULL, + `mandateTypeFk` smallint(5) NOT NULL, + PRIMARY KEY (`id`), + KEY `mandato_fgkey1_idx` (`clientFk`), + KEY `mandato_fgkey2_idx` (`companyFk`), + KEY `mandato_fgkey3_idx` (`mandateTypeFk`), + CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`clientFk`) REFERENCES `vn2008`.`Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`companyFk`) REFERENCES `vn2008`.`empresa` (`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=16862 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 `vn`.`mandate_beforeInsert` + BEFORE INSERT ON `mandate` + FOR EACH ROW +BEGIN + IF (NEW.code IS NULL) THEN + SET NEW.code=CONCAT(NEW.clientFk,'-',(SELECT AUTO_INCREMENT + FROM information_schema.TABLES + WHERE TABLE_SCHEMA='vn' and TABLE_NAME='mandate')); + 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 */ ; + +-- +-- Table structure for table `mandateType` +-- + +DROP TABLE IF EXISTS `mandateType`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `mandateType` ( + `id` smallint(5) NOT NULL AUTO_INCREMENT, + `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `mandateType__` +-- + +DROP TABLE IF EXISTS `mandateType__`; +/*!50001 DROP VIEW IF EXISTS `mandateType__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `mandate` AS SELECT +/*!50001 CREATE VIEW `mandateType__` AS SELECT + 1 AS `id`, + 1 AS `name`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `mandate__` +-- + +DROP TABLE IF EXISTS `mandate__`; +/*!50001 DROP VIEW IF EXISTS `mandate__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `mandate__` AS SELECT 1 AS `id`, 1 AS `clientFk`, 1 AS `companyFk`, @@ -23620,19 +24243,6 @@ SET character_set_client = utf8; 1 AS `mandateTypeFk`*/; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `mandateType` --- - -DROP TABLE IF EXISTS `mandateType`; -/*!50001 DROP VIEW IF EXISTS `mandateType`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `mandateType` AS SELECT - 1 AS `id`, - 1 AS `name`*/; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `manuscript` -- @@ -23677,7 +24287,7 @@ CREATE TABLE `medicalReview` ( `centerFk` int(11) NOT NULL, `date` date DEFAULT NULL, `time` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL, - `fit` tinyint(1) DEFAULT NULL, + `isFit` tinyint(1) DEFAULT NULL, `amount` double DEFAULT NULL, `invoice` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, `remark` longtext COLLATE utf8_unicode_ci, @@ -23686,7 +24296,7 @@ CREATE TABLE `medicalReview` ( KEY `frgnkWorker_idx` (`workerFk`), CONSTRAINT `frgcenter` FOREIGN KEY (`centerFk`) REFERENCES `medicalCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnkWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=274 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=304 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23707,7 +24317,7 @@ CREATE TABLE `message` ( KEY `sender` (`sender`), KEY `recipient` (`recipient`), KEY `uuid` (`uuid`(8)) -) ENGINE=InnoDB AUTO_INCREMENT=1947371 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1961608 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23729,7 +24339,7 @@ CREATE TABLE `messageInbox` ( PRIMARY KEY (`id`), KEY `uuid` (`uuid`(8)), KEY `finalRecipient` (`finalRecipient`) -) ENGINE=InnoDB AUTO_INCREMENT=2118599 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2133578 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23785,17 +24395,18 @@ CREATE TABLE `noticeSubscription` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Temporary table structure for view `observationType` +-- Table structure for table `observationType` -- DROP TABLE IF EXISTS `observationType`; -/*!50001 DROP VIEW IF EXISTS `observationType`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `observationType` AS SELECT - 1 AS `id`, - 1 AS `description`*/; -SET character_set_client = @saved_cs_client; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `observationType` ( + `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, + `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; -- -- Temporary table structure for view `orderTicket` @@ -23907,7 +24518,7 @@ CREATE TABLE `packageChecked` ( PRIMARY KEY (`id`), UNIQUE KEY `entryFk_UNIQUE` (`itemFk`), KEY `fkItem_idx` (`itemFk`) -) ENGINE=InnoDB AUTO_INCREMENT=1254 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1675 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -23952,8 +24563,8 @@ SET character_set_client = utf8; 1 AS `id`, 1 AS `volume`, 1 AS `width`, - 1 AS `height`, 1 AS `depth`, + 1 AS `height`, 1 AS `isPackageReturnable`, 1 AS `created`, 1 AS `itemFk`, @@ -23979,7 +24590,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=25455 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Tabla con los parkings del altillo'; +) ENGINE=InnoDB AUTO_INCREMENT=26175 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 */ ; @@ -24252,6 +24863,101 @@ CREATE TABLE `postCode` ( CONSTRAINT `postCodeTownFk` FOREIGN KEY (`townFk`) REFERENCES `town` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE ) ENGINE=InnoDB 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`.`postCode_beforeInsert` + BEFORE INSERT ON `postCode` FOR EACH ROW +BEGIN + DECLARE vParentFk INT; + + SELECT geoFk INTO vParentFk + FROM town WHERE id = NEW.townFk; + + SET NEW.geoFk = zoneGeo_new('postCode', NEW.`code`, vParentFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`postCode_beforeUpdate` + BEFORE UPDATE ON `postCode` FOR EACH ROW +BEGIN + -- IF !(OLD.geoFk <=> NEW.geoFk) THEN + -- CALL zoneGeo_check; + -- END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`postCode_afterUpdate` + AFTER UPDATE ON `postCode` FOR EACH ROW +BEGIN + DECLARE vParentFk INT; + + IF !(OLD.`code` <=> NEW.`code`) THEN + UPDATE zoneGeo SET `name` = NEW.`code` + WHERE id = NEW.geoFk; + END IF; + + IF !(OLD.townFk <=> NEW.townFk) THEN + SELECT geoFk INTO vParentFk + FROM town WHERE id = NEW.townFk; + + CALL zoneGeo_setParent(NEW.geoFk, vParentFk); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`postCode_afterDelete` + AFTER DELETE ON `postCode` FOR EACH ROW +BEGIN + CALL zoneGeo_delete(OLD.geoFk); +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 `preparationException` @@ -24285,7 +24991,7 @@ CREATE TABLE `priceBuilderKk` ( PRIMARY KEY (`id`), KEY `priceBuilder_fk1_idx` (`itemTypeFk`), KEY `priceBuilder_fk2_idx` (`userFk`), - CONSTRAINT `priceBuilder_fk1` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn2008`.`Tipos` (`tipo_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `priceBuilder_fk1` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `priceBuilder_fk2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -24639,21 +25345,6 @@ CREATE TABLE `referenceRateConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `responsibleMedia` --- - -DROP TABLE IF EXISTS `responsibleMedia`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `responsibleMedia` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `value` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Table to save all responsible people phones', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `role` -- @@ -24728,7 +25419,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 `vn2008`.`Trabajadores` (`Id_Trabajador`) -) ENGINE=InnoDB AUTO_INCREMENT=734 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=782 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -24831,7 +25522,7 @@ CREATE TABLE `routeLog` ( KEY `userFk` (`userFk`), CONSTRAINT `routeLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Rutas` (`Id_Ruta`) 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=82936 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=99936 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25026,6 +25717,23 @@ DROP TABLE IF EXISTS `saleVolume`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `saleVolume` AS SELECT + 1 AS `ticketFk`, + 1 AS `saleFk`, + 1 AS `litros`, + 1 AS `routeFk`, + 1 AS `shipped`, + 1 AS `volume`*/; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `saleVolume__` +-- + +DROP TABLE IF EXISTS `saleVolume__`; +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `saleVolume__` AS SELECT 1 AS `ticketFk`, 1 AS `saleFk`, 1 AS `litros`*/; @@ -25061,7 +25769,7 @@ CREATE TABLE `sector` ( PRIMARY KEY (`id`,`warehouseFk`), KEY `sector_fk1_idx` (`warehouseFk`), CONSTRAINT `sector_fk1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25109,7 +25817,7 @@ CREATE TABLE `shelving` ( `parkingFk` int(11) DEFAULT NULL, `isPrinted` tinyint(4) NOT NULL DEFAULT '0', `priority` int(11) DEFAULT NULL, - `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `parked` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`code`), KEY `shelving_fk1_idx` (`parkingFk`), CONSTRAINT `shelving_fk1` FOREIGN KEY (`parkingFk`) REFERENCES `parking` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -25127,12 +25835,12 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`shelving_BEFORE_UPDATE` BEFORE UPDATE ON `shelving` FOR EACH ROW BEGIN - IF OLD.parkingFk != NEW.parkingFk THEN +/* IF OLD.parkingFk != NEW.parkingFk THEN SET NEW.parked = NOW(); END IF; - +*/ END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -25158,7 +25866,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=142701 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=144655 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25301,7 +26009,8 @@ SET character_set_client = utf8; 1 AS `order`, 1 AS `alertLevel`, 1 AS `code`, - 1 AS `sectorProdPriority`*/; + 1 AS `sectorProdPriority`, + 1 AS `isPreviousPreparable`*/; SET character_set_client = @saved_cs_client; -- @@ -25323,7 +26032,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=763556 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=779069 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25424,7 +26133,7 @@ CREATE TABLE `tag` ( PRIMARY KEY (`id`), KEY `tagEdiTypeFkIdx` (`ediTypeFk`), CONSTRAINT `fgnTag` FOREIGN KEY (`ediTypeFk`) REFERENCES `edi`.`type` (`type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; +) ENGINE=InnoDB AUTO_INCREMENT=109 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25681,7 +26390,7 @@ CREATE TABLE `ticketLog` ( KEY `logTicketuserFk` (`userFk`), CONSTRAINT `ticketLog_ibfk_1` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketLog_user` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6860491 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=7020289 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -25753,7 +26462,7 @@ CREATE TABLE `ticketPackaging` ( CONSTRAINT `ticketPackaging_fk1` FOREIGN KEY (`ticketFk`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk2` FOREIGN KEY (`packagingFk`) REFERENCES `vn2008`.`Cubos` (`Id_Cubo`) ON UPDATE CASCADE, CONSTRAINT `ticketPackaging_fk3` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=69862 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=71087 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 */ ; @@ -25876,7 +26585,8 @@ SET character_set_client = utf8; 1 AS `alertLevel`, 1 AS `code`, 1 AS `ticket`, - 1 AS `worker`*/; + 1 AS `worker`, + 1 AS `isPreviousPreparable`*/; SET character_set_client = @saved_cs_client; -- @@ -26081,8 +26791,103 @@ CREATE TABLE `town` ( KEY `name_idx` (`name`), KEY `townProvinceFk` (`provinceFk`), CONSTRAINT `townProvinceFk` FOREIGN KEY (`provinceFk`) REFERENCES `vn2008`.`province` (`province_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=108465 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=108472 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`.`town_beforeInsert` + BEFORE INSERT ON `town` FOR EACH ROW +BEGIN + DECLARE vParentFk INT; + + SELECT geoFk INTO vParentFk + FROM province WHERE id = NEW.provinceFk; + + SET NEW.geoFk = zoneGeo_new('town', NEW.`name`, vParentFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`town_beforeUpdate` + BEFORE UPDATE ON `town` FOR EACH ROW +BEGIN + IF !(OLD.geoFk <=> NEW.geoFk) THEN + CALL zoneGeo_check; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`town_afterUpdate` + AFTER UPDATE ON `town` FOR EACH ROW +BEGIN + DECLARE vParentFk INT; + + IF !(OLD.`name` <=> NEW.`name`) THEN + UPDATE zoneGeo SET `name` = NEW.`name` + WHERE id = NEW.geoFk; + END IF; + + IF !(OLD.provinceFk <=> NEW.provinceFk) THEN + SELECT geoFk INTO vParentFk + FROM province WHERE id = NEW.provinceFk; + + CALL zoneGeo_setParent(NEW.geoFk, vParentFk); + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`town_afterDelete` + AFTER DELETE ON `town` FOR EACH ROW +BEGIN + CALL zoneGeo_delete(OLD.geoFk); +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 */ ; -- -- Table structure for table `trainingCenter` @@ -26115,6 +26920,7 @@ CREATE TABLE `trainingCourse` ( `invoice` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `amount` double DEFAULT NULL, `remark` longtext COLLATE utf8_unicode_ci, + `hasDiscount` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `frgnWorker_idx` (`workerFk`), KEY `frgnCenter_idx` (`centerFk`), @@ -26122,7 +26928,7 @@ CREATE TABLE `trainingCourse` ( CONSTRAINT `frgnCenter` FOREIGN KEY (`centerFk`) REFERENCES `trainingCenter` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnTrainingCourseType` FOREIGN KEY (`trainingCourseTypeFk`) REFERENCES `trainingCourseType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `frgnWorker` FOREIGN KEY (`workerFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=317 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Lista de trabajadores que han realizado una formación'; +) ENGINE=InnoDB AUTO_INCREMENT=342 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 */; -- @@ -26174,7 +26980,7 @@ CREATE TABLE `travel` ( CONSTRAINT `travel_ibfk_2` FOREIGN KEY (`warehouseOutFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_ibfk_3` FOREIGN KEY (`agencyFk`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) 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=136282 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=137924 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 */ ; @@ -26286,6 +27092,25 @@ CREATE TABLE `travelRecalc` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Travels to recalc it''s entry count'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Temporary table structure for view `travel_cloneWeekly` +-- + +DROP TABLE IF EXISTS `travel_cloneWeekly`; +/*!50001 DROP VIEW IF EXISTS `travel_cloneWeekly`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `travel_cloneWeekly` AS SELECT + 1 AS `id`, + 1 AS `warehouseOutFk`, + 1 AS `warehouseInFk`, + 1 AS `agencyModeFk`, + 1 AS `weekDay`, + 1 AS `duration`, + 1 AS `ref`, + 1 AS `cargoSupplierFk`*/; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `unary` -- @@ -26421,13 +27246,19 @@ SET character_set_client = utf8; /*!50001 CREATE VIEW `warehouse` AS SELECT 1 AS `id`, 1 AS `name`, - 1 AS `isInventory`, 1 AS `isFeedStock`, - 1 AS `isComparative`, - 1 AS `hasComission`, + 1 AS `addressName`, + 1 AS `delay`, 1 AS `hasAvailable`, + 1 AS `isForTicket`, + 1 AS `countryFk`, + 1 AS `isZoneLabel`, + 1 AS `hasComission`, + 1 AS `isInventory`, + 1 AS `isComparative`, + 1 AS `valuatedInventory`, 1 AS `isManaged`, - 1 AS `isForTicket`*/; + 1 AS `hasConfectionTeam`*/; SET character_set_client = @saved_cs_client; -- @@ -26597,7 +27428,22 @@ CREATE TABLE `workerDocument` ( KEY `workerDocument_ibfk_2` (`document`), CONSTRAINT `workerDocument_ibfk_1` FOREIGN KEY (`worker`) REFERENCES `vn2008`.`Trabajadores` (`user_id`) ON UPDATE CASCADE, CONSTRAINT `workerDocument_ibfk_2` FOREIGN KEY (`document`) REFERENCES `vn2008`.`gestdoc` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=11914 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12067 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `workerEmergencyBoss` +-- + +DROP TABLE IF EXISTS `workerEmergencyBoss`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `workerEmergencyBoss` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `value` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Table to save all responsible people phones', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26647,7 +27493,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=46854826 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=47892616 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26686,7 +27532,7 @@ CREATE TABLE `workerLog` ( KEY `userFk_idx` (`userFk`), CONSTRAINT `userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `workerFk` FOREIGN KEY (`originFk`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=13327 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=13471 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26749,7 +27595,7 @@ CREATE TABLE `workerTimeControl` ( KEY `warehouseFkfk1_idx` (`warehouseFk`), CONSTRAINT `warehouseFk_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `workerTimeControl_fk1` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7396726 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; +) ENGINE=InnoDB AUTO_INCREMENT=7713879 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Fichadas'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -26833,6 +27679,7 @@ SET character_set_client = utf8; 1 AS `phone`, 1 AS `workerPhone`, 1 AS `department`, + 1 AS `workerCenter`, 1 AS `maxOrder`*/; SET character_set_client = @saved_cs_client; @@ -27069,7 +27916,7 @@ CREATE TABLE `zone` ( KEY `zone_name_idx` (`name`), CONSTRAINT `fk_zone_1` FOREIGN KEY (`warehouseFk`) REFERENCES `vn2008`.`warehouse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `vn2008`.`Agencias` (`Id_Agencia`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=405 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=411 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27097,16 +27944,35 @@ DROP TABLE IF EXISTS `zoneGeo`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `zoneGeo` ( - `id` int(11) NOT NULL, + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` set('country','province','town','postCode') CHARACTER SET utf8 NOT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `parentFk` int(10) unsigned DEFAULT NULL, + `path` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `lft` int(11) DEFAULT NULL, `rgt` int(11) DEFAULT NULL, `depth` bigint(22) NOT NULL DEFAULT '0', `sons` decimal(10,0) DEFAULT NULL, PRIMARY KEY (`id`), KEY `lft_rgt_depth_idx` (`lft`,`rgt`,`depth`), - KEY `name_idx` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + KEY `name_idx` (`name`), + KEY `parentFk` (`parentFk`), + KEY `path` (`path`) +) ENGINE=InnoDB AUTO_INCREMENT=110112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `zoneGeoRecalc` +-- + +DROP TABLE IF EXISTS `zoneGeoRecalc`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zoneGeoRecalc` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `isChanged` tinyint(4) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -27127,6 +27993,22 @@ CREATE TABLE `zoneIncluded` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `zoneIncludedBackup` +-- + +DROP TABLE IF EXISTS `zoneIncludedBackup`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `zoneIncludedBackup` ( + `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, + `newName` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL, + `provinceFk` smallint(6) unsigned NOT NULL, + `zoneFk` int(11) NOT NULL, + `isIncluded` tinyint(1) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Dumping events for database 'vn' -- @@ -27261,6 +28143,24 @@ DELIMITER ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `zoneGeo_doCalc` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`%`*/ /*!50106 EVENT `zoneGeo_doCalc` ON SCHEDULE EVERY 15 SECOND STARTS '2019-09-13 15:30:47' ON COMPLETION PRESERVE DISABLE DO CALL vn.zoneGeo_doCalc */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; DELIMITER ; /*!50106 SET TIME_ZONE= @save_time_zone */ ; @@ -29033,9 +29933,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 ;; @@ -29054,7 +29954,7 @@ BEGIN SELECT SUM(IF(p.volume > 0, p.volume, - p.width * p.height * IF(p.depth = 0, i.size + 10, p.depth) + p.width * p.depth * IF(p.height, p.height, i.size + 10) )) INTO vVolume FROM packaging p JOIN item i ON i.id = vSelf @@ -29521,7 +30421,7 @@ BEGIN WHERE s.ticketFk = vTicketId; */ SELECT sum(volume) INTO vVolume - FROM ticketGetVolume + FROM saleVolume WHERE ticketFk = vTicketId; RETURN vVolume; @@ -29548,7 +30448,7 @@ BEGIN /* * Devuelve el volumen estimado del ticket sumado, en cajas * - * idT Numero de ticket + * vTicketId Numero de ticket * */ @@ -29653,6 +30553,37 @@ 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 `zoneGeo_new` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` FUNCTION `zoneGeo_new`(vType VARCHAR(255), vName VARCHAR(255), vParentFk INT) RETURNS int(11) + NO SQL +BEGIN + DECLARE vSelf INT; + + INSERT INTO zoneGeo + SET `type` = vType, + `name` = vName, + parentFk = vParentFk; + + SET vSelf = LAST_INSERT_ID(); + + UPDATE zoneGeoRecalc SET isChanged = TRUE; + + RETURN vSelf; +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 `addNoteFromDelivery` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -30555,6 +31486,273 @@ proc: BEGIN 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, + IF(i.hasKgPrice,(b.packing * b.weight) / 1000, NULL) weightPacking + 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, + CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightPacking priceKg + 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, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 2 rate, + tcc.packing grouping, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightPacking priceKg + 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, priceKg) + SELECT + tcc.warehouseFk, + tcc.itemFk, + 3 rate, + tcc.available grouping, + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightPacking priceKg + 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 `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'; @@ -30802,12 +32000,10 @@ BEGIN DELETE FROM vn.workerTimeControl WHERE timed < fourYearsAgo; DELETE FROM vn.itemShelving WHERE created < CURDATE() AND visible = 0; - UPDATE vn.shelving s - LEFT JOIN vn.itemShelving it ON it.shelvingFk = s.code - SET it.visible = 0 - WHERE it.shelvingFk IS NULL; + CALL shelving_clean; - CALL vn.ticketPackagingRecovery; + CALL vn.ticketPackagingRecovery; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -32985,6 +34181,52 @@ 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 `entrySplit_move` */; +/*!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 `entrySplit_move`() +BEGIN + + /* CREATED PAK 08/09/2019 + * PENDING REVIEW + * + * + */ + + DROP TEMPORARY TABLE IF EXISTS itemList; + + CREATE TEMPORARY TABLE itemList + SELECT DISTINCT b.itemFk, es.delayedFk, es.receivedFk + FROM vn.buy b + JOIN vn.entrySplit es ON es.delayedFk = b.entryFk + JOIN vn.itemPlacement ip ON ip.itemFk = b.itemFk + WHERE ip.modificationDate > CURDATE(); + + INSERT INTO itemList + SELECT DISTINCT ish.itemFk, es.delayedFk, es.receivedFk + FROM vn.buy b + JOIN vn.entrySplit es ON es.delayedFk = b.entryFk + JOIN vn.itemShelving ish ON ish.itemFk = b.itemFk + WHERE ish.created > CURDATE(); + + + UPDATE vn.buy b + JOIN vn.itemList il ON il.delayedFk = b.entryFk AND b.itemFk = il.itemFk + SET b.entryFk = il.receivedFk; + +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 `entryWithItem` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -33129,10 +34371,12 @@ BEGIN INNER JOIN ticket t on t.id = exp.ticketFk WHERE exp.id = vExpeditionFk; -SELECT exp.id, exp.ticketFk, exp.checked, t.routeFk , ts.alertLevel +SELECT exp.id, exp.ticketFk, exp.checked, t.routeFk,t.packages AS bultos , ts.alertLevel, a.street, a.city,a.postalCode,a.id AS addressFk,w.name AS warehouse FROM vn.expedition exp INNER JOIN ticket t ON t.id = exp.ticketFk INNER JOIN vn.ticketState ts ON ts.ticketFk = exp.ticketFk + LEFT JOIN vn.address a ON t.addressFk = a.id + LEFT JOIN vn.warehouse w ON t.warehouseFk = w.id WHERE t.routeFk = vRouteFk AND exp.isBox > 0; END ;; @@ -33279,6 +34523,9 @@ CREATE DEFINER=`root`@`%` PROCEDURE `getItemVisibleAvailable`( vWarehouse TINYINT, vRefresh BOOL) BEGIN + + /*deprecated usar vn.itemGetVisibleAvailable + jgf 2019/09/10 */ DECLARE vVisibleCalc INT; DECLARE vAvailableCalc INT; @@ -35647,7 +36894,7 @@ BEGIN FROM vn2008.item_entry_in WHERE dat BETWEEN CURDATE() AND TIMESTAMPADD(DAY,vDaysInFuture , util.dayend(curdate())) AND warehouse_id = 1 - AND i.isVirtualStock is FALSE + AND isVirtualStock = FALSE GROUP BY item_id ) buy ON buy.item_id = alt.itemFk LEFT JOIN ( @@ -35882,11 +37129,12 @@ BEGIN INSERT INTO itemPlacement(itemFk, warehouseFk, reserve,pickable) VALUES(vItemFk, vWarehouseFk, vPlacement,0) - ON DUPLICATE KEY UPDATE reserve = vPlacement; + ON DUPLICATE KEY UPDATE reserve = vPlacement, modificationDate = NOW(); ELSE INSERT INTO itemPlacement(itemFk, warehouseFk, code) VALUES(vItemFk, vWarehouseFk, vPlacement) - ON DUPLICATE KEY UPDATE code = vPlacement; + ON DUPLICATE KEY UPDATE code = vPlacement, modificationDate = NOW(); + END IF; END ;; @@ -36276,27 +37524,23 @@ 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 ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemSearchShelving`(IN `vShelvingFk` VARCHAR(3)) -BEGIN - - SELECT p.column as col , p.`row` - FROM vn.shelving s - INNER JOIN parking p - ON s.parkingFk = p.id - WHERE s.code = vShelvingFk; - - +CREATE DEFINER=`root`@`%` PROCEDURE `itemSearchShelving`(`vShelvingFk` VARCHAR(3)) +BEGIN + SELECT p.`column` AS col , p.`row` + FROM vn.shelving s + JOIN parking p ON s.parkingFk = p.id + WHERE s.`code` = vShelvingFk COLLATE utf8_general_ci; 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 `itemSetNicho` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemSetNicho__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -36306,11 +37550,18 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemSetNicho`(IN `vPlacement` VARCHAR(30), IN `vReserve` VARCHAR(30), IN `vBarcode` INT, IN `vWarehouse` INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemSetNicho__`(IN `vPlacement` VARCHAR(30), IN `vReserve` VARCHAR(30), IN `vBarcode` INT, IN `vWarehouse` INT) BEGIN + + /* DEPRECATED + * + * Usar itemPlacementSave y cambiarle el nombre + * quique + */ + DECLARE vItemFk INT DEFAULT barcodeToItem(vBarcode); -INSERT INTO itemPlacement + INSERT INTO itemPlacement SET itemFk = vItemFk, warehouseFk = vWarehouse, reserve = vReserve , @@ -36326,7 +37577,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 `itemSetOnlyNicho` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemSetOnlyNicho__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -36336,8 +37587,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemSetOnlyNicho`(IN `vPlacement` VARCHAR(30), IN `vBarcode` INT, IN `vWarehouse` INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemSetOnlyNicho__`(IN `vPlacement` VARCHAR(30), IN `vBarcode` INT, IN `vWarehouse` INT) BEGIN + /* DEPRECATED + * + * Usar itemPlacementSave y cambiarle el nombre + * quique + */ DECLARE vItemFk INT DEFAULT barcodeToItem(vBarcode); INSERT INTO itemPlacement @@ -36354,7 +37610,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 `itemSetReserva` */; +/*!50003 DROP PROCEDURE IF EXISTS `itemSetReserva__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -36364,8 +37620,13 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemSetReserva`(IN `vReserve` VARCHAR(30),IN `vBarcode` INT, IN `vWarehouse` INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemSetReserva__`(IN `vReserve` VARCHAR(30),IN `vBarcode` INT, IN `vWarehouse` INT) BEGIN + /* DEPRECATED + * + * Usar itemPlacementSave y cambiarle el nombre + * quique + */ DECLARE vItemFk INT DEFAULT barcodeToItem(vBarcode); INSERT INTO itemPlacement @@ -36689,7 +37950,69 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingProblem`(vWarehouseFk INT) +CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingProblem`(vSectorFk INT) +BEGIN + + DECLARE vVisibleCache INT; + DECLARE vWarehouseFk INT; + + SELECT warehouseFk INTO vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + CALL cache.visible_refresh (vVisibleCache, FALSE, vWarehouseFk); + + SELECT t.id as ticketFk, + CAST(s.quantity AS DECIMAL(10,0)) as Cantidad, + s.itemFk, + s.concept, + v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho, + i.subName, + GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo, + s.id as saleFk, + IFNULL(sub3.transit,0) transit, + v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, mm.Id_Movimiento + FROM vn.ticket t + JOIN vn.ticketState tst ON tst.ticketFk = t.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN cache.visible v ON s.itemFk = v.item_id AND v.calc_id = vVisibleCache + LEFT JOIN vn2008.Movimientos_mark mm ON mm.Id_Movimiento = s.id AND mm.stateFk = 26 + JOIN vn.itemShelvingStock iss ON iss.itemFk = v.item_id + LEFT JOIN + (SELECT itemFk, sum(saldo) as transit + FROM vn.itemPlacementSupplyList + WHERE saldo > 0 + AND sectorFk = vSectorFk + GROUP BY itemFk) sub3 ON sub3.itemFk = i.id + WHERE v.visible - GREATEST(0,iss.visible) < s.quantity + AND IFNULL(sub3.transit,0) < s.quantity + AND s.isPicked = FALSE + AND s.reserved = FALSE + AND t.shipped BETWEEN CURDATE() AND MIDNIGHT(CURDATE()) + AND tst.isPreviousPreparable = TRUE + AND t.warehouseFk = vWarehouseFk + AND iss.sectorFk = vSectorFk + AND mm.Id_Movimiento IS NULL + ORDER BY itemFk; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingProblem__` */; +/*!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 `itemShelvingProblem__`(vWarehouseFk INT) BEGIN DECLARE vVisibleCache INT; @@ -36700,10 +38023,12 @@ BEGIN CAST(s.quantity AS DECIMAL(10,0)) as Cantidad, s.itemFk, s.concept, - v.visible - GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Nicho, + v.visible - GREATEST(0,iss.visible) + IFNULL(sub3.transit,0) as Nicho, i.subName, GREATEST(0,iss.visible - IFNULL(sub3.transit,0)) as Altillo, - s.id as saleFk + s.id as saleFk, + IFNULL(sub3.transit,0) transit, + v.visible, s.isPicked, s.reserved, t.shipped, tst.productionOrder, mm.Id_Movimiento FROM vn.ticket t JOIN vn.ticketState tst ON tst.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id @@ -36716,13 +38041,15 @@ BEGIN FROM vn.itemPlacementSupplyList WHERE saldo > 0 GROUP BY itemFk) sub3 ON sub3.itemFk = i.id - WHERE v.visible - GREATEST(0,iss.visible) < s.quantity + WHERE v.visible - GREATEST(0,iss.visible) < s.quantity + AND IFNULL(sub3.transit,0) < s.quantity AND s.isPicked = FALSE AND s.reserved = FALSE AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) AND tst.productionOrder < 6 AND t.warehouseFk = vWarehouseFk - AND mm.Id_Movimiento IS NULL; + AND mm.Id_Movimiento IS NULL + ORDER BY itemFk; END ;; DELIMITER ; @@ -36740,7 +38067,247 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingRadar`() +CREATE DEFINER=`root`@`%` PROCEDURE `itemShelvingRadar`(vSectorFk INT) +BEGIN + + DECLARE vWarehouseFk INT; + DECLARE vCalcVisibleFk INT; + DECLARE vCalcAvailableFk INT; + + SELECT warehouseFk INTO vWarehouseFk + FROM vn.sector + WHERE id = vSectorFk; + + CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); + CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); + + DROP TEMPORARY TABLE IF EXISTS tmp.saleFilter; + CREATE TEMPORARY TABLE tmp.saleFilter + (INDEX (ticketFk, saleFk, itemFk)) ENGINE = MEMORY + SELECT DISTINCT s.ticketFk, s.id as saleFk, s.itemFk + FROM vn.ticket t + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk + JOIN vn.shelving sh ON sh.code = ish.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + WHERE p.sectorFk = vSectorFk + AND t.shipped BETWEEN CURDATE() AND util.dayend(CURDATE()) + AND ish.visible > 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.ticketState; + CREATE TEMPORARY TABLE tmp.ticketState + (INDEX (ticketFk)) ENGINE = MEMORY + SELECT ts.* FROM vn.ticketState ts + JOIN (SELECT DISTINCT ticketFk FROM tmp.saleFilter) sf ON sf.ticketFk = ts.ticket + WHERE ts.updated >= TIMESTAMPADD(WEEK, -1, CURDATE()) + AND ts.productionOrder < 6; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; + CREATE TEMPORARY TABLE tmp.itemShelvingRadar + (INDEX (itemFk)) ENGINE = MEMORY + SELECT *, + @saldo:= CAST(IF(itemFk != @item, visibleTotal - Altillo, @saldo) - quantity AS DECIMAL(10,0)) as saldo, + @item:= itemFk as item + FROM + ( + + SELECT * FROM + ( + SELECT IF(tst.updated AND st.`order` BETWEEN 4 AND 5 , + HOUR(tst.updated), + IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`))) as Hora, + IF(tst.updated AND st.`order` BETWEEN 4 AND 5, + MINUTE(tst.updated), + IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`))) as Minuto, + s.itemFk, + i.longName as concept, + s.quantity, + GREATEST(0,iss.visible) as Altillo, + v.visible as visibleTotal, + i.minimum * IFNULL(iss.packing,999) as minimum, + i.size, + ip.code as nicho, + i.upToDown, + i.subName + FROM tmp.ticketState tst + LEFT JOIN state st ON st.id = tst.stateFk + JOIN sale s ON s.ticketFk = tst.ticketFk + JOIN item i ON i.id = s.itemFk + LEFT JOIN itemPlacement ip ON ip.itemFk = i.id AND ip.warehouseFk = vWarehouseFk + JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = s.itemFk + JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + WHERE tst.productionOrder < 5 + AND iss.sectorFk = vSectorFk + + UNION ALL + + SELECT 25 as Hora, + 0 as Minuto, + iss.itemFk, + i.longName as concept, + 0 as quantity, + iss.visible as Altillo, + GREATEST(0,v.visible) as visibleTotal, + i.minimum * IFNULL(iss.packing,999) as minimum, + i.size, + ip.code as nicho, + i.upToDown, + i.subName + FROM vn.itemShelvingStock iss + JOIN vn.item i ON i.id = iss.itemFk + JOIN (SELECT DISTINCT itemFk FROM tmp.saleFilter) sf ON sf.itemFk = i.id + LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id AND ip.warehouseFk = vWarehouseFk + JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = iss.itemFk + WHERE iss.sectorFk = vSectorFk + + ) sub + ORDER BY itemFk , + Hora, + Minuto + + ) sub2; + + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadarMin; + CREATE TEMPORARY TABLE tmp.itemShelvingRadarMin + (INDEX (itemFk)) ENGINE = MEMORY + SELECT *, min(saldo) as minSaldo , min(saldo) as minSaldo2 + FROM tmp.itemShelvingRadar + GROUP BY itemFk; + + SELECT Hora, + Minuto, + i.id as itemFk, + concept, + quantity, + Altillo - IFNULL(sub3.saldo,0) as Altillo, + visibleTotal, + sub2.minimum, + i.size, + nicho, + sub2.saldo, + saldoFinal, + i.upToDown, + IF(saldoFinal = 1, minSaldo, sub2.saldo) as primerNegativo, + visibleTotal - Altillo as visibleEnNicho, + min(maxSaldo) as FinalDia , + i.subName as producer, + ca.available, + sub3.saldo as transit + FROM item i + LEFT JOIN + ( + SELECT * FROM + ( + SELECT *, 0 as minSaldo, 1000000 as maxSaldo, FALSE as saldoFinal + FROM tmp.itemShelvingRadar + WHERE saldo <= 0 + + UNION ALL + + SELECT *, TRUE as saldoFinal + FROM tmp.itemShelvingRadarMin + GROUP BY itemFk + ) sub + ORDER BY itemFk, saldoFinal, Hora, Minuto + ) sub2 ON sub2.itemFk = i.id + LEFT JOIN cache.available ca ON i.id = ca.item_id AND ca.calc_id = vCalcAvailableFk + LEFT JOIN + (SELECT itemFk, sum(saldo) as saldo + FROM vn.itemPlacementSupplyList + WHERE saldo > 0 + GROUP BY itemFk) sub3 ON sub3.itemFk = i.id + GROUP BY i.id + HAVING saldo <= 0 OR saldoFinal ; + + DROP TEMPORARY TABLE IF EXISTS tmp.saleFilter; + DROP TEMPORARY TABLE IF EXISTS tmp.ticketState; + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; + DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadarMin; + +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 `itemShelvingRadar_Entry` */; +/*!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 `itemShelvingRadar_Entry`(vEntryFk INT) +BEGIN + + DECLARE vWarehouseFk INT DEFAULT 1; + DECLARE vCalcVisibleFk INT; + DECLARE vCalcAvailableFk INT; + DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE()); + + CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1); + CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); + + DROP TEMPORARY TABLE IF EXISTS tmp.item; + CREATE TEMPORARY TABLE tmp.item + ENGINE = MEMORY + SELECT DISTINCT itemFk + FROM vn.buy + WHERE entryFk = vEntryFk; + + DROP TEMPORARY TABLE IF EXISTS tmp.item2; + CREATE TEMPORARY TABLE tmp.item2 + ENGINE = MEMORY + SELECT * + FROM tmp.item; + + SELECT i.id as itemFk, + i.minimum, + CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) AS DECIMAL(10,0)) as enNicho, + CAST(IFNULL(a.available,0) AS DECIMAL(10,0)) as disponible, + CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) - ts.todaySold AS DECIMAL(10,0)) as finalDia + FROM vn.item i + JOIN tmp.item ti ON ti.itemFk = i.id + LEFT JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = i.id + LEFT JOIN cache.available a ON i.id = a.item_id AND a.calc_id = vCalcAvailableFk + LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id + LEFT JOIN ( SELECT s.itemFk, sum(s.quantity) as todaySold + FROM vn.sale s + JOIN tmp.item2 ti ON ti.itemFk = s.itemFk + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id + WHERE t.shipped BETWEEN CURDATE() AND vTodayDayEnd + AND t.warehouseFk = vWarehouseFk + AND IFNULL(tst.productionOrder,0) < 5 + GROUP BY s.itemFK + ) ts ON ts.itemFk = i.id; + + + DROP TEMPORARY TABLE tmp.item; + DROP TEMPORARY TABLE tmp.item2; + +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 `itemShelvingRadar__` */; +/*!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 `itemShelvingRadar__`() BEGIN DECLARE vWarehouseFk INT DEFAULT 1; DECLARE vCalcVisibleFk INT; @@ -36876,213 +38443,6 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadarMin; -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 `itemShelvingRadar_betaKk` */; -/*!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 `itemShelvingRadar_betaKk`() -BEGIN - /* obsoleto usar itemShelvingRadar*/ - DECLARE vWarehouseFk INT DEFAULT 1; - DECLARE vCalcTicketShippingFk INT; - DECLARE vCalcVisibleFk INT; - DECLARE vCalcAvailableFk INT; - - CALL cache.ticketShippingRefresh(vCalcTicketShippingFk, FALSE, 1); - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, 1); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.ticketState; - CREATE TEMPORARY TABLE tmp.ticketState - SELECT * FROM vn.ticketState - WHERE updated >= TIMESTAMPADD(WEEK, -1, CURDATE()) - AND productionOrder < 6; - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadar; - CREATE TEMPORARY TABLE tmp.itemShelvingRadar - SELECT *, - @saldo:= CAST(IF(itemFk != @item, visibleTotal - Altillo, @saldo) - quantity AS DECIMAL(10,0)) as saldo, - @item:= itemFk as item - FROM - ( - - SELECT * FROM - ( - SELECT IF(tst.updated AND st.`order` BETWEEN 4 AND 5 , HOUR(tst.updated), tsh.shippingHour) as Hora, - IF(tst.updated AND st.`order` BETWEEN 4 AND 5, MINUTE(tst.updated), tsh.shippingMinute) as Minuto, - s.itemFk, - i.longName as concept, - s.quantity, - iss.visible as Altillo, - v.visible as visibleTotal, - i.minimum * IFNULL(iss.packing,999) as minimum, - i.size, - ip.code as nicho, - i.upToDown, - i.subName - FROM tmp.ticketState tst - LEFT JOIN vn.state st ON st.id = tst.stateFk - JOIN vn.sale s ON s.ticketFk = tst.ticketFk - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id AND ip.warehouseFk = vWarehouseFk - JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = s.itemFk - JOIN cache.ticketShipping tsh ON tsh.calc_id = vCalcTicketShippingFk AND tsh.ticketFk = tst.ticketFk - JOIN vn.itemShelvingStock_beta iss ON iss.itemFk = s.itemFk - WHERE tst.productionOrder < 5 - - UNION ALL - - SELECT 25 as Hora, - 0 as Minuto, - iss.itemFk, - i.longName as concept, - 0 as quantity, - iss.visible as Altillo, - v.visible as visibleTotal, - i.minimum * IFNULL(iss.packing,999) as minimum, - i.size, - ip.code as nicho, - i.upToDown, - i.subName - FROM vn.itemShelvingStock_beta iss - JOIN vn.item i ON i.id = iss.itemFk - LEFT JOIN vn.itemPlacement ip ON ip.itemFk = i.id AND ip.warehouseFk = vWarehouseFk - JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = iss.itemFk - - ) sub - ORDER BY itemFk , - Hora, - Minuto - - ) sub2; - - - - DROP TEMPORARY TABLE IF EXISTS tmp.itemShelvingRadarMin; - CREATE TEMPORARY TABLE tmp.itemShelvingRadarMin - SELECT *, min(saldo) as minSaldo , min(saldo) as minSaldo2 - FROM tmp.itemShelvingRadar - GROUP BY itemFk; - - - - SELECT Hora, - Minuto, - itemFk, - concept, - quantity, - Altillo, - visibleTotal, - sub2.minimum, - i.size, - nicho, - saldo, - saldoFinal, - i.upToDown, - IF(saldoFinal = 1, minSaldo, saldo) as primerNegativo, - visibleTotal - Altillo as visibleEnNicho, - min(maxSaldo) as FinalDia , - i.subName as producer, - ca.available - FROM item i - LEFT JOIN - ( - SELECT * FROM - ( - SELECT *, 0 as minSaldo, 1000000 as maxSaldo, FALSE as saldoFinal - FROM tmp.itemShelvingRadar - WHERE saldo <= 0 - - UNION ALL - - SELECT *, TRUE as saldoFinal - FROM tmp.itemShelvingRadarMin - GROUP BY itemFk - ) sub - ORDER BY itemFk, saldoFinal, Hora, Minuto - ) sub2 ON sub2.itemFk = id - LEFT JOIN cache.available ca ON i.id = ca.item_id AND ca.calc_id = vCalcAvailableFk - GROUP BY itemFk - HAVING saldo <= 0 OR saldoFinal ; - - -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 `itemShelvingRadar_Entry` */; -/*!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 `itemShelvingRadar_Entry`(vEntryFk INT) -BEGIN - - DECLARE vWarehouseFk INT DEFAULT 1; - DECLARE vCalcVisibleFk INT; - DECLARE vCalcAvailableFk INT; - DECLARE vTodayDayEnd DATETIME DEFAULT util.dayEnd(CURDATE()); - - CALL cache.visible_refresh(vCalcVisibleFk, FALSE, 1); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, CURDATE()); - - DROP TEMPORARY TABLE IF EXISTS tmp.item; - CREATE TEMPORARY TABLE tmp.item - ENGINE = MEMORY - SELECT DISTINCT itemFk - FROM vn.buy - WHERE entryFk = vEntryFk; - - DROP TEMPORARY TABLE IF EXISTS tmp.item2; - CREATE TEMPORARY TABLE tmp.item2 - ENGINE = MEMORY - SELECT * - FROM tmp.item; - - SELECT i.id as itemFk, - i.minimum, - CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) AS DECIMAL(10,0)) as enNicho, - CAST(IFNULL(a.available,0) AS DECIMAL(10,0)) as disponible, - CAST(IFNULL(v.visible,0) - IFNULL(iss.visible,0) - ts.todaySold AS DECIMAL(10,0)) as finalDia - FROM vn.item i - JOIN tmp.item ti ON ti.itemFk = i.id - LEFT JOIN cache.visible v ON v.calc_id = vCalcVisibleFk AND v.item_id = i.id - LEFT JOIN cache.available a ON i.id = a.item_id AND a.calc_id = vCalcAvailableFk - LEFT JOIN vn.itemShelvingStock iss ON iss.itemFk = i.id - LEFT JOIN ( SELECT s.itemFk, sum(s.quantity) as todaySold - FROM vn.sale s - JOIN tmp.item2 ti ON ti.itemFk = s.itemFk - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.ticketState tst ON tst.ticketFk = t.id - WHERE t.shipped BETWEEN CURDATE() AND vTodayDayEnd - AND t.warehouseFk = vWarehouseFk - AND IFNULL(tst.productionOrder,0) < 5 - GROUP BY s.itemFK - ) ts ON ts.itemFk = i.id; - - - DROP TEMPORARY TABLE tmp.item; - DROP TEMPORARY TABLE tmp.item2; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -38002,9 +39362,9 @@ ALTER DATABASE `vn` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = 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 ;; @@ -38060,7 +39420,7 @@ BEGIN UPDATE vn2008.Tickets JOIN vn2008.Tickets_to_fusion USING(Id_Ticket) - SET Fecha = TIMESTAMPADD(YEAR,-1 * (YEAR(Fecha)-2000), Fecha); + SET Fecha = TIMESTAMPADD(YEAR,-1 * (YEAR(Fecha)-2000), Fecha), Id_Ruta = NULL; UPDATE vn.ticketLog tl JOIN vn2008.Tickets_to_fusion t ON t.Id_Ticket = tl.originFk @@ -38811,7 +40171,40 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `productionSectorList`() +CREATE DEFINER=`root`@`%` PROCEDURE `productionSectorList`(vSectorFk INT) +BEGIN + + SELECT isa.*, + cast(max(isa.quantity mod isa.packing) as DECIMAL(10,0)) as picos, + sum(isa.available) as totalAvailable, + IF (HOUR(isa.shipped),HOUR(isa.shipped), HOUR(isa.`hour`)) Hora, + IF (MINUTE(isa.shipped),MINUTE(isa.shipped), MINUTE(isa.`hour`)) Minuto, + i.subName + FROM vn.itemShelvingAvailable isa + JOIN vn.item i ON i.id = isa.itemFk + WHERE MOD(TRUNCATE(isa.quantity,0), isa.packing)= 0 + AND isa.isPreviousPreparable = TRUE + AND isa.sectorFk = vSectorFk + GROUP BY saleFk + HAVING isa.quantity <= totalAvailable; + +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 `productionSectorList__` */; +/*!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 `productionSectorList__`() BEGIN SELECT isa.*, @@ -39226,8 +40619,8 @@ BEGIN UPDATE vn.route r JOIN (SELECT routeFk, SUM(volume) AS m3 - FROM ticketGetVolume - WHERE routeFk = vRoute + FROM saleVolume + WHERE routeFk = vRoute ) v ON v.routeFk = r.id SET r.m3 = v.m3; END ;; @@ -39278,7 +40671,7 @@ BEGIN r.kmEnd - r.kmStart, DAYNAME(r.created), r.created, - SUM(tgv.volume / ebv.m3), + SUM(sv.volume / ebv.m3), v.numberPlate, IF(ISNULL(`r`.`cost`), 'P', 'A'), r.cost @@ -39288,7 +40681,7 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.vehicle v ON v.id = r.vehicleFk - JOIN vn.ticketGetVolume tgv ON tgv.ticketFk = t.id + JOIN vn.saleVolume sv ON sv.ticketFk = t.id JOIN vn.expeditionBoxVol ebv ON ebv.boxFk = 71 WHERE YEAR(r.created) = vYear AND MONTH(r.created) = vMonth AND z.isVolumetric @@ -39898,6 +41291,72 @@ BEGIN FROM vn.saleComponent WHERE saleFk = vSaleFk; +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 `saleTracking_del` */; +/*!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 `saleTracking_del`(vSaleFk INT, vState VARCHAR(50)) +BEGIN + + DELETE st.* + FROM vn.saleTracking st + JOIN vn.state s + WHERE st.saleFk = vSaleFk + AND s.code = vState COLLATE utf8_unicode_ci; + +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 `saleTracking_new` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = 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 `saleTracking_new`( vSaleFK INT, + vIsChecked BOOLEAN, + vOriginalQuantity INT, + vWorkerFk INT, + vAction VARCHAR(50), + vState VARCHAR(50)) +BEGIN + + REPLACE vn.saleTracking(saleFk, + isChecked, + originalQuantity, + workerFk, + actionFk, + stateFk) + SELECT vSaleFk, + vIsChecked, + vOriginalQuantity, + vWorkerFk, + a.accion_id, + s.id + FROM vncontrol.accion a + JOIN vn.state s + WHERE s.code = vState COLLATE utf8_unicode_ci + AND a.accion = vAction COLLATE utf8_unicode_ci; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -40104,6 +41563,39 @@ BEGIN +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 `shelving_clean` */; +/*!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 `shelving_clean`() +BEGIN + + DELETE FROM vn.shelving + WHERE length(code) > 3 + AND parked < TIMESTAMPADD(WEEK,-1,CURDATE()); + + UPDATE vn.shelving sh + LEFT JOIN vn.itemShelving its ON its.shelvingFk = sh.`code` + SET isPrinted = 0 + WHERE isPrinted = 1 + AND its.id IS NULL + AND ( sh.parked IS NULL + OR + sh.parked < TIMESTAMPADD(MONTH,-1,CURDATE()) + ); + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -41826,6 +43318,7 @@ proc: BEGIN DECLARE vManaAutoComponent INT DEFAULT 39; + SELECT volume INTO vBoxVolume FROM vn.packaging WHERE id = '94'; @@ -41849,7 +43342,9 @@ proc: BEGIN IFNULL(pf.packing, b.packing) packing, IFNULL(pf.`grouping`, b.`grouping`) grouping, ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, - tl.buyFk, i.typeFk + tl.buyFk, + i.typeFk, + IF(i.hasKgPrice,(b.packing * b.weight) / 1000, NULL) weightPacking FROM tmp.ticketLot tl JOIN buy b ON b.id = tl.buyFk JOIN item i ON i.id = tl.itemFk @@ -41993,7 +43488,8 @@ proc: BEGIN tcc.itemFk, 1 rate, 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)) price, + CAST(SUM(tcs.sumCost) / weightPacking AS DECIMAL(10,2)) priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -42001,13 +43497,14 @@ 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) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 2 rate, tcc.packing grouping, - SUM(tcs.sumCost) price + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightPacking priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -42015,13 +43512,14 @@ 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) + INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, grouping, price, priceKg) SELECT tcc.warehouseFk, tcc.itemFk, 3 rate, tcc.available grouping, - SUM(tcs.sumCost) price + SUM(tcs.sumCost) price, + SUM(tcs.sumCost) / weightPacking priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk @@ -44400,6 +45898,62 @@ BEGIN WHERE id = vOriginalTicket; SET vNewTicket = LAST_INSERT_ID(); + + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vNewTicket, ao.observationTypeFk, ao.description + FROM addressObservation ao + JOIN ticket t ON t.addressFk = ao.addressFk + WHERE t.id = vNewTicket; + + INSERT INTO vn.ticketLog + SET originFk = vNewTicket, userFk = account.myUserGetId(), `action` = 'insert', description = CONCAT('Ha creado el ticket:', ' ', vNewTicket, ' clonando el ', vOriginalTicket); + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_Clone__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_Clone__`(vOriginalTicket INT, OUT vNewTicket INT) +BEGIN + /* jgf 2019-09-10*/ + INSERT INTO vn2008.Tickets ( + Id_Cliente, + Fecha, + Id_Consigna, + Id_Agencia, + Alias, + warehouse_id, + Id_Ruta, + empresa_id, + landing, + zoneFk + ) + SELECT + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + routeFk, + companyFk, + landed, + zoneFk + FROM vn.ticket + WHERE id = vOriginalTicket; + + SET vNewTicket = LAST_INSERT_ID(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -45573,6 +47127,42 @@ 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 `travel_weeklyClone` */; +/*!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 `travel_weeklyClone`(vSinceWeek INT, vToWeek INT) +BEGIN + DECLARE vCounter INT; + + SET vCounter = vSinceWeek; + vWeekLoop :LOOP + INSERT IGNORE INTO travel (shipped, landed, warehouseOutFk, warehouseInFk, agencyFk, ref, cargoSupplierFk) + SELECT @a := TIMESTAMPADD(DAY,vCounter * 7 - WEEKDAY(CURDATE()) - 1 + weekDay,CURDATE()), + @a := TIMESTAMPADD(DAY,duration,@a), + warehouseOutFk, + warehouseInFk, + agencyModeFk, + ref, + cargoSupplierFk + FROM travel_cloneWeekly; + IF vCounter = vToWeek THEN + LEAVE vWeekLoop; + END IF; + SET vCounter = vCounter + 1; + END LOOP; +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 `typeTagMake` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46526,7 +48116,7 @@ SELECT COUNT(*) INTO vHasSignedToday SET @day := 0; SET @lastTimed := NOW(); -SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(IF(interval_in_minutes >= v36hoursInMinutes,1,0)) , SUM(jornadas) +SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(FLOOR(interval_in_minutes/ v36hoursInMinutes)) , SUM(jornadas) INTO vDescansos12h, vDescansos36h, vJornadas FROM ( @@ -46543,12 +48133,12 @@ SELECT SUM(IF(interval_in_minutes >= v12hoursInMinutes,1,0)), SUM(IF(interval_i ( SELECT day(timed) as dayNumber, dayname(timed) as dayName, timed FROM - (SELECT TIMESTAMPADD(DAY, -10, NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior + (SELECT TIMESTAMPADD(DAY, -11, NOW()) as timed, vUserFk as userFk -- Fichada virtual para los en los que no se ha trabajado la semana anterior UNION ALL SELECT timed, userFk FROM vn.workerTimeControl wtc WHERE userFk = vUserFk - AND timed >= TIMESTAMPADD(DAY, -9,vDated) + AND timed >= TIMESTAMPADD(DAY, -10,vDated) UNION ALL SELECT IF(vHasSignedToday, '2000-01-01 00:00', NOW()) as timed, vUserFk ) sub4 @@ -46589,8 +48179,8 @@ SELECT IF(COUNT(*),vCantWork,'Sin contrato') INTO vCantWork JOIN postgresql.person p ON p.person_id = pr.person_id JOIN vn.worker w ON w.id = p.id_trabajador WHERE w.userFk = vUserFk - AND b.date_start <= CURDATE() - AND IFNULL(b.date_end,CURDATE()) >= CURDATE(); + AND b.date_start <= vDated + AND IFNULL(b.date_end,vDated) >= vDated; IF vJornadas IS NOT NULL THEN @@ -46602,7 +48192,7 @@ IF vJornadas IS NOT NULL THEN UNION ALL - SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h >= 1, 'Correcto','Error: mínimo 1 por semana') as Análisis + SELECT 'Descansos 36 h' as Item, vDescansos36h as Cantidad, IF(vDescansos36h / 2 >= FLOOR(vJornadas/10), 'Correcto','Error: mínimo 2 cada 14 dias') as Análisis UNION ALL @@ -46650,7 +48240,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 `workerWeekControl_old` */; +/*!50003 DROP PROCEDURE IF EXISTS `workerWeekControl__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -46660,7 +48250,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `workerWeekControl_old`(vUserFk INT, vDated DATE ) +CREATE DEFINER=`root`@`%` PROCEDURE `workerWeekControl__`(vUserFk INT, vDated DATE ) BEGIN /* Devuelve la cantidad de descansos de 12h y de 36 horas que ha disfrutado el trabajador @@ -46817,7 +48407,7 @@ SELECT orden `orden`, FROM ( - SELECT `order` as orden, datediff(curdate(), timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada + SELECT `order` as orden, datediff(vDated, timed) as dias, date(timed) as fecha, TIME_FORMAT(timed,'%H:%i') as fichada FROM vn.workerTimeControl wtc WHERE userFk = vUserFk AND timed >= TIMESTAMPADD(DAY, -7, vDated) @@ -47162,6 +48752,212 @@ 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 `zoneGeo_calcTree` */; +/*!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 `zoneGeo_calcTree`() +BEGIN + DECLARE vIndex INT DEFAULT 0; + DECLARE vSons INT; + + UPDATE vn.zoneGeo SET + path = NULL, + lft = NULL, + rgt = NULL, + depth = 0, + sons = 0; + + SET max_sp_recursion_depth = 5; + CALL vn.zoneGeo_calcTreeRec(NULL, '', 0, vIndex, vSons); + SET max_sp_recursion_depth = 0; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGeo_calcTreeRec` */; +/*!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 `zoneGeo_calcTreeRec`( + vParentFk INT, + vPath VARCHAR(255), + vDepth INT, + INOUT vIndex INT, + OUT vSons INT +) +BEGIN + DECLARE vChildFk INT; + DECLARE vLft INT; + DECLARE vMySons INT; + DECLARE vDone BOOL; + DECLARE vChilds CURSOR FOR + SELECT id FROM zoneGeo + WHERE (vParentFk IS NULL AND parentFk IS NULL) + OR (vParentFk IS NOT NULL AND parentFk = vParentFk); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SET vSons = 0; + SET vPath = CONCAT(vPath, '/'); + + OPEN vChilds; + myLoop: LOOP + SET vDone = FALSE; + FETCH vChilds INTO vChildFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + SET vIndex = vIndex + 1; + SET vLft = vIndex; + SET vSons = vSons + 1; + + CALL zoneGeo_calcTreeRec( + vChildFk, + CONCAT(vPath, vChildFk), + vDepth + 1, + vIndex, + vMySons + ); + + SET vIndex = vIndex + 1; + + UPDATE zoneGeo + SET path = vPath, + lft = vLft, + rgt = vIndex, + depth = vDepth, + sons = vMySons + WHERE id = vChildFk; + END LOOP; + CLOSE vChilds; +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 `zoneGeo_check` */; +/*!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 `zoneGeo_check`() +BEGIN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Column `geoFk` cannot be modified'; +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 `zoneGeo_delete` */; +/*!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 `zoneGeo_delete`(vSelf INT) +BEGIN + DELETE FROM zoneGeo WHERE id = vSelf; + UPDATE zoneGeoRecalc SET isChanged = TRUE; +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 `zoneGeo_doCalc` */; +/*!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 `zoneGeo_doCalc`() +proc: BEGIN +/** + * Recalculates the zones tree. + */ + DECLARE vIsChanged BOOL; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.zoneGeo_doCalc'); + RESIGNAL; + END; + + IF !GET_LOCK('vn.zoneGeo_doCalc', 0) THEN + LEAVE proc; + END IF; + + SELECT isChanged INTO vIsChanged + FROM zoneGeoRecalc; + + IF vIsChanged THEN + UPDATE zoneGeoRecalc SET isChanged = FALSE; + -- FIXME: Disabled until geo is fixed + -- CALL vn.zoneGeo_calcTree; + END IF; + + DO RELEASE_LOCK('vn.zoneGeo_doCalc'); +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 `zoneGeo_setParent` */; +/*!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 `zoneGeo_setParent`(vSelf INT, vParentFk INT) +BEGIN + UPDATE zoneGeo SET parentFk = vParentFk + WHERE id = vSelf; + + UPDATE zoneGeoRecalc SET isChanged = TRUE; +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 `zoneGetAgency` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47174,6 +48970,71 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetAgency`(vAddress INT, vLanded DATE) BEGIN +/** + * Devuelve el listado de agencias disponibles para la fecha + * y dirección pasadas. + * + * @param vAddress Id de dirección de envío, %NULL si es recogida + * @param vDate Fecha de recogida + * @select Listado de agencias disponibles + */ + + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddress + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetAgency; + CREATE TEMPORARY TABLE tmp.zoneGetAgency + (INDEX (agencyModeFk)) ENGINE = MEMORY + SELECT * FROM ( + SELECT * FROM ( + SELECT am.id agencyModeFk, + am.name agencyMode, + am.description, + am.deliveryMethodFk, + TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, + zi.isIncluded, + z.warehouseFk, + z.id zoneFk + FROM zoneGeo zgSon + JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt + JOIN zoneIncluded zi ON zi.geoFk = zgFather.id + JOIN zone z ON z.id = zi.zoneFk + JOIN zoneCalendar zc ON zc.zoneFk = z.id + JOIN agencyMode am ON am.id = z.agencyModeFk + WHERE zgSon.`id` = vGeoFk + AND zc.delivered = vLanded + AND TIMESTAMPADD(DAY,-z.travelingDays, vLanded) >= CURDATE() + AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) + ORDER BY z.id, zgFather.depth DESC, zi.isIncluded DESC) t + GROUP BY zoneFk + HAVING isIncluded > 0 + ORDER BY shipped) t + GROUP BY agencyModeFk; +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 `zoneGetAgency__` */; +/*!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 `zoneGetAgency__`(vAddress INT, vLanded DATE) +BEGIN /** * Devuelve el listado de agencias disponibles para la fecha * y dirección pasadas. @@ -47243,6 +49104,60 @@ BEGIN * @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida */ + + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddress + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + SELECT * FROM ( + SELECT TIMESTAMPADD(DAY,-z.travelingDays, zc.delivered) shipped, + zc.delivered landed, + zi.isIncluded + FROM zoneGeo zgSon + JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt + JOIN zoneIncluded zi ON zi.geoFk = zgFather.id + JOIN zone z ON z.id = zi.zoneFk + JOIN zoneCalendar zc ON zc.zoneFk = z.id + WHERE zgSon.`id` = vGeoFk + AND z.agencyModeFk = vAgencyModeFk + AND z.warehouseFk = vWarehouseFk + AND TIMESTAMPADD(DAY,-z.travelingDays, zc.delivered) >= CURDATE() + AND IF(TIMESTAMPADD(DAY,-z.travelingDays, zc.delivered) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) + ORDER BY landed ASC, zgFather.depth DESC) t + HAVING isIncluded > 0 LIMIT 1; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetFirstShipped__` */; +/*!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 `zoneGetFirstShipped__`(vAgencyModeFk INT, vAddress INT, vWarehouseFk INT) +BEGIN +/** +* Devuelve la primera fecha de envio disponible para una agencia en una direccion y un warehouse +* +* @param vAgencyMode id de la agencia en vn.agencyMode +* @param vAddress id de la direccion +* @param vWarehouse id del warehouse +* @return vShipped la primera fecha disponible y vLanded la fecha de llegada/recojida +*/ + DECLARE vPostalCode varchar(10); SELECT postalCode INTO vPostalCode @@ -47289,6 +49204,61 @@ BEGIN * @param vAddress Id de consignatario, %NULL para recogida * @param vAgencyMode Id agencia * @table tmp.zoneGetLanded Datos de recepción +*/ + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddress + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetLanded; + CREATE TEMPORARY TABLE tmp.zoneGetLanded + ENGINE = MEMORY + SELECT vWarehouse warehouseFk,delivered landed, isIncluded, id zoneFk FROM ( + SELECT zi.isIncluded, zc.delivered, z.id + FROM vn.zoneGeo zgSon + JOIN vn.zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt + JOIN zoneIncluded zi ON zi.geoFk = zgFather.id + JOIN zone z ON z.id = zi.zoneFk + JOIN zoneCalendar zc ON zc.zoneFk = z.id + WHERE zgSon.`id` = vGeoFk + AND zc.delivered = TIMESTAMPADD(DAY,z.travelingDays, vShipped) + AND IF(vShipped = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) + AND z.agencyModeFk = vAgencyMode + AND z.warehouseFk = vWarehouse + ORDER BY zgFather.depth DESC) t + GROUP BY zoneFk + HAVING isIncluded > 0 + LIMIT 1; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `zoneGetLanded__` */; +/*!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 `zoneGetLanded__`(vShipped DATE, vAddress INT, vAgencyMode INT, vWarehouse INT) +BEGIN +/** +* Devuelve una tabla temporal con el dia de recepcion para vShipped. +* +* @param vShipped Fecha de preparacion de mercancia +* @param vAddress Id de consignatario, %NULL para recogida +* @param vAgencyMode Id agencia +* @table tmp.zoneGetLanded Datos de recepción */ DECLARE vPostalCode varchar(10); @@ -47340,11 +49310,15 @@ BEGIN * @param vAgencyModeFk Id de la agencia * @return tmp.zoneGetShipped */ - - DECLARE vPostalCode varchar(10); - - SELECT postalCode INTO vPostalCode - FROM address WHERE id = vAddressFk; + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddressFk + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; SELECT * FROM ( SELECT * FROM ( @@ -47358,7 +49332,7 @@ BEGIN JOIN zoneIncluded zi ON zi.geoFk = zgFather.id JOIN zone z ON z.id = zi.zoneFk JOIN zoneCalendar zc ON zc.zoneFk = z.id - WHERE zgSon.`name` LIKE vPostalCode + WHERE zgSon.`id` = vGeoFk AND zc.delivered = vLanded AND z.agencyModeFk = vAgencyModeFk AND z.warehouseFk = vWarehouseFk @@ -47387,6 +49361,66 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `zoneGetShippedWarehouse`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) BEGIN +/** + * Devuelve la mínima fecha de envío para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddressFk + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + + + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGetShipped; + CREATE TEMPORARY TABLE tmp.zoneGetShipped + ENGINE = MEMORY + SELECT * FROM ( + SELECT * FROM ( + SELECT z.id, + TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, + zi.isIncluded,z.warehouseFk + FROM zoneGeo zgSon + JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt + JOIN zoneIncluded zi ON zi.geoFk = zgFather.id + JOIN zone z ON z.id = zi.zoneFk + JOIN zoneCalendar zc ON zc.zoneFk = z.id + WHERE zgSon.`id` = vGeoFk + AND zc.delivered = vLanded + AND z.agencyModeFk = vAgencyModeFk + AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) + ORDER BY z.id, shipped ASC, zgFather.depth DESC, zi.isIncluded DESC) t + GROUP BY warehouseFk, id + HAVING isIncluded > 0 + ORDER BY shipped) t + GROUP BY warehouseFk; +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 `zoneGetShippedWarehouse__` */; +/*!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 `zoneGetShippedWarehouse__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT) +BEGIN /** * Devuelve la mínima fecha de envío para cada warehouse * @@ -47429,6 +49463,61 @@ 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 `zoneGetShipped__` */; +/*!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 `zoneGetShipped__`(vLanded DATE, vAddressFk INT, vAgencyModeFk INT, vWarehouseFk INT) +BEGIN +/** + * Devuelve la mínima fecha de envía para cada warehouse + * + * @param vLanded La fecha de recepcion + * @param vAddressFk Id del consignatario + * @param vAgencyModeFk Id de la agencia + * @return tmp.zoneGetShipped + */ + + DECLARE vPostalCode varchar(10); + + SELECT postalCode INTO vPostalCode + FROM address WHERE id = vAddressFk; + + SELECT * FROM ( + SELECT * FROM ( + SELECT z.id, + TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped, + vLanded landed, + zi.isIncluded, + z.agencyModeFk + FROM zoneGeo zgSon + JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt + JOIN zoneIncluded zi ON zi.geoFk = zgFather.id + JOIN zone z ON z.id = zi.zoneFk + JOIN zoneCalendar zc ON zc.zoneFk = z.id + WHERE zgSon.`name` LIKE vPostalCode + AND zc.delivered = vLanded + AND z.agencyModeFk = vAgencyModeFk + AND z.warehouseFk = vWarehouseFk + AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) + ORDER BY z.id, zgFather.depth DESC, isIncluded DESC) t + GROUP BY id + HAVING isIncluded > 0 + ORDER BY shipped) + t + GROUP BY agencyModeFk; +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 `zoneGetWarehouse` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47451,14 +49540,16 @@ BEGIN * @select Listado de agencias disponibles */ - DECLARE vGeoFk varchar(10); - - SELECT pc.geoFk INTO vGeoFk - FROM address a - JOIN vn.postCode pc ON pc.code =a.postalCode - JOIN vn.town t ON t.name = a.city AND pc.townFK = t.id - JOIN vn.province p ON p.id = a.provinceFk AND t.provinceFk = p.id - WHERE a.id = vAddress; + DECLARE vGeoFk INT; + + SELECT p.geoFk INTO vGeoFk + FROM address a + JOIN town t ON t.provinceFk = a.provinceFk + JOIN postCode p ON p.townFk = t.id AND p.code = a.postalCode + WHERE a.id = vAddress + ORDER BY (a.city SOUNDS LIKE t.`name`) DESC + LIMIT 1; + SELECT * FROM ( SELECT * FROM ( @@ -47476,7 +49567,7 @@ BEGIN JOIN zone z ON z.id = zi.zoneFk JOIN zoneCalendar zc ON zc.zoneFk = z.id JOIN agencyMode am ON am.id = z.agencyModeFk - WHERE zgSon.`id` LIKE vGeoFk + WHERE zgSon.`id` = vGeoFk AND delivered = vLanded AND z.warehouseFk = vWarehouse AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE) @@ -47491,59 +49582,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 `zoneNest` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneNestCountry__` */; /*!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 `zoneNest`() -BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.zoneGeo; - CREATE TEMPORARY TABLE tmp.zoneGeo - (id INT AUTO_INCREMENT PRIMARY KEY) - ENGINE = MEMORY - SELECT * FROM vn.zoneGeo; - - CALL vn.zoneNestCountry(); - CALL vn.zoneNestProvince(); - - IF (SELECT COUNT(*) FROM province WHERE geoFk IS NULL) = 0 THEN - CALL zoneNestTown(); - END IF; - - IF (SELECT COUNT(*) FROM town WHERE geoFk IS NULL) = 0 THEN - CALL zoneNestPostcode(); - END IF; - - INSERT INTO zoneGeo (id, name, lft, rgt, depth, sons) - SELECT * FROM tmp.zoneGeo zg - ON DUPLICATE KEY UPDATE - name = zg.name, lft = zg.lft, rgt = zg.rgt, - depth = zg.depth, sons = zg.sons; - - DROP TEMPORARY TABLE tmp.zoneGeo; -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 `zoneNestCountry` */; -/*!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 `zoneNestCountry`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneNestCountry__`() BEGIN DECLARE vDone BOOL; DECLARE vGeoFk INT; @@ -47574,7 +49623,8 @@ BEGIN UPDATE country c SET c.geoFk = LAST_INSERT_ID() - WHERE c.id = vCountryFk; + WHERE c.id = vCountryFk + AND c.geoFk IS NULL; END LOOP; CLOSE countryCur; -- < Country cursor end @@ -47584,17 +49634,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 `zoneNestPostcode` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneNestPostcode__` */; /*!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 `zoneNestPostcode`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneNestPostcode__`() BEGIN DECLARE vDone BOOL; DECLARE vGeoFk INT DEFAULT 1; @@ -47629,7 +49679,8 @@ BEGIN UPDATE postCode pc SET pc.geoFk = LAST_INSERT_ID() WHERE pc.code = vPostcodeFk - AND pc.townFk = vTownFk; + AND pc.townFk = vTownFk + AND pc.geoFk IS NULL; END LOOP; CLOSE postcodeCur; -- < Postcode cursor end @@ -47639,17 +49690,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 `zoneNestProvince` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneNestProvince__` */; /*!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 `zoneNestProvince`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneNestProvince__`() BEGIN DECLARE vDone BOOL; DECLARE vGeoFk INT; @@ -47682,7 +49733,8 @@ BEGIN UPDATE province p SET p.geoFk = LAST_INSERT_ID() - WHERE p.id = vProvinceFk; + WHERE p.id = vProvinceFk + AND p.geoFk IS NULL; END LOOP; CLOSE provinceCur; -- < Province cursor end @@ -47692,17 +49744,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 `zoneNestTown` */; +/*!50003 DROP PROCEDURE IF EXISTS `zoneNestTown__` */; /*!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 `zoneNestTown`() +CREATE DEFINER=`root`@`%` PROCEDURE `zoneNestTown__`() BEGIN DECLARE vDone BOOL; DECLARE vGeoFk INT; @@ -47735,7 +49787,8 @@ BEGIN UPDATE town t SET t.geoFk = LAST_INSERT_ID() - WHERE t.id = vTownFk; + WHERE t.id = vTownFk + AND t.geoFk IS NULL; END LOOP; CLOSE townCur; -- < Town cursor end @@ -47745,6 +49798,48 @@ 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 `zoneNest__` */; +/*!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 `zoneNest__`() +BEGIN + DROP TEMPORARY TABLE IF EXISTS tmp.zoneGeo; + CREATE TEMPORARY TABLE tmp.zoneGeo + (id INT AUTO_INCREMENT PRIMARY KEY) + ENGINE = MEMORY + SELECT * FROM vn.zoneGeo; + + CALL vn.zoneNestCountry(); + CALL vn.zoneNestProvince(); + + IF (SELECT COUNT(*) FROM province WHERE geoFk IS NULL) = 0 THEN + CALL zoneNestTown(); + END IF; + + IF (SELECT COUNT(*) FROM town WHERE geoFk IS NULL) = 0 THEN + CALL zoneNestPostcode(); + END IF; + + INSERT INTO zoneGeo (id, name, lft, rgt, depth, sons) + SELECT * FROM tmp.zoneGeo zg + ON DUPLICATE KEY UPDATE + name = zg.name, lft = zg.lft, rgt = zg.rgt, + depth = zg.depth, sons = zg.sons; + + DROP TEMPORARY TABLE tmp.zoneGeo; +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 `__getTicketToPrePrepare` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47970,7 +50065,8 @@ CREATE TABLE `Articles` ( `value10` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `compression` decimal(5,2) NOT NULL DEFAULT '1.00' COMMENT 'Relacion de compresividad entre el volumen de las entradas en Silla y el empaquetado en los envios a clientes.\n\nMenor que 1 significa que se puede comprimir más que el volumen original.', `minimum` decimal(10,0) unsigned NOT NULL DEFAULT '3', - `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0', + `upToDown` decimal(10,0) unsigned NOT NULL DEFAULT '0' COMMENT 'Se muestra el precio por kilo ', + `hasKgPrice` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`Id_Article`), KEY `Article` (`Article`), KEY `Color` (`Color`), @@ -47984,10 +50080,10 @@ CREATE TABLE `Articles` ( CONSTRAINT `Articles_ibfk_1` FOREIGN KEY (`id_origen`) REFERENCES `Origen` (`id`) ON UPDATE CASCADE, CONSTRAINT `Articles_ibfk_2` FOREIGN KEY (`Codintrastat`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `Articles_ibfk_4` FOREIGN KEY (`iva_group_id`) REFERENCES `iva_group` (`iva_group_id`) ON UPDATE CASCADE, - CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `Tipos` (`tipo_id`) ON UPDATE CASCADE, + CONSTRAINT `Articles_ibfk_5` FOREIGN KEY (`tipo_id`) REFERENCES `vn`.`itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `expenceFk` FOREIGN KEY (`expenceFk`) REFERENCES `Gastos` (`Id_Gasto`) ON UPDATE CASCADE, CONSTRAINT `producer_id` FOREIGN KEY (`producer_id`) REFERENCES `producer` (`producer_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=364748 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=366241 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 */ ; @@ -48228,7 +50324,7 @@ CREATE TABLE `Articles_nicho` ( KEY `Articles_nicho_wh_fk` (`warehouse_id`), CONSTRAINT `Articles_nicho_wh_fk` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `Articles_nichos_fk` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=871397 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=888485 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -48267,7 +50363,7 @@ CREATE TABLE `Bancos` ( KEY `fk_Bancos_entity1_idx` (`entity_id`), KEY `foreignkey1_idx` (`cash`), KEY `Bancoscurrency_idx` (`currencyFk`), - CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, + CONSTRAINT `Bancoscurrency` FOREIGN KEY (`currencyFk`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `foreignkey1` FOREIGN KEY (`cash`) REFERENCES `vn`.`accountingType` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Apunta a la vista vn.Accounting\nLa columna cash es la FK de vn.AccountingType'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -48354,7 +50450,7 @@ CREATE TABLE `Cajas` ( KEY `warehouse_id` (`warehouse_id`), KEY `fk_Cajas_Proveedores_account1_idx` (`Proveedores_account_Id`), CONSTRAINT `Cajas_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=717040 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=721258 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 */ ; @@ -48486,7 +50582,7 @@ CREATE TABLE `Clientes` ( CONSTRAINT `canal_nuevo_cliente` FOREIGN KEY (`chanel_id`) REFERENCES `vn`.`contactChannel` (`id`) ON UPDATE CASCADE, CONSTRAINT `tipos_de_cliente` FOREIGN KEY (`clientes_tipo_id`) REFERENCES `clientes_tipo` (`clientes_tipo_id`) ON UPDATE CASCADE, CONSTRAINT `typeFk` FOREIGN KEY (`typeFk`) REFERENCES `clientes_tipo` (`code`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=16256 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=16332 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 */ ; @@ -48643,7 +50739,7 @@ CREATE TABLE `Clientes_cedidos` ( CONSTRAINT `cliente_cedido_fk` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `new_trabajador_fk` FOREIGN KEY (`Id_Trabajador_new`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `trabajador_fk` FOREIGN KEY (`Id_Trabajador_old`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que se han cambiado de comercial, pero durante un tiempo comisionan a los dos, al anterior y al actual'; +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Clientes que se han cambiado de comercial, pero durante un tiempo comisionan a los dos, al anterior y al actual'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -48761,7 +50857,7 @@ CREATE TABLE `Colas` ( KEY `Id_Trabajador` (`Id_Trabajador`), CONSTRAINT `Colas_ibfk_3` FOREIGN KEY (`Id_Prioridad`) REFERENCES `Prioridades` (`Id_Prioridad`) ON UPDATE CASCADE, CONSTRAINT `Colas_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=12586 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=20867 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -48915,7 +51011,7 @@ CREATE TABLE `Consignatarios` ( CONSTRAINT `Consignatarios_ibfk_3` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE, CONSTRAINT `Consignatarios_ibfk_4` FOREIGN KEY (`Id_Agencia`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `address_customer_id` FOREIGN KEY (`Id_cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=28665 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=28807 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 */ ; @@ -49043,7 +51139,7 @@ CREATE TABLE `Contactos` ( PRIMARY KEY (`Id_Contacto`), KEY `Telefono` (`Telefono`), KEY `Movil` (`Movil`) -) ENGINE=InnoDB AUTO_INCREMENT=2740 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2743 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 */ ; @@ -49270,7 +51366,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 `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3779917 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3812681 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -49288,7 +51384,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=138 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; +) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Relaciona las entradas con los origenes de compra'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -49376,7 +51472,7 @@ CREATE TABLE `Equipos` ( PRIMARY KEY (`id`), KEY `trabajador_id` (`trabajador_id`), CONSTRAINT `Equipos_ibfk_1` FOREIGN KEY (`trabajador_id`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=215 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -49532,7 +51628,7 @@ CREATE TABLE `Facturas` ( CONSTRAINT `Facturas_ibfk_4` FOREIGN KEY (`cplusTaxBreakFk`) REFERENCES `vn`.`cplusTaxBreak` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoice_bank_id` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `invoice_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=513179 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=513358 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 */ ; @@ -49691,69 +51787,36 @@ CREATE TABLE `Gastos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Greuges` +-- Temporary table structure for view `Greuges` -- DROP TABLE IF EXISTS `Greuges`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Greuges` ( - `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(10) unsigned NOT NULL, - `Comentario` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `Importe` decimal(10,2) NOT NULL, - `Fecha` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - `odbc_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `Greuges_type_id` int(11) DEFAULT NULL, - `Id_Ticket` int(11) DEFAULT NULL, - PRIMARY KEY (`Id`), - KEY `greuges_type_fk_idx` (`Greuges_type_id`), - KEY `Id_Ticket_Greuge_Ticket_idx` (`Id_Ticket`), - KEY `Greuges_cliente_idx` (`Id_Cliente`), - CONSTRAINT `Id_Ticket_Greuge_Ticket` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `greuges_type_fk` FOREIGN KEY (`Greuges_type_id`) REFERENCES `Greuges_type` (`Greuges_type_id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3615579 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 */ ; -/*!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`.`Greuges_BEFORE_UPDATE` BEFORE UPDATE ON `Greuges` FOR EACH ROW -BEGIN - - DECLARE vMaxDate DATETIME DEFAULT TIMESTAMPADD(YEAR,1,CURDATE()); - - IF NEW.Fecha > vMaxDate THEN - - SET NEW.Fecha = vMaxDate; - - 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 `Greuges`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Greuges` AS SELECT + 1 AS `Id`, + 1 AS `Id_Cliente`, + 1 AS `Comentario`, + 1 AS `Importe`, + 1 AS `Fecha`, + 1 AS `odbc_date`, + 1 AS `Greuges_type_id`, + 1 AS `Id_Ticket`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `Greuges_type` +-- Temporary table structure for view `Greuges_type` -- DROP TABLE IF EXISTS `Greuges_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Greuges_type` ( - `Greuges_type_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`Greuges_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Greuges_type`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Greuges_type` AS SELECT + 1 AS `Greuges_type_id`, + 1 AS `name`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Grupos` @@ -49844,21 +51907,19 @@ CREATE TABLE `Jefes` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Monedas` +-- Temporary table structure for view `Monedas` -- DROP TABLE IF EXISTS `Monedas`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Monedas` ( - `Id_Moneda` tinyint(3) unsigned NOT NULL, - `Moneda` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `Descripcion` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - `Cambio` double NOT NULL DEFAULT '1', - PRIMARY KEY (`Id_Moneda`), - UNIQUE KEY `Moneda_UNIQUE` (`Moneda`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `Monedas`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Monedas` AS SELECT + 1 AS `Id_Moneda`, + 1 AS `Moneda`, + 1 AS `Descripcion`, + 1 AS `Cambio`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Monitoring` @@ -49913,7 +51974,7 @@ CREATE TABLE `Movimientos` ( KEY `itemFk_ticketFk` (`Id_Article`,`Id_Ticket`), CONSTRAINT `Movimientos_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON UPDATE CASCADE, CONSTRAINT `movement_ticket_id` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=25583795 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=25723068 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 */ ; @@ -50083,7 +52144,7 @@ CREATE TABLE `Movimientos_mark` ( KEY `Id_Movimiento` (`Id_Movimiento`), KEY `fgnStateFk_idx` (`stateFk`), CONSTRAINT `fgnStateFk` FOREIGN KEY (`stateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=18942105 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19278727 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 */ ; @@ -50188,7 +52249,7 @@ CREATE TABLE `Ordenes` ( CONSTRAINT `fgnAtender` FOREIGN KEY (`atenderFk`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnRequester` FOREIGN KEY (`requesterFk`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `fgnTicket` FOREIGN KEY (`ticketFk`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=48418 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=49338 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 */ ; @@ -50292,7 +52353,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=2876 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2877 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50319,6 +52380,87 @@ CREATE TABLE `Paises` ( KEY `Id_Paisreal` (`Id_Paisreal`) ) ENGINE=InnoDB AUTO_INCREMENT=71 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 `vn2008`.`country_beforeInsert` + BEFORE INSERT ON `Paises` FOR EACH ROW +BEGIN + SET NEW.geoFk = vn.zoneGeo_new('country', NEW.Pais, NULL); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`country_beforeUpdate` + BEFORE UPDATE ON `Paises` FOR EACH ROW +BEGIN + IF !(OLD.geoFk <=> NEW.geoFk) THEN + CALL vn.zoneGeo_check; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`country_afterUpdate` + AFTER UPDATE ON `Paises` FOR EACH ROW +BEGIN + IF !(OLD.Pais <=> NEW.Pais) THEN + UPDATE vn.zoneGeo SET `name` = NEW.Pais + WHERE id = NEW.geoFk; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`country_afterDelete` + AFTER DELETE ON `Paises` FOR EACH ROW +BEGIN + CALL vn.zoneGeo_delete(OLD.geoFk); +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 */ ; -- -- Table structure for table `Permisos` @@ -50420,7 +52562,7 @@ CREATE TABLE `Proveedores` ( CONSTRAINT `pay_dem_id` FOREIGN KEY (`pay_dem_id`) REFERENCES `pay_dem` (`id`) ON UPDATE CASCADE, CONSTRAINT `pay_met_id` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `province_id` FOREIGN KEY (`province_id`) REFERENCES `province` (`province_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2855 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2873 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50446,7 +52588,7 @@ CREATE TABLE `Proveedores_account` ( KEY `fk_Proveedores_account_entity1_idx` (`entity_id`), KEY `fk_banco_prov_account_idx` (`Id_Banco`), CONSTRAINT `fk_banco_prov_account` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=834 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=841 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50540,7 +52682,7 @@ CREATE TABLE `Recibos` ( CONSTRAINT `Recibos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Recibos_ibfk_2` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibo_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=588731 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=591752 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 */ ; @@ -50631,7 +52773,7 @@ CREATE TABLE `Relaciones` ( KEY `Id_Contacto` (`Id_Contacto`), KEY `Id_Proveedor` (`Id_Proveedor`), KEY `Id_Cliente` (`Id_Cliente`) -) ENGINE=InnoDB AUTO_INCREMENT=2744 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2747 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50651,7 +52793,7 @@ CREATE TABLE `Remesas` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Remesas_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `Remesas_ibfk_2` FOREIGN KEY (`Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1324 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1335 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50676,7 +52818,7 @@ CREATE TABLE `Reservas` ( PRIMARY KEY (`Id_Reserva`), KEY `Id_1` (`Id_Ticket`), KEY `Id_Article` (`Id_Article`) -) ENGINE=InnoDB AUTO_INCREMENT=235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=453 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50707,7 +52849,7 @@ CREATE TABLE `Rutas` ( KEY `Fecha` (`Fecha`), KEY `gestdoc_id` (`gestdoc_id`), CONSTRAINT `Rutas_ibfk_1` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=56250 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=56802 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 */ ; @@ -50721,9 +52863,10 @@ DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`Rutas_BEFORE_UPDATE` BEFORE UPDATE ON `Rutas` FOR EACH ROW BEGIN IF NEW.ok <> FALSE AND OLD.ok = FALSE THEN - SET NEW.m3 = (SELECT SUM(volume) - FROM vn2008.v_Movimientos_Volumen_shipping_charge - WHERE Id_Ruta = NEW.Id_Ruta); + SET NEW.m3 = ( SELECT SUM(litros)/1000 + FROM vn.saleVolume s + JOIN vn.ticket t ON s.ticketFk = t.id + WHERE t.routeFk = NEW.Id_Ruta); END IF; END */;; DELIMITER ; @@ -50791,7 +52934,7 @@ CREATE TABLE `Rutas_Master` ( PRIMARY KEY (`id`), KEY `fk_rutas_warehouse_id_idx` (`warehouse_id`), CONSTRAINT `fk_rutas_warehouse_id` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=115 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50882,7 +53025,7 @@ CREATE TABLE `Saldos_Prevision` ( KEY `empresa_prevision_idx` (`empresa_id`), CONSTRAINT `banco_prevision` FOREIGN KEY (`Id_Banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `empresa_prevision` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=258 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; +) ENGINE=InnoDB AUTO_INCREMENT=320 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Aqui ponemos los gastos e ingresos pendientes de introducir '; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50917,7 +53060,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=364773 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=365796 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -50935,7 +53078,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=36850 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=36877 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51024,7 +53167,7 @@ CREATE TABLE `Tickets` ( CONSTRAINT `ticket_customer_id` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `tickets_fk10` FOREIGN KEY (`Factura`) REFERENCES `Facturas` (`Id_Factura`) ON UPDATE CASCADE, CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `vn`.`zone` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2373808 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2390927 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 */ ; @@ -51174,7 +53317,7 @@ CREATE TABLE `Tickets_dits` ( CONSTRAINT `Tickets_dits_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fgkey1` FOREIGN KEY (`idaccion_dits`) REFERENCES `accion_dits` (`idaccion_dits`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `fgkey3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=64937723 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64983115 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 */ ; @@ -51255,7 +53398,7 @@ CREATE TABLE `Tickets_turno` ( `weekDay` tinyint(1) DEFAULT NULL COMMENT 'funcion de mysql Lunes = 0, Domingo = 6', PRIMARY KEY (`Id_Ticket`), CONSTRAINT `Id_Ticket_fk` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2365902 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2384112 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51277,88 +53420,43 @@ CREATE TABLE `Tintas` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `Tipos` +-- Temporary table structure for view `Tipos` -- DROP TABLE IF EXISTS `Tipos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Tipos` ( - `tipo_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `Id_Tipo` varchar(3) COLLATE utf8_unicode_ci NOT NULL, - `Tipo` varchar(30) COLLATE utf8_unicode_ci NOT NULL, - `Orden` int(11) DEFAULT '0', - `Temperatura` tinyint(1) unsigned NOT NULL DEFAULT '0', - `reino_id` int(10) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `inventory` tinyint(4) NOT NULL DEFAULT '1', - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `f11` tinyint(4) NOT NULL DEFAULT '0', - `father_id` smallint(5) DEFAULT NULL, - `transaction` tinyint(4) NOT NULL DEFAULT '0', - `confeccion` int(10) unsigned DEFAULT NULL, - `location` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL, - `life` smallint(5) unsigned DEFAULT NULL, - `maneuver` double NOT NULL DEFAULT '0.21', - `target` double NOT NULL DEFAULT '0.15', - `top_margin` double NOT NULL DEFAULT '0.3', - `profit` double NOT NULL DEFAULT '0.02', - `FV` tinyint(3) DEFAULT '1', - `density` double NOT NULL DEFAULT '167' COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', - `promo` double NOT NULL DEFAULT '0', - `box` tinyint(4) NOT NULL DEFAULT '0', - `CYM` int(11) NOT NULL DEFAULT '0', - `isPackaging` tinyint(1) NOT NULL DEFAULT '0', - `hasComponents` tinyint(1) NOT NULL DEFAULT '1', - `roleCodeFk` varchar(14) COLLATE utf8_unicode_ci DEFAULT NULL, - `warehouseFk` smallint(6) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`Id_Tipo`), - UNIQUE KEY `tipo_id_UNIQUE` (`tipo_id`), - UNIQUE KEY `Tipo_UNIQUE` (`Tipo`,`reino_id`), - KEY `Trabajador` (`Id_Trabajador`), - KEY `reino_id` (`reino_id`), - KEY `Tipos_fk3_idx` (`confeccion`), - KEY `tipos_fk4_idx` (`roleCodeFk`), - KEY `warehouseFk5_idx` (`warehouseFk`), - CONSTRAINT `Tipos_fk3` FOREIGN KEY (`confeccion`) REFERENCES `vn`.`confectionType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `Tipos_ibfk_1` FOREIGN KEY (`reino_id`) REFERENCES `reinos` (`id`) ON UPDATE CASCADE, - CONSTRAINT `Tipos_ibfk_2` FOREIGN KEY (`roleCodeFk`) REFERENCES `account`.`role` (`name`) ON UPDATE CASCADE, - CONSTRAINT `Trabajador` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `warehouseFk5` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=279 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 */ ; -/*!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 `Tipos_bu` BEFORE UPDATE ON `Tipos` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one -BEGIN - /* - Jgallego 12-08-2019 - - DECLARE strCOD VARCHAR(40); - - SELECT CodigoRojo INTO strCOD FROM tblContadores LIMIT 1; - - IF strCOD <> 'tipos' - THEN - SET NEW.maneuver = OLD.maneuver ; - SET NEW.target = OLD.target ; - SET NEW.top_margin = OLD.top_margin ; - SET NEW.profit = OLD.profit ; - 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 `Tipos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `Tipos` AS SELECT + 1 AS `tipo_id`, + 1 AS `Id_Tipo`, + 1 AS `Tipo`, + 1 AS `Orden`, + 1 AS `reino_id`, + 1 AS `Id_Trabajador`, + 1 AS `warehouseFk`, + 1 AS `life`, + 1 AS `isPackaging`, + 1 AS `density`, + 1 AS `roleCodeFk`, + 1 AS `f11`, + 1 AS `inventory`, + 1 AS `odbc_date`, + 1 AS `father_id`, + 1 AS `transaction`, + 1 AS `confeccion`, + 1 AS `location`, + 1 AS `Temperatura`, + 1 AS `promo`, + 1 AS `box`, + 1 AS `CYM`, + 1 AS `maneuver`, + 1 AS `target`, + 1 AS `top_margin`, + 1 AS `profit`, + 1 AS `FV`, + 1 AS `hasComponents`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `Tipos_f11` @@ -51418,7 +53516,7 @@ CREATE TABLE `Trabajadores` ( KEY `empresa_id` (`empresa_id`), CONSTRAINT `Clientes` FOREIGN KEY (`Id_Cliente_Interno`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `Trabajadores_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `account`.`user` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1355 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1368 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 */ ; @@ -51527,7 +53625,7 @@ CREATE TABLE `Vehiculos` ( KEY `provinceFk_idx` (`warehouseFk`), CONSTRAINT `Vehiculos_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`province_id`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=427 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=429 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -51559,7 +53657,7 @@ CREATE TABLE `Vehiculos_consumo` ( CONSTRAINT `fk_Vehiculos_consumo_Vehiculos` FOREIGN KEY (`Id_Vehiculo`) REFERENCES `Vehiculos` (`Id_Vehiculo`) 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 `Proveedores` (`Id_Proveedor`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=12128 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=12290 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 */; -- @@ -51673,7 +53771,7 @@ CREATE TABLE `XDiario` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `XDiario_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3947056 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3956747 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 */ ; @@ -51759,7 +53857,7 @@ CREATE TABLE `account_conciliacion` ( KEY `fg_accconciliacion_key1_idx` (`Id_Proveedores_account`), KEY `index_id_calculated` (`id_calculated`), CONSTRAINT `fg_key1_accountconc` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=32357 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=33264 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 */ ; @@ -51805,7 +53903,7 @@ CREATE TABLE `account_detail` ( KEY `fk_account_detail_Proveedores_account1_idx` (`Id_Proveedores_account`), CONSTRAINT `fk_account_detail_account_detail_type1` FOREIGN KEY (`account_detail_type_id`) REFERENCES `account_detail_type` (`account_detail_type_id`) ON UPDATE CASCADE, CONSTRAINT `fk_account_detail_account_id_proveedores_account` FOREIGN KEY (`Id_Proveedores_account`) REFERENCES `Proveedores_account` (`Id_Proveedores_account`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52095,7 +54193,7 @@ CREATE TABLE `albaran` ( CONSTRAINT `fk_albaran_empresa1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `fk_albaran_recibida` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `fk_albaran_warehouse1` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3478 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3514 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52174,7 +54272,7 @@ CREATE TABLE `awb` ( CONSTRAINT `awbInvoiceIn` FOREIGN KEY (`invoiceInFk`) REFERENCES `recibida` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `awbTransitoryFk` FOREIGN KEY (`transitario_id`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE, CONSTRAINT `awb_ibfk_1` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3417 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3453 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 */ ; @@ -52336,11 +54434,11 @@ CREATE TABLE `awb_component` ( KEY `awb_component_fk` (`awb_component_type_id`), KEY `awb_role_fk` (`awb_role_id`), KEY `awb_unit_fk` (`awb_unit_id`), - CONSTRAINT `Id_Monedafk` FOREIGN KEY (`Id_Moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON DELETE CASCADE, + CONSTRAINT `Id_Monedafk` FOREIGN KEY (`Id_Moneda`) REFERENCES `vn`.`currency` (`id`) ON DELETE CASCADE, 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=28520 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=29183 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52371,10 +54469,10 @@ CREATE TABLE `awb_component_template` ( KEY `airline_idx` (`airline_id`), KEY `role_idx` (`awb_role_id`), KEY `awb_unit_fk1` (`awb_unit_id`), - CONSTRAINT `Id_Moneda` FOREIGN KEY (`Id_Moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, + CONSTRAINT `Id_Moneda` FOREIGN KEY (`Id_Moneda`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `awb_unit_fk1` FOREIGN KEY (`awb_unit_id`) REFERENCES `awb_unit` (`awb_unit_id`) ON UPDATE CASCADE, CONSTRAINT `role_fk` FOREIGN KEY (`awb_role_id`) REFERENCES `awb_role` (`awb_role_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=824 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=838 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52455,7 +54553,7 @@ CREATE TABLE `awb_gestdoc` ( KEY `awb_gestdoc_gestdoc_fk` (`gestdoc_id`), CONSTRAINT `awb_gestdoc_awb_fk` FOREIGN KEY (`awb_id`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `awb_gestdoc_gestdoc_fk` FOREIGN KEY (`gestdoc_id`) REFERENCES `gestdoc` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3017 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3041 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52574,7 +54672,7 @@ CREATE TABLE `barcodes` ( UNIQUE KEY `Id_Article_2` (`Id_Article`,`code`), KEY `Id_Article` (`Id_Article`), CONSTRAINT `barcodes_ibfk_1` FOREIGN KEY (`Id_Article`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=41335 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=41665 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -52902,77 +55000,53 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; -- --- Table structure for table `cl_act` +-- Temporary table structure for view `cl_act` -- DROP TABLE IF EXISTS `cl_act`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_act` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Id_Movimiento` int(11) DEFAULT NULL, - `cl_main_id` int(10) unsigned NOT NULL, - `Id_Trabajador` int(11) NOT NULL DEFAULT '20', - `cl_sol_id` tinyint(4) DEFAULT NULL, - `greuge` tinyint(4) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - KEY `cl_main_id` (`cl_main_id`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `Id_Movimiento` (`Id_Movimiento`), - KEY `cl_sol_id` (`cl_sol_id`), - CONSTRAINT `cl_act_ibfk_1` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cl_act_ibfk_3` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, - CONSTRAINT `cl_act_ibfk_4` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=113925 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Acciones en respuesta a las reclamaciones'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_act`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_act` AS SELECT + 1 AS `id`, + 1 AS `Id_Movimiento`, + 1 AS `cl_main_id`, + 1 AS `Id_Trabajador`, + 1 AS `cl_sol_id`, + 1 AS `greuge`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_cau` +-- Temporary table structure for view `cl_cau` -- DROP TABLE IF EXISTS `cl_cau`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_cau` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cl_main_id` int(10) unsigned NOT NULL, - `cl_res_id` int(10) unsigned NOT NULL DEFAULT '1', - `Id_Trabajador` int(11) NOT NULL DEFAULT '20', - `cl_mot_id` int(10) unsigned NOT NULL DEFAULT '1', - `cl_con_id` int(10) unsigned NOT NULL DEFAULT '1', - `cl_dev` tinyint(3) unsigned NOT NULL DEFAULT '1', - `cl_sol` tinyint(3) unsigned NOT NULL DEFAULT '2', - PRIMARY KEY (`id`), - KEY `cl_main_id` (`cl_main_id`), - KEY `cl_res_id` (`cl_res_id`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `cl_mot_id` (`cl_mot_id`), - KEY `cl_con_id` (`cl_con_id`), - KEY `cl_dev` (`cl_dev`), - KEY `cl_sol` (`cl_sol`), - CONSTRAINT `cl_cau_ibfk_10` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_11` FOREIGN KEY (`cl_dev`) REFERENCES `cl_dev` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_12` FOREIGN KEY (`cl_sol`) REFERENCES `cl_sol` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_6` FOREIGN KEY (`cl_res_id`) REFERENCES `cl_res` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_7` FOREIGN KEY (`cl_mot_id`) REFERENCES `cl_mot` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_8` FOREIGN KEY (`cl_con_id`) REFERENCES `cl_con` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_cau_ibfk_9` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=58636 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Causas de las reclamaciones'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_cau`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_cau` AS SELECT + 1 AS `id`, + 1 AS `cl_main_id`, + 1 AS `cl_res_id`, + 1 AS `Id_Trabajador`, + 1 AS `cl_mot_id`, + 1 AS `cl_con_id`, + 1 AS `cl_dev`, + 1 AS `cl_sol`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_con` +-- Temporary table structure for view `cl_con` -- DROP TABLE IF EXISTS `cl_con`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_con` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `consecuencia` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Consecuencias de los motivos'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_con`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_con` AS SELECT + 1 AS `id`, + 1 AS `consecuencia`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `cl_dep` @@ -52989,131 +55063,83 @@ CREATE TABLE `cl_dep` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `cl_det` +-- Temporary table structure for view `cl_det` -- DROP TABLE IF EXISTS `cl_det`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_det` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cl_main_id` int(10) unsigned NOT NULL, - `Id_Movimiento` int(11) DEFAULT NULL, - `cl_que_id` int(10) unsigned NOT NULL DEFAULT '1', - `cl_pet_id` int(1) unsigned NOT NULL DEFAULT '1', - `numero` double DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `Id_Movimiento` (`Id_Movimiento`), - KEY `cl_main_id` (`cl_main_id`), - CONSTRAINT `cl_det_ibfk_7` FOREIGN KEY (`Id_Movimiento`) REFERENCES `Movimientos` (`Id_Movimiento`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cl_det_ibfk_8` FOREIGN KEY (`cl_main_id`) REFERENCES `cl_main` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=149876 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 */ ; -/*!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`.`cl_det_AFTER_INSERT` AFTER INSERT ON `cl_det` FOR EACH ROW -BEGIN - - DECLARE vTicket INT; - - SELECT s.ticketFk INTO vTicket - FROM vn.sale s - WHERE s.id = NEW.Id_Movimiento; - - UPDATE vn.claim - SET ticketFk = vTicket - WHERE id = NEW.cl_main_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 */ ; +/*!50001 DROP VIEW IF EXISTS `cl_det`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_det` AS SELECT + 1 AS `id`, + 1 AS `cl_main_id`, + 1 AS `Id_Movimiento`, + 1 AS `numero`, + 1 AS `cl_que_id`, + 1 AS `cl_pet_id`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_dev` +-- Temporary table structure for view `cl_dev` -- DROP TABLE IF EXISTS `cl_dev`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_dev` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `devolucion` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Método por el cual el cliente nos devuelve la mercancía'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_dev`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_dev` AS SELECT + 1 AS `id`, + 1 AS `devolucion`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_est` +-- Temporary table structure for view `cl_est` -- DROP TABLE IF EXISTS `cl_est`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_est` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `estado` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `roleFk` int(10) unsigned NOT NULL DEFAULT '1', - PRIMARY KEY (`id`), - KEY `roleFgn_idx` (`roleFk`), - CONSTRAINT `roleFgn` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Estados posibles de las reclamaciones'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_est`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_est` AS SELECT + 1 AS `id`, + 1 AS `estado`, + 1 AS `roleFk`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_main` +-- Temporary table structure for view `cl_main` -- DROP TABLE IF EXISTS `cl_main`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_main` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Fecha` date NOT NULL, - `cl_dep_id` tinyint(3) unsigned DEFAULT NULL, - `cl_est_id` int(10) unsigned NOT NULL DEFAULT '1', - `notas` text COLLATE utf8_unicode_ci, - `Id_Cliente` int(11) NOT NULL, - `Id_Trabajador` int(11) NOT NULL, - `sensib` int(1) unsigned NOT NULL DEFAULT '3', - `mana` tinyint(1) NOT NULL DEFAULT '0', - `odbc_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `ticketFk` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `cl_dep_id` (`cl_dep_id`), - KEY `cl_est_id` (`cl_est_id`), - KEY `Id_Cliente` (`Id_Cliente`), - KEY `Id_Trabajador` (`Id_Trabajador`), - KEY `cl_main_ticketFk_idx` (`ticketFk`), - CONSTRAINT `cl_main_ibfk_3` FOREIGN KEY (`cl_est_id`) REFERENCES `cl_est` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_main_ibfk_4` FOREIGN KEY (`cl_dep_id`) REFERENCES `cl_dep` (`id`) ON UPDATE CASCADE, - CONSTRAINT `cl_main_ibfk_5` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cl_main_ticketFk` FOREIGN KEY (`ticketFk`) REFERENCES `Tickets` (`Id_Ticket`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=67296 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Reclamaciones, tabla principal'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_main`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_main` AS SELECT + 1 AS `id`, + 1 AS `Fecha`, + 1 AS `cl_est_id`, + 1 AS `notas`, + 1 AS `Id_Cliente`, + 1 AS `Id_Trabajador`, + 1 AS `sensib`, + 1 AS `mana`, + 1 AS `ticketFk`, + 1 AS `odbc_date`, + 1 AS `cl_dep_id`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_mot` +-- Temporary table structure for view `cl_mot` -- DROP TABLE IF EXISTS `cl_mot`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_mot` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `motivo` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Motivos de las fallos'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_mot`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_mot` AS SELECT + 1 AS `id`, + 1 AS `motivo`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `cl_pet` @@ -53144,36 +55170,32 @@ CREATE TABLE `cl_que` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `cl_res` +-- Temporary table structure for view `cl_res` -- DROP TABLE IF EXISTS `cl_res`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_res` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `responsable` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `sensibility` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'if=1 >sensib >culpa', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Responsables de las causas'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_res`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_res` AS SELECT + 1 AS `id`, + 1 AS `responsable`, + 1 AS `sensibility`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `cl_sol` +-- Temporary table structure for view `cl_sol` -- DROP TABLE IF EXISTS `cl_sol`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `cl_sol` ( - `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `solucion` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - `addressFk` int(10) DEFAULT NULL COMMENT 'Indica el consignatario para el ticket que regulariza el inventario', - PRIMARY KEY (`id`), - KEY `clSolAddressFk_idx` (`addressFk`), - CONSTRAINT `clSolAddressFk` FOREIGN KEY (`addressFk`) REFERENCES `Consignatarios` (`id_consigna`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Solucion ofrecida a la reclamación'; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `cl_sol`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `cl_sol` AS SELECT + 1 AS `id`, + 1 AS `solucion`, + 1 AS `addressFk`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `clientMana` @@ -53214,7 +55236,7 @@ CREATE TABLE `client_observation` ( KEY `Id_Cliente` (`Id_Cliente`), CONSTRAINT `client_observation_ibfk_1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `client_observation_ibfk_2` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=76612 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; +) ENGINE=InnoDB AUTO_INCREMENT=76825 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53337,15 +55359,18 @@ CREATE TABLE `config_host` ( `Permanente` tinyint(1) unsigned DEFAULT '1', `route_days_before` smallint(6) DEFAULT '2', `route_days_after` smallint(6) DEFAULT '1', + `sectorFk` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`config_host_id`), KEY `warehouse` (`warehouse`), KEY `empresa_id` (`empresa_id`), KEY `caja` (`caja`), KEY `Id_Impresora` (`Id_Impresora`), + KEY `config_host_ibfk_5_idx` (`sectorFk`), CONSTRAINT `config_host_ibfk_1` FOREIGN KEY (`caja`) REFERENCES `Bancos` (`Id_Banco`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `config_host_ibfk_2` FOREIGN KEY (`warehouse`) REFERENCES `warehouse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `config_host_ibfk_3` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `config_host_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON DELETE NO ACTION ON UPDATE CASCADE + CONSTRAINT `config_host_ibfk_4` FOREIGN KEY (`Id_Impresora`) REFERENCES `Impresoras` (`Id_Impresora`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `config_host_ibfk_5` FOREIGN KEY (`sectorFk`) REFERENCES `vn`.`sector` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Sustituye al antiguo TPV_Settings'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -53576,10 +55601,14 @@ CREATE TABLE `device` ( `device_id` int(11) NOT NULL AUTO_INCREMENT, `sn` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `model` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, + `macWifi` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `serialNumber` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `departmentFk` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, + `isOutOfService` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`device_id`), UNIQUE KEY `device_id_UNIQUE` (`device_id`), UNIQUE KEY `sn_UNIQUE` (`sn`) -) ENGINE=InnoDB AUTO_INCREMENT=301 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=330 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53913,23 +55942,19 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `entity` +-- Temporary table structure for view `entity` -- DROP TABLE IF EXISTS `entity`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `entity` ( - `pais_id` mediumint(8) unsigned NOT NULL DEFAULT '1', - `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `bic` varchar(11) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`entity_id`), - UNIQUE KEY `bic_UNIQUE` (`bic`), - KEY `fg_entity1_idx` (`pais_id`), - CONSTRAINT `fg_entity1` FOREIGN KEY (`pais_id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=30044 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Entidades bancarias '; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `entity`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `entity` AS SELECT + 1 AS `entity_id`, + 1 AS `pais_id`, + 1 AS `description`, + 1 AS `bic`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `escritos` @@ -53968,7 +55993,7 @@ CREATE TABLE `escritos_det` ( PRIMARY KEY (`id`), KEY `empresa_id` (`empresa_id`), CONSTRAINT `escritos_det_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=17920 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=18012 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -53998,7 +56023,7 @@ CREATE TABLE `expeditions` ( KEY `index4` (`ticket_id`), CONSTRAINT `Id_Agencia` FOREIGN KEY (`agency_id`) REFERENCES `Agencias` (`Id_Agencia`) ON UPDATE CASCADE, CONSTRAINT `ticket_id` FOREIGN KEY (`ticket_id`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=3231826 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=3260025 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 */ ; @@ -54242,7 +56267,7 @@ CREATE TABLE `gestdoc` ( UNIQUE KEY `emp_id` (`emp_id`,`orden`,`warehouse_id`), KEY `trabajador_id` (`trabajador_id`), KEY `warehouse_id` (`warehouse_id`) -) ENGINE=InnoDB AUTO_INCREMENT=1309756 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='document managment system'; +) ENGINE=InnoDB AUTO_INCREMENT=1320483 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 */ ; @@ -54448,7 +56473,7 @@ CREATE TABLE `intrastat_data` ( KEY `recibida` (`recibida_id`), CONSTRAINT `intrastat_data_ibfk_1` FOREIGN KEY (`intrastat_id`) REFERENCES `Intrastat` (`Codintrastat`) ON UPDATE CASCADE, CONSTRAINT `intrastat_data_ibfk_2` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=79394 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=80181 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54745,7 +56770,7 @@ CREATE TABLE `mail` ( PRIMARY KEY (`id`), KEY `sent_idx` (`sent`), KEY `creation_idx` (`DATE_ODBC`) -) ENGINE=InnoDB AUTO_INCREMENT=1833908 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1848508 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -54782,67 +56807,35 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `mandato` +-- Temporary table structure for view `mandato` -- DROP TABLE IF EXISTS `mandato`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mandato` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `Id_Cliente` int(11) NOT NULL, - `empresa_id` smallint(5) unsigned NOT NULL, - `Id_mandato` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, - `FAlta` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `Fbaja` timestamp NULL DEFAULT NULL, - `idmandato_tipo` smallint(5) NOT NULL, - PRIMARY KEY (`id`), - KEY `mandato_fgkey1_idx` (`Id_Cliente`), - KEY `mandato_fgkey2_idx` (`empresa_id`), - KEY `mandato_fgkey3_idx` (`idmandato_tipo`), - CONSTRAINT `mandato_fgkey1` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `mandato_fgkey2` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, - CONSTRAINT `mandato_fgkey3` FOREIGN KEY (`idmandato_tipo`) REFERENCES `mandato_tipo` (`idmandato_tipo`) ON DELETE NO ACTION ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=16787 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 = '' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 trigger mandato_ins before insert -on mandato -for each row -begin - if (NEW.Id_mandato IS NULL) THEN - SET NEW.Id_mandato=CONCAT(NEW.Id_Cliente,'-',(SELECT AUTO_INCREMENT - from information_schema.TABLES - where TABLE_SCHEMA='vn2008' and TABLE_NAME='mandato')); - 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 `mandato`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `mandato` AS SELECT + 1 AS `id`, + 1 AS `Id_Cliente`, + 1 AS `empresa_id`, + 1 AS `Id_mandato`, + 1 AS `FAlta`, + 1 AS `Fbaja`, + 1 AS `idmandato_tipo`*/; +SET character_set_client = @saved_cs_client; -- --- Table structure for table `mandato_tipo` +-- Temporary table structure for view `mandato_tipo` -- DROP TABLE IF EXISTS `mandato_tipo`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `mandato_tipo` ( - `idmandato_tipo` smallint(5) NOT NULL AUTO_INCREMENT, - `Nombre` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`idmandato_tipo`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `mandato_tipo`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `mandato_tipo` AS SELECT + 1 AS `idmandato_tipo`, + 1 AS `Nombre`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `movement_label` @@ -54893,18 +56886,17 @@ CREATE TABLE `nichos` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `observation_type` +-- Temporary table structure for view `observation_type` -- DROP TABLE IF EXISTS `observation_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `observation_type` ( - `observation_type_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(15) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`observation_type_id`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `observation_type`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `observation_type` AS SELECT + 1 AS `observation_type_id`, + 1 AS `description`*/; +SET character_set_client = @saved_cs_client; -- -- Temporary table structure for view `order` @@ -55009,10 +57001,10 @@ CREATE TABLE `pago` ( KEY `fk_pago_pago_sdc1_idx` (`pago_sdc_id`), CONSTRAINT `pago_ibfk_1` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_ibfk_2` FOREIGN KEY (`id_banco`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, - CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `Monedas` (`Id_Moneda`) ON UPDATE CASCADE, + CONSTRAINT `pago_moneda` FOREIGN KEY (`id_moneda`) REFERENCES `vn`.`currency` (`id`) ON UPDATE CASCADE, CONSTRAINT `pago_pay_met` FOREIGN KEY (`pay_met_id`) REFERENCES `pay_met` (`id`) ON UPDATE CASCADE, CONSTRAINT `proveedor_pago` FOREIGN KEY (`id_proveedor`) REFERENCES `Proveedores` (`Id_Proveedor`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=50963 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=51126 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 */ ; @@ -55092,7 +57084,7 @@ CREATE TABLE `pago_sdc` ( KEY `pago_sdc_entity_fk_idx` (`entity_id`), CONSTRAINT `empresa_sdc` FOREIGN KEY (`empresa_id`) REFERENCES `empresa` (`id`) ON UPDATE CASCADE, CONSTRAINT `financial_type_fk` FOREIGN KEY (`financialProductTypefk`) REFERENCES `financialProductType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `pago_sdc_entity_fk` FOREIGN KEY (`entity_id`) REFERENCES `entity` (`entity_id`) ON UPDATE CASCADE + CONSTRAINT `pago_sdc_entity_fk` FOREIGN KEY (`entity_id`) REFERENCES `vn`.`bankEntity` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Seguros de cambio'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -55509,7 +57501,7 @@ CREATE TABLE `price_fixed` ( KEY `date_end` (`date_end`), KEY `warehouse_id` (`warehouse_id`), CONSTRAINT `price_fixed_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `Articles` (`Id_Article`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=63892 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=64019 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 */ ; @@ -55571,7 +57563,7 @@ CREATE TABLE `producer` ( `visible` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`producer_id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=12235 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=12600 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -55632,22 +57624,85 @@ CREATE TABLE `province` ( CONSTRAINT `province_ibfk_1` FOREIGN KEY (`Paises_Id`) REFERENCES `Paises` (`Id`) ON UPDATE CASCADE, CONSTRAINT `province_zone_fk` FOREIGN KEY (`zone`) REFERENCES `zones` (`zone_id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `warehouse_Id` FOREIGN KEY (`warehouse_id`) REFERENCES `warehouse` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=206 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 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 `vn2008`.`provinceBeforeInsert` +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`province_beforeInsert` BEFORE INSERT ON `province` FOR EACH ROW BEGIN - IF NEW.`name` = '' THEN - CALL util.throw ('EMPTY_NAME'); + DECLARE vParentFk INT; + + IF NEW.`name` = '' THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Column `name` cannot be empty'; + END IF; + + SELECT geoFk INTO vParentFk + FROM vn.country WHERE id = NEW.Paises_id; + + SET NEW.geoFk = vn.zoneGeo_new('province', NEW.`name`, vParentFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `province_beforeUpdate` BEFORE UPDATE ON `province` FOR EACH ROW BEGIN + IF !(OLD.geoFk <=> NEW.geoFk) THEN + CALL vn.zoneGeo_check; + END IF; +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_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`.`province_afterUpdate` + AFTER UPDATE ON `province` FOR EACH ROW +BEGIN + DECLARE vParentFk INT; + + IF !(OLD.`name` <=> NEW.`name`) THEN + IF NEW.`name` = '' THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'Column `name` cannot be empty'; + END IF; + + UPDATE vn.zoneGeo SET `name` = NEW.`name` + WHERE id = NEW.geoFk; + END IF; + + IF !(OLD.Paises_id <=> NEW.Paises_id) THEN + SELECT geoFk INTO vParentFk + FROM vn.country WHERE id = NEW.Paises_id; + + CALL vn.zoneGeo_setParent(NEW.geoFk, vParentFk); END IF; END */;; DELIMITER ; @@ -55658,18 +57713,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 ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`provinceBeforeUpdate` - BEFORE UPDATE ON `province` FOR EACH ROW +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn2008`.`province_afterDelete` + AFTER DELETE ON `province` FOR EACH ROW BEGIN - IF NEW.`name` = '' THEN - CALL util.throw ('EMPTY_NAME'); - END IF; + CALL vn.zoneGeo_delete(OLD.geoFk); END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55740,7 +57793,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=85334 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=85928 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 */ ; @@ -56329,7 +58382,7 @@ CREATE TABLE `recibida_iva` ( CONSTRAINT `recibida_iva_ibfk_2` FOREIGN KEY (`iva_id`) REFERENCES `iva_codigo` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_5` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `recibida_iva_ibfk_6` FOREIGN KEY (`gastos_id`) REFERENCES `Gastos` (`Id_Gasto`) ON DELETE NO ACTION ON UPDATE NO ACTION -) ENGINE=InnoDB AUTO_INCREMENT=146229 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=149814 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56352,7 +58405,7 @@ CREATE TABLE `recibida_vencimiento` ( KEY `banco_id` (`banco_id`), CONSTRAINT `recibida_vencimiento_ibfk_6` FOREIGN KEY (`banco_id`) REFERENCES `Bancos` (`Id_Banco`) ON UPDATE CASCADE, CONSTRAINT `recibida_vencimiento_ibfk_7` FOREIGN KEY (`recibida_id`) REFERENCES `recibida` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=144306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=147938 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 */ ; @@ -56395,7 +58448,7 @@ CREATE TABLE `recovery` ( KEY `cliente_idx` (`Id_Cliente`), CONSTRAINT `cliente333` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE, CONSTRAINT `cliente_cliente` FOREIGN KEY (`Id_Cliente`) REFERENCES `Clientes` (`id_cliente`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=306 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='En esta tabla apuntaremos los acuerdos de recobro semanal a '; +) ENGINE=InnoDB AUTO_INCREMENT=309 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 */; -- @@ -56448,25 +58501,23 @@ CREATE TABLE `reference_rate` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `reinos` +-- Temporary table structure for view `reinos` -- DROP TABLE IF EXISTS `reinos`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `reinos` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `reino` varchar(45) COLLATE utf8_unicode_ci NOT NULL, - `orden` int(10) unsigned DEFAULT NULL, - `display` tinyint(4) NOT NULL DEFAULT '1', - `color` char(6) COLLATE utf8_unicode_ci DEFAULT NULL, - `efimero` int(11) NOT NULL DEFAULT '0' COMMENT 'Sirve para filtrar aquellos reinos que tienen precios estables', - `mercancia` tinyint(1) NOT NULL DEFAULT '1', - `icon` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `reino_UNIQUE` (`reino`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +/*!50001 DROP VIEW IF EXISTS `reinos`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `reinos` AS SELECT + 1 AS `id`, + 1 AS `reino`, + 1 AS `display`, + 1 AS `color`, + 1 AS `icon`, + 1 AS `mercancia`, + 1 AS `orden`, + 1 AS `efimero`*/; +SET character_set_client = @saved_cs_client; -- -- Table structure for table `reparacion` @@ -56577,7 +58628,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=103650 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Se borra automaticamente 8 dias en el pasado desde vn2008.clean'; +) ENGINE=InnoDB AUTO_INCREMENT=105074 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 */; -- @@ -56619,7 +58670,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=1304033 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=1324937 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -56641,7 +58692,7 @@ CREATE TABLE `sharingcart` ( KEY `Suplent` (`Id_Suplente`), CONSTRAINT `Suplent_key` FOREIGN KEY (`Id_Suplente`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE, CONSTRAINT `Trabajador_key` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=2155 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2163 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 */ ; @@ -56851,9 +58902,11 @@ CREATE TABLE `state` ( `alert_level` int(11) NOT NULL DEFAULT '0', `code` varchar(45) CHARACTER SET utf8 NOT NULL, `sectorProdPriority` tinyint(3) DEFAULT NULL, + `nextStateFk` tinyint(4) NOT NULL COMMENT 'Estado al que tiene que cambiar el ticket despues de preparacion previa', + `isPreviousPreparable` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57136,8 +59189,8 @@ CREATE TABLE `ticket_observation` ( UNIQUE KEY `Id_Ticket` (`Id_Ticket`,`observation_type_id`), KEY `observation_type_id` (`observation_type_id`), CONSTRAINT `ticket_observation_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `ticket_observation_ibfk_2` FOREIGN KEY (`observation_type_id`) REFERENCES `observation_type` (`observation_type_id`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=1436068 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; + CONSTRAINT `ticket_observation_ibfk_2` FOREIGN KEY (`observation_type_id`) REFERENCES `vn`.`observationType` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=1448138 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Todas las observaciones referentes a un ticket'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57296,7 +59349,7 @@ CREATE TABLE `travel_dits` ( KEY `fgkey2_idx` (`Id_Ticket`), KEY `fgkey3_idx` (`Id_Trabajador`), CONSTRAINT `travel_dits_ibfk_1` FOREIGN KEY (`Id_Trabajador`) REFERENCES `Trabajadores` (`Id_Trabajador`) ON DELETE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=234193 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=236008 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57570,14 +59623,14 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Temporary table structure for view `v_Movimientos_Volumen_shipping_charge` +-- Temporary table structure for view `v_Movimientos_Volumen_shipping_charge__` -- -DROP TABLE IF EXISTS `v_Movimientos_Volumen_shipping_charge`; -/*!50001 DROP VIEW IF EXISTS `v_Movimientos_Volumen_shipping_charge`*/; +DROP TABLE IF EXISTS `v_Movimientos_Volumen_shipping_charge__`; +/*!50001 DROP VIEW IF EXISTS `v_Movimientos_Volumen_shipping_charge__`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; -/*!50001 CREATE VIEW `v_Movimientos_Volumen_shipping_charge` AS SELECT +/*!50001 CREATE VIEW `v_Movimientos_Volumen_shipping_charge__` AS SELECT 1 AS `Id_Ticket`, 1 AS `Id_Ruta`, 1 AS `Id_Movimiento`, @@ -58601,7 +60654,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=225 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=232 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -58646,6 +60699,21 @@ SET character_set_client = utf8; 1 AS `alias`*/; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `zoneNicknameKk` +-- + +DROP TABLE IF EXISTS `zoneNicknameKk`; +/*!50001 DROP VIEW IF EXISTS `zoneNicknameKk`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE VIEW `zoneNicknameKk` AS SELECT + 1 AS `warehouse_id`, + 1 AS `agency_id`, + 1 AS `zona`, + 1 AS `alias`*/; +SET character_set_client = @saved_cs_client; + -- -- Table structure for table `zones` -- @@ -60321,7 +62389,7 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 DROP FUNCTION IF EXISTS `ticket_volumen` */; +/*!50003 DROP FUNCTION IF EXISTS `ticket_volumen_encajado__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -60331,7 +62399,48 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` FUNCTION `ticket_volumen`(idT INT) RETURNS decimal(10,3) +CREATE DEFINER=`root`@`%` FUNCTION `ticket_volumen_encajado__`(idT INT) RETURNS decimal(10,1) + READS SQL DATA +BEGIN + +/* Devuelve el volumen estimado de un pedido, en cajas +* +* idT Numero de ticket +* +*/ + + + DECLARE vVolumenCajaM3 DOUBLE; + DECLARE vTicketVolumenEnCajas DECIMAL(10,1); + DECLARE CAJA VARCHAR(10) DEFAULT '94'; + + SELECT Volumen/1000000 INTO vVolumenCajaM3 FROM Cubos WHERE Id_Cubo = CAJA; + + SELECT SUM(volume)/vVolumenCajaM3 INTO vTicketVolumenEnCajas + FROM vn2008.v_Movimientos_Volumen_shipping_charge + WHERE Id_Ticket = idT; + + -- SET vTicketVolumenEnCajas = ticket_volumen(idT) / vVolumenCajaM3; + + RETURN vTicketVolumenEnCajas; + +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 `ticket_volumen__` */; +/*!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`@`%` FUNCTION `ticket_volumen__`(idT INT) RETURNS decimal(10,3) READS SQL DATA BEGIN -- OBSOLETA USAR vn.ticketTotalVolumen JGF 2018-05-22 @@ -60357,47 +62466,6 @@ BEGIN RETURN dblVolume; -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 `ticket_volumen_encajado` */; -/*!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`@`%` FUNCTION `ticket_volumen_encajado`(idT INT) RETURNS decimal(10,1) - READS SQL DATA -BEGIN - -/* Devuelve el volumen estimado de un pedido, en cajas -* -* idT Numero de ticket -* -*/ - - - DECLARE vVolumenCajaM3 DOUBLE; - DECLARE vTicketVolumenEnCajas DECIMAL(10,1); - DECLARE CAJA VARCHAR(10) DEFAULT '94'; - - SELECT Volumen/1000000 INTO vVolumenCajaM3 FROM Cubos WHERE Id_Cubo = CAJA; - - SELECT SUM(volume)/vVolumenCajaM3 INTO vTicketVolumenEnCajas - FROM vn2008.v_Movimientos_Volumen_shipping_charge - WHERE Id_Ticket = idT; - - -- SET vTicketVolumenEnCajas = ticket_volumen(idT) / vVolumenCajaM3; - - RETURN vTicketVolumenEnCajas; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63270,6 +65338,8 @@ proc: BEGIN 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'; @@ -66198,6 +68268,9 @@ BEGIN C.Tarifa2 = @t2:= ROUND(@t3 * (1 + ( (TC.t2 - TC.t3)/100) ),2), C.Tarifa2 = IF(@t2 <= @t3, @t3 , @t2) WHERE C.Id_Compra = v_buy; + + DROP TEMPORARY TABLE tblTARIFAS; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66230,33 +68303,28 @@ BEGIN WHERE a.code = strAWB LIMIT 1; - CALL buy_tarifas_table(vEntryFk); + CALL buy_tarifas_table(vEntryFk); - UPDATE Compres C - LEFT JOIN Cubos CB USING(Id_Cubo) - JOIN Articles A USING(Id_Article) - JOIN Entradas E USING(Id_Entrada) - JOIN vn.duaEntry de ON de.entryFk = E.Id_Entrada - JOIN vn.dua d ON d.id = de.duaFk - JOIN v_awb_volumen va ON va.awb_id = d.awbFk - JOIN Tipos TP USING(tipo_id) - JOIN travel TR ON TR.id = E.travel_id - JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia - JOIN tblTARIFAS TC - - SET C.Portefijo = @PF:= round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 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 - - C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100) ),2), - - C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) - - WHERE va.codigo = strAWB ; + UPDATE Compres C + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING(Id_Entrada) + JOIN vn.duaEntry de ON de.entryFk = E.Id_Entrada + JOIN vn.dua d ON d.id = de.duaFk + JOIN v_awb_volumen va ON va.awb_id = d.awbFk + JOIN Tipos TP USING(tipo_id) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + JOIN tblTARIFAS TC + SET C.Portefijo = @PF:= round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 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 + C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100) ),2), + C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) + WHERE va.codigo = strAWB ; + + DROP TEMPORARY TABLE tblTARIFAS; END ;; DELIMITER ; @@ -66307,6 +68375,66 @@ drop temporary table killme; CLOSE rs; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_tarifas_awb__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas_awb__`(IN strAWB varchar(18)) +BEGIN + + DECLARE vWarehouseFk INT; + DECLARE vEntryFk INT; + + SELECT tr.warehouseInFk, de.entryFk + INTO vWarehouseFk, vEntryFk + FROM vn.travel tr + JOIN vn.entry e ON e.travelFk = tr.id + JOIN vn.duaEntry de ON de.entryFk = e.id + JOIN vn.dua d ON d.id = de.duaFk + JOIN vn.awb a ON a.id = d.awbFk + WHERE a.code = strAWB + LIMIT 1; + + CALL buy_tarifas_table(vEntryFk); + + UPDATE Compres C + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING(Id_Entrada) + JOIN vn.duaEntry de ON de.entryFk = E.Id_Entrada + JOIN vn.dua d ON d.id = de.duaFk + JOIN v_awb_volumen va ON va.awb_id = d.awbFk + JOIN Tipos TP USING(tipo_id) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + JOIN tblTARIFAS TC + + SET C.Portefijo = @PF:= round((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 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 + + C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100) ),2), + + C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) + + WHERE va.codigo = strAWB ; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66324,6 +68452,60 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas_entry`(IN entryFk INT(11)) +BEGIN + + DECLARE vIsWarehouseFloramondo BOOLEAN DEFAULT FALSE; + + CALL buy_tarifas_table(entryFk); + + SELECT t.id INTO vIsWarehouseFloramondo + FROM vn.entry e + JOIN vn.travel t ON t.id = e.travelFk + JOIN vn.warehouse w ON w.id = t.warehouseInFk + WHERE w.`name` = 'Floramondo' AND e.id = entryFk; + + UPDATE Compres C + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Entradas E USING(Id_Entrada) + LEFT JOIN vn.duaEntry de on E.Id_Entrada = de.entryFk + LEFT JOIN vn.dua d ON d.id = de.duaFk + LEFT JOIN v_awb_volumen va ON va.awb_id = d.awbFk + JOIN Tipos TP USING(tipo_id) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + JOIN tblTARIFAS TC + SET C.Portefijo = @PF:= + IF (va.importe, + ROUND((va.importe * A.density * CM3_2(C.Id_Cubo, C.Id_Article) / 1000) / (va.Vol_Total * 167 * C.Packing ),3), + ROUND(IFNULL(((AG.m3 * @cm3:= cm3_2(C.Id_Cubo, C.Id_Article)) / 1000000) / C.Packing,0),3) + ), + C.Comisionfija = @CF:= ROUND(IFNULL(E.comision * C.Costefijo / 100,0),3), + C.Embalajefijo = @EF:= IF(CB.Retornable != 0 OR vIsWarehouseFloramondo, 0, ROUND(IFNULL( CB.Valor / C.Packing ,0),3)), + C.Tarifa3 = @t3:= IF(TC.t3 = 0, C.Costefijo,ROUND((C.Costefijo + @CF + @EF + @PF) / ((100 - TC.t3 - TP.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + C.Tarifa2 = @t2:= round(@t3 * (1 + ( (TC.t2 - TC.t3)/100)),2), + C.Tarifa2 = @t2:= IF(@t2 <= @t3, @t3 , @t2) + WHERE C.Id_Entrada = entryFk; + + 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 `buy_tarifas_entry__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas_entry__`(IN entryFk INT(11)) BEGIN DECLARE vIsWarehouseFloramondo BOOLEAN DEFAULT FALSE; @@ -66803,11 +68985,7 @@ BEGIN ORDER BY fecha DESC LIMIT 1; - UPDATE bi.rotacion r - JOIN Compres c ON c.Id_Article = r.Id_Article - SET cm3 = vn2008.cm3_unidad(c.Id_Compra) - WHERE Id_Entrada = v_entry - AND r.warehouse_id = v_wh; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66869,6 +69047,111 @@ 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_tarifas_table__` */; +/*!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 `buy_tarifas_table__`(v_entry INT) +BEGIN + DECLARE v_date DATE; + DECLARE v_wh INT; + + -- Obtiene fecha de llegada y almacén entrante + + SELECT landing, warehouse_id INTO v_date , v_wh + FROM travel TR + JOIN Entradas E ON TR.id = E.travel_id + WHERE Id_Entrada = v_entry; + + -- Prepara una tabla con las tarifas aplicables en funcion de la fecha y el almacén + + DROP TEMPORARY TABLE IF EXISTS tblTARIFAS; + CREATE TEMPORARY TABLE tblTARIFAS + ENGINE = MEMORY + + SELECT t0, t1, t2, t3 + FROM tarifas + WHERE fecha <= v_date + AND warehouse_id = v_wh + ORDER BY fecha DESC + LIMIT 1; + + UPDATE bi.rotacion r + JOIN Compres c ON c.Id_Article = r.Id_Article + SET cm3 = vn2008.cm3_unidad(c.Id_Compra) + WHERE Id_Entrada = v_entry + AND r.warehouse_id = v_wh; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_tarifas__` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_tarifas__`(v_buy INT) +BEGIN + DECLARE v_entry INT; + DECLARE v_wh INT; + DECLARE vIsWarehouseFloramondo BOOLEAN DEFAULT FALSE; + DECLARE vWarehouseFloramondo INT DEFAULT 40; + + SELECT Id_Entrada, warehouse_id + INTO v_entry, v_wh + FROM Compres + JOIN Entradas USING(Id_Entrada) + JOIN travel ON travel.id = travel_id + WHERE v_buy = Id_Compra; + + SELECT t.id INTO vIsWarehouseFloramondo + FROM vn.entry e + JOIN vn.travel t ON t.id = e.travelFk + WHERE t.warehouseInFk = vWarehouseFloramondo AND e.id = v_entry; + + CALL buy_tarifas_table (v_entry); + + UPDATE Compres C + LEFT JOIN Cubos CB USING(Id_Cubo) + JOIN Articles A USING(Id_Article) + JOIN Tipos TP USING(tipo_id) + JOIN Entradas E USING(Id_Entrada) + JOIN travel TR ON TR.id = E.travel_id + JOIN Agencias AG ON TR.agency_id = AG.Id_Agencia + LEFT JOIN recibida_entrada re ON E.Id_Entrada = re.Id_Entrada + LEFT JOIN awb_recibida ar ON re.awb_recibida = ar.recibida_id + LEFT JOIN v_awb_volumen va ON va.awb_id = ar.awb_id + JOIN 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) + ), + 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), + C.Tarifa3 = @t3:= IF(TC.t3 = 0, C.Costefijo,ROUND((C.Costefijo + @CF + @EF + @PF) / ((100 - TC.t3 - TP.promo ) /100) ,2)), -- He añadido que el coste sea igual a tarifa3 si t3 = 0 + C.Tarifa2 = @t2:= ROUND(@t3 * (1 + ( (TC.t2 - TC.t3)/100) ),2), + C.Tarifa2 = IF(@t2 <= @t3, @t3 , @t2) + WHERE C.Id_Compra = v_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 `buy_transfer` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68705,7 +70988,7 @@ BEGIN SELECT `sql` INTO strFILTRO FROM filtros WHERE id = i_filtro; END IF; - IF days < 0 OR days > 30 THEN + IF days < 0 OR days > 60 THEN SET days = 15; END IF; @@ -68884,7 +71167,7 @@ BEGIN ,(IFNULL(it.itemFk,0) != 0) isTagged ,A.tag5, A.value5, A.tag6, A.value6, A.tag7, A.value7, A.tag8, A.value8 - ,A.tag9, A.value9, A.tag10, A.value10, A.description,A.isActive + ,A.tag9, A.value9, A.tag10, A.value10, A.description,A.isActive, A.density FROM vn2008.article_inventory i JOIN vn2008.Articles A ON A.Id_Article = i.article_id LEFT JOIN vn.itemTagged it ON it.itemFk = i.article_id @@ -73361,6 +75644,228 @@ proc: BEGIN LEAVE proc; END IF; + SET date_tomorrow = TIMESTAMPADD(DAY, 1,date_ticket); + SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, GREATEST(days_max,15), date_ticket),'23:59:59'); + SET date_top = TIMESTAMPADD(DAY, 1,date_end); + + IF date_ticket <= CURDATE() THEN + SELECT FechaInventario INTO date_start FROM tblContadores; + ELSE + SET date_start = date_ticket; + END IF; + + -- Calculo del inventario dia D a las 24:00 zulu + + UPDATE article_inventory AI INNER JOIN + + ( + + SELECT Id_Article, SUM(amount) as Subtotal FROM + + ( + + SELECT Id_Article, -Cantidad AS amount + + FROM Movimientos M + JOIN Tickets T USING (Id_Ticket) + JOIN warehouse W ON W.id = T.warehouse_id + WHERE DATE(Fecha) BETWEEN date_start AND date_ticket + AND IF(wh = 0, W.is_comparative, wh =T.warehouse_id) + + UNION ALL + + SELECT Id_Article, Cantidad + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + LEFT JOIN travel TR ON E.travel_id = TR.id + JOIN warehouse W ON W.id = TR.warehouse_id -- PAK + WHERE TR.landing BETWEEN date_start AND date_ticket + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id) + AND E.Inventario = 0 + AND E.Redada = 0 + + UNION ALL + + SELECT Id_Article, -Cantidad + FROM Compres C + JOIN Entradas E USING (Id_Entrada) + JOIN travel TR ON E.travel_id = TR.id + JOIN warehouse W ON W.id = TR.warehouse_id_out + WHERE TR.shipment BETWEEN date_start AND date_ticket + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id_out) + AND E.Inventario = 0 + AND E.Redada = 0 + + ) AS T1 + + GROUP BY Id_Article + + ) AS T2 + + ON AI.article_id = T2.Id_Article + + SET AI.inventory = T2.Subtotal, + + AI.visible = T2.Subtotal, + + AI.avalaible = T2.Subtotal, + + AI.sd = T2.Subtotal; + + -- Calculo del visible + + UPDATE article_inventory AI INNER JOIN + ( + SELECT Id_Article, SUM(amount) as Subtotal FROM + ( + SELECT Id_Article, Cantidad AS amount + FROM Movimientos M + JOIN Tickets T USING (Id_Ticket) + JOIN warehouse W ON W.id = T.warehouse_id -- PAK + WHERE Fecha >= date_ticket AND Fecha < date_tomorrow -- PAK + AND (M.OK = 0 AND T.Etiquetasemitidas = 0 AND T.Factura IS NULL) + AND IF(wh = 0, W.is_comparative, wh =T.warehouse_id) + + UNION ALL + + SELECT Id_Article, -Cantidad + FROM Compres C + JOIN Entradas E USING (Id_Entrada) + JOIN travel TR ON E.travel_id = TR.id + JOIN warehouse W ON W.id = TR.warehouse_id -- PAK + WHERE TR.landing = date_ticket + AND TR.received = 0 + AND E.Inventario = 0 + AND E.Redada = 0 + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id) + + UNION ALL + + SELECT Id_Article, Cantidad + FROM Compres C INNER JOIN Entradas E USING (Id_Entrada) + LEFT JOIN travel TR ON E.travel_id = TR.id + INNER JOIN warehouse W ON W.id = TR.warehouse_id_out + WHERE TR.shipment = date_ticket + AND TR.delivered = 0 + AND E.Inventario = 0 + AND E.Redada = 0 + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id_out) + + ) AS T1 + + GROUP BY Id_Article + + ) AS T2 + + ON AI.article_id = T2.Id_Article + + SET AI.visible = AI.visible + T2.Subtotal; + + -- Calculo del disponible + + CALL item_travel (wh, date_ticket); + + UPDATE article_inventory AI INNER JOIN + ( + SELECT Tic3.Id_Article, SUM(amount) AS sd, minacum(Fecha, amount, date_ticket) as smd FROM + ( + + SELECT Tic2.Id_Article, Fecha, SUM(amount) AS amount FROM + ( + SELECT Id_Article, DATE(Fecha) as Fecha, -Cantidad AS amount + FROM Movimientos M + JOIN Tickets T USING (Id_Ticket) + JOIN warehouse W ON W.id = T.warehouse_id + WHERE Fecha BETWEEN date_tomorrow AND date_end + AND IF(wh = 0, W.is_comparative, wh =T.warehouse_id) + + UNION ALL + + SELECT Id_Article, landing as Fecha, Cantidad + FROM Compres C + JOIN Entradas E USING (Id_Entrada) + JOIN travel TR ON E.travel_id = TR.id + JOIN warehouse W ON W.id = TR.warehouse_id -- PAK + WHERE TR.landing BETWEEN date_tomorrow AND date_end + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id) + AND E.Inventario = 0 + AND E.Redada = 0 + + UNION ALL + + SELECT Id_Article, shipment as Fecha, -Cantidad + FROM Compres C + JOIN Entradas E USING (Id_Entrada) + JOIN travel TR ON E.travel_id = TR.id + JOIN warehouse W ON W.id = TR.warehouse_id_out + WHERE TR.shipment BETWEEN date_tomorrow AND date_end + AND IF(wh = 0, W.is_comparative, wh =TR.warehouse_id_out) + AND E.Inventario = 0 + AND E.Redada = 0 + + ) AS Tic2 + + GROUP BY Tic2.Id_Article, Fecha + ) Tic3 + + LEFT JOIN Articles A ON Tic3.Id_Article = A.Id_Article + LEFT JOIN Origen O ON O.id = A.id_origen + LEFT JOIN item_travel t ON t.wh = O.warehouse_id + + WHERE Fecha < IF(days_max < 0 AND t.landing IS NOT NULL, + t.landing, + date_top) + + GROUP BY Tic3.Id_Article + + + ) AS Tic5 + + ON Tic5.Id_Article = AI.article_id + SET AI.avalaible = IF(Tic5.smd > 0, AI.avalaible, AI.avalaible + Tic5.smd), + AI.sd = AI.inventory + Tic5.sd; +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 `inventario_multiple_2__` */; +/*!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 `inventario_multiple_2__`( + date_ticket DATETIME + ,wh TINYINT + ,days_max TINYINT +) +proc: BEGIN + DECLARE date_end DATETIME DEFAULT CURDATE(); + DECLARE date_start DATETIME; + DECLARE date_top DATETIME; + DECLARE date_tomorrow DATETIME; + + SET date_ticket = DATE(date_ticket); -- PAK + + ALTER TABLE `article_inventory` + ADD `avalaible` INT NOT NULL, + ADD `sd` INT NOT NULL, + ADD `rest` INT NOT NULL, + ADD `expected` INT NOT NULL, + ADD `inventory` INT NOT NULL, + ADD `visible` INT NOT NULL, + ADD `life` TINYINT NOT NULL DEFAULT '0'; + + IF date_ticket < CURDATE() + THEN + LEAVE proc; + END IF; + SELECT FechaInventario INTO date_start FROM tblContadores; SET date_end = TIMESTAMP(TIMESTAMPADD(DAY, IF(days_max >= 0, days_max,15), date_ticket),'23:59:59'); @@ -74479,8 +76984,6 @@ BEGIN * Calcula el stock del v_wh desde FechaInventario hasta v_date **/ - DECLARE n TINYINT; - DECLARE v_diff TIME; DECLARE v_curdate DATETIME DEFAULT CURDATE(); SET v_date = TIMESTAMP(DATE(v_date), '00:00:00'); @@ -74536,7 +77039,7 @@ CREATE DEFINER=`root`@`%` PROCEDURE `item_stock_visible`(v_wh SMALLINT, v_item I BEGIN DECLARE v_curdate DATETIME DEFAULT TIMESTAMP(CURDATE(), '00:00:00'); DECLARE v_tomorrow DATETIME DEFAULT TIMESTAMPADD(HOUR, 24, CURDATE()); - + INSERT INTO tmp_item (item_id, visible) SELECT item_id, SUM(amount) amount FROM ( @@ -74568,7 +77071,7 @@ BEGIN SELECT item_id, amount FROM item_entry_in iei LEFT JOIN vn.itemPlacement ip ON ip.itemFk = iei.item_id AND ip.warehouseFk = v_wh - WHERE (iei.received != FALSE OR ip.modificationDate > CURDATE()) + WHERE (iei.received != FALSE /*OR ip.modificationDate > CURDATE()*/) AND iei.dat >= v_curdate AND iei.dat < v_tomorrow AND iei.warehouse_id = v_wh AND (v_item IS NULL OR iei.item_id = v_item) @@ -74578,7 +77081,7 @@ BEGIN WHERE delivered != FALSE AND dat >= v_curdate AND dat < v_tomorrow AND warehouse_id = v_wh - AND (v_item IS NULL OR item_id = v_item) + AND (v_item IS NULL OR item_id = v_item)/* UNION ALL -- PAK 20/4/2019 SELECT iei.item_id, sub.shelved FROM item_entry_in iei @@ -74599,7 +77102,7 @@ BEGIN AND iei.warehouse_id = v_wh AND (v_item IS NULL OR iei.item_id = v_item) AND iei.isVirtualStock is FALSE - + */ ) t GROUP BY item_id ON DUPLICATE KEY UPDATE @@ -76736,40 +79239,6 @@ DROP TEMPORARY TABLE IF EXISTS lastid; CREATE TEMPORARY TABLE lastid SELECT last_insert_id() 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 `productionStateKk` */; -/*!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 `productionStateKk`(vWarehouse INT , vDate DATE) -BEGIN - - -SELECT IF(a.Vista= 2, z.alias, a.Agencia) Agencia, t.Id_Ruta, count(*) Pedidos -FROM Tickets t -JOIN Consignatarios CS on CS.Id_Consigna = t.Id_Consigna -JOIN Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN Agencias_province ap on ap.province_id = CS.province_id AND ap.warehouse_id = t.warehouse_id AND ap.agency_id = a.agency_id - LEFT JOIN Tickets_state tls on tls.Id_Ticket = t.Id_Ticket - LEFT JOIN zoneNickname z ON z.warehouse_id = ap.warehouse_id and z.agency_id = ap.agency_id AND z.zona = ap.zona - LEFT JOIN vncontrol.inter vni ON vni.inter_id = tls.inter_id - LEFT JOIN state s ON s.id = vni.state_id -WHERE Fecha BETWEEN vDate AND util.dayend(vDate) -AND s.alert_level = 1 -AND t.warehouse_id = vWarehouse -GROUP BY Agencia, Id_Ruta; - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76906,7 +79375,7 @@ BEGIN LEFT JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket LEFT JOIN `vn`.`saleTracking` `stPrevious` ON `stPrevious`.`saleFk` = M.Id_Movimiento - AND `stPrevious`.`stateFk` = 26 + JOIN vn.state st ON st.id = `stPrevious`.`stateFk` JOIN vn2008.Articles A ON A.Id_Article = M.Id_Article JOIN vn2008.Tipos tp on tp.tipo_id = A.tipo_id LEFT JOIN cache.visible v ON A.Id_Article = v.item_id AND v.calc_id = vVisibleCache @@ -76916,6 +79385,7 @@ BEGIN ) nicho ON nicho.Id_Article = A.Id_Article LEFT JOIN cache.available av ON av.item_id = A.Id_Article AND av.calc_id = vAvailableCache WHERE IFNULL(av.available,0) >= 0 + AND st.code = 'PREVIOUS_PREPARATION' AND M.Cantidad > IFNULL(v.visible,0) AND M.OK = FALSE AND stPrevious.saleFk IS NULL @@ -76928,33 +79398,7 @@ BEGIN AND nicho.Id_Article IS NULL; - /*-- La cantidad del movimiento es superior a la cantidad que hay en el nicho - INSERT INTO tmp.buffer_problems(Id_Ticket, problem) - SELECT tt.Id_Ticket, CONCAT('ALT (', CAST(M.Cantidad AS DECIMAL(10,0)), ') ',M.Id_Article, ' ', Concepte) - FROM tmp.ticket_list tt - JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket - JOIN vn.ticketStateToday tst ON tst.ticket = t.Id_Ticket - JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket - JOIN cache.visible v ON M.Id_Article = v.item_id AND v.calc_id = vVisibleCache - JOIN ( - SELECT `ish`.`itemFk` AS `itemFk`, - SUM(`ish`.`visible`) AS `visible` - FROM - vn.`itemShelving` `ish` - JOIN vn.`shelving` `sh` ON `sh`.`code` = `ish`.`shelvingFk` - JOIN vn.`parking` `p` ON `p`.`id` = `sh`.`parkingFk` - JOIN vn.`sector` `s` ON `s`.`id` = `p`.`sectorFk` - WHERE - `s`.`warehouseFk` = vWarehouse - GROUP BY itemFk - ) iss ON iss.itemFk = v.item_id - WHERE v.visible - iss.visible < M.Cantidad - AND M.OK = FALSE - AND M.Reservado = FALSE - AND CURDATE() = vDate - AND tst.productionOrder < 6 - AND t.warehouse_id = vWarehouse - ;*/ + -- La cantidad del movimiento es superior a la cantidad que hay en el nicho INSERT INTO tmp.buffer_problems(Id_Ticket, problem) SELECT tt.Id_Ticket, CONCAT('ALT (', CAST(M.Cantidad AS DECIMAL(10,0)), ') ',M.Id_Article, ' ', Concepte) @@ -76962,10 +79406,14 @@ BEGIN JOIN Tickets t on t.Id_Ticket = tt.Id_Ticket JOIN vn.ticketStateToday tst ON tst.ticket = t.Id_Ticket JOIN vn2008.Movimientos M ON M.Id_Ticket = t.Id_Ticket + LEFT JOIN `vn`.`saleTracking` `stPrevious` + ON `stPrevious`.`saleFk` = M.Id_Movimiento AND stPrevious.isChecked = TRUE + 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 WHERE v.visible - visible.visible < M.Cantidad AND M.OK = FALSE + AND stPrevious.saleFk IS NULL AND M.Reservado = FALSE AND CURDATE() = vDate AND tst.productionOrder < 6 @@ -77020,199 +79468,199 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `production_control_source`(vWarehouseId INT, vScopeDays TINYINT) BEGIN - DECLARE vMidnight DATETIME DEFAULT TIMESTAMP(CURDATE(),'23:59:59'); - DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,vMidnight); - DECLARE SAFE_ALERT_LEVEL INT DEFAULT 3; + DECLARE vMidnight DATETIME DEFAULT TIMESTAMP(CURDATE(),'23:59:59'); + DECLARE vEndingDate DATETIME DEFAULT TIMESTAMPADD(DAY,vScopeDays,vMidnight); + DECLARE SAFE_ALERT_LEVEL INT DEFAULT 3; - CALL prepare_ticket_list(TIMESTAMPADD(DAY,0,CURDATE()-1), vEndingDate); - CALL prepare_client_list; + CALL prepare_ticket_list(TIMESTAMPADD(DAY,0,CURDATE()-1), vEndingDate); + CALL prepare_client_list; CALL production_buffer_problems; - DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer; - CREATE TEMPORARY TABLE tmp.production_buffer - (PRIMARY KEY(Id_Ticket)) - ENGINE = MEMORY - SELECT t.Id_Ticket - , t.Id_Cliente - , t.warehouse_id - , t.Alias - , t.Bultos - , IF(HOUR(t.Fecha), HOUR(t.Fecha), HOUR(z.hour)) as Hora - , HOUR(z.hour) as Departure + DROP TEMPORARY TABLE IF EXISTS tmp.production_buffer; + CREATE TEMPORARY TABLE tmp.production_buffer + (PRIMARY KEY(Id_Ticket)) + ENGINE = MEMORY + SELECT t.Id_Ticket + , t.Id_Cliente + , t.warehouse_id + , t.Alias + , t.Bultos + , IF(HOUR(t.Fecha), HOUR(t.Fecha), HOUR(z.hour)) as Hora + , HOUR(z.hour) as Departure , MINUTE(t.Fecha) as minuto - , t.Id_Ruta - , IF(a.Vista = 2,ap.zona,0) as zona - , CS.Consignatario - , CS.CODPOSTAL - , CS.POBLACION - , p.name PROVINCIA - , IF(a.Vista= 2, CONCAT(LEFT(z.alias,16),' ',IFNULL(RIGHT(t.Id_Ruta,3),'')), a.Agencia) Agencia - , a.agency_id - , 0 AS `lines` - , CAST( 0 AS DECIMAL(5,2)) AS m3 - , 0 AS problems - , " " as problem - , IFNULL(tls.state,2) AS state - , w.Codigotrabajador - , DATE(t.Fecha) AS Fecha - , wk.code AS Comercial - , p.province_id - , tls.productionOrder as state_order - , ifnull(tls.alertLevel,0) alert_level - , t.boxed as palletized + , t.Id_Ruta + , IF(a.Vista = 2,ap.zona,0) as zona + , CS.Consignatario + , CS.CODPOSTAL + , CS.POBLACION + , p.name PROVINCIA + , IF(a.Vista= 2, CONCAT(LEFT(z.alias,16),' ',IFNULL(RIGHT(t.Id_Ruta,3),'')), a.Agencia) Agencia + , a.agency_id + , 0 AS `lines` + , CAST( 0 AS DECIMAL(5,2)) AS m3 + , 0 AS problems + , " " as problem + , IFNULL(tls.state,2) AS state + , w.Codigotrabajador + , DATE(t.Fecha) AS Fecha + , wk.code AS Comercial + , p.province_id + , tls.productionOrder as state_order + , ifnull(tls.alertLevel,0) alert_level + , t.boxed as palletized , rg.deviceId ubicacion - FROM tmp.ticket_list tt - JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket + FROM tmp.ticket_list tt + JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket LEFT JOIN vn.client c ON c.id = t.Id_Cliente LEFT JOIN vn.worker wk ON wk.id = c.salesPersonFk - JOIN Consignatarios CS on CS.Id_Consigna = t.Id_Consigna - LEFT JOIN province p on p.province_id = CS.province_id - JOIN Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN Agencias_province ap on ap.province_id = CS.province_id AND ap.warehouse_id = t.warehouse_id AND ap.agency_id = a.agency_id - LEFT JOIN vn.ticketState tls on tls.ticket = tt.Id_Ticket - LEFT JOIN Trabajadores w on w.Id_Trabajador = tls.worker + JOIN Consignatarios CS on CS.Id_Consigna = t.Id_Consigna + LEFT JOIN province p on p.province_id = CS.province_id + JOIN Agencias a ON a.Id_Agencia = t.Id_Agencia + LEFT JOIN Agencias_province ap on ap.province_id = CS.province_id AND ap.warehouse_id = t.warehouse_id AND ap.agency_id = a.agency_id + LEFT JOIN vn.ticketState tls on tls.ticket = tt.Id_Ticket + LEFT JOIN Trabajadores w on w.Id_Trabajador = tls.worker LEFT JOIN zoneNickname z ON z.warehouse_id = ap.warehouse_id and z.agency_id = ap.agency_id AND z.zona = ap.zona LEFT JOIN vn.routeGate rg ON rg.routeFk = t.Id_Ruta LEFT JOIN vn.zone z ON z.id = t.zoneFk - WHERE t.warehouse_id = vWarehouseId - AND a.Vista IN (1,2,3); + WHERE t.warehouse_id = vWarehouseId + AND a.Vista IN (1,2,3); - -- Líneas y volumen por ticket + -- Líneas y volumen por ticket - UPDATE tmp.production_buffer pb - JOIN ( - SELECT m.Id_Ticket, COUNT(Id_Movimiento) as `lines`, cast( sum( m.Cantidad * r.cm3 / 1000000 ) as decimal(10,2)) as m3 - FROM tmp.ticket_list tt - JOIN Movimientos m on tt.Id_Ticket = m.Id_Ticket - JOIN bi.rotacion r on m.Id_Article = r.Id_Article - WHERE r.warehouse_id = vWarehouseId - GROUP BY m.Id_Ticket - ) m on m.Id_Ticket = pb.Id_Ticket - SET pb.`lines` = m.`lines`, - pb.m3 = m.m3; + UPDATE tmp.production_buffer pb + JOIN ( + SELECT m.Id_Ticket, COUNT(Id_Movimiento) as `lines`, cast( sum( m.Cantidad * r.cm3 / 1000000 ) as decimal(10,2)) as m3 + FROM tmp.ticket_list tt + JOIN Movimientos m on tt.Id_Ticket = m.Id_Ticket + JOIN bi.rotacion r on m.Id_Article = r.Id_Article + WHERE r.warehouse_id = vWarehouseId + GROUP BY m.Id_Ticket + ) m on m.Id_Ticket = pb.Id_Ticket + SET pb.`lines` = m.`lines`, + pb.m3 = m.m3; - DELETE FROM tmp.production_buffer - WHERE `lines`= 0; + DELETE FROM tmp.production_buffer + WHERE `lines`= 0; - -- Cajas + -- Cajas - ALTER TABLE tmp.production_buffer - ADD Cajas DOUBLE DEFAULT NULL; + ALTER TABLE tmp.production_buffer + ADD Cajas DOUBLE DEFAULT NULL; /* - UPDATE tmp.production_buffer pb - JOIN ( - SELECT t.Id_Ticket, sum(floor(m.Cantidad / c.Packing) * bultoCubico) as Cajas - FROM tmp.ticket_list tt - JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket - JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket - JOIN cache.last_buy lb on lb.warehouse_id = t.warehouse_id AND lb.item_id = m.Id_Article - JOIN Compres c on c.Id_Compra = lb.buy_id - JOIN Cubos cb on cb.Id_Cubo = c.Id_Cubo - WHERE m.Cantidad >= c.Packing - GROUP BY t.Id_Ticket - HAVING Cajas >= 1 - ) sub ON sub.Id_Ticket = pb.Id_Ticket - SET pb.Cajas = sub.Cajas; -*/ - -- Artificial, Seco y Preservado: Reino 4 + UPDATE tmp.production_buffer pb + JOIN ( + SELECT t.Id_Ticket, sum(floor(m.Cantidad / c.Packing) * bultoCubico) as Cajas + FROM tmp.ticket_list tt + JOIN Tickets t on tt.Id_Ticket = t.Id_Ticket + JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN cache.last_buy lb on lb.warehouse_id = t.warehouse_id AND lb.item_id = m.Id_Article + JOIN Compres c on c.Id_Compra = lb.buy_id + JOIN Cubos cb on cb.Id_Cubo = c.Id_Cubo + WHERE m.Cantidad >= c.Packing + GROUP BY t.Id_Ticket + HAVING Cajas >= 1 + ) sub ON sub.Id_Ticket = pb.Id_Ticket + SET pb.Cajas = sub.Cajas; +*/ + -- Artificial, Seco y Preservado: Reino 4 - ALTER TABLE tmp.production_buffer - ADD lineasArtificial INT DEFAULT NULL; + ALTER TABLE tmp.production_buffer + ADD lineasArtificial INT DEFAULT NULL; - UPDATE tmp.production_buffer pb - JOIN ( - SELECT tt.Id_Ticket, COUNT(m.Id_Movimiento) as Lineas - FROM tmp.ticket_list tt - JOIN Movimientos m ON m.Id_Ticket = tt.Id_Ticket + UPDATE tmp.production_buffer pb + JOIN ( + SELECT tt.Id_Ticket, COUNT(m.Id_Movimiento) as Lineas + FROM tmp.ticket_list tt + JOIN Movimientos m ON m.Id_Ticket = tt.Id_Ticket JOIN Articles a ON a.Id_Article = m.Id_Article JOIN Tipos tp ON tp.tipo_id = a.tipo_id JOIN reinos r ON r.id = tp.reino_id - WHERE reino = 'Artificial' - GROUP BY tt.Id_Ticket - HAVING Lineas >= 1 - ) sub ON sub.Id_Ticket = pb.Id_Ticket - SET pb.lineasArtificial = sub.Lineas; + WHERE reino = 'Artificial' + GROUP BY tt.Id_Ticket + HAVING Lineas >= 1 + ) sub ON sub.Id_Ticket = pb.Id_Ticket + SET pb.lineasArtificial = sub.Lineas; - -- Problemas por ticket + -- Problemas por ticket - UPDATE tmp.production_buffer pb - JOIN ( - SELECT Id_Ticket, COUNT(Id_Ticket) as problems, GROUP_CONCAT(problem) problem - FROM tmp.buffer_problems - GROUP BY Id_Ticket - ) p on p.Id_Ticket = pb.Id_Ticket - SET pb.problems = p.problems, - pb.problem = p.problem; + UPDATE tmp.production_buffer pb + JOIN ( + SELECT Id_Ticket, COUNT(Id_Ticket) as problems, GROUP_CONCAT(problem) problem + FROM tmp.buffer_problems + GROUP BY Id_Ticket + ) p on p.Id_Ticket = pb.Id_Ticket + SET pb.problems = p.problems, + pb.problem = p.problem; - -- Entradas + -- Entradas - INSERT INTO tmp.production_buffer( - Fecha - , Id_Ticket - , Agencia - , Id_Cliente - , Consignatario - , state - , CodigoTrabajador - , m3 - , `lines` - ) - SELECT DISTINCT c.shipment AS Fecha - , c.Id_Entrada AS Id_Ticket - , warehouse.name - , c.Id_Proveedor - , c.ref AS Consignatario - , IF(BIT_OR(controlado.Id_Compra),6,IF(BIT_OR(preparado.Id_Compra),5,3)) AS state - , c.Id_Trabajador AS CodigoTrabajador - , round(sum(cm3) / 1000000,2) AS m3 - , count(c.Id_Compra) as `lines` - FROM v_compres c - INNER JOIN warehouse ON c.warehouse_id = warehouse.id - LEFT JOIN Compres_ok preparado ON c.Id_Compra = preparado.Id_Compra AND preparado.valor = 1 - LEFT JOIN Compres_ok controlado ON c.Id_Compra = controlado.Id_Compra AND controlado.valor = 2 - WHERE warehouse_id_out = vWarehouseId AND IFNULL(c.Confirmada,FALSE) = FALSE - AND c.shipment >= CURDATE() - GROUP BY Id_Entrada; + INSERT INTO tmp.production_buffer( + Fecha + , Id_Ticket + , Agencia + , Id_Cliente + , Consignatario + , state + , CodigoTrabajador + , m3 + , `lines` + ) + SELECT DISTINCT c.shipment AS Fecha + , c.Id_Entrada AS Id_Ticket + , warehouse.name + , c.Id_Proveedor + , c.ref AS Consignatario + , IF(BIT_OR(controlado.Id_Compra),6,IF(BIT_OR(preparado.Id_Compra),5,3)) AS state + , c.Id_Trabajador AS CodigoTrabajador + , round(sum(cm3) / 1000000,2) AS m3 + , count(c.Id_Compra) as `lines` + FROM v_compres c + INNER JOIN warehouse ON c.warehouse_id = warehouse.id + LEFT JOIN Compres_ok preparado ON c.Id_Compra = preparado.Id_Compra AND preparado.valor = 1 + LEFT JOIN Compres_ok controlado ON c.Id_Compra = controlado.Id_Compra AND controlado.valor = 2 + WHERE warehouse_id_out = vWarehouseId AND IFNULL(c.Confirmada,FALSE) = FALSE + AND c.shipment >= CURDATE() + GROUP BY Id_Entrada; - -- Refresca la caché para el cierre dinámico de agencias + -- Refresca la caché para el cierre dinámico de agencias - CALL cache.departure_timing(vWarehouseId); + CALL cache.departure_timing(vWarehouseId); - -- Tickets de recogida + -- Tickets de recogida - REPLACE tmp.production_buffer( - Fecha - , Id_Ticket - , Agencia - , Id_Cliente - , Consignatario - , state - , CodigoTrabajador - , alert_level - , warehouse_id - ) - SELECT - DATE(t.Fecha) AS Fecha - , t.Id_Ticket - , a.Agencia - , t.Id_Cliente - , CS.Consignatario - , s.id as state - , w.Codigotrabajador - , ifnull(tls.alertLevel,0) alert_level - , vWarehouseId - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios CS on CS.Id_Consigna = t.Id_Consigna - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = a.Id_Agencia - LEFT JOIN vn.ticketState tls on tls.ticket = t.Id_Ticket - LEFT JOIN vn.state s ON s.id = tls.state - LEFT JOIN vn2008.Trabajadores w on w.Id_Trabajador = tls.worker - WHERE t.Fecha between TIMESTAMPADD(WEEK,-1,CURDATE()) AND dayend(TIMESTAMPADD(DAY,-1,CURDATE())) - AND wp.warehouse_id = vWarehouseId; + REPLACE tmp.production_buffer( + Fecha + , Id_Ticket + , Agencia + , Id_Cliente + , Consignatario + , state + , CodigoTrabajador + , alert_level + , warehouse_id + ) + SELECT + DATE(t.Fecha) AS Fecha + , t.Id_Ticket + , a.Agencia + , t.Id_Cliente + , CS.Consignatario + , s.id as state + , w.Codigotrabajador + , ifnull(tls.alertLevel,0) alert_level + , vWarehouseId + FROM vn2008.Tickets t + JOIN vn2008.Consignatarios CS on CS.Id_Consigna = t.Id_Consigna + JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia + LEFT JOIN vn2008.warehouse_pickup wp ON wp.agency_id = a.Id_Agencia + LEFT JOIN vn.ticketState tls on tls.ticket = t.Id_Ticket + LEFT JOIN vn.state s ON s.id = tls.state + LEFT JOIN vn2008.Trabajadores w on w.Id_Trabajador = tls.worker + WHERE t.Fecha between TIMESTAMPADD(WEEK,-1,CURDATE()) AND dayend(TIMESTAMPADD(DAY,-1,CURDATE())) + AND wp.warehouse_id = vWarehouseId; - -- DROP TEMPORARY TABLE tmp.ticket_list; - -- DROP TEMPORARY TABLE IF EXISTS tmp.risk; + -- DROP TEMPORARY TABLE tmp.ticket_list; + -- DROP TEMPORARY TABLE IF EXISTS tmp.risk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -78187,10 +80635,6 @@ BEGIN -- SELECT TIMESTAMP(TIMESTAMPADD(DAY, 14, yesterday),'23:59:59') INTO maxDate; -- Creamos una tabla con los Comerciales de los que se mostraran los tickets - IF worker = 2 AND curdate() between '2018-07-02' AND '2018-07-09' THEN - SET worker = 43; - END IF; - CALL subordinate(worker, TRUE); -- Se genera una tabla con los tickets representados @@ -78506,10 +80950,6 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`%` PROCEDURE `raidUpdate`() BEGIN - UPDATE travel - SET shipment = CURDATE(), - landing = TIMESTAMPADD(DAY, 1, CURDATE()) - WHERE id = 12505; UPDATE Entradas e JOIN Entradas_Auto ea USING (Id_Entrada) @@ -81225,6 +83665,249 @@ 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 `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 = 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 `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) + + 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, + T.Fecha, + 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, + Date(T.Fecha) as Fecha_Simple, + 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_Simple 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 `tickets_in_a_week` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -81696,7 +84379,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 `ticket_volumen` */; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_volumen__` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -81706,11 +84389,11 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -CREATE DEFINER=`root`@`%` PROCEDURE `ticket_volumen`(IN idT INT) +CREATE DEFINER=`root`@`%` PROCEDURE `ticket_volumen__`(IN idT INT) BEGIN DECLARE intWh INTEGER; DECLARE datFecha DATE; - + -- OBSOLETA USAR vn.ticketTotalVolumen JGF 2018-05-22 DROP TEMPORARY TABLE IF EXISTS ticket_volumen; SELECT warehouse_id, Fecha INTO intWh,datFecha FROM Tickets WHERE Id_Ticket = idT; @@ -82007,83 +84690,44 @@ BEGIN 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, - + 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.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 - + 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 @@ -82120,30 +84764,18 @@ BEGIN END IF; -- --------------------------------------------- - SELECT t.*, - + SELECT t.*, Cantidad - MOD(Cantidad , `grouping`) as Subcantidad, - - MOD(Cantidad , `grouping`) as Soll, - + 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; @@ -82151,7 +84783,8 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS Traslados; DROP TEMPORARY TABLE IF EXISTS tmp_item; DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - + DROP TEMPORARY TABLE tblTARIFAS; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -82591,6 +85224,81 @@ DELIMITER ; /*!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 + 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 Compres c_land -- Entradas que llegan a vnh + 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 (t_land.warehouse_id = 7 AND t_land.landing = CURDATE()) + ) land -- Entradas que llegan a vnh + LEFT JOIN ( SELECT SUM(c_ship.Etiquetas) Etiquetas,c_ship.Packing,SUM(c_ship.Cantidad) Cantidad + FROM Compres c_ship -- Entradas que salen de vnh + 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() + ) ship ON TRUE-- Entrada destino + 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 */ ; +/*!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; @@ -82690,6 +85398,83 @@ BEGIN 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; + 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); @@ -82747,6 +85532,220 @@ BEGIN 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 */ ; @@ -84440,7 +87439,7 @@ CREATE TABLE `inter` ( CONSTRAINT `inter_ibfk_1` FOREIGN KEY (`Id_Ticket`) REFERENCES `vn2008`.`Tickets` (`Id_Ticket`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inter_state` FOREIGN KEY (`state_id`) REFERENCES `vn2008`.`state` (`id`) ON UPDATE CASCADE, CONSTRAINT `responsable` FOREIGN KEY (`Id_Supervisor`) REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=19296331 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19607035 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 */ ; @@ -84803,24 +87802,6 @@ USE `bi`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `rutas` --- - -/*!50001 DROP VIEW IF EXISTS `rutas`*/; -/*!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 `rutas` AS select `tm`.`year` AS `year`,`tm`.`month` AS `month`,`a`.`warehouseFk` AS `warehouse_id`,`r`.`id` AS `Id_Ruta`,`ar`.`id` AS `Id_Agencia`,(`r`.`kmEnd` - `r`.`kmStart`) AS `km`,dayname(`r`.`created`) AS `Dia`,`r`.`created` AS `Fecha`,`r`.`cost` AS `cost`,if(`ap`.`isVolumetric`,(`vn2008`.`ticket_volumen`(`t`.`id`) / `ebv`.`m3`),`t`.`packages`) AS `Bultos`,`v`.`numberPlate` AS `Matricula`,if(isnull(`r`.`cost`),'P','A') AS `Tipo`,`ap`.`isVolumetric` AS `isVolumetric`,`t`.`id` AS `ticketFk` from (((((((((`vn`.`route` `r` join `vn`.`agencyMode` `ar` on((`ar`.`id` = `r`.`agencyModeFk`))) join `vn`.`agency` `a` on((`a`.`id` = `ar`.`agencyFk`))) join `vn`.`time` `tm` on((`tm`.`dated` = `r`.`created`))) join `vn`.`ticket` `t` on((`t`.`routeFk` = `r`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `ad` on((`ad`.`id` = `t`.`addressFk`))) join `vn`.`agencyProvince` `ap` on(((`ap`.`warehouseFk` = `t`.`warehouseFk`) and (`ap`.`provinceFk` = `ad`.`provinceFk`) and (`ap`.`agencyFk` = `am`.`agencyFk`)))) join `vn`.`expeditionBoxVol` `ebv` on((`ebv`.`boxFk` = 71))) left join `vn`.`vehicle` `v` on((`v`.`id` = `r`.`vehicleFk`))) where ((`r`.`created` > '2016-01-01') and (`t`.`packages` > 0)) */; -/*!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 `saleVolume` -- @@ -85703,6 +88684,60 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `__itemCategory` +-- + +/*!50001 DROP VIEW IF EXISTS `__itemCategory`*/; +/*!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 `__itemCategory` AS select `r`.`id` AS `id`,`r`.`reino` AS `name`,`r`.`display` AS `display`,`r`.`color` AS `color`,`r`.`icon` AS `icon`,`r`.`mercancia` AS `merchandise`,`r`.`orden` AS `order`,`r`.`efimero` AS `shortLife` from `vn2008`.`reinos` `r` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `__itemType` +-- + +/*!50001 DROP VIEW IF EXISTS `__itemType`*/; +/*!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 `__itemType` AS select `t`.`tipo_id` AS `id`,`t`.`Id_Tipo` AS `code`,`t`.`Tipo` AS `name`,`t`.`Orden` AS `order`,`t`.`reino_id` AS `categoryFk`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`life` AS `life`,`t`.`isPackaging` AS `isPackaging`,`t`.`density` AS `density`,`t`.`roleCodeFk` AS `roleCodeFk`,`t`.`f11` AS `f11`,`t`.`inventory` AS `isInventory`,`t`.`odbc_date` AS `created`,`t`.`father_id` AS `father`,`t`.`transaction` AS `transaction`,`t`.`confeccion` AS `making`,`t`.`location` AS `location`,`t`.`Temperatura` AS `temperature`,`t`.`promo` AS `promo`,`t`.`box` AS `isBox`,`t`.`CYM` AS `CYM`,`t`.`maneuver` AS `maneuver`,`t`.`target` AS `target`,`t`.`top_margin` AS `topMargin`,`t`.`profit` AS `profit`,`t`.`FV` AS `isFV`,`t`.`hasComponents` AS `hasComponents` from `vn2008`.`Tipos` `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 `__observationType` +-- + +/*!50001 DROP VIEW IF EXISTS `__observationType`*/; +/*!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 `__observationType` AS select `ot`.`observation_type_id` AS `id`,`ot`.`description` AS `description` from `vn2008`.`observation_type` `ot` */; +/*!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 `absenceType` -- @@ -85747,12 +88782,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 `address` AS select `t`.`id_consigna` AS `id`,`t`.`Id_cliente` AS `clientFk`,`t`.`domicilio` AS `street`,`t`.`poblacion` AS `city`,`t`.`codPostal` AS `postalCode`,`t`.`province_id` AS `provinceFk`,`t`.`telefono` AS `phone`,`t`.`movil` AS `mobile`,`t`.`consignatario` AS `nickname`,`t`.`predeterminada` AS `isDefaultAddress`,`t`.`longitude` AS `longitude`,`t`.`latitude` AS `latitude`,`t`.`warehouse_id` AS `warehouseFk`,`t`.`Id_Agencia` AS `agencyModeFk`,`t`.`isEqualizated` AS `isEqualizated`,`t`.`active` AS `isActive` from `vn2008`.`Consignatarios` `t` */; +/*!50001 VIEW `address` AS select `a`.`id_consigna` AS `id`,`a`.`Id_cliente` AS `clientFk`,`a`.`domicilio` AS `street`,`a`.`poblacion` AS `city`,`a`.`codPostal` AS `postalCode`,`a`.`province_id` AS `provinceFk`,`a`.`telefono` AS `phone`,`a`.`movil` AS `mobile`,`a`.`consignatario` AS `nickname`,`a`.`predeterminada` AS `isDefaultAddress`,`a`.`longitude` AS `longitude`,`a`.`latitude` AS `latitude`,`a`.`warehouse_id` AS `warehouseFk`,`a`.`Id_Agencia` AS `agencyModeFk`,`a`.`isEqualizated` AS `isEqualizated`,`a`.`active` AS `isActive` from `vn2008`.`Consignatarios` `a` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85902,10 +88937,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `bankEntity` +-- Final view structure for view `bankEntity__` -- -/*!50001 DROP VIEW IF EXISTS `bankEntity`*/; +/*!50001 DROP VIEW IF EXISTS `bankEntity__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -85914,7 +88949,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `bankEntity` AS select `e`.`entity_id` AS `id`,`e`.`pais_id` AS `countryFk`,`e`.`description` AS `name`,`e`.`bic` AS `bic` from `vn2008`.`entity` `e` */; +/*!50001 VIEW `bankEntity__` AS select `e`.`entity_id` AS `id`,`e`.`pais_id` AS `countryFk`,`e`.`description` AS `name`,`e`.`bic` AS `bic` from `vn2008`.`entity` `e` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85956,10 +88991,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `claim` +-- Final view structure for view `claimBeginning__` -- -/*!50001 DROP VIEW IF EXISTS `claim`*/; +/*!50001 DROP VIEW IF EXISTS `claimBeginning__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -85968,16 +89003,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claim` AS select `c`.`id` AS `id`,`c`.`Fecha` AS `ticketCreated`,`c`.`cl_est_id` AS `claimStateFk`,`c`.`notas` AS `observation`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`sensib` AS `responsibility`,`c`.`mana` AS `isChargedToMana`,`c`.`ticketFk` AS `ticketFk`,`c`.`odbc_date` AS `created` from `vn2008`.`cl_main` `c` */; +/*!50001 VIEW `claimBeginning__` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`numero` AS `quantity`,`c`.`cl_que_id` AS `claimComplaintFk`,`c`.`cl_pet_id` AS `claimRequestFk` from `vn2008`.`cl_det` `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 `claimBeginning` +-- Final view structure for view `claimDestination__` -- -/*!50001 DROP VIEW IF EXISTS `claimBeginning`*/; +/*!50001 DROP VIEW IF EXISTS `claimDestination__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -85986,16 +89021,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimBeginning` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`numero` AS `quantity` from `vn2008`.`cl_det` `c` */; +/*!50001 VIEW `claimDestination__` AS select `c`.`id` AS `id`,`c`.`solucion` AS `description`,`c`.`addressFk` AS `addressFk` from `vn2008`.`cl_sol` `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 `claimDestination` +-- Final view structure for view `claimDevelopment__` -- -/*!50001 DROP VIEW IF EXISTS `claimDestination`*/; +/*!50001 DROP VIEW IF EXISTS `claimDevelopment__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86004,16 +89039,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimDestination` AS select `c`.`id` AS `id`,`c`.`solucion` AS `description`,`c`.`addressFk` AS `addressFk` from `vn2008`.`cl_sol` `c` */; +/*!50001 VIEW `claimDevelopment__` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`cl_res_id` AS `claimResponsibleFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_mot_id` AS `claimReasonFk`,`c`.`cl_con_id` AS `claimResultFk`,`c`.`cl_dev` AS `claimRedeliveryFk`,`c`.`cl_sol` AS `claimDestinationFk` from `vn2008`.`cl_cau` `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 `claimDevelopment` +-- Final view structure for view `claimEnd__` -- -/*!50001 DROP VIEW IF EXISTS `claimDevelopment`*/; +/*!50001 DROP VIEW IF EXISTS `claimEnd__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86022,25 +89057,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimDevelopment` AS select `c`.`id` AS `id`,`c`.`cl_main_id` AS `claimFk`,`c`.`cl_res_id` AS `claimResponsibleFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_mot_id` AS `claimReasonFk`,`c`.`cl_con_id` AS `claimResultFk`,`c`.`cl_dev` AS `claimRedeliveryFk`,`c`.`cl_sol` AS `claimDestinationFk` from `vn2008`.`cl_cau` `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 `claimEnd` --- - -/*!50001 DROP VIEW IF EXISTS `claimEnd`*/; -/*!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 `claimEnd` AS select `c`.`id` AS `id`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_sol_id` AS `claimDestinationFk` from `vn2008`.`cl_act` `c` */; +/*!50001 VIEW `claimEnd__` AS select `c`.`id` AS `id`,`c`.`Id_Movimiento` AS `saleFk`,`c`.`cl_main_id` AS `claimFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`cl_sol_id` AS `claimDestinationFk`,`c`.`greuge` AS `isGreuge` from `vn2008`.`cl_act` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86064,10 +89081,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `claimReason` +-- Final view structure for view `claimReason__` -- -/*!50001 DROP VIEW IF EXISTS `claimReason`*/; +/*!50001 DROP VIEW IF EXISTS `claimReason__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86076,16 +89093,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimReason` AS select `c`.`id` AS `id`,`c`.`motivo` AS `description` from `vn2008`.`cl_mot` `c` */; +/*!50001 VIEW `claimReason__` AS select `c`.`id` AS `id`,`c`.`motivo` AS `description` from `vn2008`.`cl_mot` `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 `claimRedelivery` +-- Final view structure for view `claimRedelivery__` -- -/*!50001 DROP VIEW IF EXISTS `claimRedelivery`*/; +/*!50001 DROP VIEW IF EXISTS `claimRedelivery__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86094,16 +89111,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimRedelivery` AS select `e`.`id` AS `id`,`e`.`devolucion` AS `description` from `vn2008`.`cl_dev` `e` */; +/*!50001 VIEW `claimRedelivery__` AS select `e`.`id` AS `id`,`e`.`devolucion` AS `description` from `vn2008`.`cl_dev` `e` */; /*!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 `claimResponsible` +-- Final view structure for view `claimResponsible__` -- -/*!50001 DROP VIEW IF EXISTS `claimResponsible`*/; +/*!50001 DROP VIEW IF EXISTS `claimResponsible__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86112,16 +89129,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimResponsible` AS select `c`.`id` AS `id`,`c`.`responsable` AS `description`,`c`.`sensibility` AS `responsability` from `vn2008`.`cl_res` `c` */; +/*!50001 VIEW `claimResponsible__` AS select `c`.`id` AS `id`,`c`.`responsable` AS `description`,`c`.`sensibility` AS `responsability` from `vn2008`.`cl_res` `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 `claimResult` +-- Final view structure for view `claimResult__` -- -/*!50001 DROP VIEW IF EXISTS `claimResult`*/; +/*!50001 DROP VIEW IF EXISTS `claimResult__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86130,16 +89147,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimResult` AS select `c`.`id` AS `id`,`c`.`consecuencia` AS `description` from `vn2008`.`cl_con` `c` */; +/*!50001 VIEW `claimResult__` AS select `c`.`id` AS `id`,`c`.`consecuencia` AS `description` from `vn2008`.`cl_con` `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 `claimState` +-- Final view structure for view `claimState__` -- -/*!50001 DROP VIEW IF EXISTS `claimState`*/; +/*!50001 DROP VIEW IF EXISTS `claimState__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86148,7 +89165,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `claimState` AS select `c`.`id` AS `id`,`c`.`estado` AS `description`,`c`.`roleFk` AS `roleFk` from `vn2008`.`cl_est` `c` */; +/*!50001 VIEW `claimState__` AS select `c`.`id` AS `id`,`c`.`estado` AS `description`,`c`.`roleFk` AS `roleFk` from `vn2008`.`cl_est` `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 `claim__` +-- + +/*!50001 DROP VIEW IF EXISTS `claim__`*/; +/*!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 `claim__` AS select `c`.`id` AS `id`,`c`.`Fecha` AS `ticketCreated`,`c`.`cl_est_id` AS `claimStateFk`,`c`.`notas` AS `observation`,`c`.`Id_Cliente` AS `clientFk`,`c`.`Id_Trabajador` AS `workerFk`,`c`.`sensib` AS `responsibility`,`c`.`mana` AS `isChargedToMana`,`c`.`ticketFk` AS `ticketFk`,`c`.`odbc_date` AS `created`,`c`.`cl_dep_id` AS `claimDepartmentFk` from `vn2008`.`cl_main` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86441,24 +89476,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `contactChannelkk` --- - -/*!50001 DROP VIEW IF EXISTS `contactChannelkk`*/; -/*!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 `contactChannelkk` AS select `c`.`chanel_id` AS `id`,`c`.`name` AS `name` from `vn2008`.`chanel` `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 `coolerPath` -- @@ -86514,10 +89531,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `currency` +-- Final view structure for view `currency__` -- -/*!50001 DROP VIEW IF EXISTS `currency`*/; +/*!50001 DROP VIEW IF EXISTS `currency__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -86526,7 +89543,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `currency` AS select `m`.`Id_Moneda` AS `id`,`m`.`Moneda` AS `code`,`m`.`Descripcion` AS `name` from `vn2008`.`Monedas` `m` */; +/*!50001 VIEW `currency__` AS select `m`.`Id_Moneda` AS `id`,`m`.`Moneda` AS `code`,`m`.`Descripcion` AS `name`,`m`.`Cambio` AS `ratio` from `vn2008`.`Monedas` `m` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -86603,6 +89620,42 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `deviceProduction` +-- + +/*!50001 DROP VIEW IF EXISTS `deviceProduction`*/; +/*!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 `deviceProduction` AS select `d`.`device_id` AS `id`,`d`.`sn` AS `imei`,`d`.`macWifi` AS `macWifi`,`d`.`departmentFk` AS `serialNumber`,`d`.`serialNumber` AS `departmentFk`,`d`.`model` AS `modelFk`,`d`.`isOutOfService` AS `isOutOfService` from `vn2008`.`device` `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 `deviceProductionUser` +-- + +/*!50001 DROP VIEW IF EXISTS `deviceProductionUser`*/; +/*!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 `deviceProductionUser` AS select `d`.`device_id` AS `deviceProductionFk`,`d`.`user_id` AS `userFk` from `vn2008`.`device_user` `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 `dms` -- @@ -86964,10 +90017,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `greuge` +-- Final view structure for view `greugeType__` -- -/*!50001 DROP VIEW IF EXISTS `greuge`*/; +/*!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 */; @@ -86976,16 +90029,16 @@ USE `vn`; /*!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 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 `greugeType` +-- Final view structure for view `greuge__` -- -/*!50001 DROP VIEW IF EXISTS `greugeType`*/; +/*!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 */; @@ -86994,7 +90047,7 @@ USE `vn`; /*!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 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 */; @@ -87300,7 +90353,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`caja` AS `box`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown`,`t`.`compression` AS `compression` from `vn2008`.`Articles` `t` */; +/*!50001 VIEW `item` AS select `t`.`Id_Article` AS `id`,`t`.`Article` AS `name`,`t`.`tipo_id` AS `typeFk`,`t`.`Medida` AS `size`,`t`.`Color` AS `inkFk`,`t`.`Categoria` AS `category`,`t`.`Tallos` AS `stems`,`t`.`id_origen` AS `originFk`,`t`.`description` AS `description`,`t`.`producer_id` AS `producerFk`,`t`.`Codintrastat` AS `intrastatFk`,`t`.`offer` AS `isOnOffer`,`t`.`caja` AS `box`,`t`.`expenceFk` AS `expenceFk`,`t`.`bargain` AS `isBargain`,`t`.`comments` AS `comment`,`t`.`relevancy` AS `relevancy`,`t`.`Foto` AS `image`,`t`.`generic` AS `generic`,`t`.`density` AS `density`,`t`.`iva_group_id` AS `taxClassFk`,`t`.`PVP` AS `minPrice`,`t`.`Min` AS `hasMinPrice`,`t`.`isActive` AS `isActive`,`t`.`longName` AS `longName`,`t`.`subName` AS `subName`,`t`.`tag5` AS `tag5`,`t`.`value5` AS `value5`,`t`.`tag6` AS `tag6`,`t`.`value6` AS `value6`,`t`.`tag7` AS `tag7`,`t`.`value7` AS `value7`,`t`.`tag8` AS `tag8`,`t`.`value8` AS `value8`,`t`.`tag9` AS `tag9`,`t`.`value9` AS `value9`,`t`.`tag10` AS `tag10`,`t`.`value10` AS `value10`,`t`.`minimum` AS `minimum`,`t`.`upToDown` AS `upToDown`,`t`.`compression` AS `compression`,`t`.`hasKgPrice` AS `hasKgPrice` 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 */; @@ -87359,24 +90412,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `itemCategory` --- - -/*!50001 DROP VIEW IF EXISTS `itemCategory`*/; -/*!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 `itemCategory` AS select `r`.`id` AS `id`,`r`.`reino` AS `name`,`r`.`display` AS `display`,`r`.`color` AS `color`,`r`.`icon` AS `icon`,`r`.`mercancia` AS `merchandise`,`r`.`orden` AS `order`,`r`.`efimero` AS `shortLife` from `vn2008`.`reinos` `r` */; -/*!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` -- @@ -87390,7 +90425,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`vn`.`itemCategory` `c` left join `vn`.`itemCategoryI18n` `i` on(((`i`.`categoryFk` = `c`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; +/*!50001 VIEW `itemCategoryL10n` AS select `c`.`id` AS `id`,ifnull(`i`.`name`,`c`.`name`) AS `name` from (`itemCategory` `c` left join `itemCategoryI18n` `i` on(((`i`.`categoryFk` = `c`.`id`) and (`i`.`lang` = `util`.`lang`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87426,7 +90461,25 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`p`.`code` AS `parking` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id` */; +/*!50001 VIEW `itemPlacementSupplyList` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`p`.`code` AS `parking`,`p`.`sectorFk` AS `sectorFk` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `itemPlacementSupplyList__` +-- + +/*!50001 DROP VIEW IF EXISTS `itemPlacementSupplyList__`*/; +/*!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 `itemPlacementSupplyList__` AS select `ips`.`id` AS `id`,`ips`.`itemFk` AS `itemFk`,`ips`.`quantity` AS `quantity`,`ips`.`priority` AS `priority`,`ips`.`created` AS `created`,`ips`.`userFk` AS `userFk`,`ips`.`repoUserFk` AS `repoUserFk`,(`ips`.`quantity` - sum(ifnull(`isps`.`quantity`,0))) AS `saldo`,concat(`i`.`longName`,' ',`i`.`size`) AS `longName`,`i`.`subName` AS `subName`,`i`.`size` AS `size`,`w`.`code` AS `workerCode`,`rw`.`code` AS `repoCode`,`p`.`code` AS `parking` from (((((((`vn`.`itemPlacementSupply` `ips` join `vn`.`itemShelving` `ish` on((`ish`.`itemFk` = `ips`.`itemFk`))) join `vn`.`item` `i` on((`i`.`id` = `ish`.`itemFk`))) left join `vn`.`worker` `w` on((`w`.`userFk` = `ips`.`userFk`))) left join `vn`.`worker` `rw` on((`rw`.`userFk` = `ips`.`repoUserFk`))) left join `vn`.`itemShelvingPlacementSupply` `isps` on((`isps`.`itemPlacementSupplyFk` = `ips`.`id`))) left join `vn`.`shelving` `s` on((`ish`.`shelvingFk` = `s`.`code`))) left join `vn`.`parking` `p` on((`s`.`parkingFk` = `p`.`id`))) where (`ips`.`created` >= curdate()) group by `ips`.`priority`,`ips`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87444,25 +90497,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,ifnull(`stk`.`isChecked`,0) AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`its`.`available` AS `available`,`pk`.`sectorFk` AS `sectorFk`,`sh`.`code` AS `matricula`,`pk`.`id` AS `parking`,`its`.`id` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`its`.`grouping` AS `grouping`,`its`.`packing` AS `packing`,`z`.`hour` AS `hour` from (((((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelving` `its` on((`its`.`itemFk` = `s`.`itemFk`))) join `vn`.`shelving` `sh` on((`sh`.`code` = `its`.`shelvingFk`))) join `vn`.`parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) join `vn`.`sector` `sc` on(((`sc`.`id` = `pk`.`sectorFk`) and (`sc`.`warehouseFk` = `t`.`warehouseFk`)))) left join `vn`.`saleTracking` `stk` on(((`stk`.`saleFk` = `s`.`id`) and (`stk`.`stateFk` = 26)))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and (`its`.`available` > 0) and (`sh`.`code` <> 'FUE') and (`its`.`grouping` <= `s`.`quantity`) and `st`.`sectorProdPriority`) */; -/*!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 `itemShelvingAvailableKk` --- - -/*!50001 DROP VIEW IF EXISTS `itemShelvingAvailableKk`*/; -/*!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 `itemShelvingAvailableKk` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,`s`.`isPicked` AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`its`.`available` AS `available`,`pk`.`sectorFk` AS `sectorFk`,`sh`.`code` AS `matricula`,`pk`.`id` AS `parking`,`its`.`id` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`its`.`grouping` AS `grouping`,`its`.`packing` AS `packing` from (((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelving` `its` on((`its`.`itemFk` = `s`.`itemFk`))) join `vn`.`shelving` `sh` on((`sh`.`code` = `its`.`shelvingFk`))) join `vn`.`parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) join `vn`.`sector` `sc` on(((`sc`.`id` = `pk`.`sectorFk`) and (`sc`.`warehouseFk` = `t`.`warehouseFk`)))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and (`its`.`available` > 0) and (`sh`.`code` <> 'FUE') and (`its`.`grouping` <= `s`.`quantity`) and `st`.`sectorProdPriority`) */; +/*!50001 VIEW `itemShelvingAvailable` AS select `s`.`id` AS `saleFk`,`tst`.`updated` AS `Modificado`,`s`.`ticketFk` AS `ticketFk`,ifnull(`stk`.`isChecked`,0) AS `isPicked`,`s`.`itemFk` AS `itemFk`,`s`.`quantity` AS `quantity`,`s`.`concept` AS `concept`,`i`.`size` AS `size`,`st`.`name` AS `Estado`,`st`.`sectorProdPriority` AS `sectorProdPriority`,`its`.`available` AS `available`,`pk`.`sectorFk` AS `sectorFk`,`sh`.`code` AS `matricula`,`pk`.`id` AS `parking`,`its`.`id` AS `itemShelving`,`am`.`name` AS `Agency`,`t`.`shipped` AS `shipped`,`its`.`grouping` AS `grouping`,`its`.`packing` AS `packing`,`z`.`hour` AS `hour`,`st`.`isPreviousPreparable` AS `isPreviousPreparable` from (((((((((((`vn`.`sale` `s` join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`ticketStateToday` `tst` on((`tst`.`ticket` = `t`.`id`))) join `vn`.`state` `st` on((`st`.`id` = `tst`.`state`))) join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`itemShelving` `its` on((`its`.`itemFk` = `s`.`itemFk`))) join `vn`.`shelving` `sh` on((`sh`.`code` = `its`.`shelvingFk`))) join `vn`.`parking` `pk` on((`pk`.`id` = `sh`.`parkingFk`))) join `vn`.`sector` `sc` on(((`sc`.`id` = `pk`.`sectorFk`) and (`sc`.`warehouseFk` = `t`.`warehouseFk`)))) left join `vn`.`saleTracking` `stk` on(((`stk`.`saleFk` = `s`.`id`) and (`stk`.`stateFk` = 26)))) left join `vn`.`zone` `z` on((`z`.`id` = `t`.`zoneFk`))) where ((`t`.`shipped` between `util`.`yesterday`() and `util`.`dayend`(curdate())) and (`its`.`available` > 0) and (`sh`.`code` <> 'FUE') and (`its`.`grouping` <= `s`.`quantity`) and `st`.`sectorProdPriority`) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87503,6 +90538,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `itemShelvingSaleSum` +-- + +/*!50001 DROP VIEW IF EXISTS `itemShelvingSaleSum`*/; +/*!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 `itemShelvingSaleSum` AS select `iss`.`id` AS `id`,`iss`.`itemShelvingFk` AS `itemShelvingFk`,`iss`.`saleFk` AS `saleFk`,sum(`iss`.`quantity`) AS `quantity`,`iss`.`created` AS `created` from `itemShelvingSale` `iss` group by `iss`.`saleFk` */; +/*!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 `itemShelvingStock` -- @@ -87516,7 +90569,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`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; +/*!50001 VIEW `itemShelvingStock` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed`,`p`.`sectorFk` AS `sectorFk`,`s`.`warehouseFk` AS `warehouseFk` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) group by `ish`.`itemFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87540,10 +90593,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `itemShelvingStock_beta` +-- Final view structure for view `itemShelvingStock__` -- -/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_beta`*/; +/*!50001 DROP VIEW IF EXISTS `itemShelvingStock__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -87552,25 +90605,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemShelvingStock_beta` AS select `ish`.`itemFk` AS `itemFk`,(sum(`ish`.`visible`) - `issr`.`removed`) AS `visible`,min(`ish`.`packing`) AS `packing`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,`issr`.`removed` AS `removed` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `itemShelvingStock_old` --- - -/*!50001 DROP VIEW IF EXISTS `itemShelvingStock_old`*/; -/*!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 `itemShelvingStock_old` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing` from (((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; +/*!50001 VIEW `itemShelvingStock__` AS select `ish`.`itemFk` AS `itemFk`,sum(`ish`.`visible`) AS `visible`,min(`ish`.`packing`) AS `packing`,`s`.`description` AS `sector`,sum(`ish`.`visible`) AS `visibleOriginal`,sum(`issr`.`removed`) AS `removed` from ((((`itemShelving` `ish` join `shelving` `sh` on((`sh`.`code` = `ish`.`shelvingFk`))) join `parking` `p` on((`p`.`id` = `sh`.`parkingFk`))) join `sector` `s` on((`s`.`id` = `p`.`sectorFk`))) left join `itemShelvingStockRemoved` `issr` on((`issr`.`itemShelvingFk` = `ish`.`id`))) where (`s`.`warehouseFk` = 1) group by `ish`.`itemFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87611,24 +90646,6 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `itemType` --- - -/*!50001 DROP VIEW IF EXISTS `itemType`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemType` AS select `t`.`tipo_id` AS `id`,`t`.`Id_Tipo` AS `code`,`t`.`Tipo` AS `name`,`t`.`reino_id` AS `categoryFk`,`t`.`life` AS `life`,`t`.`Id_Trabajador` AS `workerFk`,`t`.`warehouseFk` AS `warehouseFk`,`t`.`isPackaging` AS `isPackaging`,`t`.`density` AS `density`,`t`.`Orden` AS `order` from `vn2008`.`Tipos` `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 `itemTypeL10n` -- @@ -87642,7 +90659,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`vn`.`itemType` `t` left join `vn`.`itemTypeI18n` `i` on(((`i`.`typeFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; +/*!50001 VIEW `itemTypeL10n` AS select `t`.`id` AS `id`,ifnull(`i`.`name`,`t`.`name`) AS `name` from (`itemType` `t` left join `itemTypeI18n` `i` on(((`i`.`typeFk` = `t`.`id`) and (`i`.`lang` = `util`.`LANG`())))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87684,10 +90701,10 @@ USE `vn`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `mandate` +-- Final view structure for view `mandateType__` -- -/*!50001 DROP VIEW IF EXISTS `mandate`*/; +/*!50001 DROP VIEW IF EXISTS `mandateType__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -87696,16 +90713,16 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `mandate` AS select `m`.`id` AS `id`,`m`.`Id_Cliente` AS `clientFk`,`m`.`empresa_id` AS `companyFk`,`m`.`Id_mandato` AS `code`,`m`.`FAlta` AS `created`,`m`.`Fbaja` AS `finished`,`m`.`idmandato_tipo` AS `mandateTypeFk` from `vn2008`.`mandato` `m` */; +/*!50001 VIEW `mandateType__` AS select `m`.`idmandato_tipo` AS `id`,`m`.`Nombre` AS `name` from `vn2008`.`mandato_tipo` `m` */; /*!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 `mandateType` +-- Final view structure for view `mandate__` -- -/*!50001 DROP VIEW IF EXISTS `mandateType`*/; +/*!50001 DROP VIEW IF EXISTS `mandate__`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; /*!50001 SET @saved_col_connection = @@collation_connection */; @@ -87714,25 +90731,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `mandateType` AS select `m`.`idmandato_tipo` AS `id`,`m`.`Nombre` AS `name` from `vn2008`.`mandato_tipo` `m` */; -/*!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 `observationType` --- - -/*!50001 DROP VIEW IF EXISTS `observationType`*/; -/*!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 `observationType` AS select `ot`.`observation_type_id` AS `id`,`ot`.`description` AS `description` from `vn2008`.`observation_type` `ot` */; +/*!50001 VIEW `mandate__` AS select `m`.`id` AS `id`,`m`.`Id_Cliente` AS `clientFk`,`m`.`empresa_id` AS `companyFk`,`m`.`Id_mandato` AS `code`,`m`.`FAlta` AS `created`,`m`.`Fbaja` AS `finished`,`m`.`idmandato_tipo` AS `mandateTypeFk` from `vn2008`.`mandato` `m` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87840,7 +90839,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `packaging` AS select `c`.`Id_Cubo` AS `id`,`c`.`Volumen` AS `volume`,`c`.`X` AS `width`,`c`.`Y` AS `height`,`c`.`Z` AS `depth`,`c`.`Retornable` AS `isPackageReturnable`,`c`.`odbc_date` AS `created`,`c`.`item_id` AS `itemFk`,`c`.`pvp` AS `price`,`c`.`bultoCubico` AS `isBox` from `vn2008`.`Cubos` `c` */; +/*!50001 VIEW `packaging` AS select `c`.`Id_Cubo` AS `id`,`c`.`Volumen` AS `volume`,`c`.`X` AS `width`,`c`.`Y` AS `depth`,`c`.`Z` AS `height`,`c`.`Retornable` AS `isPackageReturnable`,`c`.`odbc_date` AS `created`,`c`.`item_id` AS `itemFk`,`c`.`pvp` AS `price`,`c`.`bultoCubico` AS `isBox` from `vn2008`.`Cubos` `c` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88379,8 +91378,26 @@ USE `vn`; /*!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 `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round((((`i`.`compression` * `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` 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 */; + +-- +-- Final view structure for view `saleVolume__` +-- + +/*!50001 DROP VIEW IF EXISTS `saleVolume__`*/; +/*!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=`z-developer`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleVolume` AS select `s`.`ticketFk` AS `ticketFk`,`s`.`id` AS `saleFk`,ifnull(round((((`i`.`compression` * `r`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros` 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` * `r`.`cm3`) * `s`.`quantity`) / 1000),2),0) AS `litros` 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 */; @@ -88470,7 +91487,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `state` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`order` AS `order`,`s`.`alert_level` AS `alertLevel`,`s`.`code` AS `code`,`s`.`sectorProdPriority` AS `sectorProdPriority` from `vn2008`.`state` `s` */; +/*!50001 VIEW `state` AS select `s`.`id` AS `id`,`s`.`name` AS `name`,`s`.`order` AS `order`,`s`.`alert_level` AS `alertLevel`,`s`.`code` AS `code`,`s`.`sectorProdPriority` AS `sectorProdPriority`,`s`.`isPreviousPreparable` AS `isPreviousPreparable` from `vn2008`.`state` `s` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88758,7 +91775,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`ts`.`Id_Ticket` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alert_level` AS `alertLevel`,`s`.`code` AS `code`,`ts`.`Id_Ticket` AS `ticket`,`i`.`Id_Trabajador` AS `worker` from ((`vn2008`.`Tickets_state` `ts` join `vncontrol`.`inter` `i` on((`i`.`inter_id` = `ts`.`inter_id`))) join `vn2008`.`state` `s` on((`s`.`id` = `i`.`state_id`))) */; +/*!50001 VIEW `ticketState` AS select `i`.`odbc_date` AS `updated`,`i`.`state_id` AS `stateFk`,`i`.`Id_Trabajador` AS `workerFk`,`ts`.`Id_Ticket` AS `ticketFk`,`s`.`id` AS `state`,`s`.`order` AS `productionOrder`,`s`.`alert_level` AS `alertLevel`,`s`.`code` AS `code`,`ts`.`Id_Ticket` AS `ticket`,`i`.`Id_Trabajador` AS `worker`,`s`.`isPreviousPreparable` AS `isPreviousPreparable` from ((`vn2008`.`Tickets_state` `ts` join `vncontrol`.`inter` `i` on((`i`.`inter_id` = `ts`.`inter_id`))) join `vn2008`.`state` `s` on((`s`.`id` = `i`.`state_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88866,7 +91883,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `ticketeToPreparePrepared` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,(`mk`.`original_quantity` - ifnull(`is`.`quantity`,0)) AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,hour(`t`.`shipped`) AS `Hora`,hour(`t`.`shipped`) AS `Departure`,minute(`t`.`shipped`) AS `Minuto`,`am`.`agencyFk` AS `agency_id`,`t`.`warehouseFk` AS `warehouse_id`,`a`.`provinceFk` AS `province_id`,`is`.`quantity` AS `picked`,`t`.`CodigoTrabajador` AS `trabajador` from ((((((((`vn2008`.`Movimientos_mark` `mk` join `vn`.`state` `st` on((`st`.`id` = `mk`.`stateFk`))) join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSale` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) left join `vn2008`.`Trabajadores` `t` on((`t`.`Id_Trabajador` = `mk`.`Id_Trabajador`))) where ((`st`.`code` like 'PREVIOUS_PREPARATION') and (`t`.`warehouseFk` = 1)) group by `mk`.`Id_Movimiento_mark` */; +/*!50001 VIEW `ticketeToPreparePrepared` AS select `m`.`Id_Ticket` AS `Id_Ticket`,`mk`.`Id_Movimiento` AS `Id_Movimiento`,`mk`.`Id_Movimiento_mark` AS `Id_Movimiento_mark`,`mk`.`Id_Trabajador` AS `Id_Trabjador`,`m`.`Id_Article` AS `Id_Article`,`m`.`Concepte` AS `Concepte`,`art`.`subName` AS `subName`,(`mk`.`original_quantity` - ifnull(`is`.`quantity`,0)) AS `Cantidad`,`mk`.`original_quantity` AS `original_quantity`,hour(`t`.`shipped`) AS `Hora`,hour(`t`.`shipped`) AS `Departure`,minute(`t`.`shipped`) AS `Minuto`,`am`.`agencyFk` AS `agency_id`,`t`.`warehouseFk` AS `warehouse_id`,`a`.`provinceFk` AS `province_id`,`is`.`quantity` AS `picked`,`t`.`CodigoTrabajador` AS `trabajador` from ((((((((`vn2008`.`Movimientos_mark` `mk` join `vn`.`state` `st` on((`st`.`id` = `mk`.`stateFk`))) join `vn2008`.`Movimientos` `m` on((`m`.`Id_Movimiento` = `mk`.`Id_Movimiento`))) join `vn`.`ticket` `t` on((`m`.`Id_Ticket` = `t`.`id`))) join `vn`.`agencyMode` `am` on((`am`.`id` = `t`.`agencyModeFk`))) join `vn`.`address` `a` on((`a`.`id` = `t`.`addressFk`))) left join `vn`.`itemShelvingSaleSum` `is` on((`is`.`saleFk` = `mk`.`Id_Movimiento`))) join `vn2008`.`Articles` `art` on((`art`.`Id_Article` = `m`.`Id_Article`))) left join `vn2008`.`Trabajadores` `t` on((`t`.`Id_Trabajador` = `mk`.`Id_Trabajador`))) where ((`st`.`code` like 'PREVIOUS_PREPARATION') and (`t`.`warehouseFk` = 1)) group by `mk`.`Id_Movimiento_mark` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88907,6 +91924,24 @@ USE `vn`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `travel_cloneWeekly` +-- + +/*!50001 DROP VIEW IF EXISTS `travel_cloneWeekly`*/; +/*!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 `travel_cloneWeekly` AS select `tp`.`travel_pattern_id` AS `id`,`tp`.`warehouse_out` AS `warehouseOutFk`,`tp`.`warehouse_in` AS `warehouseInFk`,`tp`.`agency_id` AS `agencyModeFk`,`tp`.`day_out` AS `weekDay`,`tp`.`duration` AS `duration`,`tp`.`ref` AS `ref`,`tp`.`cargoSupplierFk` AS `cargoSupplierFk` from `vn2008`.`travel_pattern` `tp` */; +/*!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 `unary` -- @@ -89046,7 +92081,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`inventario` AS `isInventory`,`t`.`fuente` AS `isFeedStock`,`t`.`is_comparative` AS `isComparative`,`t`.`comisionantes` AS `hasComission`,`t`.`reserve` AS `hasAvailable`,`t`.`isManaged` AS `isManaged`,`t`.`tpv` AS `isForTicket` from `vn2008`.`warehouse` `t` */; +/*!50001 VIEW `warehouse` AS select `t`.`id` AS `id`,`t`.`name` AS `name`,`t`.`fuente` AS `isFeedStock`,`t`.`address_name` AS `addressName`,`t`.`delay` AS `delay`,`t`.`reserve` AS `hasAvailable`,`t`.`tpv` AS `isForTicket`,`t`.`Id_Paises` AS `countryFk`,`t`.`zone_label` AS `isZoneLabel`,`t`.`comisionantes` AS `hasComission`,`t`.`inventario` AS `isInventory`,`t`.`is_comparative` AS `isComparative`,`t`.`valuatedInventory` AS `valuatedInventory`,`t`.`isManaged` AS `isManaged`,`t`.`hasConfectionTeam` AS `hasConfectionTeam` from `vn2008`.`warehouse` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89244,7 +92279,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`w`.`phone` AS `workerPhone`,`d`.`name` AS `department`,count(`wtc`.`order`) AS `maxOrder` from (((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`workerFk` = `w`.`id`))) where (cast(`wtc`.`timed` as date) = curdate()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */; +/*!50001 VIEW `workerTimeControlWorking` AS select `wtc`.`userFk` AS `userFk`,`wtc`.`timed` AS `timed`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`pm`.`mediaValue` AS `phone`,`wm`.`mediaValue` AS `workerPhone`,`d`.`name` AS `department`,`wc`.`name` AS `workerCenter`,count(`wtc`.`order`) AS `maxOrder` from (((((((`vn`.`workerTimeControl` `wtc` join `vn`.`worker` `w` on((`w`.`userFk` = `wtc`.`userFk`))) left join `vn`.`personMedia` `pm` on((`pm`.`workerFk` = `w`.`id`))) left join `vn`.`workerMedia` `wm` on((`wm`.`workerFk` = `w`.`id`))) left join `vn`.`workerDepartment` `wd` on((`wd`.`workerFk` = `w`.`id`))) left join `vn`.`department` `d` on((`d`.`id` = `wd`.`departmentFk`))) left join `vn`.`workerLabour` `wl` on((`wl`.`businessFk` = (select `wl2`.`businessFk` from `vn`.`workerLabour` `wl2` where (`wl2`.`workerFk` = `w`.`id`) order by `wl2`.`started` desc limit 1)))) left join `vn`.`workCenter` `wc` on((`wc`.`id` = `wl`.`workCenterFk`))) where (cast(`wtc`.`timed` as date) = curdate()) group by `wtc`.`userFk` having ((`maxOrder` % 2) = 1) order by `wtc`.`timed` desc */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89327,6 +92362,78 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `Greuges` +-- + +/*!50001 DROP VIEW IF EXISTS `Greuges`*/; +/*!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 `Greuges` AS select `g`.`Id` AS `Id`,`g`.`clientFk` AS `Id_Cliente`,`g`.`description` AS `Comentario`,`g`.`amount` AS `Importe`,`g`.`shipped` AS `Fecha`,`g`.`created` AS `odbc_date`,`g`.`greugeTypeFk` AS `Greuges_type_id`,`g`.`ticketFk` AS `Id_Ticket` from `vn`.`greuge` `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 `Greuges_type` +-- + +/*!50001 DROP VIEW IF EXISTS `Greuges_type`*/; +/*!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 `Greuges_type` AS select `gt`.`id` AS `Greuges_type_id`,`gt`.`name` AS `name` from `vn`.`greugeType` `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 `Monedas` +-- + +/*!50001 DROP VIEW IF EXISTS `Monedas`*/; +/*!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 `Monedas` AS select `c`.`id` AS `Id_Moneda`,`c`.`code` AS `Moneda`,`c`.`name` AS `Descripcion`,`c`.`ratio` AS `Cambio` from `vn`.`currency` `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 `Tipos` +-- + +/*!50001 DROP VIEW IF EXISTS `Tipos`*/; +/*!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 `Tipos` AS select `it`.`id` AS `tipo_id`,`it`.`code` AS `Id_Tipo`,`it`.`name` AS `Tipo`,`it`.`order` AS `Orden`,`it`.`categoryFk` AS `reino_id`,`it`.`workerFk` AS `Id_Trabajador`,`it`.`warehouseFk` AS `warehouseFk`,`it`.`life` AS `life`,`it`.`isPackaging` AS `isPackaging`,`it`.`density` AS `density`,`it`.`roleCodeFk` AS `roleCodeFk`,`it`.`f11` AS `f11`,`it`.`isInventory` AS `inventory`,`it`.`created` AS `odbc_date`,`it`.`father` AS `father_id`,`it`.`transaction` AS `transaction`,`it`.`making` AS `confeccion`,`it`.`location` AS `location`,`it`.`temperature` AS `Temperatura`,`it`.`promo` AS `promo`,`it`.`isBox` AS `box`,`it`.`CYM` AS `CYM`,`it`.`maneuver` AS `maneuver`,`it`.`target` AS `target`,`it`.`topMargin` AS `top_margin`,`it`.`profit` AS `profit`,`it`.`isFV` AS `FV`,`it`.`hasComponents` AS `hasComponents` from `vn`.`itemType` `it` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Final view structure for view `V_edi_item_track` -- @@ -89435,6 +92542,186 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `cl_act` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_act`*/; +/*!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 `cl_act` AS select `c`.`id` AS `id`,`c`.`saleFk` AS `Id_Movimiento`,`c`.`claimFk` AS `cl_main_id`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`claimDestinationFk` AS `cl_sol_id`,`c`.`isGreuge` AS `greuge` from `vn`.`claimEnd` `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 `cl_cau` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_cau`*/; +/*!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 `cl_cau` AS select `c`.`id` AS `id`,`c`.`claimFk` AS `cl_main_id`,`c`.`claimResponsibleFk` AS `cl_res_id`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`claimReasonFk` AS `cl_mot_id`,`c`.`claimResultFk` AS `cl_con_id`,`c`.`claimRedeliveryFk` AS `cl_dev`,`c`.`claimDestinationFk` AS `cl_sol` from `vn`.`claimDevelopment` `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 `cl_con` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_con`*/; +/*!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 `cl_con` AS select `c`.`id` AS `id`,`c`.`description` AS `consecuencia` from `vn`.`claimResult` `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 `cl_det` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_det`*/; +/*!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 `cl_det` AS select `c`.`id` AS `id`,`c`.`claimFk` AS `cl_main_id`,`c`.`saleFk` AS `Id_Movimiento`,`c`.`quantity` AS `numero`,`c`.`claimComplaintFk` AS `cl_que_id`,`c`.`claimRequestFk` AS `cl_pet_id` from `vn`.`claimBeginning` `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 `cl_dev` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_dev`*/; +/*!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 `cl_dev` AS select `c`.`id` AS `id`,`c`.`description` AS `devolucion` from `vn`.`claimRedelivery` `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 `cl_est` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_est`*/; +/*!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 `cl_est` AS select `c`.`id` AS `id`,`c`.`description` AS `estado`,`c`.`roleFk` AS `roleFk` from `vn`.`claimState` `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 `cl_main` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_main`*/; +/*!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 `cl_main` AS select `c`.`id` AS `id`,`c`.`ticketCreated` AS `Fecha`,`c`.`claimStateFk` AS `cl_est_id`,`c`.`observation` AS `notas`,`c`.`clientFk` AS `Id_Cliente`,`c`.`workerFk` AS `Id_Trabajador`,`c`.`responsibility` AS `sensib`,`c`.`isChargedToMana` AS `mana`,`c`.`ticketFk` AS `ticketFk`,`c`.`created` AS `odbc_date`,`c`.`claimDepartmentFk` AS `cl_dep_id` from `vn`.`claim` `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 `cl_mot` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_mot`*/; +/*!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 `cl_mot` AS select `c`.`id` AS `id`,`c`.`description` AS `motivo` from `vn`.`claimReason` `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 `cl_res` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_res`*/; +/*!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 `cl_res` AS select `c`.`id` AS `id`,`c`.`description` AS `responsable`,`c`.`responsability` AS `sensibility` from `vn`.`claimResponsible` `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 `cl_sol` +-- + +/*!50001 DROP VIEW IF EXISTS `cl_sol`*/; +/*!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 `cl_sol` AS select `c`.`id` AS `id`,`c`.`description` AS `solucion`,`c`.`addressFk` AS `addressFk` from `vn`.`claimDestination` `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 `clientMana` -- @@ -89705,6 +92992,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `entity` +-- + +/*!50001 DROP VIEW IF EXISTS `entity`*/; +/*!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 `entity` AS select `e`.`id` AS `entity_id`,`e`.`countryFk` AS `pais_id`,`e`.`name` AS `description`,`e`.`bic` AS `bic` from `vn`.`bankEntity` `e` */; +/*!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 `itemTag` -- @@ -89795,6 +93100,60 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `mandato` +-- + +/*!50001 DROP VIEW IF EXISTS `mandato`*/; +/*!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 `mandato` AS select `m`.`id` AS `id`,`m`.`clientFk` AS `Id_Cliente`,`m`.`companyFk` AS `empresa_id`,`m`.`code` AS `Id_mandato`,`m`.`created` AS `FAlta`,`m`.`finished` AS `Fbaja`,`m`.`mandateTypeFk` AS `idmandato_tipo` from `vn`.`mandate` `m` */; +/*!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 `mandato_tipo` +-- + +/*!50001 DROP VIEW IF EXISTS `mandato_tipo`*/; +/*!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 `mandato_tipo` AS select `m`.`id` AS `idmandato_tipo`,`m`.`name` AS `Nombre` from `vn`.`mandateType` `m` */; +/*!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 `observation_type` +-- + +/*!50001 DROP VIEW IF EXISTS `observation_type`*/; +/*!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 `observation_type` AS select `co`.`id` AS `observation_type_id`,`co`.`description` AS `description` from `vn`.`observationType` `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 `order` -- @@ -89903,6 +93262,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `reinos` +-- + +/*!50001 DROP VIEW IF EXISTS `reinos`*/; +/*!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 `reinos` AS select `r`.`id` AS `id`,`r`.`name` AS `reino`,`r`.`display` AS `display`,`r`.`color` AS `color`,`r`.`icon` AS `icon`,`r`.`merchandise` AS `mercancia`,`r`.`order` AS `orden`,`r`.`shortLife` AS `efimero` from `vn`.`itemCategory` `r` */; +/*!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 `sms` -- @@ -90066,19 +93443,19 @@ USE `vn2008`; /*!50001 SET collation_connection = @saved_col_connection */; -- --- Final view structure for view `v_Movimientos_Volumen_shipping_charge` +-- Final view structure for view `v_Movimientos_Volumen_shipping_charge__` -- -/*!50001 DROP VIEW IF EXISTS `v_Movimientos_Volumen_shipping_charge`*/; +/*!50001 DROP VIEW IF EXISTS `v_Movimientos_Volumen_shipping_charge__`*/; /*!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 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_Movimientos_Volumen_shipping_charge` AS select `s`.`ticketFk` AS `Id_Ticket`,`t`.`routeFk` AS `Id_Ruta`,`s`.`id` AS `Id_Movimiento`,`t`.`shipped` AS `Fecha`,`az`.`price` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `az`.`price`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` from ((((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`address` `c` on((`c`.`id` = `t`.`addressFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `vn`.`agencyMode` `a` on((`a`.`id` = `t`.`agencyModeFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) join `vn`.`agencyProvince` `ap` on(((`ap`.`agencyFk` = `a`.`agencyFk`) and (`ap`.`provinceFk` = `c`.`provinceFk`) and (`ap`.`warehouseFk` = `t`.`warehouseFk`)))) straight_join `vn`.`agencyModeZone` `az` on(((`az`.`agencyModeFk` = `t`.`agencyModeFk`) and (`az`.`zone` = `ap`.`zone`) and (`az`.`warehouseFk` = `t`.`warehouseFk`) and (`az`.`itemFk` = 71)))) */; +/*!50001 VIEW `v_Movimientos_Volumen_shipping_charge__` AS select `s`.`ticketFk` AS `Id_Ticket`,`t`.`routeFk` AS `Id_Ruta`,`s`.`id` AS `Id_Movimiento`,`t`.`shipped` AS `Fecha`,`az`.`price` AS `price`,((((`s`.`quantity` * `r`.`cm3`) * `az`.`price`) * `i`.`compression`) / `cb`.`volume`) AS `freight`,(((`s`.`quantity` * `r`.`cm3`) * `i`.`compression`) / 1000000) AS `volume` from ((((((((`vn`.`sale` `s` join `vn`.`item` `i` on((`i`.`id` = `s`.`itemFk`))) join `vn`.`ticket` `t` on((`t`.`id` = `s`.`ticketFk`))) join `vn`.`address` `c` on((`c`.`id` = `t`.`addressFk`))) join `vn`.`packaging` `cb` on((`cb`.`id` = '94'))) join `vn`.`agencyMode` `a` on((`a`.`id` = `t`.`agencyModeFk`))) join `bi`.`rotacion` `r` on(((`r`.`Id_Article` = `s`.`itemFk`) and (`r`.`warehouse_id` = `t`.`warehouseFk`)))) join `vn`.`agencyProvince` `ap` on(((`ap`.`agencyFk` = `a`.`agencyFk`) and (`ap`.`provinceFk` = `c`.`provinceFk`) and (`ap`.`warehouseFk` = `t`.`warehouseFk`)))) straight_join `vn`.`agencyModeZone` `az` on(((`az`.`agencyModeFk` = `t`.`agencyModeFk`) and (`az`.`zone` = `ap`.`zone`) and (`az`.`warehouseFk` = `t`.`warehouseFk`) and (`az`.`itemFk` = 71)))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90276,7 +93653,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_descuadre_bionic` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Alias` AS `Alias`,`m`.`Concepte` AS `Concepte`,sum(`mc`.`Valor`) AS `suma_componente`,`m`.`Preu` AS `Preu`,`m`.`Descuento` AS `Descuento`,(((`m`.`Preu` * (100 - `m`.`Descuento`)) / 100) - sum(`mc`.`Valor`)) AS `diferencia`,`t`.`Fecha` AS `Fecha`,((`m`.`Preu` > 0) and (`tp`.`reino_id` <> 6) and (`a`.`tipo_id` not in (7,115))) AS `benvenut` from ((((((`Movimientos` `m` join `Tickets` `t` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) join `Clientes` `c` on((`t`.`Id_Cliente` = `c`.`id_cliente`))) join `warehouse` `w` on((`w`.`id` = `t`.`warehouse_id`))) join `Articles` `a` on((`m`.`Id_Article` = `a`.`Id_Article`))) join `Tipos` `tp` on((`a`.`tipo_id` = `tp`.`tipo_id`))) left join `Movimientos_componentes` `mc` on((`m`.`Id_Movimiento` = `mc`.`Id_Movimiento`))) where ((`t`.`Fecha` >= '2015-09-01') and (`t`.`empresa_id` in (442,791,567)) and `w`.`reserve` and `c`.`real` and (`tp`.`reino_id` <> 6)) group by `m`.`Id_Movimiento` having ((abs(`diferencia`) > 0.01) or isnull(`diferencia`)) */; +/*!50001 VIEW `v_descuadre_bionic` AS select `t`.`Id_Ticket` AS `Id_Ticket`,`t`.`Alias` AS `Alias`,`m`.`Concepte` AS `Concepte`,sum(`mc`.`Valor`) AS `suma_componente`,`m`.`Preu` AS `Preu`,`m`.`Descuento` AS `Descuento`,(((`m`.`Preu` * (100 - `m`.`Descuento`)) / 100) - sum(`mc`.`Valor`)) AS `diferencia`,`t`.`Fecha` AS `Fecha`,((`m`.`Preu` > 0) and (`tp`.`reino_id` <> 6) and (`a`.`tipo_id` not in (7,115))) AS `benvenut` from ((((((`vn2008`.`Movimientos` `m` join `vn2008`.`Tickets` `t` on((`m`.`Id_Ticket` = `t`.`Id_Ticket`))) join `vn2008`.`Clientes` `c` on((`t`.`Id_Cliente` = `c`.`id_cliente`))) join `vn2008`.`warehouse` `w` on((`w`.`id` = `t`.`warehouse_id`))) join `vn2008`.`Articles` `a` on((`m`.`Id_Article` = `a`.`Id_Article`))) join `vn2008`.`Tipos` `tp` on((`a`.`tipo_id` = `tp`.`tipo_id`))) left join `vn2008`.`Movimientos_componentes` `mc` on((`m`.`Id_Movimiento` = `mc`.`Id_Movimiento`))) where ((`t`.`Fecha` >= '2015-09-01') and (`t`.`empresa_id` in (442,791,567)) and `w`.`reserve` and `c`.`real` and (`tp`.`reino_id` <> 6)) group by `m`.`Id_Movimiento` having ((abs(`diferencia`) > 0.01) or isnull(`diferencia`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90492,7 +93869,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_miriam` AS select `M`.`Id_Article` AS `Id_Article`,`M`.`Concepte` AS `Concepte`,`M`.`Cantidad` AS `Cantidad`,`M`.`Preu` AS `Preu`,`M`.`Descuento` AS `Descuento`,`T`.`Fecha` AS `Fecha`,`T`.`Id_Cliente` AS `Id_Cliente`,(((`M`.`Cantidad` * `M`.`Preu`) * (100 - `M`.`Descuento`)) / 100) AS `Importe` from (((`Tickets` `T` join `Movimientos` `M` on((`T`.`Id_Ticket` = `M`.`Id_Ticket`))) join `Articles` `A` on((`M`.`Id_Article` = `A`.`Id_Article`))) join `Tipos` `TP` on((`A`.`tipo_id` = `TP`.`tipo_id`))) where ((`T`.`Fecha` >= '2011-01-01') and (`A`.`tipo_id` = 7)) */; +/*!50001 VIEW `v_miriam` AS select `M`.`Id_Article` AS `Id_Article`,`M`.`Concepte` AS `Concepte`,`M`.`Cantidad` AS `Cantidad`,`M`.`Preu` AS `Preu`,`M`.`Descuento` AS `Descuento`,`T`.`Fecha` AS `Fecha`,`T`.`Id_Cliente` AS `Id_Cliente`,(((`M`.`Cantidad` * `M`.`Preu`) * (100 - `M`.`Descuento`)) / 100) AS `Importe` from (((`vn2008`.`Tickets` `T` join `vn2008`.`Movimientos` `M` on((`T`.`Id_Ticket` = `M`.`Id_Ticket`))) join `vn2008`.`Articles` `A` on((`M`.`Id_Article` = `A`.`Id_Article`))) join `vn2008`.`Tipos` `TP` on((`A`.`tipo_id` = `TP`.`tipo_id`))) where ((`T`.`Fecha` >= '2011-01-01') and (`A`.`tipo_id` = 7)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90654,7 +94031,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`%` SQL SECURITY DEFINER */ -/*!50001 VIEW `v_ventes` AS select `Agencias`.`Agencia` AS `Agencia`,`A`.`Categoria` AS `Categoria`,`A`.`tipo_id` AS `tipo_id`,`A`.`Medida` AS `Medida`,`A`.`Article` AS `Article`,`A`.`Color` AS `Color`,`CS`.`Id_cliente` AS `Id_Cliente`,`TP`.`Id_Tipo` AS `Tipo`,`T`.`Factura` AS `Factura`,`T`.`warehouse_id` AS `warehouse_id`,`M`.`Id_Movimiento` AS `Id_Movimiento`,`M`.`Id_Article` AS `Id_Article`,`TP`.`Id_Tipo` AS `Familia`,`M`.`Id_Ticket` AS `Id_Ticket`,`M`.`Concepte` AS `Concepte`,`M`.`Cantidad` AS `Cantidad`,`M`.`quantity` AS `quantity`,`M`.`Preu` AS `Preu`,`M`.`Descuento` AS `Descuento`,if((`T`.`Fecha` >= '2015-10-01'),`M`.`CostFixat`,((`M`.`Preu` * (100 - `M`.`Descuento`)) / 100)) AS `CostFixat`,`M`.`Reservado` AS `Reservado`,`M`.`OK` AS `OK`,`M`.`PrecioFijado` AS `PrecioFijado`,`M`.`odbc_date` AS `odbc_date`,cast(`T`.`Fecha` as date) AS `Fecha`,`T`.`Fecha` AS `FechaCompleta`,`CS`.`consignatario` AS `Alias`,`T`.`Id_Consigna` AS `Id_Consigna`,(((`M`.`Cantidad` * `M`.`Preu`) * (100 - `M`.`Descuento`)) / 100) AS `Importe`,`O`.`Origen` AS `Origen`,`TP`.`reino_id` AS `reino_id`,`C`.`invoice` AS `invoice`,`A`.`producer_id` AS `producer_id` from ((((((((`Movimientos` `M` join `Tickets` `T` on((`M`.`Id_Ticket` = `T`.`Id_Ticket`))) join `Consignatarios` `CS` on((`CS`.`id_consigna` = `T`.`Id_Consigna`))) join `Clientes` `C` on((`CS`.`Id_cliente` = `C`.`id_cliente`))) join `Articles` `A` on((`M`.`Id_Article` = `A`.`Id_Article`))) join `Origen` `O` on((`O`.`id` = `A`.`id_origen`))) join `Tipos` `TP` on((`A`.`tipo_id` = `TP`.`tipo_id`))) join `reinos` `r` on((`TP`.`reino_id` = `r`.`id`))) join `Agencias` on((`Agencias`.`Id_Agencia` = `T`.`Id_Agencia`))) where ((`T`.`Fecha` >= '2013-01-01') and (`C`.`real` > 0) and (`r`.`id` <> 6)) */; +/*!50001 VIEW `v_ventes` AS select `vn2008`.`Agencias`.`Agencia` AS `Agencia`,`A`.`Categoria` AS `Categoria`,`A`.`tipo_id` AS `tipo_id`,`A`.`Medida` AS `Medida`,`A`.`Article` AS `Article`,`A`.`Color` AS `Color`,`CS`.`Id_cliente` AS `Id_Cliente`,`TP`.`Id_Tipo` AS `Tipo`,`T`.`Factura` AS `Factura`,`T`.`warehouse_id` AS `warehouse_id`,`M`.`Id_Movimiento` AS `Id_Movimiento`,`M`.`Id_Article` AS `Id_Article`,`TP`.`Id_Tipo` AS `Familia`,`M`.`Id_Ticket` AS `Id_Ticket`,`M`.`Concepte` AS `Concepte`,`M`.`Cantidad` AS `Cantidad`,`M`.`quantity` AS `quantity`,`M`.`Preu` AS `Preu`,`M`.`Descuento` AS `Descuento`,if((`T`.`Fecha` >= '2015-10-01'),`M`.`CostFixat`,((`M`.`Preu` * (100 - `M`.`Descuento`)) / 100)) AS `CostFixat`,`M`.`Reservado` AS `Reservado`,`M`.`OK` AS `OK`,`M`.`PrecioFijado` AS `PrecioFijado`,`M`.`odbc_date` AS `odbc_date`,cast(`T`.`Fecha` as date) AS `Fecha`,`T`.`Fecha` AS `FechaCompleta`,`CS`.`consignatario` AS `Alias`,`T`.`Id_Consigna` AS `Id_Consigna`,(((`M`.`Cantidad` * `M`.`Preu`) * (100 - `M`.`Descuento`)) / 100) AS `Importe`,`O`.`Origen` AS `Origen`,`TP`.`reino_id` AS `reino_id`,`C`.`invoice` AS `invoice`,`A`.`producer_id` AS `producer_id` from ((((((((`vn2008`.`Movimientos` `M` join `vn2008`.`Tickets` `T` on((`M`.`Id_Ticket` = `T`.`Id_Ticket`))) join `vn2008`.`Consignatarios` `CS` on((`CS`.`id_consigna` = `T`.`Id_Consigna`))) join `vn2008`.`Clientes` `C` on((`CS`.`Id_cliente` = `C`.`id_cliente`))) join `vn2008`.`Articles` `A` on((`M`.`Id_Article` = `A`.`Id_Article`))) join `vn2008`.`Origen` `O` on((`O`.`id` = `A`.`id_origen`))) join `vn2008`.`Tipos` `TP` on((`A`.`tipo_id` = `TP`.`tipo_id`))) join `vn2008`.`reinos` `r` on((`TP`.`reino_id` = `r`.`id`))) join `vn2008`.`Agencias` on((`vn2008`.`Agencias`.`Id_Agencia` = `T`.`Id_Agencia`))) where ((`T`.`Fecha` >= '2013-01-01') and (`C`.`real` > 0) and (`r`.`id` <> 6)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90839,6 +94216,24 @@ USE `vn2008`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; +-- +-- Final view structure for view `zoneNicknameKk` +-- + +/*!50001 DROP VIEW IF EXISTS `zoneNicknameKk`*/; +/*!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 `zoneNicknameKk` AS select `ap`.`warehouse_id` AS `warehouse_id`,`ap`.`agency_id` AS `agency_id`,`ap`.`zona` AS `zona`,concat('ZONA ',`ap`.`zona`,' ',if((`ap`.`zona` = 20),'Madrid',`p`.`name`)) AS `alias` from (`Agencias_province` `ap` join `province` `p` on((`p`.`province_id` = `ap`.`province_id`))) group by `ap`.`zona`,`ap`.`warehouse_id`,`ap`.`agency_id` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + -- -- Current Database: `vncontrol` -- @@ -90854,4 +94249,4 @@ USE `vncontrol`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-09-04 7:55:48 +-- Dump completed on 2019-09-16 13:00:36 diff --git a/db/export-data.sh b/db/export-data.sh index efe62813b..1f5e4fe04 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -41,6 +41,10 @@ TABLES=( cplusTaxBreak pgc tag + claimResponsible + claimReason + claimRedelivery + claimResult ) dump_tables ${TABLES[@]} @@ -49,16 +53,11 @@ TABLES=( accion_dits bionic_updating_options businessReasonEnd - cl_con - cl_res - cl_dev - cl_mot container department escritos Grupos iva_group_codigo - Monedas state tarifa_componentes tarifa_componentes_series diff --git a/modules/item/back/methods/item/getSummary.js b/modules/item/back/methods/item/getSummary.js index 44e599e4a..51fed3753 100644 --- a/modules/item/back/methods/item/getSummary.js +++ b/modules/item/back/methods/item/getSummary.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('getSummary', { - description: 'Updates the item taxes', + description: 'return the item information', accessType: 'READ', accepts: [{ arg: 'id', diff --git a/modules/order/back/methods/order/specs/getTotalVolume.spec.js b/modules/order/back/methods/order/specs/getTotalVolume.spec.js index 04eb8f911..7cd9c9e64 100644 --- a/modules/order/back/methods/order/specs/getTotalVolume.spec.js +++ b/modules/order/back/methods/order/specs/getTotalVolume.spec.js @@ -4,7 +4,7 @@ describe('order getTotalVolume()', () => { it('should return the total', async() => { let result = await app.models.Order.getTotalVolume(1); - expect(result.totalVolume).toEqual(1.562); + expect(result.totalVolume).toEqual(1.568); expect(result.totalBoxes).toEqual(11.1); }); }); diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index ab72c612f..0c6bade81 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -67,8 +67,8 @@ describe('sale updatePrice()', () => { let saleUpdated = await app.models.Sale.findById(saleId); createdSaleComponent = await app.models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponentId}}); - expect(saleUpdated.price).toEqual(price); - expect(createdSaleComponent.value).toEqual(-2.13); + expect(saleUpdated.price).toBe(price); + expect(createdSaleComponent.value).toEqual(-2.14); }); it('should check that the mana of salesPerson changed', async() => { diff --git a/modules/ticket/back/methods/ticket/specs/getTotalVolume.spec.js b/modules/ticket/back/methods/ticket/specs/getTotalVolume.spec.js index a99dd6578..1901e2cb2 100644 --- a/modules/ticket/back/methods/ticket/specs/getTotalVolume.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTotalVolume.spec.js @@ -4,7 +4,7 @@ describe('ticket getTotalVolume()', () => { it('should return the total volume of a ticket', async() => { let ticketFk = 1; - let expectedResult = 1.562; + let expectedResult = 1.568; let result = await app.models.Ticket.getTotalVolume(ticketFk);